STATE CloseAttrValueStateInsert(TextEngine *pEngine, TCHAR chr) { // OutputDebugString(_T("Close Attribute Value\n")); STATE state = STATE_CLOSEATTRIBUTEVALUE; CheckRun(pEngine, state); if(!pEngine->m_pRun->text.length() && chr == _T('\"')) { pEngine->m_pRun->text.insert(pEngine->m_pRun->text.begin() + pEngine->m_pRun->text.length(), chr); pEngine->m_pRun->flags = state; } else if(_tcschr(_T("\t "), chr)) { state = WhitespaceStateInsert(pEngine, chr); } else if(_tcschr(_T("\r\n"), chr)) { state = NewLineStateInsert(pEngine, chr); } else if(chr == _T('/')) { state = TagSlashStateInsert(pEngine, chr); } else if(chr == _T('>')) { state = CloseTagStateInsert(pEngine, chr); } else { state = InvalidStateInsert(pEngine, chr); } return state; }
STATE TagNameStateInsert(TextEngine *pEngine, TCHAR chr) { // OutputDebugString(_T("Tag Name\n")); STATE state = STATE_TAGNAME; CheckRun(pEngine, state); if(chr == _T('<')) { state = InvalidStateInsert(pEngine, chr); } else if(_tcschr(_T("\t "), chr)) { state = WhitespaceStateInsert(pEngine, chr); } else if(_tcschr(_T("\r\n"), chr)) { state = NewLineStateInsert(pEngine, chr); } else if(chr == _T('/')) { state = TagSlashStateInsert(pEngine, chr); } else if(chr == _T('>')) { state = CloseTagStateInsert(pEngine, chr); } else { pEngine->m_pRun->text.insert(pEngine->m_pRun->text.begin() + pEngine->m_pRun->text.length(), chr); pEngine->m_pRun->flags = state; } return state; }
int main (int argc, char * const argv[]) { g_MasterLoop = CFRunLoopGetCurrent(); signal (SIGTERM, CancelExec); signal (SIGHUP, ForceStartup); signal (SIGALRM, ForceInventory); // a bit of runway for network services sleep(30); CheckRun(true); // initial check CFAuto<CFRunLoopTimerRef> SCATimer; SCATimer.Attach( CFRunLoopTimerCreate( kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + SurveyTime, SurveyTime, 0, 0, InventoryCheckTimerFunc, NULL)); CFRunLoopAddTimer(g_MasterLoop, SCATimer, kCFRunLoopDefaultMode); CFRunLoopRun(); CFRunLoopTimerInvalidate( SCATimer ); }
STATE CloseTagStateInsert(TextEngine *pEngine, TCHAR chr) { // OutputDebugString(_T("Close Tag\n")); STATE state = STATE_CLOSETAG; CheckRun(pEngine, state); if(!pEngine->m_pRun->text.length()) { if(chr == _T('>')) { pEngine->m_pRun->text.insert(pEngine->m_pRun->text.begin() + pEngine->m_pRun->text.length(), chr); pEngine->m_pRun->flags = state; } else { state = InvalidStateInsert(pEngine, chr); } } else { if(_tcschr(_T("\t "), chr)) { state = WhitespaceStateInsert(pEngine, chr); } else if(_tcschr(_T("\r\n"), chr)) { state = NewLineStateInsert(pEngine, chr); } else { state = FreeTextStateInsert(pEngine, chr); } } return state; }
virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_TIMER: if (WaitForSingleObject(m_hFileNotify, 0) == WAIT_OBJECT_0) { m_profileList.DeleteAllItems(); ProfileEnumData ped(m_profileList, m_pd->ptszProfile); findProfiles(m_pd->ptszProfileDir, EnumProfilesForList, (LPARAM)&ped); FindNextChangeNotification(m_hFileNotify); } break; case WM_FOCUSTEXTBOX: SetFocus(m_profileList.GetHwnd()); if (m_pd->ptszProfile[0] == 0 || m_profileList.GetSelectedCount() == 0) m_profileList.SetItemState(0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); break; case WM_SHOWWINDOW: if (wParam) CheckRun(); break; case WM_CONTEXTMENU: ExecuteMenu(lParam); break; } return CDlgBase::DlgProc(msg, wParam, lParam); }
STATE TagSlashStateInsert(TextEngine *pEngine, TCHAR chr) { // OutputDebugString(_T("Tag Slash\n")); STATE state = STATE_TAGSLASH; CheckRun(pEngine, state); if(!pEngine->m_pRun->text.length()) { if(chr == _T('/')) { pEngine->m_pRun->text.insert(pEngine->m_pRun->text.begin() + pEngine->m_pRun->text.length(), chr); pEngine->m_pRun->flags = state; } else { state = InvalidStateInsert(pEngine, chr); } } else { Run *pRun = pEngine->PreviousRun(); STATE prevState = pRun? pRun->flags: STATE_UNKNOWN; switch(prevState) { case STATE_WHITESPACE: case STATE_TAGNAME: case STATE_CLOSEATTRIBUTEVALUE: state = CloseTagStateInsert(pEngine, chr); break; case STATE_OPENTAG: if(_tcschr(_T("\t "), chr)) { state = WhitespaceStateInsert(pEngine, chr); } else { state = TagNameStateInsert(pEngine, chr); } break; default: state = InvalidStateInsert(pEngine, chr); break; } } return state; }
void SPIListener::Run() { Setup(); CheckRun(); // Run until terminated while (1) { // Let the thread sleep for 1/10th of a second. usleep(LISTENER_SLEEP_DELAY); // Check each bus for a signal ResetBuffer(); CheckSignal(SPI_BUS_CAR); ResetBuffer(); CheckSignal(SPI_BUS_RF); } }
STATE NewLineStateInsert(TextEngine *pEngine, TCHAR chr) { // OutputDebugString(_T("New Line\n")); STATE state = STATE_NEWLINE; CheckRun(pEngine, state); if(chr == _T('\r')) { pEngine->m_pRun->text.insert(pEngine->m_pRun->text.begin() + pEngine->m_pRun->text.length(), chr); pEngine->m_pRun->flags = state; } else if(chr == _T('\n')) { pEngine->m_pRun->text.insert(pEngine->m_pRun->text.begin() + pEngine->m_pRun->text.length(), chr); pEngine->m_pRun->flags = state; pEngine->NewRun(true); } else { state = STATE_UNKNOWN; } if(state == STATE_UNKNOWN) { Run *pRun = pEngine->LastNonWhitespaceRun(); STATE lastState = pRun? pRun->flags: STATE_UNKNOWN; switch(lastState) { case STATE_TAGNAME: case STATE_CLOSEATTRIBUTEVALUE: state = AttrNameStateInsert(pEngine, chr); case STATE_CLOSETAG: case STATE_FREETEXT: state = FreeTextStateInsert(pEngine, chr); break; case STATE_ATTRIBUTEVALUE: state = AttrValueStateInsert(pEngine, chr); break; default: state = InvalidStateInsert(pEngine, chr); break; } } return state; }
STATE AttrEqualStateInsert(TextEngine *pEngine, TCHAR chr) { // OutputDebugString(_T("Attribute Equal\n")); STATE state = STATE_ATTRIBUTEEQUAL; CheckRun(pEngine, state); if(!pEngine->m_pRun->text.length() && chr == _T('=')) { pEngine->m_pRun->text.insert(pEngine->m_pRun->text.begin() + pEngine->m_pRun->text.length(), chr); pEngine->m_pRun->flags = state; } else if(chr == _T('\"')) { state = OpenAttrValueStateInsert(pEngine, chr); } else { state = InvalidStateInsert(pEngine, chr); } return state; }
STATE InvalidStateInsert(TextEngine *pEngine, TCHAR chr) { STATE state = STATE_INVALID; CheckRun(pEngine, state); if(_tcschr(_T("\r\n"), chr)) { state = NewLineStateInsert(pEngine, chr); } else if(_tcschr(_T("\t "), chr)) { state = WhitespaceStateInsert(pEngine, chr); } else { pEngine->m_pRun->text.insert(pEngine->m_pRun->text.begin() + pEngine->m_pRun->text.length(), chr); pEngine->m_pRun->flags = STATE_INVALID; } // DebugBreak(); return state; }
STATE AttrNameStateInsert(TextEngine *pEngine, TCHAR chr) { // OutputDebugString(_T("Attribute Name\n")); STATE state = STATE_ATTRIBUTENAME; CheckRun(pEngine, state); if(_tcschr(_T("</>\r\n\t \""), chr)) { state = InvalidStateInsert(pEngine, chr); } else if(chr == _T('=')) { state = AttrEqualStateInsert(pEngine, chr); } else { pEngine->m_pRun->text.insert(pEngine->m_pRun->text.begin() + pEngine->m_pRun->text.length(), chr); pEngine->m_pRun->flags = state; } return state; }
STATE OpenAttrValueStateInsert(TextEngine *pEngine, TCHAR chr) { // OutputDebugString(_T("Open Attribute Value\n")); STATE state = STATE_OPENATTRIBUTEVALUE; CheckRun(pEngine, state); if(chr == _T('\"')) { if(!pEngine->m_pRun->text.length()) { pEngine->m_pRun->text.insert(pEngine->m_pRun->text.begin() + pEngine->m_pRun->text.length(), chr); pEngine->m_pRun->flags = state; } else { state = CloseAttrValueStateInsert(pEngine, chr); } } else { state = AttrValueStateInsert(pEngine, chr); } return state; }
STATE FreeTextStateInsert(TextEngine *pEngine, TCHAR chr) { STATE state = STATE_FREETEXT; CheckRun(pEngine, state); if(_tcschr(_T("\r\n"), chr)) { state = NewLineStateInsert(pEngine, chr); } else if(_tcschr(_T("\t "), chr)) { state = WhitespaceStateInsert(pEngine, chr); } else if(chr == _T('<')) { state = OpenTagStateInsert(pEngine, chr); } else { pEngine->m_pRun->text.insert(pEngine->m_pRun->text.begin() + pEngine->m_pRun->text.length(), chr); pEngine->m_pRun->flags = state; } return state; }
STATE WhitespaceStateInsert(TextEngine *pEngine, TCHAR chr) { // OutputDebugString(_T("Attribute Whitespace\n")); STATE state = STATE_WHITESPACE; CheckRun(pEngine, state); if(_tcschr(_T("\t "), chr)) { pEngine->m_pRun->text.insert(pEngine->m_pRun->text.begin() + pEngine->m_pRun->text.length(), chr); pEngine->m_pRun->flags = state; } else if(_tcschr(_T("\r\n"), chr)) { state = NewLineStateInsert(pEngine, chr); } else { Run *pRun = pEngine->LastNonWhitespaceRun(); STATE lastState = pRun? pRun->flags: STATE_UNKNOWN; switch(lastState) { case STATE_OPENTAG: case STATE_TAGNAME: if(chr == _T('/')) { state = TagSlashStateInsert(pEngine, chr); } else if(chr == _T('>')) { state = CloseTagStateInsert(pEngine, chr); } else if(chr == _T('<')) { state = InvalidStateInsert(pEngine, chr); } else { if(lastState == STATE_TAGNAME) { state = AttrNameStateInsert(pEngine, chr); } else { state = TagNameStateInsert(pEngine, chr); } } break; case STATE_OPENATTRIBUTEVALUE: case STATE_ATTRIBUTEVALUE: state = AttrValueStateInsert(pEngine, chr); break; case STATE_CLOSEATTRIBUTEVALUE: if(chr == _T('/')) { state = TagSlashStateInsert(pEngine, chr); } else if(chr == _T('>')) { state = CloseTagStateInsert(pEngine, chr); } else if(chr == _T('<')) { state = InvalidStateInsert(pEngine, chr); } else { state = AttrNameStateInsert(pEngine, chr); } break; case STATE_CLOSETAG: case STATE_FREETEXT: state = FreeTextStateInsert(pEngine, chr); break; case STATE_TAGSLASH: pRun = pEngine->PreviousRun(1); lastState = pRun? pRun->flags: STATE_UNKNOWN; if(lastState == STATE_OPENTAG) { if(chr == _T('>')) { state = CloseTagStateInsert(pEngine, chr); } else { state = TagNameStateInsert(pEngine, chr); } } else { state = InvalidStateInsert(pEngine, chr); } break; default: state = InvalidStateInsert(pEngine, chr); break; } } return state; }
void ForceStartup (int WTFIT) { CheckRun(true, false); }
void ForceInventory (int WTFIT) { CheckRun(false, true); }
bool QtCreate::MFPSStatusUpdate(int timeslice, int tasknum, int partition) { bool PartObtainSystemTime = true; bool flag = false; bool flag2 = false; for (int i = 1; i <= tasknum; i++) { //if (t[i].stat == Suspend && timeslice == t[i].offset) if (t[i].stat == Suspend && t[i].partitionid == partition) { t[i].stat = Ready; //printf("Task id%d is Ready, timeslice is %d\n", t[i].id, timeslice); Sleep(100); ui.ConsoleTextEdit->append(QString("Task id%1 is Ready, timeslice is %2").arg(t[i].id).arg(timeslice)); ui.ConsoleTextEdit->repaint(); ui.ResultTextEdit->append(QString("Task Id %1 is Ready in %2 (timeslice)").arg(t[i].id).arg(timeslice)); ui.ResultTextEdit->repaint(); //Output to Ready file QFile dataRea("OutputReady.txt"); if (dataRea.open(QIODevice::Text | QIODevice::Append)) { QTextStream out(&dataRea); out << QString("%1").arg(t[i].id) << endl; out << QString("%1").arg(timeslice) << endl; out << QString("%1").arg(timeslice + 0.4) << endl; } TaskCycle[i] = timeslice; if (flag == false) { t[i].respclock++; flag = true; } } if (t[i].stat == Finish && timeslice - TaskCycle[i] >= t[i].period) { t[i].stat = Ready; //printf("Task id%d is Ready, timeslice is %d\n", t[i].id, timeslice); Sleep(100); ui.ConsoleTextEdit->append(QString("Task id%1 is Ready, timeslice is %2").arg(t[i].id).arg(timeslice)); ui.ConsoleTextEdit->repaint(); ui.ResultTextEdit->append(QString("Task Id %1 is Ready in %2 (timeslice)").arg(t[i].id).arg(timeslice)); ui.ResultTextEdit->repaint(); //Output to file QFile dataRea("OutputReady.txt"); if (dataRea.open(QIODevice::Text | QIODevice::Append)) { QTextStream out(&dataRea); out << QString("%1").arg(t[i].id) << endl; out << QString("%1").arg(timeslice) << endl; out << QString("%1").arg(timeslice + 0.4) << endl; } TaskCycle[i] = timeslice; if (flag == false) { t[i].respclock++; flag = true; } } if (t[i].stat == Ready) { /*if (t[i].respclock == t[i].deadline) { t[i].stat = Error; printf("Task id%d is Error, timeslice is %d\n", t[i].id, timeslice); }*/ if (ScheduleStrategy == 1) { if (CheckPriorityReaEDF(i, partition, tasknum) == false && CheckRun(i, tasknum) == false && t[i].partitionid == partition) { t[i].stat = Running; //printf("Task id%d is Running, timeslice is %d\n", t[i].id, timeslice); Sleep(100); ui.ConsoleTextEdit->append(QString("Task id%1 is Running, timeslice is %2").arg(t[i].id).arg(timeslice)); ui.ConsoleTextEdit->repaint(); //Output to file QFile data("Output.txt"); if (data.open(QIODevice::Text | QIODevice::Append)) { QTextStream out(&data); //out << QString("%1 Run %2").arg(t[i].id).arg(timeslice) << endl; out << QString("%1").arg(t[i].id) << endl; out << QString("%1").arg(timeslice) << endl; } } if (flag == false) { t[i].respclock++; flag = true; } } else if (ScheduleStrategy == 2) { if (CheckPriorityReaRMS(i, partition, tasknum) == false && CheckRun(i, tasknum) == false && t[i].partitionid == partition) { t[i].stat = Running; //printf("Task id%d is Running, timeslice is %d\n", t[i].id, timeslice); Sleep(100); ui.ConsoleTextEdit->append(QString("Task id%1 is Running, timeslice is %2").arg(t[i].id).arg(timeslice)); ui.ConsoleTextEdit->repaint(); //Output to file QFile data("Output.txt"); if (data.open(QIODevice::Text | QIODevice::Append)) { QTextStream out(&data); //out << QString("%1 Run %2").arg(t[i].id).arg(timeslice) << endl; out << QString("%1").arg(t[i].id) << endl; out << QString("%1").arg(timeslice) << endl; } } if (flag == false) { t[i].respclock++; flag = true; } } else if (ScheduleStrategy == 3) { if (CheckPriorityReaDMS(i, partition, tasknum) == false && CheckRun(i, tasknum) == false && t[i].partitionid == partition) { t[i].stat = Running; //printf("Task id%d is Running, timeslice is %d\n", t[i].id, timeslice); Sleep(100); ui.ConsoleTextEdit->append(QString("Task id%1 is Running, timeslice is %2").arg(t[i].id).arg(timeslice)); ui.ConsoleTextEdit->repaint(); //Output to file QFile data("Output.txt"); if (data.open(QIODevice::Text | QIODevice::Append)) { QTextStream out(&data); //out << QString("%1 Run %2").arg(t[i].id).arg(timeslice) << endl; out << QString("%1").arg(t[i].id) << endl; out << QString("%1").arg(timeslice) << endl; } } if (flag == false) { t[i].respclock++; flag = true; } } } if (t[i].stat == Running) { if (ScheduleStrategy == 1) { if (CheckPriorityReaEDF(i, partition, tasknum) == true || t[i].partitionid != partition) { t[i].stat = Ready; //printf("Task id%d is Ready, timeslice is %d\n", t[i].id, timeslice); Sleep(100); ui.ConsoleTextEdit->append(QString("Task id%1 is Ready, timeslice is %2").arg(t[i].id).arg(timeslice)); ui.ConsoleTextEdit->repaint(); ui.ResultTextEdit->append(QString("Task Id %1 is Ready in %2 (timeslice)").arg(t[i].id).arg(timeslice)); ui.ResultTextEdit->repaint(); //Output to file QFile data("Output.txt"); if (data.open(QIODevice::Text | QIODevice::Append)) { QTextStream out(&data); //out << QString("%1 Rea %2").arg(t[i].id).arg(timeslice) << endl; out << QString("%1").arg(timeslice) << endl; } } if (flag == false) { t[i].respclock++; flag = true; } } else if (ScheduleStrategy == 2) { if (CheckPriorityReaRMS(i, partition, tasknum) == true || t[i].partitionid != partition) { t[i].stat = Ready; //printf("Task id%d is Ready, timeslice is %d\n", t[i].id, timeslice); Sleep(100); ui.ConsoleTextEdit->append(QString("Task id%1 is Ready, timeslice is %2").arg(t[i].id).arg(timeslice)); ui.ConsoleTextEdit->repaint(); ui.ResultTextEdit->append(QString("Task Id %1 is Ready in %2 (timeslice)").arg(t[i].id).arg(timeslice)); ui.ResultTextEdit->repaint(); //Output to file QFile data("Output.txt"); if (data.open(QIODevice::Text | QIODevice::Append)) { QTextStream out(&data); //out << QString("%1 Rea %2").arg(t[i].id).arg(timeslice) << endl; out << QString("%1").arg(timeslice) << endl; } } if (flag == false) { t[i].respclock++; flag = true; } } else if (ScheduleStrategy == 3) { if (CheckPriorityReaDMS(i, partition, tasknum) == true || t[i].partitionid != partition) { t[i].stat = Ready; //printf("Task id%d is Ready, timeslice is %d\n", t[i].id, timeslice); Sleep(100); ui.ConsoleTextEdit->append(QString("Task id%1 is Ready, timeslice is %2").arg(t[i].id).arg(timeslice)); ui.ConsoleTextEdit->repaint(); ui.ResultTextEdit->append(QString("Task Id %1 is Ready in %2 (timeslice)").arg(t[i].id).arg(timeslice)); ui.ResultTextEdit->repaint(); //Output to file QFile data("Output.txt"); if (data.open(QIODevice::Text | QIODevice::Append)) { QTextStream out(&data); //out << QString("%1 Rea %2").arg(t[i].id).arg(timeslice) << endl; out << QString("%1").arg(timeslice) << endl; } } if (flag == false) { t[i].respclock++; flag = true; } } if (flag2 == false) { t[i].execclock++; flag2 = true; } } if (t[i].stat == Error) { return false; } flag = false; flag2 = false; } return true; }
void InventoryCheckTimerFunc( CFRunLoopTimerRef Timer, void * info) { CheckRun(false); }
void list_OnItemChanged(CCtrlListView::TEventInfo*) { CheckRun(); }
void list_OnDblClick(CCtrlListView::TEventInfo*) { CheckRun(); EndDialog(GetParent(m_hwndParent), 1); }