static void dispatchKeyboardEvent(char c) { KeyboardInputReport report; static CFAbsoluteTime sDeadline = 0; CFAbsoluteTime delta; bzero(&report, sizeof(report)); if ( c < 'a' || c > 'z' ) return; printf("dispatching keyboard event for '%c'\n", c); pthread_mutex_lock(&gMuxtex); delta = sDeadline - CFAbsoluteTimeGetCurrent(); if ( delta > 0 ) usleep(delta*1000000); report.keys[0] = 4 + c - 97; printReport((uint8_t*)&report, sizeof(report), 0); IOHIDUserDeviceHandleReport(gDevice, (uint8_t*)&report, sizeof(report)); usleep(kKeyboardInterval*1000000); report.keys[0] = 0; printReport((uint8_t*)&report, sizeof(report), 0); IOHIDUserDeviceHandleReport(gDevice, (uint8_t*)&report, sizeof(report)); sDeadline = CFAbsoluteTimeGetCurrent() + kKeyboardInterval; pthread_mutex_unlock(&gMuxtex); }
int main(int argc, char **argv) { srand(time(NULL)); pi = 4.0 * atan(1); min_x = 0.0; max_x = 3.0 * pi; if (argc > 1) { if (strcmp(argv[1], "-n") == 0) { no_random = 1; } else { print_usage(argv[0]); return 1; } } Table my_table = createMyTable(); Table doubled_table = doubleTable(&my_table, min_x); Table left_table = createTable(min_x, max_x, 0); Table middle_table = createTable(min_x, max_x, numof_parts / 2); Table right_table = createTable(min_x, max_x, numof_parts - 1); printReport(&my_table, "Initial table"); printReport(&doubled_table, "Doubled table"); printReport(&left_table, "Left table"); printReport(&middle_table, "Middle table"); printReport(&right_table, "Right table"); resetFunction(&right_table, my_g); resetFunction(&middle_table, my_g); resetFunction(&left_table, my_g); resetFunction(&doubled_table, my_g); resetFunction(&my_table, my_g); printReport(&my_table, "Initial table"); printReport(&doubled_table, "Doubled table"); printReport(&left_table, "Left table"); printReport(&middle_table, "Middle table"); printReport(&right_table, "Right table"); disposeTable(&right_table); disposeTable(&middle_table); disposeTable(&left_table); disposeTable(&doubled_table); disposeTable(&my_table); reportMaxError(); return 0; }
void readData (DynamicArray *workforce, FILE *fp) { char transaction[6]; while (!feof(fp)) { fscanf(fp, "%6[^|]", transaction); if (strcmp(transaction, "INSERT") == 0) { Employee temp; char tempstr[64]; temp.name = constructStr(8); fscanf(fp,"|%i|%64[^|]|%i|%lf\n", &temp.id, tempstr, &temp.age, &temp.salary); int i; for (i = 0; tempstr[i]; i++) { insertStr (tempstr[i], temp.name); } insert (&temp, workforce); } if (strcmp(transaction, "REPORT") == 0) { printReport(workforce); fscanf(fp, "\n"); } } }
static void dispatchUnicodeEvent(char c) { UnicodeReport report; static CFAbsoluteTime sDeadline = 0; CFAbsoluteTime delta; bzero(&report, sizeof(report)); if ( c < 'a' || c > 'z' ) return; printf("dispatching unicode event for '%c'\n", c); pthread_mutex_lock(&gMuxtex); delta = sDeadline - CFAbsoluteTimeGetCurrent(); if ( delta > 0 ) usleep(delta*1000000); report.usage = c; OSSwapHostToLittleInt16(report.usage); printReport((uint8_t*)&report, sizeof(report), 0); IOHIDUserDeviceHandleReport(gDevice, (uint8_t*)&report, sizeof(report)); sDeadline = CFAbsoluteTimeGetCurrent() + kKeyboardInterval; pthread_mutex_unlock(&gMuxtex); }
void Server::sendResponse(const DataReply& reply) { QTcpSocket* client_socket = qobject_cast<QTcpSocket*>(sender()); QString str = QString("%1%2\n").arg(reply.ok?"OK":"FAILED").arg(reply.result.isEmpty()?"":" " + reply.result); printReport(tr("%1: > %2").arg(client_socket->socketDescriptor()).arg(str)); client_socket->write(str.toUtf8()); }
void Server::onNewConnection() { QTcpSocket* client_socket = server->nextPendingConnection(); connect(client_socket, SIGNAL(readyRead()), this, SLOT(readData())); connect(client_socket, SIGNAL(disconnected()), this, SLOT(onSocketDisconnected())); connect(client_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(onSocketError(QAbstractSocket::SocketError))); printReport(tr("%1: User connected").arg(client_socket->socketDescriptor())); }
int Triangulation::checkAndRepair() { if (mergeCoincidentEdges()) JMesh::warning("Some coincident edges have been merged.\n"); if (removeDegenerateTriangles()) JMesh::warning("Some edges have been swapped or collapsed to eliminate degenerate triangles.\n"); printReport(); return 1; }
static void dispatchDigitizerUnicodeEvent(char c) { DigitizerUnicodeInputReport report; static CFAbsoluteTime sDeadline = 0; CFAbsoluteTime delta; if ( c < 'a' || c > 'z' ) return; printf("dispatching digitizer unicode event for '%c'\n", c); bzero(&report, sizeof(report)); // first candidate report.chars[0].encoding = 1; report.chars[0].quality = 50; report.chars[0].length = 2; report.chars[0].string[0] = c; // second candidate report.chars[1].encoding = 1; report.chars[1].quality = 50; report.chars[1].length = 2; report.chars[1].string[0] = c-32; pthread_mutex_lock(&gMuxtex); delta = sDeadline - CFAbsoluteTimeGetCurrent(); if ( delta > 0 ) usleep(delta*1000000); printReport((uint8_t*)&report, sizeof(report), 0); IOHIDUserDeviceHandleReport(gDevice, (uint8_t*)&report, sizeof(report)); sDeadline = CFAbsoluteTimeGetCurrent() + kKeyboardInterval; bzero(&report, sizeof(report)); printReport((uint8_t*)&report, sizeof(report), 0); IOHIDUserDeviceHandleReport(gDevice, (uint8_t*)&report, sizeof(report)); pthread_mutex_unlock(&gMuxtex); }
uint8_t XBOXUSB::Poll() { if (!bPollEnable) return 0; uint16_t BUFFER_SIZE = EP_MAXPKTSIZE; pUsb->inTransfer(bAddress, epInfo[ XBOX_INPUT_PIPE ].epAddr, &BUFFER_SIZE, readBuf); // input on endpoint 1 readReport(); #ifdef PRINTREPORT printReport(); // Uncomment "#define PRINTREPORT" to print the report send by the Xbox 360 Controller #endif return 0; }
QFFitResultsEvaluationEditorBase::QFFitResultsEvaluationEditorBase(QString iniPrefix, QFPluginServices* services, QFEvaluationPropertyEditor* propEditor, QWidget* parent) : QFEvaluationEditor(services, propEditor, parent) { m_iniPrefix=iniPrefix; m_currentFPSSaveDir=ProgramOptions::getInstance()->getHomeQFDirectory(); m_currentSaveDirectory=""; actSaveReport=new QFActionWithNoMenuRole(QIcon(":/lib/savereport.png"), tr("Save Report"), this); connect(actSaveReport, SIGNAL(triggered()), this, SLOT(saveReport())); actPrintReport=new QFActionWithNoMenuRole(QIcon(":/lib/printreport.png"), tr("Print Report"), this); connect(actPrintReport, SIGNAL(triggered()), this, SLOT(printReport())); }
void MicroProfiler::stopProfiling() { CHECK(profiling.isProfiling_) << "Trying to stop profiling but profiling hasn't been started!"; profiling.isProfiling_ = false; profiling.endTime_ = nowNs(); std::lock_guard<std::mutex> lock(profiling.mutex_); printReport(); clearProfiling(); }
EOSProfiler::~EOSProfiler() { printReport(); // delete timings std::map<const char*, KernelProfilingData*>::iterator it; for(it = timings.begin(); it != timings.end(); ++it) delete it->second; timings.clear(); // delete timer if(timer) delete timer; }
int main(int argc,char **argv) { int indval,field; SEVCHK(ca_task_initialize(),"ca_task_initialize"); SEVCHK(ca_search("enumCputDTYP",&putCchid[0]),"ca_search failure"); SEVCHK(ca_search("enumCputPRIO",&putCchid[1]),"ca_search failure"); SEVCHK(ca_search("enumCputVAL" ,&putCchid[2]),"ca_search failure"); SEVCHK(ca_search("enumMDbputDTYP",&putMDbchid[0]),"ca_search failure"); SEVCHK(ca_search("enumMDbputPRIO",&putMDbchid[1]),"ca_search failure"); SEVCHK(ca_search("enumMDbputVAL" ,&putMDbchid[2]),"ca_search failure"); SEVCHK(ca_search("enumMCaputDTYP",&putMCachid[0]),"ca_search failure"); SEVCHK(ca_search("enumMCaputPRIO",&putMCachid[1]),"ca_search failure"); SEVCHK(ca_search("enumMCaputVAL" ,&putMCachid[2]),"ca_search failure"); SEVCHK(ca_search("enumCmbbi.DTYP" ,&getCchid[0]),"ca_search failure"); SEVCHK(ca_search("enumCmbbi.PRIO" ,&getCchid[1]),"ca_search failure"); SEVCHK(ca_search("enumCmbbi.VAL" ,&getCchid[2]),"ca_search failure"); SEVCHK(ca_search("enumMDbmbbi.DTYP" ,&getMDbchid[0]),"ca_search failure"); SEVCHK(ca_search("enumMDbmbbi.PRIO" ,&getMDbchid[1]),"ca_search failure"); SEVCHK(ca_search("enumMDbmbbi.VAL" ,&getMDbchid[2]),"ca_search failure"); SEVCHK(ca_search("enumMCambbi.DTYP" ,&getMCachid[0]),"ca_search failure"); SEVCHK(ca_search("enumMCambbi.PRIO" ,&getMCachid[1]),"ca_search failure"); SEVCHK(ca_search("enumMCambbi.VAL" ,&getMCachid[2]),"ca_search failure"); SEVCHK(ca_pend_io(5.0),"ca_pend_io failure"); for(indval=0; indval<2; indval++) { SEVCHK(ca_put(DBR_STRING,putCchid[0],dtypValue[indval]),"ca_put"); SEVCHK(ca_put(DBR_STRING,putCchid[1],prioValue[indval]),"ca_put"); SEVCHK(ca_put(DBR_STRING,putCchid[2],valValue[indval]),"ca_put"); SEVCHK(ca_put(DBR_STRING,putMDbchid[0],dtypValue[indval]),"ca_put"); SEVCHK(ca_put(DBR_STRING,putMDbchid[1],prioValue[indval]),"ca_put"); SEVCHK(ca_put(DBR_STRING,putMDbchid[2],valValue[indval]),"ca_put"); SEVCHK(ca_put(DBR_STRING,putMCachid[0],dtypValue[indval]),"ca_put"); SEVCHK(ca_put(DBR_STRING,putMCachid[1],prioValue[indval]),"ca_put"); SEVCHK(ca_put(DBR_STRING,putMCachid[2],valValue[indval]),"ca_put"); /*Wait until evertthing updated*/ ca_pend_event(2.0); for(field=0; field<3; field++) { SEVCHK(ca_get(DBR_STRING,getCchid[field],&getCvalue[field]), "ca_get"); SEVCHK(ca_get(DBR_STRING,getMDbchid[field],&getMDbvalue[field]), "ca_get"); SEVCHK(ca_get(DBR_STRING,getMCachid[field],&getMCavalue[field]), "ca_get"); } SEVCHK(ca_pend_io(5.0),"ca_pend_io failure"); printReport(indval); } return(0); }
void Server::readData() { QTcpSocket* client_socket = qobject_cast<QTcpSocket*>(sender()); QString message = QString(client_socket->readAll()); QStringList instructions = message.split('\n'); for (int i = 0; i < instructions.size(); i++) { QString str = instructions[i].trimmed(); if (i == instructions.size()-1) { if (!str.isEmpty()) sendResponse({false}); continue; } printReport(tr("%1: < %2").arg(client_socket->socketDescriptor()).arg(str)); QStringList signature = str.split(' ', QString::SkipEmptyParts); if (signature.size() == 2); else if (signature.size() == 1) signature.append(""); else { sendResponse({false}); continue; } if (commands.find(signature[0]) == commands.end()) { printReport(tr("Command \"%1\" not found").arg(signature[0])); sendResponse({false}); continue; } if (diode.isNull()) { printReport(tr("Diode data not found").arg(signature[0])); sendResponse({false}); continue; } bool ok; QString result = commands[signature[0]](*diode, signature[1], ok); sendResponse({ok, result}); } }
uint32_t wzl_run(char* name, wzl_function setup, wzl_function teardown, wzl_function* tests, uint32_t numTests) { printf("\n\n%s\n---------------------------\n", name); numErrors = 0; uint32_t i; for(i=0; i<numTests; ++i) { uint32_t currentErrors = numErrors; printf("\n+++ run test number: %d +++\n", i); setup(); tests[i](); teardown(); printf("+++ errors: %d +++\n", numErrors-currentErrors); } printReport(numTests, numErrors); return numErrors; }
void Server::listen() { if (server->listen()) { // change network interface QString ipAddress; QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses(); for (int i = 0; i < ipAddressesList.size(); ++i) { if (ipAddressesList.at(i) != QHostAddress::LocalHost && ipAddressesList.at(i).toIPv4Address()) { ipAddress = ipAddressesList.at(i).toString(); break; } } if (ipAddress.isEmpty()) ipAddress = QHostAddress(QHostAddress::LocalHost).toString(); connect(server, SIGNAL(newConnection()), this, SLOT(onNewConnection())); connect(server, SIGNAL(acceptError(QAbstractSocket::SocketError)), this, SLOT(onServerError(QAbstractSocket::SocketError))); printReport(tr("The server is running on IP: %1 port: %2").arg(ipAddress).arg(server->serverPort())); } else printReport(tr("Unable to start the server: %1").arg(server->errorString())); }
uint8_t PS3USB::Poll() { if(!bPollEnable) return 0; if(PS3Connected || PS3NavigationConnected) { uint16_t BUFFER_SIZE = EP_MAXPKTSIZE; pUsb->inTransfer(bAddress, epInfo[ PS3_INPUT_PIPE ].epAddr, &BUFFER_SIZE, readBuf); // input on endpoint 1 if(millis() - timer > 100) { // Loop 100ms before processing data readReport(); #ifdef PRINTREPORT printReport(); // Uncomment "#define PRINTREPORT" to print the report send by the PS3 Controllers #endif } } else if(PS3MoveConnected) { // One can only set the color of the bulb, set the rumble, set and get the bluetooth address and calibrate the magnetometer via USB if(millis() - timer > 4000) { // Send at least every 4th second Move_Command(writeBuf, MOVE_REPORT_BUFFER_SIZE); // The Bulb and rumble values, has to be written again and again, for it to stay turned on timer = millis(); } } return 0; }
/* Assumes there is a net */ flag standardNetTrain(void) { int i, lastReport, batchesAtCriterion; flag willReport, groupCritReached, value = TCL_OK, done; unsigned long startTime; Algorithm A; if (Net->numUpdates < 0) return warning("numUpdates (%d) must be positive.", Net->numUpdates); if (Net->numUpdates == 0) return result(""); if (!Net->trainingSet) return warning("There is no training set."); if (Net->learningRate < 0.0) return warning("learningRate (%f) cannot be negative.", Net->learningRate); if (Net->momentum < 0.0 && Net->momentum >= 1.0) return warning("momentum (%f) is out of range [0,1).", Net->momentum); if (Net->weightDecay < 0.0 || Net->weightDecay > 1.0) return warning("weightDecay (%f) must be in the range [0,1].", Net->weightDecay); if (Net->reportInterval < 0) return warning("reportInterval (%d) cannot be negative.", Net->reportInterval); A = getAlgorithm(Net->algorithm); print(1, "Performing %d updates using %s...\n", Net->numUpdates, A->longName); if (Net->reportInterval) printReportHeader(); startTime = getTime(); lastReport = batchesAtCriterion = 0; groupCritReached = FALSE; done = FALSE; /* It always does at least one update. */ for (i = 1; !done; i++) { RUN_PROC(preEpochProc); if ((value = Net->netTrainBatch(&groupCritReached))) break; if (Net->error < Net->criterion || groupCritReached) batchesAtCriterion++; else batchesAtCriterion = 0; if ((Net->minCritBatches > 0 && batchesAtCriterion >= Net->minCritBatches) || i >= Net->numUpdates) done = TRUE; willReport = (Net->reportInterval && ((i % Net->reportInterval == 0) || done)) ? TRUE : FALSE; RUN_PROC(postEpochProc); /* Here's the weight update (one epoch). */ A->updateWeights(willReport); RUN_PROC(postUpdateProc); updateDisplays(ON_UPDATE); Net->totalUpdates++; if (willReport) { printReport(lastReport, i, startTime); lastReport = i; } /* Stop if requested. */ if (smartUpdate(FALSE)) break; /* Change the algorithm if requested. */ if (A->code != Net->algorithm) { A = getAlgorithm(Net->algorithm); print(1, "Changing algorithm to %s...\n", A->longName); } } startTime = (getTime() - startTime); updateDisplays(ON_TRAINING); if (value == TCL_ERROR) return TCL_ERROR; result("Performed %d updates\n", i - 1); if (!done) { append("Training halted prematurely\n", i); value = TCL_ERROR; } if (Net->error <= Net->criterion && batchesAtCriterion >= Net->minCritBatches) append("Network reached overall error criterion of %f\n", Net->criterion); if (groupCritReached && batchesAtCriterion >= Net->minCritBatches) append("Network reached group output criterion\n"); append("Total time elapsed: %.3f seconds", ((real) startTime * 1e-3)); return value; }
ListView::ListView( QObject* parent, QWidget* parentWidget ) : View( parent ), m_model( NULL ), m_selectedIssueId( 0 ), m_isRead( false ), m_isSubscribed( false ), m_isAdmin( false ), m_hasIssues( false ), m_currentViewId( 0 ), m_searchColumn( Column_Name ) { QAction* action; action = new QAction( IconLoader::icon( "file-reload" ), tr( "&Update Folder" ), this ); action->setShortcut( QKeySequence::Refresh ); connect( action, SIGNAL( triggered() ), this, SLOT( updateFolder() ), Qt::QueuedConnection ); setAction( "updateFolder", action ); action = new QAction( IconLoader::icon( "issue-open" ), tr( "&Open Issue" ), this ); action->setShortcut( QKeySequence::Open ); connect( action, SIGNAL( triggered() ), this, SLOT( openIssue() ), Qt::QueuedConnection ); setAction( "openIssue", action ); action = new QAction( IconLoader::icon( "issue-new" ), tr( "&Add Issue..." ), this ); action->setShortcut( QKeySequence::New ); connect( action, SIGNAL( triggered() ), this, SLOT( addIssue() ), Qt::QueuedConnection ); setAction( "addIssue", action ); action = new QAction( IconLoader::icon( "edit-modify" ), tr( "&Edit Attributes..." ), this ); action->setShortcut( tr( "F2" ) ); connect( action, SIGNAL( triggered() ), this, SLOT( editIssue() ), Qt::QueuedConnection ); setAction( "editIssue", action ); action = new QAction( IconLoader::icon( "issue-clone" ), tr( "Clone Issue..." ), this ); connect( action, SIGNAL( triggered() ), this, SLOT( cloneIssue() ), Qt::QueuedConnection ); setAction( "cloneIssue", action ); action = new QAction( IconLoader::icon( "issue-move" ), tr( "&Move Issue..." ), this ); action->setIconText( tr( "Move" ) ); connect( action, SIGNAL( triggered() ), this, SLOT( moveIssue() ), Qt::QueuedConnection ); setAction( "moveIssue", action ); action = new QAction( IconLoader::icon( "edit-delete" ), tr( "&Delete Issue" ), this ); action->setIconText( tr( "Delete" ) ); action->setShortcut( QKeySequence::Delete ); connect( action, SIGNAL( triggered() ), this, SLOT( deleteIssue() ), Qt::QueuedConnection ); setAction( "deleteIssue", action ); action = new QAction( IconLoader::icon( "issue" ), tr( "Mark As Read" ), this ); connect( action, SIGNAL( triggered() ), this, SLOT( markAsRead() ), Qt::QueuedConnection ); setAction( "markAsRead", action ); action = new QAction( IconLoader::icon( "folder-read" ), tr( "Mark All As Read" ), this ); action->setIconText( tr( "Mark All As Read", "icon text" ) ); setAction( "popupMarkAll", action ); action = new QAction( IconLoader::icon( "folder-read" ), tr( "Mark All As Read" ), this ); connect( action, SIGNAL( triggered() ), this, SLOT( markAllAsRead() ), Qt::QueuedConnection ); setAction( "markAllAsRead", action ); action = new QAction( IconLoader::icon( "folder-unread" ), tr( "Mark All As Unread" ), this ); connect( action, SIGNAL( triggered() ), this, SLOT( markAllAsUnread() ), Qt::QueuedConnection ); setAction( "markAllAsUnread", action ); action = new QAction( IconLoader::icon( "issue-subscribe" ), tr( "Subscribe" ), this ); connect( action, SIGNAL( triggered() ), this, SLOT( subscribe() ), Qt::QueuedConnection ); setAction( "subscribe", action ); action = new QAction( IconLoader::icon( "file-print" ), tr( "Print List" ), this ); action->setIconText( tr( "Print" ) ); action->setShortcut( QKeySequence::Print ); connect( action, SIGNAL( triggered() ), this, SLOT( printReport() ), Qt::QueuedConnection ); setAction( "printReport", action ); action = new QAction( IconLoader::icon( "export-pdf" ), tr( "Export List" ), this ); action->setIconText( tr( "Export" ) ); setAction( "popupExport", action ); action = new QAction( IconLoader::icon( "export-csv" ), tr( "Export To CSV" ), this ); connect( action, SIGNAL( triggered() ), this, SLOT( exportCsv() ), Qt::QueuedConnection ); setAction( "exportCsv", action ); action = new QAction( IconLoader::icon( "export-html" ), tr( "Export To HTML" ), this ); connect( action, SIGNAL( triggered() ), this, SLOT( exportHtml() ), Qt::QueuedConnection ); setAction( "exportHtml", action ); action = new QAction( IconLoader::icon( "export-pdf" ), tr( "Export To PDF" ), this ); connect( action, SIGNAL( triggered() ), this, SLOT( exportPdf() ), Qt::QueuedConnection ); setAction( "exportPdf", action ); action = new QAction( IconLoader::icon( "configure-views" ), tr( "&Manage Views..." ), this ); connect( action, SIGNAL( triggered() ), this, SLOT( manageViews() ), Qt::QueuedConnection ); setAction( "manageViews", action ); action = new QAction( IconLoader::icon( "view-new" ), tr( "Add View" ), this ); setAction( "popupAddView", action ); action = new QAction( IconLoader::icon( "view-new" ), tr( "&Add View" ), this ); connect( action, SIGNAL( triggered() ), this, SLOT( addView() ), Qt::QueuedConnection ); setAction( "addView", action ); action = new QAction( IconLoader::icon( "view-clone" ), tr( "&Clone View" ), this ); connect( action, SIGNAL( triggered() ), this, SLOT( cloneView() ), Qt::QueuedConnection ); setAction( "cloneView", action ); action = new QAction( IconLoader::icon( "edit-modify" ), tr( "M&odify View" ), this ); connect( action, SIGNAL( triggered() ), this, SLOT( modifyView() ), Qt::QueuedConnection ); setAction( "modifyView", action ); setTitle( "sectionAdd", tr( "Add" ) ); setTitle( "sectionFolder", tr( "Folder" ) ); setTitle( "sectionIssue", tr( "Issue" ) ); setTitle( "sectionViews", tr( "Views" ) ); setTitle( "sectionReport", tr( "Report" ) ); setPopupMenu( "popupExport", "menuExport", "exportPdf" ); setPopupMenu( "popupMarkAll", "menuMarkAll", "markAllAsRead" ); setPopupMenu( "popupAddView", "menuAddView", "addView" ); setDefaultMenuAction( "menuIssue", "openIssue" ); loadXmlUiFile( ":/resources/folderview.xml" ); QWidget* main = new QWidget( parentWidget ); QVBoxLayout* mainLayout = new QVBoxLayout( main ); mainLayout->setMargin( 0 ); mainLayout->setSpacing( 0 ); QHBoxLayout* viewLayout = new QHBoxLayout(); viewLayout->setMargin( 3 ); viewLayout->setSpacing( 5 ); mainLayout->addLayout( viewLayout ); QLabel* viewLabel = new QLabel( tr( "&View:" ), main ); viewLayout->addWidget( viewLabel ); m_viewCombo = new SeparatorComboBox( main ); m_viewCombo->setMaxVisibleItems( 15 ); m_viewCombo->setMaximumWidth( 200 ); m_viewCombo->setMinimumWidth( 100 ); connect( m_viewCombo, SIGNAL( activated( int ) ), this, SLOT( viewActivated( int ) ) ); viewLayout->addWidget( m_viewCombo, 1 ); viewLabel->setBuddy( m_viewCombo ); viewLayout->addStretch( 0 ); QLabel* searchLabel = new QLabel( tr( "&Search:" ), main ); viewLayout->addWidget( searchLabel ); m_searchBox = new SearchEditBox( main ); m_searchBox->setMaximumWidth( 200 ); m_searchBox->setMinimumWidth( 100 ); connect( m_searchBox, SIGNAL( textChanged( const QString& ) ), this, SLOT( quickSearchChanged( const QString& ) ) ); m_searchMenu = new QMenu( m_searchBox ); m_searchBox->setOptionsMenu( m_searchMenu ); m_searchActionGroup = new QActionGroup( this ); connect( m_searchActionGroup, SIGNAL( triggered( QAction* ) ), this, SLOT( searchActionTriggered( QAction* ) ) ); viewLayout->addWidget( m_searchBox, 1 ); searchLabel->setBuddy( m_searchBox ); m_list = new QTreeView( main ); mainLayout->addWidget( m_list ); TreeViewHelper helper( m_list ); helper.initializeView(); connect( m_list, SIGNAL( customContextMenuRequested( const QPoint& ) ), this, SLOT( listContextMenu( const QPoint& ) ) ); connect( m_list->header(), SIGNAL( customContextMenuRequested( const QPoint& ) ), this, SLOT( headerContextMenu( const QPoint& ) ) ); connect( m_list, SIGNAL( doubleClicked( const QModelIndex& ) ), this, SLOT( doubleClicked( const QModelIndex& ) ) ); connect( m_searchBox, SIGNAL( deactivate() ), m_list, SLOT( setFocus() ) ); main->installEventFilter( this ); m_list->installEventFilter( this ); m_list->viewport()->installEventFilter( this ); setMainWidget( main ); setViewerSizeHint( QSize( 700, 500 ) ); setViewerSizeKey( "FolderView" ); m_list->setFocus(); }
/*-----------------------------------------------------------*/ int reduction(int benchmarkType){ int dataSizeIter, sizeofBuf; /* Initialise repsToDo to defaultReps */ repsToDo = defaultReps; /* Start loop over data sizes */ dataSizeIter = minDataSize; /* initialise dataSizeIter */ while (dataSizeIter <= maxDataSize){ /* allocate space for the main data arrays.. */ allocateReduceData(dataSizeIter); /* Perform benchmark warm-up */ if (benchmarkType == REDUCE){ reduceKernel(warmUpIters, dataSizeIter); /* Master process tests if reduce was a success */ if (myMPIRank == 0){ testReduce(dataSizeIter, benchmarkType); } } else if (benchmarkType == ALLREDUCE){ /* calculate sizeofBuf for test */ sizeofBuf = dataSizeIter * numThreads; allReduceKernel(warmUpIters, dataSizeIter); /* all processes need to perform unit test */ testReduce(sizeofBuf, benchmarkType); } /* Initialise the benchmark */ benchComplete = FALSE; /* Execute benchmark until target time is reached */ while (benchComplete != TRUE){ /* Start timer */ MPI_Barrier(comm); startTime = MPI_Wtime(); /* Execute reduce for repsToDo repetitions */ if (benchmarkType == REDUCE){ reduceKernel(repsToDo, dataSizeIter); } else if (benchmarkType == ALLREDUCE){ allReduceKernel(repsToDo, dataSizeIter); } /* Stop timer */ MPI_Barrier(comm); finishTime = MPI_Wtime(); totalTime = finishTime - startTime; /* Test if target time was reached with the number of reps */ if (myMPIRank==0){ benchComplete = repTimeCheck(totalTime, repsToDo); } /* Ensure all procs have the same value of benchComplete */ /* and repsToDo */ MPI_Bcast(&benchComplete, 1, MPI_INT, 0, comm); MPI_Bcast(&repsToDo, 1, MPI_INT, 0, comm); } /* Master process sets benchmark result for reporting */ if (myMPIRank == 0){ setReportParams(dataSizeIter, repsToDo, totalTime); printReport(); } /* Free allocated data */ freeReduceData(); /* Double dataSize and loop again */ dataSizeIter = dataSizeIter * 2; } return 0; }
void input(){ static const char filename[] = "objects/input3.txt"; FILE *file = fopen ( filename, "r" ); if (file != NULL) { char line [ 128 ]; int i; while ( fgets ( line, sizeof line, file ) != NULL ) /* read a line */ { if (line[0]=='#' || line[0]==' ' || line[0]=='\n' ){ continue; } else if(line[0]=='v'){ float x,y,z; sscanf (line,"v %f,%f,%f ",&x, &y, &z); //~ printf("V[%d]: x= %4.2f, y= %4.2f, z= %4.2f \n",vIndex,x,y,z); createVertex(vIndex,x,y,z); vIndex++; } else if(line[0]=='f'){ int v1,v2,v3,v4; sscanf (line,"f %d,%d,%d,%d ",&v1, &v2, &v3, &v4); //~ printf("Face found: v1= %d, v2= %d, v3=%d, v4=%d \n",v1,v2,v3,v4); if (v1>vIndex || v2>vIndex || v3>vIndex || v4>vIndex ) { //~ printf("Invalid Vertex Index \n"); } else{ //~ printf("BEFORE findex : %d, eIndex : %d\n",fIndex,eIndex); faces[fIndex].edge1=-1; faces[fIndex].edge2=-1; faces[fIndex].edge3=-1; faces[fIndex].edge4=-1; faces[fIndex].vert1=v1; faces[fIndex].vert2=v2; // Vertices set faces[fIndex].vert3=v3; faces[fIndex].vert4=v4; eIndex=createEdge(fIndex,1,eIndex,v1, v2); eIndex=createEdge(fIndex,2,eIndex,v2, v3); eIndex=createEdge(fIndex,3,eIndex,v3, v4); // Edges Set eIndex=createEdge(fIndex,4,eIndex,v4, v1); fIndex++; #ifdef PRINTALL printf("AFter findex : %d, eIndex : %d \n",fIndex,eIndex); #endif } } else { #ifdef PRINTALL printf("INVALID LINE : \t"); #endif fputs ( line, stdout ); /* write the line */ } } #ifdef PRINTALL printf("INPUT COMPLETE \n \tVertices scanned:\t %d \n \t Faces Scanned: \t %d \n Edges Scanned:\t %d \n",vIndex,fIndex,eIndex); printReport(); printf("Face1 > %d, %d \n",edges[faces[1].edge3].vert1,edges[faces[1].edge3].vert2); #endif fclose ( file ); } else { perror ( filename ); /* why didn't the file open? */ } }
/*-----------------------------------------------------------*/ int haloExchange(int benchmarkType){ int dataSizeIter; /* find the ranks of the left and right neighbour */ findNeighbours(); /* initialise repsToDo to defaultReps */ repsToDo = defaultReps; /* Start loop over data sizes */ dataSizeIter = minDataSize; /* Initialise dataSizeIter */ MPI_Barrier(comm); while (dataSizeIter <= maxDataSize){ /* set sizeofBuffer */ sizeofBuffer = dataSizeIter * numThreads; /*Allocate space for the main data arrays */ allocateHaloexchangeData(sizeofBuffer); /* perform benchmark warm-up */ if (benchmarkType == MASTERONLY){ masteronlyHaloexchange(warmUpIters, dataSizeIter); } else if (benchmarkType == FUNNELLED){ funnelledHaloexchange(warmUpIters, dataSizeIter); } else if (benchmarkType == MULTIPLE){ multipleHaloexchange(warmUpIters, dataSizeIter); } GASPI(barrier(GASPI_GROUP_ALL, GASPI_BLOCK)); /* Each process performs a verification test */ testHaloexchange(sizeofBuffer, dataSizeIter); MPI_Barrier(comm); /*Initialise the benchmark */ benchComplete = FALSE; /*Execute benchmark until target time is reached */ while (benchComplete != TRUE){ /*Start timer */ GASPI(barrier(GASPI_GROUP_ALL, GASPI_BLOCK)); startTime = MPI_Wtime(); /*Execute benchmarkType for repsToDo repetitions*/ if (benchmarkType == MASTERONLY){ masteronlyHaloexchange(repsToDo, dataSizeIter); } else if (benchmarkType == FUNNELLED){ funnelledHaloexchange(repsToDo, dataSizeIter); } else if (benchmarkType == MULTIPLE){ multipleHaloexchange(repsToDo, dataSizeIter); } /*Stop timer */ GASPI(barrier(GASPI_GROUP_ALL, GASPI_BLOCK)); finishTime = MPI_Wtime(); totalTime = finishTime - startTime; MPI_Barrier(comm); /* Test if target time is reached with the number of reps */ if (myMPIRank==0){ benchComplete = repTimeCheck(totalTime, repsToDo); } /* Ensure all procs have the same value of benchComplete */ /* and repsToDo */ MPI_Bcast(&benchComplete, 1, MPI_INT, 0, comm); MPI_Bcast(&repsToDo, 1, MPI_INT, 0, comm); } /* Master process sets benchmark results */ if (myMPIRank == 0 ){ setReportParams(dataSizeIter, repsToDo, totalTime); printReport(); } /* Free allocated data */ freeHaloexchangeData(); /* Double dataSize and loop again */ dataSizeIter = dataSizeIter * 2; } return 0; }
void client(NodeId remoteNodeId){ isClient = true; currentPhase = 0; memcpy(allPhases, testSpec, sizeof(testSpec)); int counter = 0; int sigCounter = 0; while(true){ TestPhase * current = &allPhases[currentPhase]; if(current->noOfSignals == current->noOfSignalSent && current->noOfSignals == current->noOfSignalReceived){ /** * Test phase done */ current->stopTime = NdbTick_CurrentMillisecond(); current->accTime += (current->stopTime - current->startTime); NdbSleep_MilliSleep(500 / loopCount); current->startTime = NdbTick_CurrentMillisecond(); current->noOfSignalSent = 0; current->noOfSignalReceived = 0; current->loopCount ++; if(current->loopCount == loopCount){ printReport(allPhases[currentPhase]); currentPhase ++; if(currentPhase == noOfTests){ /** * Now we are done */ break; } NdbSleep_MilliSleep(500); current = &allPhases[currentPhase]; current->startTime = NdbTick_CurrentMillisecond(); } } int signalsLeft = current->noOfSignals - current->noOfSignalSent; if(signalsLeft > 0){ for(; signalsLeft > 0; signalsLeft--){ if(sendSignalTo(remoteNodeId,current->signalSize,sigCounter)== SEND_OK){ current->noOfSignalSent++; sigCounter++; } else { ndbout << "Failed to send: " << sigCounter << endl; tReg->external_IO(10); break; } } } if(counter % 10 == 0) tReg->checkConnections(); tReg->external_IO(0); counter++; } }
void Server::onSocketError(QAbstractSocket::SocketError err) { QTcpSocket* client_socket = qobject_cast<QTcpSocket*>(sender()); printReport(tr("%1: (%2) %3").arg(client_socket->socketDescriptor()).arg(err).arg(client_socket->errorString())); client_socket->disconnectFromHost(); }
void Server::onServerError(QAbstractSocket::SocketError err) { printReport(tr("Server Error: (%1) %2").arg(err).arg(server->errorString())); }
void Server::onSocketDisconnected() { QTcpSocket* client_socket = qobject_cast<QTcpSocket*>(sender()); printReport(tr("User disconnected")); client_socket->close(); }
void prompt(int menu) { console_clrscr(); switch (menu) { case MAIN_MENU:{ printf("\n LibXenon NANDFlasher v%s \n",version); printf(" **************************\n\n"); printf("Flashconfig 0x%08X\n",flashconfig); printf("NAND-Size %i MB\n\n",sfc.size_mb); printf("Press A to save NAND to file on USB.\n"); printf("Press X to write file from USB to NAND.\n"); printf("Press B to analyze NAND.\n"); printf("Press Y to update XeLL.\n"); printf("Press START for DMA test.\n"); printf("Press GUIDE to return to XeLL.\n"); struct controller_data_s controller; while(1) { struct controller_data_s button; if (get_controller_data(&button, 0)) { if((button.a)&&(!controller.a)) prompt(DUMP_SUBMENU); if((button.x)&&(!controller.x)) writeNand("uda:/updflash.bin"); if((button.b)&&(!controller.b)) prompt(ANALYZE_SUBMENU); if((button.y)&&(!controller.y)) updateXeLL("uda:/updxell.bin"); if((button.start)&&(!controller.start)) dmatest(); if((button.logo)&&(!controller.logo)) break; controller=button; } usb_do_poll(); } } case DUMP_SUBMENU:{ int nand_sz = sfc.size_bytes; if (nand_sz != NAND_SIZE_256MB && nand_sz != NAND_SIZE_512MB) readNand("uda:/flashdmp.bin", FULL_DUMP); printf("\n DUMP MENU \n"); printf(" **************************\n\n"); printf("Press A to dump whole NAND.\n"); printf("Press B to dump only flash-partition.\n"); printf("Press BACK to go back to main menu.\n"); struct controller_data_s controller; while(1) { struct controller_data_s button; if (get_controller_data(&button, 0)) { if((button.a)&&(!controller.a)) readNand("uda:/flashdmp.bin", FULL_DUMP); if((button.b)&&(!controller.b)) readNand("uda:/flashdmp.bin", BB64MB_ONLY); if((button.select)&&(!controller.select)) prompt(MAIN_MENU); controller=button; } usb_do_poll(); } } case ANALYZE_SUBMENU:{ printf("\n ANALYZE MENU \n"); printf(" **************************\n\n"); printf("Press A to analyze physical NAND.\n"); printf("Press B to analyze file updflash.bin.\n"); printf("Press BACK to go back to main menu.\n"); struct controller_data_s controller; while(1) { struct controller_data_s button; if (get_controller_data(&button, 0)) { if((button.a)&&(!controller.a)) prompt(ANALYZE_PHYS_SUBMENU); if((button.b)&&(!controller.b)) prompt(ANALYZE_FILE_SUBMENU); if((button.select)&&(!controller.select)) prompt(MAIN_MENU); controller=button; } usb_do_poll(); } } case ANALYZE_PHYS_SUBMENU:{ int nand_sz = sfc.size_bytes; int blocks = sfc.size_blocks; if (nand_sz == NAND_SIZE_256MB || nand_sz == NAND_SIZE_512MB) blocks = 0x200; printf("\n ANALYZE NAND \n"); printf(" **************************\n\n"); printf("Press A to scan for Bad Blocks.\n"); printf("Press B to scan for Bad Blocks and EDC errors.\n"); printf("Press BACK to go back to main menu.\n"); struct controller_data_s controller; while(1) { struct controller_data_s button; if (get_controller_data(&button, 0)) { if((button.a)&&(!controller.a)){ analyzeNand(0,blocks,0); printReport(BBMnand); waitforexit(); } if((button.b)&&(!controller.b)){ analyzeNand(0,blocks,1); printReport(BBMnand); waitforexit(); } if((button.select)&&(!controller.select)) prompt(MAIN_MENU); controller=button; } usb_do_poll(); } } case ANALYZE_FILE_SUBMENU:{ int nand_sz = sfc.size_bytes; int blocks = sfc.size_blocks; if (nand_sz == NAND_SIZE_256MB || nand_sz == NAND_SIZE_512MB) blocks = 0x200; printf("\n ANALYZE FILE \n"); printf(" **************************\n\n"); printf("Press A to scan for Bad Blocks.\n"); printf("Press B to scan for Bad Blocks and EDC errors.\n"); printf("Press BACK to go back to main menu.\n"); struct controller_data_s controller; while(1) { struct controller_data_s button; if (get_controller_data(&button, 0)) { if((button.a)&&(!controller.a)){ analyzeFile("uda:/updflash.bin",0,blocks, 0); printReport(BBMfile); waitforexit(); } if((button.b)&&(!controller.b)){ analyzeFile("uda:/updflash.bin",0,blocks, 1); printReport(BBMfile); waitforexit(); } if((button.select)&&(!controller.select)) prompt(MAIN_MENU); controller=button; } usb_do_poll(); } } } return 0; }
int main(int argc, char *argv[]){ int numberTrials; char fileName[100]; char input[1]; int c,d,i; int sfd; pthread_t optimalThread; pthread_t fifoThread; pthread_t lruThread; pthread_t mruThread; pthread_t lfuThread; pthread_t mfuThread; pthread_t randThread; pthread_attr_t attr; if (argc == 2){ sequenceLength = 0; strcpy(fileName, argv[1]); numberTrials = 1; FILE* file = fopen(fileName, "r"); c = 0; fscanf (file, "%d", &c); while (!feof(file)){ sequenceLength++; fscanf(file, "%d", &c); } fclose(file); } else if(argc == 3){ sequenceLength = atoi(argv[1]); numberTrials = atoi(argv[2]); printf("Testing Belady's Anomaly using %d random sequences and Trying %d time\n", sequenceLength, numberTrials); } else{ printf("Usage : \n"); printf("PERPA <sequence-file> | <sequence-length> <trials-number> \n"); exit(1); } int pageSequence[sequenceLength]; if(argc == 2){ FILE* file = fopen(fileName, "r"); c = 0; d = 0; fscanf(file, "%d", &c); while(!feof(file)){ pageSequence[d] = c; fscanf (file, "%d", &c); d++; } fclose(file); } printf("\n"); srand(time(NULL) + getpid() *42); pthread_attr_init(&attr); initializeBeladySummary(); totalBeladyCount = 0; for(i = 0; i < numberTrials; i++){ trialCounter = i; //initializeReportData(); //initializeBeladyReport(); if(argc == 3){ printf("Trial #%d\n", i+1); generateSequence(pageSequence); } else{ printf("Using Sequence stored in File: %s\n", fileName); } pthread_create(&optimalThread, &attr, optimalPage, (void *) pageSequence); pthread_create(&fifoThread, &attr, FIFO, (void *) pageSequence); pthread_create(&lruThread, &attr, leastRecent, (void *) pageSequence); pthread_create(&mruThread, &attr, mostRecent, (void *) pageSequence); pthread_create(&lfuThread, &attr, leastFrequent, (void *) pageSequence); pthread_create(&mfuThread, &attr, mostFrequent, (void *) pageSequence); pthread_create(&randThread, &attr, randomSelect, (void *) pageSequence); sleep(2); printReport((i+1), pageSequence); beladyReport(); } beladySummary(); exit(0); }
int main(int argc, char **argv) { fprintf(stderr, "hello world\n"); // this can hold blockcounts: // uint64_t blockCounts[256]; // We need 128 of these, hold block counts for each level const size_t toMalloc = 256*sizeof(uint64_t) * 128; // [ table size ] * [num tables] fprintf(stderr, "mallocing %d bytes of memory to block tables... ", toMalloc); char * blockTable = (char*)malloc(toMalloc); fprintf(stderr, "ok.\n"); fprintf(stderr, "clearing... "); memset(blockTable, 0, toMalloc); fprintf(stderr, "ok.\n"); walkDir(argv[1], blockTable); fprintf(stderr, "\n-- REPORT --\n"); //fprintf(stderr, "Read %u chunks\n", numChunks); printReport("data.js", blockTable); free(blockTable); /* Test code: TODO, move this elsewhere printf("read in %d bytes: %d\n", r, (unsigned int)(*buf)); char t[256] = "\x00\x00\x00\x01\x00\x09\x00\x05hello\x00\x00\x00\x06\x01\x02\x03\x04\x05\x06\x12"; char *test = t; NBT_Int i(test); printf("int val=%d\n", i.getValue()); assert(i.getValue() == 1); test += i.size; NBT_Short s(test); printf("short val=%d\n", s.getValue()); assert(s.getValue() == 9); test+=s.size; NBT_String str(test); printf("str val=%s\n", str.getString().c_str()); assert(strncmp(str.getString().c_str(), "hello", 5) == 0); test += str.size; assert(str.size == 7); NBT_Byte_Array ba(test); assert(ba.size == (4+6)); assert(ba.length() == 6); assert(memcmp(ba.buff, "\x01\x02\x03\x04\x05\x06", 6) == 0); test += ba.size; NBT_Byte b(test); assert(b.getByte() == 0x12); assert(b.size == 1); test += b.size; char t2[256] = "\x09\x00\x06mylist\x02\x00\x00\x00\x04\x00\x01\x00\x02\x00\x03\x00\x04"; test = t2; test += 1; NBT_String t_name(test); test += t_name.size; printf("name: %s\n", t_name.getString().c_str()); NBT_List l(test); assert(l.getListType() == TAG_Short); assert(l.getList().size() == 4); printf("start Compounttest:\n"); char t3[256] = "\x01\x00\x04\x42yte\xab\x03\x00\x05myint\x00\x00\x00\x08\x02\x00\x07myshort\x00\xff\x00"; test = t3; NBT_Compound cmp(test); printf("real data test\n----\n"); test = buf; test++; NBT_String buf_string(test); test += buf_string.size; printf("compound name: %s\n", buf_string.getString().c_str()); NBT_Compound buf_compound(test); buf_compound.name = buf_string.getString(); printf("\n\n"); buf_compound.print(0); list<NBT_Tag*> listlist = buf_compound.getList(); //t->print(); //free(testbuf); */ return 0; }
void Server::setDiode(const Diode& diode_) { diode.reset(new Diode(diode_)); printReport(tr("Diode = {\n\tstate: %1\n\tcolor: %2\n\trate: %3\n}").arg(diode->state()?"on":"off").arg(diode->color()).arg(diode->rate())); }