bool PRadEventFilter::IsBadPeriod(const EventData &begin, const EventData &end) const { // loop the whole list for(auto &interval : bad_events_list) { // firstly, either begin or end itself is a bad event if(IsBadEvent(begin) || IsBadEvent(end)) return true; // secondly, if the whole period contains a bad period if((begin.event_number < interval.begin) && (end.event_number > interval.end)) return true; } return false; }
void EventStatDialog::UpdateEventsData() { CSingleLock dataLock(&m_csEventData); /*if (dataLock.IsLocked()) { return; }*/ dataLock.Lock(); time_t currentTime; time(¤tTime); m_hasBadEventRecently = false; for(int i = 0; i < NUMBER_OF_EVENT_TYPES;i++) { int eventCnt[NUMBER_OF_TIME_SLICE_TYPES]; for (int n=0; n < NUMBER_OF_TIME_SLICE_TYPES; n++) { eventCnt[n]=0; } TimeSliceType currentTimeSlice = LAST_15MINS; TimeSliceType nextTimeSlice = LAST_10MINS; deque<time_t>::iterator eventTime; for( eventTime = m_data[i].begin(); eventTime != m_data[i].end();) { if (m_data[i].empty()) { break; } double timeDiff = difftime(currentTime,(*eventTime)); /* // hard code version if (timeDiff > GetTime(LAST_15MINS)) { //delete this item in the queue m_data[i].pop_front(); eventTime = m_data[i].begin(); continue; } else if (timeDiff > GetTime(LAST_10MINS)) { eventCnt[LAST_15MINS]++; } else if (timeDiff > GetTime(LAST_5MINS)) { eventCnt[LAST_10MINS]++; } else if (timeDiff > GetTime(LAST_1MIN)) { eventCnt[LAST_5MINS]++; } else if (timeDiff > GetTime(LAST_30S)) { eventCnt[LAST_1MIN]++; } else if (timeDiff > GetTime(LAST_10S)) { eventCnt[LAST_30S]++; } else { eventCnt[LAST_10S]++; } */ if (timeDiff > GetTime(currentTimeSlice)) { if (currentTimeSlice == LAST_15MINS) { //delete this item in the queue m_data[i].pop_front(); eventTime = m_data[i].begin(); // Increment the RemovedEvents counter to // keep track of # of removed events m_numOfRemovedEvents[i]++; continue; } else { //do nothing, just skip this } } else if (timeDiff > GetTime(nextTimeSlice)) { eventCnt[currentTimeSlice]++; } else { if (nextTimeSlice != LAST_10S) { currentTimeSlice = nextTimeSlice; nextTimeSlice = (TimeSliceType)(nextTimeSlice-1); continue; } else { eventCnt[LAST_10S]++; } } eventTime++; } //sum up the number of events /* //hard code version eventCnt[LAST_30S]+=eventCnt[LAST_10S]; eventCnt[LAST_1MIN]+=eventCnt[LAST_30S]; eventCnt[LAST_5MINS]+=eventCnt[LAST_1MIN]; eventCnt[LAST_10MINS]+=eventCnt[LAST_5MINS]; eventCnt[LAST_15MINS]+=eventCnt[LAST_10MINS]; */ for(unsigned int j=0; j < (unsigned int)NUMBER_OF_TIME_SLICE_TYPES - 1; j++) { eventCnt[j+1] += eventCnt[j]; } // Adding # of removed events back to "Since Start" time slice category eventCnt[NUMBER_OF_TIME_SLICE_TYPES - 1] += m_numOfRemovedEvents[i]; char buff[32]; for(int cn = 0; cn < sk_numOfColumns; cn++) { sprintf(buff,"%d",eventCnt[m_columnsData[cn]]); m_eventTable.SetItemText(i, cn + 1, buff); } // check to see if there is bad event if (IsBadEvent((EventType)i)&&eventCnt[0]) { m_hasBadEventRecently = true; } } dataLock.Unlock(); }