bool CMOOSRemoteLite::MailLoop() { m_bRunMailLoop = true; while(!m_bQuit) { MOOSPause(300); MOOSMSG_LIST MailIn; if(m_bRunMailLoop && m_Comms.Fetch(MailIn)) { //process mail //simply write out MOOSMSG_LIST::iterator p; //make it in time order MailIn.sort(); MailIn.reverse(); for(p = MailIn.begin();p!=MailIn.end();p++) { if(p->IsSkewed(MOOSTime())) continue; if(MOOSStrCmp(p->m_sKey,"NAV_SUMMARY")) { DoNavSummary(*p); } else if(p->GetKey().find("DEBUG")!=string::npos) { //we print MOOS_DEBUG messages to the screen string sMsg = p->m_sVal; MOOSRemoveChars(sMsg,"\r\n"); MOOSTrace(">%-10s @ %7.2f \"%s\"\n", p->m_sSrc.c_str(), p->m_dfTime-GetAppStartTime(), sMsg.c_str()); } else { CUSTOMJOURNAL_MAP::iterator w = m_CustomJournals.find(p->GetKey()); if(w!=m_CustomJournals.end()) { w->second.Add(p->GetAsString()); } } } UpdateMOOSVariables(MailIn); } } return true; }
bool CMOOSApp::DoRunWork() { bool bIterateRequired = true; SleepAsRequired(bIterateRequired); //std::cerr<<"bIterate:"<<bIterateRequired<<"\n"; //store for derived class use the last time iterate was called; m_dfLastRunTime = MOOSLocalTime(); //local vars MOOSMSG_LIST MailIn; if(m_bUseMOOSComms) { if( m_Comms.Fetch(MailIn)) { ///////////////////////////// // process mail if(m_bSortMailByTime) MailIn.sort(MOOSMsgTimeSorter); //call our own private version OnNewMailPrivate(MailIn); //classes will have their own personal versions of this OnNewMail(MailIn); m_nMailCount++; } if(m_Comms.IsConnected() || CanIterateWithoutComms() ) { //do private work IteratePrivate(); if(bIterateRequired) { ////////////////////////////////////// // do application specific processing /** called just after Iterate has finished - another place to overload*/ bool bOK = true; bOK = OnIteratePrepare(); if(m_bQuitOnIterateFail && !bOK) return false; bOK = Iterate(); if(m_bQuitOnIterateFail && !bOK) return false; bOK = OnIterateComplete(); if(m_bQuitOnIterateFail && !bOK) return false; } m_nIterateCount++; } } else { //do private work IteratePrivate(); if(bIterateRequired) { ///////////////////////////////////////// // do application specific processing bool bOK = Iterate(); if(m_bQuitOnIterateFail && !bOK) return false; } m_nIterateCount++; } return true; }