void XmlSchemaGenerator::generateData ( const DOMElement &element, size_t nIndent /*= 0*/) { wxString name = WrapXerces::toString ( element.getTagName() ); if ( mElements[name].name.empty() ) { // Only generate data once generateData ( name, nIndent ); } DOMElement *child = element.getFirstElementChild(); for ( ; child != NULL; child = child->getNextElementSibling() ) { generateData ( *child, nIndent ); } }
void mouse (int button, int state, int x, int y) { static int clickx; static int clicky; switch (button) { case GLUT_LEFT_BUTTON: if (state == GLUT_DOWN) { Complex c; screenToComplex (x, (n2 - y - 1), &c); if (glutGetModifiers () == GLUT_ACTIVE_SHIFT) { if (mode == 1) { mode = 0; julia = c; } else { mode = 1; } trans = newComplex (0, 0); zoom = 2; } else { trans = c; if (glutGetModifiers () == GLUT_ACTIVE_CTRL) zoom /= 0.7; else zoom *= 0.7; } generateData (); glutPostRedisplay (); } break; case GLUT_RIGHT_BUTTON: if (state == GLUT_DOWN) { clickx = x; clicky = y; } else { Complex c; Complex r; screenToComplex (clickx, (n2 - clicky - 1), &c); screenToComplex (x, (n2 - y - 1), &r); trans = addComplex (&trans, &c); trans = minusComplex (&trans, &r); generateData (); glutPostRedisplay (); } default: break; } }
bool TimeExchangeView::init() { CCLoadSprite::doResourceByCommonIndex(11, true); setCleanFunction([](){ CCLoadSprite::doResourceByCommonIndex(11, false); }); auto temCCB = CCBLoadFile("TimeExchangeView", this, this); setContentSize(temCCB->getContentSize()); auto size = CCDirector::sharedDirector()->getWinSize(); float dh = size.height - 852 - 8; m_infoList->setContentSize(CCSize(m_infoList->getContentSize().width, m_infoList->getContentSize().height + dh)); m_data = CCArray::create(); m_tabView = CCMultiColTableView::create(this, m_infoList->getContentSize()); m_tabView->setDirection(kCCScrollViewDirectionVertical); m_tabView->setVerticalFillOrder(kCCTableViewFillTopDown); m_tabView->setMultiColTableViewDelegate(this); m_tabView->setTouchPriority(Touch_Popup); m_infoList->addChild(m_tabView); string msg = _lang("105082"); m_infoLabel->setString(msg); m_st = true; m_maxRwdLv = PortActController::getInstance()->getMaxRwdLv(); generateData(NULL); onEnterFrame(0); return true; }
Generator::Generator(quint64 durationUs, int frequency, int SR,QObject *parent) : QObject(parent) { m_data=NULL; m_nSample=0; generateData(durationUs, frequency, SR); }
int main(int argc, char* argv[]){ char* filePath = argv[1]; int size = atoi(argv[2]); int amount = atoi(argv[3]); srand(time(NULL)); // printf("File path: %s\n", filePath); int myFile; myFile = open(filePath,O_CREAT|O_WRONLY|O_TRUNC,S_IRUSR|S_IWUSR|S_IWOTH|S_IROTH|S_IRGRP|S_IWGRP); if(myFile == -1) printf("Error creating file to write\n"); char *buffor = malloc(size*(sizeof(char)+1)); int error; int i; for (i = 0; i < amount; ++i) { generateData(size, buffor); // printf("%s\n", buffor); error = write(myFile, buffor, size); if(error == -1) printf("Error writting data to file\n"); } if(close(myFile)==-1) printf("Error closing file\n"); return 0; }
void iter(void *arg) { /* perform read write operations ... */ static char out[EXPECTED_BYTES]; static int pos = 0; printf("so far %d, expecting up to %d\n", pos, EXPECTED_BYTES-pos); int n = get_all_buf(SocketFD, out+pos, EXPECTED_BYTES-pos); if (n) printf("read! %d\n", n); pos += n; if (pos >= EXPECTED_BYTES) { shutdown(SocketFD, SHUT_RDWR); close(SocketFD); done = 1; emscripten_cancel_main_loop(); #if EMSCRIPTEN char *comp = generateData(); int result = strcmp(comp, out); if (result != 0) { for (int i = 0; i < DATA_SIZE; i++) { printf("%d:%d\n", comp[i], out[i]); } } REPORT_RESULT(); #endif } }
qint64 CMBaseAudioSource::readData(char *data, qint64 maxlen) { qint64 total = 0; if (!isOpen()) { qWarning("source: Trying to read closed source"); return -1; } if (maxlen==0) { qWarning("source: Zero read"); return 0; } m_buffer_length=generateData(qMin((qint64)m_buffer.size(), maxlen)); if (m_buffer_length==0) { qWarning("Source failed to generate data"); return 0; } while (m_buffer_length - total > 0) { const qint64 chunk = qMin((m_buffer_length - m_pos), m_buffer_length - total); memcpy(data + total, m_buffer.constData() + m_pos, chunk); m_pos = (m_pos + chunk) % m_buffer_length; total += chunk; } return total; }
AudioGenerator::AudioGenerator(const QAudioFormat &format, qint64 durationUs, int frequency, QObject *parent) : Generator(format,durationUs,frequency,parent), lastFloatRight(0.0f), lastFloatLeft(0.0f) { #ifdef USE_GENERATOR_BUFFFER generateData(format, durationUs, frequency); #endif }
int main() { int shmId = createSharedMemory(); if(shmId == -1) { perror("Could not create shared memory"); return 1; } Buffer* buffer; if(sharedBufferInit(shmId, &buffer, BUFFERSIZE)) { perror("Could not initialize buffer"); return 1; } fprintf(stderr, "%d", shmId); sigset_t sigset; int sig; sigemptyset(&sigset); sigaddset(&sigset, SIGUSR1); sigprocmask(SIG_BLOCK, &sigset, NULL); printf("[%s] Producer is ready. Waiting for SIGUSR1 to PID=%d.\n", getTime(), getpid()); sigwait(&sigset, &sig); generateData(buffer); destroySharedMemory(shmId); return 0; }
void special (int key, int x, int y) { switch (key) { case GLUT_KEY_UP: trans.imaginary += (zoom * 0.1); break; case GLUT_KEY_DOWN: trans.imaginary -= (zoom * 0.1); break; case GLUT_KEY_LEFT: trans.real -= (zoom * 0.1); break; case GLUT_KEY_RIGHT: trans.real += (zoom * 0.1); break; case GLUT_KEY_PAGE_UP: zoom *= 0.7; break; case GLUT_KEY_PAGE_DOWN: zoom /= 0.7; break; default: return; } generateData (); glutPostRedisplay (); }
const wxString &XmlSchemaGenerator::generate ( Grammar::GrammarType grammarType, const wxString &filepath, const char *buffer, size_t len ) { mGrammarType = grammarType; mElements.clear(); mSchema.Clear(); XercesCatalogResolver catalogResolver; std::auto_ptr<XercesDOMParser> parser ( new XercesDOMParser() ); parser->setDoNamespaces ( true ); parser->setDoSchema ( true ); parser->setValidationSchemaFullChecking ( false ); parser->setEntityResolver ( &catalogResolver ); MemBufInputSource source ( ( const XMLByte * ) buffer, len, filepath.mb_str( wxConvLocal ) ); try { //XMLPlatformUtils::fgSSE2ok = false; parser->parse ( source ); } catch ( XMLException& e ) { mLastError = WrapXerces::toString ( e.getMessage() ); return mSchema; } xercesc::DOMDocument *doc = parser->getDocument(); if ( doc == NULL ) { mLastError = _ ("Failed to load xml file."); return mSchema; } size_t size = len / 3; if ( size > maxReservedSchemaBuffer ) size = maxReservedSchemaBuffer; mSchema.Alloc ( size ); if ( mGrammarType == Grammar::SchemaGrammarType ) mSchema << _T("<?xml version=\"1.0\" encoding=\"UTF-8\"?>") << getEOL() << _T("<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" elementFormDefault=\"qualified\">") << getEOL(); xercesc::DOMElement *root = doc->getDocumentElement(); if ( root != NULL ) { findAllElements ( *root ); generateData ( *root, 1 ); if ( mInlineSimpleType && mGrammarType == Grammar::SchemaGrammarType ) outputSchema ( *root ); } if ( mGrammarType == Grammar::SchemaGrammarType ) mSchema << _T("</xs:schema>") << getEOL(); mSchema.Shrink(); return mSchema; }
//отправление данных по всем кораблям void MyServer::sendAllData(){ //deleteShipButton->setEnabled(false); QByteArray block; QDataStream out (&block, QIODevice::WriteOnly); out.setVersion(QDataStream::Qt_5_5); out << quint16(0) << logNumbersOfRemovedShips.size(); //количество удаленных кораблей for(int k = 0; k < logNumbersOfRemovedShips.size(); k++){ //номер лога удаленного корабля out << logNumbersOfRemovedShips.at(k); // } logNumbersOfRemovedShips.clear(); out << shipCounter; //количество существующих на сервере кораблей //для всех кораблей for(int i=0; i < shipCounter; i++){ generateData(shipList.at(i)); //генерируем новые данные out << shipList.at(i)->id << shipList.at(i)->startX << shipList.at(i)->startY << shipList.at(i)->courseAngle << shipList.at(i)->speed << shipList.at(i)->viewAngle << shipList.at(i)->viewLength << shipList.at(i)->pathLength << shipList.at(i)->time; QTextEdit *te = (QTextEdit*)txtStack->widget(i); //получение указателя на лог текущего корабля te->append(QString("Id: %1").arg(shipList.at(i)->id+1));//вывод сгенерированной информации в лог if(shipList.at(i)->isNew){ te->append(QString("Start X: %1\nStart Y: %2") .arg(shipList.at(i)->startX) .arg(shipList.at(i)->startY)); } te->append(QString("Course angle: %1 deg\nSpeed: %2\nView angle: %3 deg\nViewLength: %4\nPath length: %5 m\nTime: %6 sec\n") .arg(shipList.at(i)->courseAngle) .arg(shipList.at(i)->speed).arg(shipList.at(i)->viewAngle) .arg(shipList.at(i)->viewLength).arg(shipList.at(i)->pathLength).arg(shipList.at(i)->time/1000.0f)); shipList.at(i)->isNew=0; } out.device()->seek(0); //переход в начало блока out<<quint16(block.size()-sizeof(quint16)); //размер блока данных if(isClientConnected) socket->write(block); //посылка клиенту, если он подключен block.clear(); //очистка используемого блока if(!deleteShipButton->isEnabled()&& shipCounter>0) deleteShipButton->setEnabled(true); }
void keyboard (unsigned char key, int x, int y) { switch (key) { case 27: exit(0); break; case 'P': case 'p': if (animToggle == 1) glutIdleFunc (idle); else glutIdleFunc (NULL); animToggle = -animToggle; break; case 'R': case 'r': trans = newComplex (0, 0); zoom = 2; generateData (); glutPostRedisplay (); break; case 'A': case 'a': dir = -dir; break; case '1': cmap = goodega; cimax = goodega_len; glutPostRedisplay (); break; case '2': cmap = chroma; cimax = chroma_len; glutPostRedisplay (); break; case '3': cmap = blues; cimax = blues_len; glutPostRedisplay (); break; case '4': cmap = volcano; cimax = volcano_len; glutPostRedisplay (); break; case '5': cmap = fractintdefault; cimax = fractintdefault_len; glutPostRedisplay (); break; case 'V': case 'v': if (mode == 1) printf("Parameter space\n"); else printf("c = %f + %fi\n", julia.real, julia.imaginary); printf ("Zoom: %f\n", zoom); printf ("Centre: %f + %fi\n", trans.real, trans.imaginary); printf ("Size: %d x %d\n\n", n1, n2); default: break; } }
TransientPeriod::TransientPeriod(QWidget *parent) : QDialog(parent), ui(new Ui::TransientPeriod) { ui->setupUi(this); QObject::connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(generateData())); }
Planet::Planet(): dataCount(0), indexesCount(0), pData(0), pIndexes(0) { generateData(18, 36); }
MyObject::MyObject(): dataCount(0), indexesCount(0), pData(0), pIndexes(0) { generateData(); }
FightSheet::FightSheet(Object *o, Keeper *keeper, QWidget *parent) : ReportWidget(o, keeper, parent) { setObjectName(QString("FightSheet:%1:%2").arg(o->objectName()).arg(o->get("id"))); dockWidget->close(); generateReport( generateData() ); }
ListReports::ListReports(bool today_only,bool active_only,int dow, QWidget *parent) : QDialog(parent,"",true) { list_today_only=today_only; list_active_only=active_only; list_dow=dow; // // Fix the Window Size // setMinimumWidth(sizeHint().width()); setMaximumWidth(sizeHint().width()); setMinimumHeight(sizeHint().height()); setMaximumHeight(sizeHint().height()); setCaption(tr("RDLibrary Reports")); // // Create Fonts // QFont font=QFont("Helvetica",12,QFont::Bold); font.setPixelSize(12); // // Reports List // list_reports_box=new QComboBox(this); list_reports_box->setGeometry(50,10,sizeHint().width()-60,19); list_reports_box->insertItem(tr("Event Report")); list_reports_box->insertItem(tr("Upload/Download Report")); QLabel *list_reports_label= new QLabel(list_reports_box,tr("Type:"),this); list_reports_label->setGeometry(10,10,35,19); list_reports_label->setFont(font); list_reports_label->setAlignment(Qt::AlignRight|Qt::AlignVCenter|Qt::TextShowMnemonic); // // Generate Button // QPushButton *generate_button=new QPushButton(this); generate_button-> setGeometry(sizeHint().width()-180,sizeHint().height()-60,80,50); generate_button->setDefault(true); generate_button->setFont(font); generate_button->setText(tr("&Generate")); connect(generate_button,SIGNAL(clicked()),this,SLOT(generateData())); // // Close Button // QPushButton *close_button=new QPushButton(this); close_button->setGeometry(sizeHint().width()-90,sizeHint().height()-60, 80,50); close_button->setFont(font); close_button->setText(tr("&Close")); connect(close_button,SIGNAL(clicked()),this,SLOT(closeData())); }
MainWidget::MainWidget(QWidget *parent,const char *name) :QWidget(parent,name) { unsigned schema=0; // // Fix the Window Size // setMinimumWidth(sizeHint().width()); setMaximumWidth(sizeHint().width()); setMinimumHeight(sizeHint().height()); setMaximumHeight(sizeHint().height()); // // Generate Fonts // QFont font("Helvetica",12,QFont::Normal); font.setPixelSize(12); // // Open Database // rd_config=new RDConfig(RD_CONF_FILE); rd_config->load(); QString err; test_db=RDInitDb(&schema,&err); if(!test_db) { QMessageBox::warning(this,"Can't Connect", err,0,1,1); exit(0); } // // Generate Button // QPushButton *button=new QPushButton(this,"generate_button"); button->setGeometry(10,10,sizeHint().width()-20,50); button->setText("Generate Test"); button->setFont(font); connect(button,SIGNAL(clicked()),this,SLOT(generateData())); // // Remove Button // button=new QPushButton(this,"remove_button"); button->setGeometry(10,70,sizeHint().width()-20,50); button->setText("Remove Test"); button->setFont(font); connect(button,SIGNAL(clicked()),this,SLOT(removeData())); // // Exit Button // button=new QPushButton(this,"cancel_button"); button->setGeometry(10,130,sizeHint().width()-20,50); button->setText("Exit"); button->setFont(font); connect(button,SIGNAL(clicked()),this,SLOT(cancelData())); }
MyObject::MyObject(): pData(0), dataCount(0), radius(1), pIndexes(0), indexesCount(0) { generateData(); }
Generator::Generator(const QAudioFormat &format, qint64 durationUs, int frequency, QObject *parent) : QIODevice(parent) , m_pos(0) { generateData(format, durationUs, frequency); }
void Chunk::generate() { if (m_generated) return; generateData(); generateBuffers(); m_generated = true; }
Generator::Generator(const QAudioFormat &format, qint64 durationUs, int sampleRate, QObject *parent) : QIODevice(parent) , m_pos(0) { generateData(format, durationUs, sampleRate); }
/** * This example shows the different in error estimation between the different * type of accumulators. * * @param argc the number of arguments * @param argv the argument array * @return the exit code */ int main(int argc, char** argv) { // Create the empty set of accumulators std::cout << "Creating accumulator set..." << std::endl; alps::accumulators::accumulator_set set; // We will accumulate the same data with the 4 different types of // accumulators. We first define the labels for the accumulators. std::string fullbin = "fullbin"; std::string logbin = "logbin"; std::string nobin = "nobin"; std::string mean = "mean"; // We create the accumulators of the appropriate type and add them // to the set set << alps::accumulators::FullBinningAccumulator<double>(fullbin) << alps::accumulators::LogBinningAccumulator<double>(logbin) << alps::accumulators::NoBinningAccumulator<double>(nobin) << alps::accumulators::MeanAccumulator<double>(mean); // Generate and accumulate the data std::cout << "Generating data..." << std::endl; generateData(set, mean, nobin, logbin, fullbin); // Extracts the results alps::accumulators::result_set results(set); // Prints out the direct result from the accumulator. // The "mean" accumulator will have no error associated with it. // The "nobin" accumulator will have an error, but it will be underestimated. // The "logbin" accumulator will have the correct error, and the estimation // becomes better with the bigger bin size. // The "fullbin" accumulator error estimation will be the same as the "logbin". std::cout << "Results from accumulators:" << std::endl; std::cout << "mean: " << results[mean] << std::endl; std::cout << "nobin: " << results[nobin] << std::endl; std::cout << "logbin: " << results[logbin] << std::endl; std::cout << "fullbin: " << results[fullbin] << std::endl; // Prints out the result obtained by squaring the accumulator, after // the results are computed. // The "mean" accumulator will have no error associated with it. // The "nobin" accumulator will have an error, but it will be underestimated // because of the auto-correlation and the computation. // The "logbin" accumulator will have an error, also underestimated but // because of the computation only. // The "fullbin" accumulator will have the correct error. std::cout << "Results from squared accumulators:" << std::endl; std::cout << "mean: " << results[mean] * results[mean] << std::endl; std::cout << "nobin: " << results[nobin] * results[nobin] << std::endl; std::cout << "logbin: " << results[logbin] * results[logbin] << std::endl; std::cout << "fullbin: " << results[fullbin] * results[fullbin] << std::endl; return 0; }
void Generator::preCommit(RenderContext &/*ctx*/) { auto type = child("generatorType").valueAs<std::string>(); auto params = child("parameters").valueAs<std::string>(); if (lastType != type || lastParams != params) { lastType = type; lastParams = params; generateData(); commit(); } }
int main (int argc, char *argv[]) { printf("This tool generates websites!\n.\n.\n.\n"); printf("Run in dev mode? 0=NO, 1=YES: "); scanf("%d", &an); if (an) { DEV=1; } printf("Processing...\n"); generateData(); return 0; }
Generator::Generator(const QAudioFormat &format, qint64 durationUs, int sampleRate, QObject *parent) : QIODevice(parent) , m_pos(0) { if (format.isValid()) { qDebug() << "generating" << durationUs << "at" << sampleRate; generateData(format, durationUs, sampleRate); } }
Sorts::Sorts() { // Fills array with random integers of size DATASET generateData(); // Do bubble sort runs for(int i = 0; i < DATARUNS; i++) { // Capture time clock_t t1 = clock(); // Perform bubble sort bubblesort(); //Capture time again clock_t t2 = clock(); // Add run time to result array bubbleSortTimes[i] = timediff(t1, t2); // Reset operating data to originaly generated random numbers to ensure we are // comparing the sorting speed on the exact same random numbers dataReset(); } // Repeat above process for other sorts // Do quick sort runs for(int i = 0; i < DATARUNS; i++) { clock_t t1 = clock(); quickSort(array, 0, DATASET-1); clock_t t2 = clock(); quickSortTimes[i] = timediff(t1, t2); dataReset(); } // Do merge sort runs for(int i = 0; i < DATARUNS; i++) { clock_t t1 = clock(); mergeSort(array, 0, DATASET-1); clock_t t2 = clock(); mergeSortTimes[i] = timediff(t1, t2); dataReset(); } // Display all the results displayResults(); }
MyObject::MyObject(int r, int x_,int y_, int z_) : pData(0), dataCount(0), radius(r), pIndexes(0), indexesCount(0), x(x_), y(y_), z(z_) { dt = glutGet(GLUT_ELAPSED_TIME) / 1000.0f; velocity = glm::vec3(0.1, 0, 0); generateData(); }
void reshape (int width, int height) { if (height <= 0) height = 1; if (width <= 0) width = 1; n1 = width; n2 = height; if ((n1 * n2) > fracData_len) allocData (); generateData (); glMatrixMode (GL_PROJECTION); glLoadIdentity (); gluOrtho2D (0, width, 0, height); glMatrixMode (GL_MODELVIEW); glLoadIdentity (); glViewport (0, 0, (GLsizei)width, (GLsizei)height); }