uint8_t mesh_recvloop_plus(uint8_t state){ static int recvend=0; static int pktctr=0; if (state==0){ recvend=M_RECVTIM/SYSTICKSPEED+getTimer(); pktctr=0; mesh_recvqloop_setup(); state=1; }; if(state==1){ if( mesh_recvqloop_work() ){ pktctr++; }else{ delayms_power(10); }; if(getTimer()>recvend || pktctr>MESHBUFSIZE) state=0xff; }; if(state==0xff){ return 0xff; }; return state; };
void BattlegroundRV::PostUpdateImpl(uint32 diff) { if (GetStatus() != STATUS_IN_PROGRESS) return; if (getTimer() < diff) { switch (getState()) { case BG_RV_STATE_OPEN_FENCES: // Open fire (only at game start) for (uint8 i = BG_RV_OBJECT_FIRE_1; i <= BG_RV_OBJECT_FIREDOOR_2; ++i) DoorOpen(i); setTimer(BG_RV_CLOSE_FIRE_TIMER); setState(BG_RV_STATE_CLOSE_FIRE); break; case BG_RV_STATE_CLOSE_FIRE: for (uint8 i = BG_RV_OBJECT_FIRE_1; i <= BG_RV_OBJECT_FIREDOOR_2; ++i) DoorClose(i); // Fire got closed after five seconds, leaves twenty seconds before toggling pillars setTimer(BG_RV_FIRE_TO_PILLAR_TIMER); setState(BG_RV_STATE_SWITCH_PILLARS); break; case BG_RV_STATE_SWITCH_PILLARS: TogglePillarCollision(); setTimer(BG_RV_PILLAR_SWITCH_TIMER); break; } } else setTimer(getTimer() - diff); }
xgc_void XGameMap::OnDestroy() { mMapConf.mCellConf.cx = 0; mMapConf.mCellConf.cy = 0; mMapConf.mCellSize.cx = 0.0f; mMapConf.mCellSize.cy = 0.0f; mMapConf.mTransfrom.x = 0.0f; mMapConf.mTransfrom.y = 0.0f; mAreaSize.cx = 0.0f; mAreaSize.cy = 0.0f; mAreaConf.cx = 0; mAreaConf.cy = 0; SAFE_DELETE_ARRAY( mpCells ); SAFE_DELETE_ARRAY( mpAreas ); for( auto it : mMapClock ) getTimer().remove( it.second ); mMapClock.clear(); for( auto it : mMapTimer ) getTimer().remove( it.second ); mMapTimer.clear(); mMapEventConf.clear(); }
/** reaction.c * First l0dable for my r0ket * Improvement is welcome * * AUTHOR: hubba */ void ram(void) { char x = gpioGetValue(RB_LED1); int rand_wait = 0; int react_time=0; int start_time = 0; int end_time = 0; gpioSetValue (RB_LED1,0); //upperleft LED off lcdClear(); lcdPrintln("Hello"); lcdPrintln(GLOBAL(nickname)); lcdPrintln("ReACTION"); lcdRefresh(); delayms(500); while(1) { react_time = 0; lcdPrintln("Press ENTER if "); lcdPrintln("LED is on!"); lcdRefresh(); rand_wait = getRandom(); rand_wait = rand_wait%50; rand_wait = 40 + rand_wait*4; // Minimum pause time is 400ms for(int i =0; i<=rand_wait; i++) //directly calling delayms(rand_wait) didn't work { delayms(10); } gpioSetValue (RB_LED1, 1); //upperleft LED ON getInputWaitRelease(); start_time = getTimer()*(SYSTICKSPEED); while (getInputWait() != BTN_ENTER); //wait for user input { } end_time = getTimer()*(SYSTICKSPEED); react_time = end_time - start_time; //measure used time lcdClear(); lcdPrint("Needed "); lcdPrintInt(react_time); lcdPrintln(" ms"); lcdPrintln("DOWN: Exit"); lcdPrintln("0ther: New game"); lcdRefresh(); gpioSetValue (RB_LED1,0); //upperleft LED off getInputWaitRelease(); if(getInputWait() == BTN_DOWN) //Check for Exit/new game { gpioSetValue (RB_LED1, x); //upperleft LED as before l0dable executed return; } } /* NEVER LAND HERE */ lcdPrintln("Flow-Error"); lcdRefresh(); return; };
void applyWeights(matrix * X, matrix * w, matrix * yhat) { /* X*w -> yhat */ int last = getTimer(); multAB(X,w,yhat); if(opt->verbose==3 || opt->verbose==7) print("applyWeights TIME: %i SECONDS\n\n",getTimer()-last); }
void testQueryProcessor(QUERY_TYPE fromType, QUERY_TYPE toType, int numQuery,int numThread) { // HANDLE dispatchMutex = CreateMutex( NULL, FALSE, NULL ); InitializeCriticalSection(&(PoolLock)); MyThreadPoolCop *pool=(MyThreadPoolCop*)malloc(sizeof(MyThreadPoolCop)); pool->create(numThread);//always one thread to handle query request regardsless how many query are there. int i=0; tp_batchQuery** pData=(tp_batchQuery**)malloc(sizeof(tp_batchQuery*)*numThread); char** sqlQuery=(char**)malloc(sizeof(char*)*numQuery); //QUERY_TYPE* queryType=(QUERY_TYPE*)malloc(sizeof(QUERY_TYPE)*numQuery); Query_stat* gQStat=new Query_stat[numQuery]; for(i=0;i<numQuery;i++) { sqlQuery[i]=new char[512]; gQStat[i].qT=makeRandomQuery(fromType,toType,sqlQuery[i]); //cout<<gQStat[i].speedupGPUoverCPU<<endl; gQStat[i].isAssigned=false; } int curID=0; int numActiveThread=numThread; for( i=0; i<numThread; i++ ) { // Allocate memory for thread data. pData[i] = (tp_batchQuery*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(tp_batchQuery)); if( pData[i] == NULL ) ExitProcess(2); pData[i]->init(&curID,numQuery,sqlQuery,gQStat,i); pool->assignParameter(i, pData[i]); pool->assignTask(i, tp_naiveQP); } int timer=genTimer(2); getTimer(timer); pool->run(); double t=getTimer(timer); char outputFilename[50]; sprintf(outputFilename, "./Output/K_level_Time.tony"); K_ofp = fopen(outputFilename, "a"); if(K_ofp !=NULL){ fprintf(K_ofp,"<%d> <%d>\n",numQueries,numThread); fprintf(K_ofp,"%lf\n",t); fclose(K_ofp); }else{ fprintf(stderr,"\t output file is not created, please check file premission!\n"); } printf("------------Kernel level Query finished in %lfd---------------\n\n",t); for(i=0;i<numThread;i++) { HeapFree(GetProcessHeap(),0, pData[i]); } free(pData); pool->destory(); }
void BattlegroundRV::Update(uint32 diff) { Battleground::Update(diff); if (GetStatus() == STATUS_IN_PROGRESS) { if (GetStartTime() >= 47*MINUTE*IN_MILLISECONDS) // after 47 minutes without one team losing, the arena closes with no winner and no rating change { UpdateArenaWorldState(); CheckArenaAfterTimerConditions(); } } if (getTimer() < diff) { uint32 i; switch(getState()) { case BG_RV_STATE_OPEN_FENCES: { setTimer(BG_RV_PILAR_TO_FIRE_TIMER); setState(BG_RV_STATE_CLOSE_FIRE); break; } case BG_RV_STATE_CLOSE_FIRE: for (i = BG_RV_OBJECT_FIRE_1; i <= BG_RV_OBJECT_FIREDOOR_2; ++i) DoorClose(i); setTimer(BG_RV_FIRE_TO_PILAR_TIMER); setState(BG_RV_STATE_OPEN_PILARS); break; case BG_RV_STATE_OPEN_PILARS: for (i = BG_RV_OBJECT_PILAR_1; i <= BG_RV_OBJECT_PULLEY_2; ++i) DoorOpen(i); setTimer(BG_RV_PILAR_TO_FIRE_TIMER); setState(BG_RV_STATE_OPEN_FIRE); break; case BG_RV_STATE_OPEN_FIRE: // FIXME: after 3.2.0 it's only decorative and should be opened only one time at battle start for (i = BG_RV_OBJECT_FIRE_1; i <= BG_RV_OBJECT_FIREDOOR_2; ++i) DoorOpen(i); setTimer(BG_RV_FIRE_TO_PILAR_TIMER); setState(BG_RV_STATE_CLOSE_PILARS); break; case BG_RV_STATE_CLOSE_PILARS: uint32 i; for (i = BG_RV_OBJECT_PILAR_1; i <= BG_RV_OBJECT_PULLEY_2; ++i) DoorOpen(i); setTimer(BG_RV_PILAR_TO_FIRE_TIMER); setState(BG_RV_STATE_CLOSE_FIRE); break; } } else setTimer(getTimer() - diff); }
/* **************************************************************************** * * getCurrentTime - */ int getCurrentTime(void) { if (getTimer() == NULL) { LM_T(LmtSoftError, ("getTimer() == NULL - calling exit function for library user")); orionExitFunction(1, "getTimer() == NULL"); return -1; } return getTimer()->getCurrentTime(); }
void mesh_recvloop(void){ int recvend=M_RECVTIM/SYSTICKSPEED+getTimer(); int pktctr=0; mesh_recvqloop_setup(); do{ if( mesh_recvqloop_work() ){ pktctr++; }else{ delayms_power(10); }; }while(getTimer()<recvend || pktctr>MESHBUFSIZE); mesh_recvqloop_end(); };
// Save the list to the current filename, rturn true if success bool MainWindow::save() { // Open the file QFile file(this->currentFilename); if (!file.open(QIODevice::WriteOnly)) { QString message = tr("Couldn't open the file %1.").arg(this->currentFilename); QMessageBox::critical(this, tr("Error"), message, QMessageBox::Ok); return false; } // Write into the file QDataStream stream(&file); for (int row = 0; row < this->timerTable->rowCount(); row++) { Timer* timer = getTimer(row); stream << timer->getFilename() << timer->getPeriod() << timer->getKeySequence() << timer->getModifiers() << timer->getVirtualKey(); } if (stream.status() != QDataStream::Ok) { QString message = tr("Couldn't write into the file %1.").arg(this->currentFilename); QMessageBox::critical(this, tr("Error"), message, QMessageBox::Ok); return false; } this->modified.setModified(false); return true; }
void MainWindow::deleteAllTimers() { for (int row = 0; row < this->timerTable->rowCount(); row++) { Timer* timer = getTimer(row); delete timer; } }
//! Compares to the last call of this function to return double and triple clicks. u32 CIrrDeviceStub::checkSuccessiveClicks(s32 mouseX, s32 mouseY, EMOUSE_INPUT_EVENT inputEvent ) { const s32 MAX_MOUSEMOVE = 3; irr::u32 clickTime = getTimer()->getRealTime(); if ( (clickTime-MouseMultiClicks.LastClickTime) < MouseMultiClicks.DoubleClickTime && core::abs_(MouseMultiClicks.LastClick.X - mouseX ) <= MAX_MOUSEMOVE && core::abs_(MouseMultiClicks.LastClick.Y - mouseY ) <= MAX_MOUSEMOVE && MouseMultiClicks.CountSuccessiveClicks < 3 && MouseMultiClicks.LastMouseInputEvent == inputEvent ) { ++MouseMultiClicks.CountSuccessiveClicks; } else { MouseMultiClicks.CountSuccessiveClicks = 1; } MouseMultiClicks.LastMouseInputEvent = inputEvent; MouseMultiClicks.LastClickTime = clickTime; MouseMultiClicks.LastClick.X = mouseX; MouseMultiClicks.LastClick.Y = mouseY; return MouseMultiClicks.CountSuccessiveClicks; }
int Spi::sync() { uint32_t timer; int res = 0; if (!m_autoSlaveSelect) return 0; SSP_IntConfig(LPC_SSP1, SSP_INTCFG_RX, DISABLE); setTimer(&timer); while(1) { if(checkIdle()) { res = 1; break; } if (getTimer(timer)>500000) // timeout .5 seconds break; } SSP_IntConfig(LPC_SSP1, SSP_INTCFG_RX, ENABLE); return res; }
/* **************************************************************************** * * versionTreat - */ std::string versionTreat ( ConnectionInfo* ciP, int components, std::vector<std::string>& compV, ParseData* parseDataP ) { std::string out = ""; std::string tag = "orion"; std::string indent = ""; #ifdef UNIT_TEST std::string uptime = "0 d, 0 h, 0 m, 0 s"; #else std::string uptime = parsedUptime(getTimer()->getCurrentTime() - startTime); #endif out += startTag1(indent, tag, true, true); out += valueTag1(indent + " ", "version", versionString, true); out += valueTag1(indent + " ", "uptime", uptime, true); out += valueTag1(indent + " ", "git_hash", GIT_HASH, true); out += valueTag1(indent + " ", "compile_time", COMPILE_TIME, true); out += valueTag1(indent + " ", "compiled_by", COMPILED_BY, true); out += valueTag1(indent + " ", "compiled_in", COMPILED_IN, false); out += endTag(indent, false, false, true, true); ciP->httpStatusCode = SccOk; return out; }
//! Compares to the last call of this function to return double and triple clicks. UINT32 CSapphireDeviceStub::checkSuccessiveClicks(SINT32 mouseX, SINT32 mouseY, EMOUSE_INPUT_EVENT inputEvent) { const SINT32 MAX_MOUSEMOVE = 3; UINT32 clickTime = getTimer()->getRealTime(); if ((clickTime - MouseMultiClicks.LastClickTime) < MouseMultiClicks.DoubleClickTime && Math::Abs(MouseMultiClicks.LastClick.x - mouseX) <= MAX_MOUSEMOVE && Math::Abs(MouseMultiClicks.LastClick.y - mouseY) <= MAX_MOUSEMOVE && MouseMultiClicks.CountSuccessiveClicks < 3 && MouseMultiClicks.LastMouseInputEvent == inputEvent ) { ++MouseMultiClicks.CountSuccessiveClicks; } else { MouseMultiClicks.CountSuccessiveClicks = 1; } MouseMultiClicks.LastMouseInputEvent = inputEvent; MouseMultiClicks.LastClickTime = clickTime; MouseMultiClicks.LastClick.x = mouseX; MouseMultiClicks.LastClick.y = mouseY; return MouseMultiClicks.CountSuccessiveClicks; }
uint8_t Blade::lowerBladePoll(uint8_t reset) { if (reset == RESET) bladeStatus = NOT_STARTED; switch (bladeStatus) { case NOT_STARTED: //first time polled if (IS_BLADE_DOWN()) bladeStatus = DONE; else { BLADE_RELEASE(); setTimer(); bladeStatus = WORKING; } break; case WORKING: if (IS_BLADE_DOWN()) bladeStatus = DONE; else if (getTimer() > BLADE_DOWN_MAX_TIME) bladeStatus = ERROR; break; case DONE: bladeStatus = COMPLETE; break; } return bladeStatus; }
void handleAWB() { static uint32_t timer; static uint8_t state = 0; uint8_t awbp=0; if (state==2) return; prm_get("Auto White Balance on power-up", &awbp, END); if (!awbp) return; // exit if auto white balance on power-up is disabled else if (state==0) { setTimer(&timer); cam_setAWB(1); state = 1; } else if (state==1) { if (getTimer(timer)>AWB_TIMEOUT) { cam_setAWB(0); state = 2; // end state machine (only run once) } } }
int TapeDrive::ProcessCmdNR(short mt_op, daddr_t mt_count) { static struct mtop cmd; cmd.mt_op = mt_op; cmd.mt_count = mt_count; DOASSERT(mt_op >= 0 && mt_op < _max_mt_op, "Invalid tape command"); mt_ios[mt_op]++; mt_cnt[mt_op] += (mt_count >= 0 ? mt_count : -mt_count); TAPEDBG(cout << "Tape " << fileno(file) << ", command " << mt_op << ", count " << mt_count << " started" << endl); startTimer(); int status = ioctl(fileno(file), MTIOCTOP, (char *)&cmd); mt_tim[mt_op] += getTimer(); if (status < 0) reportErrSys("ioctl"); TAPEDBG(cout << "Tape " << fileno(file) << ", command " << mt_op << ", count " << mt_count << " finished, status = " << status << endl); return status; }
short isTimerDisarmed(const timer_t timerid) { struct itimerspec timeout; timeout = getTimer(timerid); return (timeout.it_value.tv_sec == 0 && timeout.it_value.tv_nsec == 0 && timeout.it_interval.tv_sec == 0 && timeout.it_interval.tv_nsec == 0); }
struct timeval Timer::getTimer() const { struct timeval tv; gettimeofday(&tv, NULL); return getTimer(tv); }
bool timer::stopwatch(int ms) { if ( timeGetTime() > stopwatch_start + ms ) { stopwatch_start = getTimer(); return true; } else return false; }
void BattlegroundRV::PostUpdateImpl(uint32 diff) { if(GetStatus() != STATUS_IN_PROGRESS) return; if (getTimer() < diff) { switch (getState()) { case BG_RV_STATE_OPEN_FENCES: setTimer(BG_RV_PILAR_TO_FIRE_TIMER); setState(BG_RV_STATE_CLOSE_FIRE); break; case BG_RV_STATE_CLOSE_FIRE: for (uint8 i = BG_RV_OBJECT_FIRE_1; i <= BG_RV_OBJECT_FIREDOOR_2; ++i) DoorClose(i); setTimer(BG_RV_FIRE_TO_PILAR_TIMER); setState(BG_RV_STATE_OPEN_PILARS); break; case BG_RV_STATE_OPEN_PILARS: for (uint8 i = BG_RV_OBJECT_PILAR_1; i <= BG_RV_OBJECT_PULLEY_2; ++i) DoorOpen(i); setTimer(BG_RV_PILAR_TO_FIRE_TIMER); setState(BG_RV_STATE_OPEN_FIRE); SwitchDynLos(); break; case BG_RV_STATE_OPEN_FIRE: // FIXME: after 3.2.0 it's only decorative and should be opened only one time at battle start for (uint8 i = BG_RV_OBJECT_FIRE_1; i <= BG_RV_OBJECT_FIREDOOR_2; ++i) DoorOpen(i); setTimer(BG_RV_FIRE_TO_PILAR_TIMER); setState(BG_RV_STATE_CLOSE_PILARS); break; case BG_RV_STATE_CLOSE_PILARS: for (uint8 i = BG_RV_OBJECT_PILAR_1; i <= BG_RV_OBJECT_PULLEY_2; ++i) DoorOpen(i); setTimer(BG_RV_PILAR_TO_FIRE_TIMER); setState(BG_RV_STATE_CLOSE_FIRE); SwitchDynLos(); break; } } else setTimer(getTimer() - diff); }
void BattlegroundRV::Update(uint32 diff) { Battleground::Update(diff); if (getTimer() < diff) { uint32 i; switch(getState()) { case BG_RV_STATE_OPEN_FENCES: { setTimer(BG_RV_PILAR_TO_FIRE_TIMER); setState(BG_RV_STATE_CLOSE_FIRE); break; } case BG_RV_STATE_CLOSE_FIRE: for (i = BG_RV_OBJECT_FIRE_1; i <= BG_RV_OBJECT_FIREDOOR_2; ++i) DoorClose(i); setTimer(BG_RV_FIRE_TO_PILAR_TIMER); setState(BG_RV_STATE_OPEN_PILARS); break; case BG_RV_STATE_OPEN_PILARS: for (i = BG_RV_OBJECT_PILAR_1; i <= BG_RV_OBJECT_PULLEY_2; ++i) DoorOpen(i); setTimer(BG_RV_PILAR_TO_FIRE_TIMER); setState(BG_RV_STATE_OPEN_FIRE); break; case BG_RV_STATE_OPEN_FIRE: for (i = BG_RV_OBJECT_FIRE_1; i <= BG_RV_OBJECT_FIREDOOR_2; ++i) DoorOpen(i); setTimer(BG_RV_FIRE_TO_PILAR_TIMER); setState(BG_RV_STATE_CLOSE_PILARS); break; case BG_RV_STATE_CLOSE_PILARS: uint32 i; for (i = BG_RV_OBJECT_PILAR_1; i <= BG_RV_OBJECT_PULLEY_2; ++i) DoorOpen(i); setTimer(BG_RV_PILAR_TO_FIRE_TIMER); setState(BG_RV_STATE_CLOSE_FIRE); break; } } else setTimer(getTimer() - diff); }
double CStatisticTimer::GetTime() { uint64 total = mTotal; if (mRunning) total += getTimer()-mStart; return (double)((int64)(total/getTimerFrequency())); }
void ButtonMachine::wait(uint32_t us) { uint32_t timer; setTimer(&timer); while(getTimer(timer)<us); periodic(); }
/// /// 删除定时器 /// [7/28/2014] create by albert.xu /// xgc_void XGameMap::DeleteTimer( xgc_lpcstr lpSourceName ) { auto iter = mMapTimer.find( lpSourceName ); if( iter != mMapTimer.end() ) { getTimer().remove( iter->second ); mMapTimer.erase( iter ); } }
void Minesweeper::saveScore(){ ofstream file; file.open(getScoreFilename().c_str(), ofstream::app); file << getTimer() << endl; file.close(); }
void RanaTimerBank::setTimerPeriodTime(const RanaSpaceHandle& _spaceHandle, RanaTimerHandle _timerHandle, RanaTIME _periodTime) { RanaTimer *timer = getTimer(_spaceHandle, _timerHandle); if (timer && _periodTime > 0.0) { timer->setPeriodTime(_periodTime); } }
void RanaTimerBank::setTimerRepeat(const RanaSpaceHandle& _spaceHandle, RanaTimerHandle _timerHandle, bool _isRepeat) { RanaTimer *timer = getTimer(_spaceHandle, _timerHandle); if (timer) { timer->setRepeat(_isRepeat); } }
void printDialog::printSetup() { QString str = tr("<h2>General Model Settings</h2><br>"); str.append(fv(tr("Name"), getModelName())); str.append(fv(tr("Timer1"), getTimer(0))); //value, mode, count up/down str.append(fv(tr("Timer2"), getTimer(1))); //value, mode, count up/down str.append(fv(tr("Protocol"), getProtocol())); //proto, numch, delay, str.append(fv(tr("Pulse Polarity"), g_model->pulsePol ? "NEG" : "POS")); str.append(fv(tr("Throttle Trim"), g_model->thrTrim ? tr("Enabled") : tr("Disabled"))); str.append(fv(tr("Throttle Expo"), g_model->thrExpo ? tr("Enabled") : tr("Disabled"))); str.append(fv(tr("Trainer"), g_model->traineron ? tr("Enabled") : tr("Disabled"))); str.append(fv(tr("Trim Switch"), getSWName(g_model->trimSw,0))); str.append(fv(tr("Trim Increment"), getTrimInc())); str.append(fv(tr("Center Beep"), getCenterBeep())); // specify which channels beep str.append("<br><br>"); te->append(str); }