void MusicControl::updateTime() { long len = m_c->length(); m_seekSlider->setMaximum(len); long pos = m_c->position(); m_seekSlider->setValue(pos); QString timeString; if (pos || len) { int sec = pos/1000; int min = sec/60; int hour = min/60; int msec = pos; QTime playTime(hour%60, min%60, sec%60, msec%1000); sec = len / 1000; min = sec / 60; hour = min / 60; msec = len; QTime stopTime(hour%60, min%60, sec%60, msec%1000); QString timeFormat = "m:ss"; if(hour > 0) timeFormat = "h:mm:ss"; timeString = playTime.toString(timeFormat); if(len) timeString += " / " + stopTime.toString(timeFormat); } m_timeLabel->setText(timeString); }
// show playing time (left or elapsed just click on the label to switch) void Player::updateTime() { long len = videoPlayer->mediaObject()->totalTime(); long pos = videoPlayer->mediaObject()->currentTime(); timeSlider->setValue(pos); QString timeString; if (pos || len) { int sec = pos/1000; int min = sec/60; int hour = min/60; int msec = pos; QTime playTime(hour%60, min%60, sec%60, msec%1000); sec = len / 1000; min = sec / 60; hour = min / 60; msec = len; QTime stopTime(hour%60, min%60, sec%60, msec%1000); QString timeFormat = "hh:mm:ss"; timeString = playTime.toString(timeFormat); } timeLabel->setText(timeString); }
void Scoremiddlegoal() { waitForButton(); starttask(CollectD); { drive_Enc(63,7,4); } stopdrivemotors(); StopTask(CollectD); StartTask(medgoal); { stopTime(1.75);//wait for arm drive_Enc(63,8,5);//drive foward } StopTask(medgoal); spit(0.75); drive_Enc(-63,4,2); spit(0.75); StartTask(armDown); { drive_Enc(-63,15,5); } StopTask(armDown); waitForButton(); StartTask(CollectD); { drive_Enc(70,15,5); } StopTask(CollectD); }
void Sudoku::on_actionSalir_triggered() { if (QMessageBox::Yes == QMessageBox::question(this, "Salir", "Si no ha guardado, se perderá la partida actual.\n¿Seguro que desea salir?", QMessageBox::Yes|QMessageBox::No)){ QMessageBox::information(this,"Salir","Vuelva pronto!"); stopTime(); close(); } }
void Sudoku::on_actionVolver_al_men_principal_triggered() { if (QMessageBox::Yes == QMessageBox::question(this, "Volver", "Si no ha guardado, se perderá la partida actual.\n¿Desea continuar?", QMessageBox::Yes|QMessageBox::No)){ Ventana_principal *v = new Ventana_principal(); stopTime(); close(); v->show(); } }
void BoardDispatch::sendRequestMatchMode(void) { if(connection) { stopTime(); //maybe?? boardwindow->getUi()->undoButton->setEnabled(false); connection->sendRequestMatchMode(gameData->number); } }
void BoardDispatch::sendRequestDraw(void) { if(connection) { stopTime(); //protocol specific or not? boardwindow->getUi()->drawButton->setEnabled(false); connection->sendRequestDraw(gameData->number); } }
/* FIXME * note that after a request count is sent in tygem, * NO other button can be hit until the response occurs, * you can't even resign. * Its also likely that you can only request one count * per turn. * But so this suggests maybe a lock buttons button. * I don't like the placement of the request count * button right now either. Also, done button means * nothing. If it closes the window, that's one thing * but otherwise, why have two buttons. done is for * score, should be disabled afterwards. * Also, closing windows is generally not allowed. It * should always force a resign or prompt or maybe ask * for an adjourn */ void BoardDispatch::sendRequestCount(void) { if(connection) { stopTime(); //protocol specific or not? FIXME, huge issue if protocol does this to!!! see cyberoro killActiveMatchTimers, figure out who should do this when boardwindow->getUi()->countButton->setEnabled(false); connection->sendRequestCount(gameData->number); } }
/* * initialises the scoring phase in match mode */ void qGoBoardMatchInterface::enterScoreMode() { if(boardwindow->getGamePhase() == phaseScore) return; stopTime(); qGoBoard::enterScoreMode(); //boardwindow->getUi().doneButton->setEnabled(true); kibitzReceived(tr("SCORE MODE: click on a stone to mark as dead...")); }
void drive_Highgoal() { spit(0.5);/// let the spinners roll out. drivetime(80,1.2); stopDrivemotors(); ;//zero-out the motors //stopTime(1.75);//wait for arm // drivetime(50,2);//drive foward more... stopTime(20);//sit at the wall for three seconds. // drive_Enc(-85,2.75,3.4);//back up and spit. // spit(4);// spit // drive_Enc(-100, 7,2);//back up }
void Timer::step (std::string text) { stopTime(); stopMemory(); clock_t clickNb = eTime - iTime; time = ((float)clickNb)/CLOCKS_PER_SEC; memory = eMemory - iMemory; if (text != "") { std::cout << text << ": "; } std::cout << "STEP TIMER " << id << " (" << time << " sec, " << memory << " bytes)" << std::endl; iTime = clock(); iMemory = getMemory(); }
// ------------------------- int _tmain(int argc, _TCHAR* argv[]) { // decl a default time cTime a; // a.mHours == 0 // decl a time set to 1:15:30 (and :0 ms) cTime b( 1, 15, 30 ); SYSTEMTIME st; //GetSystemTime(&st); GetLocalTime(&st); // regular constructor cTime now(st); // decl a time set to the value of b cTime c(b); // const // copy c to d // equality operator cTime d = c; // half as efficient as cTime d( c ); a.ToString(); b.ToString(); c.ToString(); d.ToString(); now.ToString(); if(c == b) { cout << "c == b" << endl; } else { cout << "c != b" << endl; } cTime stopTime(0, 0, 30); cTime clock; //0, 0, 0 cTime frameTime(0, 0, 1); //1 frame per second GetLocalTime(&st); cTime before(st); while(clock < stopTime) { GetLocalTime(&st); cTime now(st); cTime elapsed = now - before; if(elapsed >= frameTime) { clock += (elapsed.CalcSum()); clock.ToString(); before = now; } } //::OutputDebugString("Hello World\n"); //great to use later on for debugging cout << "Time is up!" << endl; return 0; }
BOOL WizUserInteraction::OnCommand(WPARAM wParam, LPARAM lParam) { switch( LOWORD( wParam ) ) { case IDOK: // map properties { m_interfaceInteractionPage.UpdateData(TRUE); // m_modelInteractionPage.UpdateData(TRUE); // m_ppUserInteractionStructure.UpdateData(TRUE); m_ppUserInteractionSimControl.UpdateData(TRUE); gpHydroModel->m_collectionInterval = m_interfaceInteractionPage.m_collectionint; gpHydroModel->m_checkMassBalance = m_interfaceInteractionPage.m_updateClassificationExtent; gpHydroModel->m_streamDataToCollect = m_interfaceInteractionPage.m_radioq; gpHydroModel->m_cellDataToCollect = m_interfaceInteractionPage.m_radioswc; gpMapWnd->m_maxBinValue=m_interfaceInteractionPage.m_maxq; gpMapWnd->m_minBinValue=m_interfaceInteractionPage.m_minq; gpMapWnd->m_numBin = m_interfaceInteractionPage.m_numbin; gpHydroModel->m_saveEmfOutput = m_interfaceInteractionPage.m_saveEmfOutput; // added by MG gpHydroModel->m_spinUp = m_interfaceInteractionPage.m_spinUp; gpHydroModel->m_updateStream = m_interfaceInteractionPage.m_updatestream; gpHydroModel->m_updateUpland = m_interfaceInteractionPage.m_updateupland; gpHydroModel->m_cellDataToCollect=m_interfaceInteractionPage.m_radioswc; /* gpHydroModel->m_checkCKsat=m_modelEvaluation.m_ppModelEvalModelEvaluation.m_checkKSat; gpHydroModel->m_checkCFC=m_modelEvaluation.m_ppModelEvalModelEvaluation.m_checkFieldCapac; gpHydroModel->m_checkCInit=m_modelEvaluation.m_ppModelEvalModelEvaluation.m_checkInitSat; gpHydroModel->m_checkCK1= m_modelEvaluation.m_ppModelEvalModelEvaluation.m_checkK1; gpHydroModel->m_checkCKD=m_modelEvaluation.m_ppModelEvalModelEvaluation.m_checkKDepth; gpHydroModel->m_checkCPhi=m_modelEvaluation.m_ppModelEvalModelEvaluation.m_checkPhi; gpHydroModel->m_checkCSD=m_modelEvaluation.m_ppModelEvalModelEvaluation.m_checkSoilDepth; gpHydroModel->m_checkCVan=m_modelEvaluation.m_ppModelEvalModelEvaluation.m_checkVanGenuctN; */ if (m_interfaceInteractionPage.m_updatestream) gpHydroModel->m_updateStream=TRUE; else gpHydroModel->m_updateStream=FALSE; if (m_interfaceInteractionPage.m_updateupland) gpHydroModel->m_updateUpland=TRUE; else gpHydroModel->m_updateUpland=FALSE; gpHydroModel->m_cellDataArray.RemoveAll(); for ( int i=0; i < m_ppUserInteractionSimControl.m_cellList.GetCount(); i++ ) { char buffer[ 64 ]; m_ppUserInteractionSimControl.m_cellList.GetText( i, buffer ); if (gpHydroModel->m_modelStructureMethod==WH_DISTRIBUTE_FPGRID || gpHydroModel->m_modelStructureMethod==WH_DISTRIBUTE_WTHEIGHT) { int cell;int cell2; int fields = sscanf( buffer, "%i ,%i", &cell, &cell2 ); //ASSERT( fields == 1 ); gpHydroModel->m_cellDataArray.Add( cell ); gpHydroModel->m_cellDataArray.Add( cell2 ); } else { int cell; int fields = sscanf( buffer, "%i", &cell ); ASSERT( fields == 1 ); gpHydroModel->m_cellDataArray.Add( cell ); } } gpHydroModel->m_reachDataArray.RemoveAll(); for ( i=0; i < m_ppUserInteractionSimControl.m_reachList.GetCount(); i++ ) { char buffer[ 64 ]; m_ppUserInteractionSimControl.m_reachList.GetText( i, buffer ); int reach; int fields = sscanf( buffer, "%i", &reach ); ASSERT( fields == 1 ); gpHydroModel->m_reachDataArray.Add( reach ); } gpHydroModel->SetDeltaX( gpHydroModel->m_deltaX ); gpHydroModel->SetTimeStep( m_ppUserInteractionSimControl.m_initialTimeStep ); CString start ,stop; int indexStart = m_ppUserInteractionSimControl.m_comboStartTime.GetCurSel(); int indexStop = m_ppUserInteractionSimControl.m_comboStopTime.GetCurSel(); m_ppUserInteractionSimControl.m_comboStartTime.GetLBText(indexStart,start); m_ppUserInteractionSimControl.m_comboStopTime.GetLBText(indexStop,stop); int stopMonth = atoi(stop.Left(2)); int stopDay = atoi(stop.Mid(3,2)); int stopYear = atoi(stop.Right(4)); COleDateTime stopTime( stopYear, stopMonth, stopDay, 0, 0, 0 ); int startMonth=atoi(start.Left(2)); int startDay = atoi(start.Mid(3,2)); int startYear = atoi(start.Right(4)); COleDateTime startTime( startYear, startMonth, startDay, 0, 0, 0 ); gpHydroModel->SetStopTime( stopTime.m_dt ); gpHydroModel->m_stopTimeHolder = stopTime.m_dt; gpHydroModel->SetStartTime( startTime.m_dt ); gpHydroModel->m_useVariableStep = m_ppUserInteractionSimControl.m_useVariableStep ? true : false; gpHydroModel->m_timeStep=m_ppUserInteractionSimControl.m_initialTimeStep; gpHydroModel->m_rkvMinTimeStep=m_ppUserInteractionSimControl.m_minimumTimeStep; gpHydroModel->m_rkvMaxTimeStep=m_ppUserInteractionSimControl.m_maximumTimeStep; gpHydroModel->m_rkvTolerance=m_ppUserInteractionSimControl.m_errorTolerance; m_interfaceInteractionPage.SetModified(false); // m_modelInteractionPage.SetModified(false); // m_ppUserInteractionStructure.SetModified(false); m_ppUserInteractionSimControl.SetModified(false); // m_ppUserInteractionFlowMod.SetModified(false); // m_ppUserInteractionTracer.SetModified(false); } ShowWindow(SW_HIDE); break; case IDCANCEL: { ShowWindow(SW_HIDE); } break; case 12321: { m_interfaceInteractionPage.UpdateData(TRUE); //m_modelInteractionPage.UpdateData(TRUE); //m_ppUserInteractionStructure.UpdateData(TRUE); m_ppUserInteractionSimControl.UpdateData(TRUE); m_interfaceInteractionPage.SetModified(FALSE); // m_modelInteractionPage.SetModified(FALSE); // m_ppUserInteractionStructure.SetModified(FALSE); m_ppUserInteractionSimControl.SetModified(FALSE); } break; } // return CPropertySheet::OnCommand(wParam, lParam); return true; }
/* Return microseconds until Mod's stop time */ mtime_t calcDeactivationDelay(mtime_t now) { mtime_t stime = stopTime(); return now < stime ? (stime - now) : 0; }
BitSplit::BitSplit() { fontDb.addApplicationFont(":/fonts/OpenSans-Light.ttf"); fontDb.addApplicationFont(":/fonts/OpenSans-Regular.ttf"); exit = true; blockToggle = false; searchExisting = false; /* Timer setup*/ guiUpdater = new QTimer( this ); guiUpdater->setInterval(25); syncAnimator = new QTimer( this ); syncAnimator->setInterval(75); /* Interface setup */ fileInterface.debug = false; fileInterface.copyDirection = BothDirections; actionCreator.fileInterface = &fileInterface; smartMatch.fileInterface = &fileInterface; actionHandler.fileInterface = &fileInterface; updater.fileInterface = &fileInterface; /* Set up icons */ remove = new QIcon(":images/general/remove.png"); done = new QIcon(":images/table/tick.png"); errorIcon = new QIcon(":images/table/error.png"); skip = new QIcon(":images/table/skip.png"); sync1 = new QIcon(":images/table/sync1.png"); syncAnimation.append(sync1); sync2 = new QIcon(":images/table/sync2.png"); syncAnimation.append(sync2); sync3 = new QIcon(":images/table/sync3.png"); syncAnimation.append(sync3); sync4 = new QIcon(":images/table/sync4.png"); syncAnimation.append(sync4); sync5 = new QIcon(":images/table/sync5.png"); syncAnimation.append(sync5); sync6 = new QIcon(":images/table/sync6.png"); syncAnimation.append(sync6); sync7 = new QIcon(":images/table/sync7.png"); syncAnimation.append(sync7); sync8 = new QIcon(":images/table/sync8.png"); syncAnimation.append(sync8); ui.setupUi( this ); ui.runButton->setDisabled(true); /* Connect buttons to their dialogs */ connect(ui.editSettingsButton, SIGNAL(clicked()), this, SLOT(editSettings())); connect(ui.newProfileButton, SIGNAL(clicked()), this, SLOT(newProfile())); /* Log Connections*/ connect(ui.actionView_Log, SIGNAL(triggered()), this, SLOT(showLog())); connect(ui.exitLog, SIGNAL(clicked()), this, SLOT(showMain())); connect(&fileInterface, SIGNAL(updateLog(QString)), ui.log, SLOT(append(QString))); connect(ui.errorViewLog, SIGNAL(clicked()), this, SLOT(showLog())); /* Top Bar connections*/ connect(&fileInterface, SIGNAL(matchComplete()), this, SLOT(matchComplete())); connect(&fileInterface, SIGNAL(updateSingle(QString)), ui.topBarSingle, SLOT(setText(QString))); connect(&fileInterface, SIGNAL(updateTopMP(QString)), ui.mp_top, SLOT(setText(QString))); connect(&fileInterface, SIGNAL(updateBottomMP(QString)), ui.mp_bottom, SLOT(setText(QString))); connect(&fileInterface, SIGNAL(updateOperationMP(QString)), ui.mp_operation, SLOT(setText(QString))); connect(guiUpdater, SIGNAL(timeout()), &smartMatch, SLOT(updateGuiLabels())); connect(&smartMatch, SIGNAL(startTime()), guiUpdater, SLOT(start())); connect(&smartMatch, SIGNAL(stopTime()), guiUpdater, SLOT(stop())); connect(&smartMatch, SIGNAL(setTopBarLineStack(int)), this, SLOT(setTopBarLineStack(int))); /* Unmatched files tree Connections */ connect(ui.unmatchedTree, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(toggleTree(QTreeWidgetItem*,int))); connect(&fileInterface, SIGNAL(updateFileTree(bool, QTreeWidgetItem *)), this, SLOT(insertTreeItem(bool, QTreeWidgetItem *))); connect(&fileInterface, SIGNAL(pop()), this, SLOT(popParent())); connect(&fileInterface, SIGNAL(expandTree()), this, SLOT(expandTree())); /* Matched Table Connections */ connect(&fileInterface, SIGNAL(insertMatchTableRow(QList<QTableWidgetItem*>*)), this, SLOT(insertMatchTableRow(QList<QTableWidgetItem*>*))); /* Action Table Connections*/ connect(&fileInterface, SIGNAL(insertActionTableRow(QList<QTableWidgetItem*>*)), this, SLOT(insertActionTableRow(QList<QTableWidgetItem*>*))); /* Error connections */ connect(&smartMatch, SIGNAL(operationFailed()), this, SLOT(error())); connect(&actionCreator, SIGNAL(operationFailed()), this, SLOT(error())); connect(&actionHandler, SIGNAL(exception()), this, SLOT(error())); /* Developer Test Connections */ connect(ui.actionDeveloper_Test, SIGNAL(triggered()), this, SLOT(runDeveloperTest())); connect(&smartMatch, SIGNAL(stopTestTime()), this, SLOT(endTimer())); /* Action Handler Connections */ connect(&actionHandler, SIGNAL(updateProgress(int)), ui.progressBar, SLOT(setValue(int))); connect(&actionHandler, SIGNAL(updateActionLabel(QString)), ui.actionLabel, SLOT(setText(QString))); connect(&actionHandler, SIGNAL(updateSpeedLabel(QString)), ui.speedLabel, SLOT(setText(QString))); connect(&actionHandler, SIGNAL(updatePercentageLabel(QString)), ui.mp_busyIndicator, SLOT(setText(QString))); connect(&actionHandler, SIGNAL(setComplete(int)), this, SLOT(setDone(int))); connect(&actionHandler, SIGNAL(setSkipped(int)), this, SLOT(setSkip(int))); connect(&actionHandler, SIGNAL(setError(int)), this, SLOT(setError(int))); connect(&actionHandler, SIGNAL(setInProgress(int)), this, SLOT(setSync(int))); /* Updater Connections */ connect(&updater, SIGNAL(complete()), this, SLOT(updaterComplete())); /* General Connections & Button Stack Connections */ connect(syncAnimator, SIGNAL(timeout()), this, SLOT(showSync())); connect(ui.finishEditButton, SIGNAL(clicked()), this, SLOT(createActions())); connect(&actionCreator, SIGNAL(complete()), this, SLOT(actionsComplete())); connect(ui.runButton, SIGNAL(clicked()), this, SLOT(runActionHandler())); connect(ui.searchButton, SIGNAL(clicked()), this, SLOT(searchForSync())); connect(&actionHandler, SIGNAL(complete()), this, SLOT(actionHandlerComplete())); /* General Setup*/ frame = 0; currentAction = -1; actionHandler.table = ui.actionsTable; ui.mp_ProfileLabel->fontMetrics().width(ui.mp_ProfileLabel->text()); createTrayIcon(); setupTable(); fileInterface.loadDatabase(); recentProfiles = fileInterface.loadRecentProfiles(); if(recentProfiles.size() > 0) showRecentProfiles(); }
int main(int argc, char** argv) { int* pointers[700]; int* myPointers[700]; myinit(); int i; int validStartIndex = 1; int validEndIndex = 0; for (i = 1; i < 700; i++) { struct timespec start; struct timespec end; if (i % 7 >= 5) { myfree(myPointers[validStartIndex]); free(pointers[validStartIndex]); validStartIndex++; } else { myPointers[validEndIndex] = (unsigned int*) mymalloc(sizeof (unsigned int) * i); pointers[validEndIndex] = (unsigned int*) malloc(sizeof (unsigned int) * i); memcpy(myPointers[validEndIndex], pointers[validEndIndex], sizeof (unsigned int) * i); validEndIndex++; } } struct memstat stats; mymemstat(&stats); int totalMemory; for (i = validStartIndex; i < validEndIndex; i++) { if (!compare(pointers[i], myPointers[i], i)) return (EXIT_FAILURE); totalMemory += i; free(pointers[i]); myfree(myPointers[i]); } totalMemory *= sizeof (unsigned int); printf("Memory consumption: %d out of %d bytes (%f%%)", totalMemory, stats.allocatedpages * 4096, (float) totalMemory / stats.allocatedpages * 100); validStartIndex = 1; validEndIndex = 0; startTime(); for (i = 1; i < 700; i++) { if (i % 7 >= 5) { myfree(myPointers[validStartIndex]); validStartIndex++; } else { myPointers[validEndIndex] = (unsigned int*) mymalloc(sizeof (unsigned int) * i); validEndIndex++; } } unsigned long long timeMy = stopTime(); validStartIndex = 1; validEndIndex = 0; startTime(); for (i = 1; i < 700; i++) { if (i % 7 >= 5) { free(pointers[validStartIndex]); validStartIndex++; } else { pointers[validEndIndex] = (unsigned int*) malloc(sizeof (unsigned int) * i); validEndIndex++; } } unsigned long long timeSystem = stopTime(); for (i = validStartIndex; i < validEndIndex; i++) { totalMemory += i; free(pointers[i]); myfree(myPointers[i]); } printf("Throughput: %llu out of %llu us (%f%%)", timeMy, timeSystem, 100.0f*(float) timeMy / (float) timeSystem); return (EXIT_SUCCESS); }