//------------------------------------------------------------------------------ void MainWindow::updateCounter(QTime ¤tTime, QTime &previousTime) { switch (_state) { case Paused : ui->counterLCDNumber->display(_timeOnCounter.toString(QString(_timeTemplate).arg(INDICATOR_COLUMN))); break; case Running : runStep(currentTime, previousTime); ui->counterLCDNumber->display(_timeOnCounter.toString(QString(_timeTemplate).arg(_timeOnCounter.msec() / TIMER_HALF_SECOND ? INDICATOR_COLUMN : INDICATOR_SPACE))); break; case Firing : fireStep(currentTime, previousTime); ui->counterLCDNumber->display(QTime::currentTime().msec() / TIMER_HALF_SECOND ? "" : _timeOnCounter.toString(QString(_timeTemplate).arg(INDICATOR_COLUMN))); break; } if (0 == _timeOnCounter.hour()) ui->counterLCDNumber->setDigitCount(TIME_TEMPALTE_LENGTH); else ui->counterLCDNumber->setDigitCount(_showSeconds ? TIME_TEMPALTE_SECONDS_LENGTH : TIME_TEMPALTE_LENGTH); }
int GpsSync::run() { // Run all the time while(1) { runStep(); } return 0; }
void Game::run() { glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); while (!quitting_) { double newAppTime = 0.001 * double(SDL_GetTicks()); if (0.1 < newAppTime - appTime_) { appTime_ = newAppTime; } if (config_->fps) { double dt = 1.0 / double(config_->fps); while (dt < float(newAppTime - appTime_)) { runStep(float(dt)); } } else { runStep(float(newAppTime - appTime_)); } } }
void RPNScript::run(bool debug) { curCmd = 0; if (debug) printf("RPN running started from %d/%d command\n", curCmd, count - 1); while (!isEnd()) { if (debug) printf("RPN running %d/%d command ", curCmd, count - 1); if (debug) (*this)[curCmd].print(*master); if (debug) printf("\nRPN stack on begin:\n"); if (debug) stack->print(); runStep(); if (debug) printf("\n"); } }
void GraphicBoard::afterWordCommited(QString word) { currentWord->setText(NULL); if (sender() == gameManager->getFirstPlayer()) { firstPlayerWords->addItem(word); } else { secondPlayerWords->addItem(word); } if (sender() == gameManager->getFirstPlayer()) { int score = gameManager->getFirstPlayer()->getScore(); firstPlayerScore->setText(QString::number(score)); } else { int score = gameManager->getSecondPlayer()->getScore(); secondPlayerScore->setText(QString::number(score)); } runStep(); }
int main(int argc, char * argv[]) { initAll(); if(argc != 2) { error("Minus takes a single argument: the program file to run.\n"); } FILE * file = readFile(argv[1]); process(file); fclose(file); //printf("%s\n\n", processedProgram); runInit(); while(1) runStep(); }
// the main program int main(int argc, char* argv[]){ //for parameters int nstep = 1000; char* filename = "output.dat"; getMyArgs(argc, argv, &nstep, filename); //the initial state float site[] = {0.0,0.0}; FILE* fp = fopen(filename, "w"); output(fp, 0, site); //walking .... int i; for(i=1; i<nstep; ++i){ float step[2]; getStep(step); runStep(site, step); output(fp, i, site); } fclose(fp); }
/** * Run the loaded brainfreeze program. This method will run the brainfreeze * program until it has reached the end of script command. * * \returns True if the program executed through to completion, or false if * there were errors when attempting to run. */ bool BFProgram::run() { // Make sure the program was compiled, and if it wasn't then compile it if (! m_bCompiled ) { compile(); } // Obviously we shouldn't be running if there were errors if ( hasErrors() ) { return false; } // Run the application until we hit the terminating point // XXX can we get rid of the null sentinel? while( m_ip != m_instructions.end() && !m_ip->isA(OP_EOF) ) { runStep(); // maybe bring m_ip++ here and change runStep name } return true; }
//==================================== void openCommand() //==================================== { struct stat st; int ch,nsteps=1000,x,i,n,stop=0,loop,projNo = 0,ok=0,tmp; char *p,str[120],sstr[20],fileName[120],temp[120],syscom[120]; char command[40][40]; s_mode = S_ADMIN; g_silent = 0; readMsg(gplFile); while(strstr(str,"ex") == NULL) { anyErrors(); unoInfo(); wmove(uno,board_h-2,1); wprintw(uno," "); if(g_silent==S_NO )mvwprintw(uno,board_h-2,1,"A%1d>",confWinMode); if(g_silent==S_YES)mvwprintw(uno,board_h-2,1,"A%1d<",confWinMode); strcpy(command[0],""); wgetstr(uno,str); n = tokCommand(command,str); strcpy(sstr,command[0]); p = str; projNo = atoi(sstr); if(strstr(sstr,"gpl")) { readMsg(gplFile); } else if(strstr(sstr,"err")) { readMsg(fileTemp); } else if(strstr(sstr,"run")) { stop = 1; if(n == 2)stop = atoi(command[1]); stop = checkRange(HEAL,"step",stop); runMode(stop); if(stop==0)putMsg(2,"Back in Admin Mode!"); } else if(strstr(sstr,"res")) // reset simulation { resetSim(); init(confWinMode); unoInfo(); readMsg(currentConf); } else if(strstr(sstr,"help")) // { strcpy(fileName,fileInfoAdmin); readMsg(fileName); } else if(strstr(sstr,"rem")) // { if(n == 4) { if(strstr(command[1],"a"))g_pinType = ANA; if(strstr(command[1],"d"))g_pinType = DIG; g_pinNo = atoi(command[2]); g_pinStep = atoi(command[3]); if(g_pinType == ANA) ok = checkRange(S_OK,"anapin",g_pinNo); if(g_pinType == DIG) ok = checkRange(S_OK,"digpin",g_pinNo); if(ok == S_OK) { g_scenSource = 1; sprintf(syscom,"cd servuino;./servuino %d %d %d %d %d %d %d;",confSteps,g_scenSource,g_pinType,g_pinNo,0,g_pinStep,S_DELETE); //putMsg(2,syscom); tmp=system(syscom); initSim(); readSketchInfo(); readSimulation(); runStep(S_FORWARD); readMsg(fileServScen); } else putMsg(2,"Wrong pin number or pin type!"); } else putMsg(2,"Syntax: rem <a or d> <pin> <step>"); } else if(strstr(sstr,"add")) // { if(n == 5) { if(strstr(command[1],"a"))g_pinType = ANA; if(strstr(command[1],"d"))g_pinType = DIG; g_pinNo = atoi(command[2]); g_pinStep = atoi(command[3]); g_pinValue = atoi(command[4]); ok = S_OK; if(g_pinType == ANA) ok = checkRange(S_OK,"anapin",g_pinNo); if(g_pinType == DIG) ok = checkRange(S_OK,"digpin",g_pinNo); ok = ok + checkRange(S_OK,"step",g_pinStep); if(ok == S_OK) { g_scenSource = 1; sprintf(syscom,"cd servuino;./servuino %d %d %d %d %d %d %d;",confSteps,g_scenSource,g_pinType,g_pinNo,g_pinValue,g_pinStep,S_ADD); tmp=system(syscom); initSim(); readSketchInfo(); readSimulation(); runStep(S_FORWARD); readMsg(fileServScen); } } else putMsg(2,"Syntax: add <a or d> <pin> <step> <value>"); } else if(strstr(sstr,"info")) { if(n == 2) { if(strstr(command[1],"conf")) { readMsg(fileDefault); } else if(strstr(command[1],"err")) { readMsg(fileServError); } else if(strstr(command[1],"g++")) { readMsg(fileServComp); } else if(strstr(command[1],"help")) { readMsg(fileInfoAdmin); } else if(strstr(command[1],"loop")) { showLoops(); } else if(strstr(command[1],"scen")) // scenario { readMsg(fileServScen); } } else { readMsg(fileInfoAdmin); } } else if(strstr(sstr,"proj")) { if(n == 2) { strcpy(currentConf,command[1]); strcat(currentConf,".conf"); readConfig(currentConf); g_warning = S_YES; unoInfo(); } readMsg(currentConf); } else if(strstr(sstr,"list")) { readMsg(fileProjList); } else if(strstr(sstr,"sketch")) { if(n == 2) { if(strstr(command[1],"conf")) { readMsg(confSketchFile); } else if(strstr(command[1],"work")) { readMsg(fileServSketch); } } else readMsg(fileServSketch); } else if(strstr(sstr,"conf")) { if(n == 3) { if(strstr(command[1],"sim")) { confSteps = atoi(command[2]); } else if(strstr(command[1],"win")) { confWinMode = atoi(command[2]); if(confWinMode > WIN_MODES)confWinMode = 0; init(confWinMode); unoInfo(); } else if(strstr(command[1],"sketch")) { strcpy(temp,command[2]); if(stat(temp,&st) == 0) { strcpy(confSketchFile,command[2]); } else { sprintf(temp,"Sketch not found: %s",command[2]);// Issue 16 putMsg(msg_h-2,temp); } } saveConfig(currentConf); } readMsg(currentConf); } else if(strstr(sstr,"sav")) //save config { if(n == 2) { strcpy(currentConf,command[1]); strcat(currentConf,".conf"); } saveConfig(currentConf); readMsg(currentConf); sprintf(syscom,"ls *.conf > %s;",fileProjList); x=system(syscom); } else if(strstr(sstr,"del")) //delete config { if(n == 2) { strcpy(currentConf,command[1]); strcat(currentConf,".conf"); } if(strstr(currentConf,"default") == NULL) { sprintf(syscom,"rm %s;",currentConf); x=system(syscom); sprintf(syscom,"ls *.conf > %s;",fileProjList); x=system(syscom); readMsg(fileProjList); strcpy(currentConf,fileDefault); } } else if(strstr(sstr,"win")) //windows layout { if(n == 2) { confWinMode = atoi(command[1]); if(confWinMode > WIN_MODES)confWinMode = 0; init(confWinMode); unoInfo(); } } else if(strstr(sstr,"loop")) { if(n == 2)loop = atoi(command[1]); loop = checkRange(HEAL,"loop",loop); runLoops(loop); } else if(strstr(sstr,"clear")) { sprintf(syscom,"rm servuino/sketch.ino;rm servuino/data.su;rm servuino/data.scen;"); x=system(syscom); } else if(strstr(sstr,"load")) { if(n == 2) { confSteps = atoi(command[1]); } g_scenSource = 0; loadCurrentProj(); } else if(projNo > 0 && projNo < 10) { selectProj(projNo,currentConf); readConfig(currentConf); g_warning = S_YES; unoInfo(); readMsg(currentConf); } else if(strstr(sstr,"data")) { if(n == 2) { if(strstr(command[1],"ard")) { readMsg(fileServArduino); } else if(strstr(command[1],"cus")) { readMsg(fileServCustom); } else if(strstr(command[1],"cod")) { readMsg(fileServCode); } else if(strstr(command[1],"err")) { readMsg(fileServError); } else if(strstr(command[1],"sce")) { readMsg(fileServScen); } } else readMsg(fileServArduino); } else { putMsg(msg_h-2,"Unknown Admin command"); } } }
void PerformLogin::restart() { mStep = 0; runStep(); }
void PerformLogin::proceed() { ++mStep; runStep(); }
void * runStep_C(void * s) { runStep(s); return NULL; }
// Run all steps until you're either done or hit a wait. void LLGestureMgr::stepGesture(LLMultiGesture* gesture) { if (!gesture) { return; } if (!isAgentAvatarValid() || hasLoadingAssets(gesture)) return; // Of the ones that started playing, have any stopped? std::set<LLUUID>::iterator gest_it; for (gest_it = gesture->mPlayingAnimIDs.begin(); gest_it != gesture->mPlayingAnimIDs.end(); ) { if (gesture->mLocal) { // Local, erase if no longer playing (or gone) LLMotion* motion = gAgentAvatarp->findMotion(*gest_it); if (!motion || motion->isStopped()) gesture->mPlayingAnimIDs.erase(gest_it); ++gest_it; } // look in signaled animations (simulator's view of what is // currently playing. else if (gAgentAvatarp->mSignaledAnimations.find(*gest_it) != gAgentAvatarp->mSignaledAnimations.end()) { ++gest_it; } else { // not found, so not currently playing or scheduled to play // delete from the triggered set gesture->mPlayingAnimIDs.erase(gest_it++); } } // Of all the animations that we asked the sim to start for us, // pick up the ones that have actually started. for (gest_it = gesture->mRequestedAnimIDs.begin(); gest_it != gesture->mRequestedAnimIDs.end(); ) { LLVOAvatar::AnimIterator play_it = gAgentAvatarp->mSignaledAnimations.find(*gest_it); if (play_it != gAgentAvatarp->mSignaledAnimations.end()) { // Hooray, this animation has started playing! // Copy into playing. gesture->mPlayingAnimIDs.insert(*gest_it); gesture->mRequestedAnimIDs.erase(gest_it++); } else { // nope, not playing yet ++gest_it; } } // Run the current steps BOOL waiting = FALSE; while (!waiting && gesture->mPlaying) { // Get the current step, if there is one. // Otherwise enter the waiting at end state. LLGestureStep* step = NULL; if (gesture->mCurrentStep < (S32)gesture->mSteps.size()) { step = gesture->mSteps[gesture->mCurrentStep]; llassert(step != NULL); } else { // step stays null, we're off the end gesture->mWaitingAtEnd = TRUE; } // If we're waiting at the end, wait for all gestures to stop // playing. // TODO: Wait for all sounds to complete as well. if (gesture->mWaitingAtEnd) { // Neither do we have any pending requests, nor are they // still playing. if ((gesture->mRequestedAnimIDs.empty() && gesture->mPlayingAnimIDs.empty())) { // all animations are done playing gesture->mWaitingAtEnd = FALSE; gesture->mPlaying = FALSE; } else { waiting = TRUE; } continue; } // If we're waiting on our animations to stop, poll for // completion. if (gesture->mWaitingAnimations) { // Neither do we have any pending requests, nor are they // still playing. if ((gesture->mRequestedAnimIDs.empty() && gesture->mPlayingAnimIDs.empty())) { // all animations are done playing gesture->mWaitingAnimations = FALSE; gesture->mCurrentStep++; } else if (gesture->mWaitTimer.getElapsedTimeF32() > MAX_WAIT_ANIM_SECS) { // we've waited too long for an animation LL_INFOS() << "Waited too long for animations to stop, continuing gesture." << LL_ENDL; gesture->mWaitingAnimations = FALSE; gesture->mCurrentStep++; } else { waiting = TRUE; } continue; } // If we're waiting a fixed amount of time, check for timer // expiration. if (gesture->mWaitingTimer) { // We're waiting for a certain amount of time to pass LLGestureStepWait* wait_step = (LLGestureStepWait*)step; F32 elapsed = gesture->mWaitTimer.getElapsedTimeF32(); if (elapsed > wait_step->mWaitSeconds) { // wait is done, continue execution gesture->mWaitingTimer = FALSE; gesture->mCurrentStep++; } else { // we're waiting, so execution is done for now waiting = TRUE; } continue; } // Not waiting, do normal execution runStep(gesture, step); } }
void Game::runUntil(Scalar<SIUnit::Time> time, MessageCallbackType messageCallback) { const Scalar<SIUnit::Time> dt = 1.0 / 32; while (clock + dt < time) { runStep(dt, messageCallback); } }
void Game::runUntil(Scalar<SIUnit::Time> time) { while (clock + stepTime < time) { runStep(); } }