/* * Return the timer id of the timer that most recently expired * */ int TimerList::WhichExpired(unsigned int CurSeconds, unsigned int CurUSeconds) { //We have the current time, find the timer entry whose difference in time is the smallest SecTime CurTime(CurSeconds, CurUSeconds); SecTime SmallestTime(0x7FFFFFFF, 0x7FFFFFFF); int CurIndex = -1; int i = 0; //Find the entry with the minimal time difference for (i = 0; i < MAX_NUM_TIMERS; i++) { if (Timers[i].TimerID == TIMER_INACTIVE) continue; //See if this timer's start time plus its timer value is less than the current time SecTime TimerExpireTime = Timers[i].TimerVal + Timers[i].StartTime; if (TimerExpireTime < CurTime) { if (TimerExpireTime < SmallestTime) { SmallestTime = TimerExpireTime; CurIndex = i; } } } //If we could not find a timer if (CurIndex == -1) return -1; //Otherwise, i is the timer found //Save the new current time for the timer Timers[CurIndex].StartTime = CurTime; return Timers[CurIndex].TimerID; }
double TimeElapsed() { double answer; double fNewTimeStamp; _ftime( &tstruct ); fNewTimeStamp = CurTime(); answer = fNewTimeStamp - fLastTimeStamp; fLastTimeStamp = fNewTimeStamp; return answer; }
void ImageAnalysis::MakeDecision(int64 hash, double hist, int diff, int index) { qDebug()<<hash<<hist<<diff; qDebug()<<"Zone:"<<index+1; if((hash>0&&hist<0.9&&diff>0)||(hash>0&&diff>=15)||(diff>=30)) { emit ZoneStatus(index); qDebug()<<"Update Zone State"<<CurTime(); WriteLog(index); } }
void ImageAnalysis::WriteLog(int index) { QFile file("./zones.log"); file.open(QIODevice::ReadWrite| QIODevice::Text); QString a; QTextStream in(&file); a=in.readAll(); a=QString::number(index)+" "+CurTime()+"\n"; QTextStream out(&file); out<<a; file.close(); }