bool CMOOSRemoteLite::MakeCustomSummary() { STRING_LIST sParams; if(m_MissionReader.GetConfiguration(GetAppName(),sParams)) { STRING_LIST::iterator p; for(p = sParams.begin();p!=sParams.end();p++) { string sLine = *p; string sTok,sVal; m_MissionReader.GetTokenValPair(sLine,sTok,sVal); if(MOOSStrCmp(sTok,"CUSTOMSUMMARY")) { m_CustomSummaryList.push_front(sVal); AddMOOSVariable(sVal,sVal,"",0.2); } } } RegisterMOOSVariables(); return true; }
Triggerconf::STRING_LIST Triggerconf::getChildsAttribute (DOMNode* root, string nodename, string attribute) { STRING_LIST ret; if (root == NULL) { setError ("invalid root node"); return ret; } DOMNodeList* childs = root->getChildNodes (); if (childs == NULL) return ret; for (unsigned int i=0; i<childs->getLength (); i++) { DOMNode* child = childs->item (i); if (child == NULL || child->getNodeType () != DOMNode::ELEMENT_NODE) continue; const XMLCh* xnodename = child->getNodeName (); char* charname = XMLString::transcode (xnodename); if (nodename.compare (charname) == 0) ret.push_back (getAttributeValue (child, attribute)); XMLString::release (&charname); } // for (unsigned int i=0; i<childs->getLength (); i++) return ret; }
Triggerconf::STRING_LIST Triggerconf::tokenize (string path) { STRING_LIST ret; int first = 0; int last = 0; while (true) { last = (int) path.find (PATH_DELIMITER, first); if (last == (int)string::npos) { if (path.length () - first >= 1) ret.push_back (path.substr (first, path.length () - first)); break; } if (last-first >= 1) ret.push_back (path.substr (first, last-first)); first = last + 1; } return ret; }
bool CHelmApp::OnPreIterate() { TASK_LIST::iterator p; STRING_LIST NewResources; STRING_LIST::iterator q; for(p = m_Tasks.begin();p!=m_Tasks.end();p++) { CMOOSBehaviour* pBehaviour = *p; if(pBehaviour->HasNewRegistration()) { NewResources.clear(); pBehaviour->GetRegistrations(NewResources); for(q = NewResources.begin();q!=NewResources.end();q++) { if(m_Comms.IsConnected()) { m_Comms.Register(*q,UPDATE_INTERVAL); } } } } return true; }
bool CProcessConfigReader::GetConfigurationAndPreserveSpace(std::string sAppName, STRING_LIST &Params) { Params.clear(); int nBrackets = 0; Params.clear(); Reset(); std::string sKey = "PROCESSCONFIG="+sAppName; if(GoTo(sKey)) { std::string sBracket = GetNextValidLine(); if(sBracket.find("{")==0) { nBrackets++; while(!GetFile()->eof()) { std::string sLine = GetNextValidLine(); MOOSTrimWhiteSpace(sLine); if(sLine.find("}")!=0) { std::string sVal(sLine); std::string sTok = MOOSChomp(sVal, "="); MOOSTrimWhiteSpace(sTok); MOOSTrimWhiteSpace(sVal); if (!sTok.empty()) { if (!sVal.empty()) { Params.push_back(sTok+"="+sVal); } else if(sLine.find("[")!=std::string::npos || sLine.find("]")!=std::string::npos) { Params.push_back(sLine); } } } else { return true; } //quick error check - we don't allow nested { on single lines if(sLine.find("{")==0) { MOOSTrace("CProcessConfigReader::GetConfiguration() missing \"}\" syntax error in mission file\n"); } } } } return false; }
/// READ STRINGS bool CProcessConfigReader::GetConfigurationParam(std::string sAppName,std::string sParam, std::string &sVal) { Reset(); //remember all names we were asked for.... std::string sl = sParam; MOOSToLower(sl); m_Audit[sAppName].insert(sl); STRING_LIST sParams; if(GetConfigurationAndPreserveSpace( sAppName, sParams)) { STRING_LIST::iterator p; for(p = sParams.begin(); p!=sParams.end(); p++) { std::string sTmp = *p; std::string sTok = MOOSChomp(sTmp,"="); MOOSTrimWhiteSpace(sTok); if (sTmp.empty()) return false; if(MOOSStrCmp(sTok,sParam)) { MOOSTrimWhiteSpace(sTmp); sVal=sTmp; return true; } } } return false; }
bool CMOOSDB::OnProcessSummaryRequested(CMOOSMsg &Msg, MOOSMSG_LIST &MsgTxList) { DBVAR_MAP::iterator p; STRING_LIST::iterator q; STRING_LIST Clients; m_pCommServer->GetClientNames(Clients); for(q=Clients.begin();q!=Clients.end();q++) { string sWho = *q; string sPublished= "PUBLISHED="; string sSubscribed = "SUBSCRIBED="; for(p=m_VarMap.begin();p!=m_VarMap.end();p++) { CMOOSDBVar & rVar = p->second; if(rVar.m_Writers.find(sWho)!=rVar.m_Writers.end()) { if(!sPublished.empty()) { sPublished+=","; } sPublished+=rVar.m_sName; } if(rVar.m_Subscribers.find(sWho)!=rVar.m_Subscribers.end()) { if(!sSubscribed.empty()) { sSubscribed+=","; } sSubscribed+=rVar.m_sName; } } CMOOSMsg MsgReply; MsgReply.m_nID = Msg.m_nID; MsgReply.m_cMsgType = MOOS_NOTIFY; MsgReply.m_cDataType = MOOS_STRING; MsgReply.m_dfTime = MOOSTime()-m_dfStartTime; //for display MsgReply.m_sSrc = m_sDBName; MsgReply.m_sKey = "PROC_SUMMARY"; MsgReply.m_sVal = sWho+":"+sSubscribed+","+sPublished; MsgReply.m_dfVal = -1; MsgTxList.push_front(MsgReply); } return true; }
bool COrbitTask::GetRegistrations(STRING_LIST &List) { List.push_front("NAV_X"); List.push_front("NAV_Y"); List.push_front("NAV_YAW"); //always call base class version CMOOSBehaviour::GetRegistrations(List); return true; }
//----------------------------------------------------------------------------- // Purpose: Parse the VSS history command and generate a list of files & versions // Input : *pFileName - // Output : STRING_LIST //----------------------------------------------------------------------------- STRING_LIST &ParseHistory( const char *pProjectName, const char *pFileName ) { int nameLen = strlen( pProjectName ); STRING_LIST *list = new STRING_LIST; FILE *fp = fopen( pFileName, "r" ); if ( fp ) { char buf[1024]; string currentFile; string project; int currentVersion; while ( !feof(fp) ) { fgets( buf, 1024, fp ); if ( !strncmp( buf, "*****", 5 ) ) { char *pStr = buf + 7; strtok( pStr, " \n" ); currentFile = pStr; } else if ( !strncmp( buf, "Version", 7 ) ) { currentVersion = atoi( buf + 8 ); } else if ( !strncmp( buf, "Checked in", 10 ) ) { char *pStr = buf + 11; strtok( pStr, " \n" ); if ( strncmp( pProjectName, pStr, nameLen ) ) { project = pProjectName; pStr = StringSkipTo( pStr, '/' ); // skip $/ pStr = StringSkipTo( pStr, '/' ); // skip xxx/ project += "/"; project += pStr; } else { project = pStr; } project += "/"; project += currentFile; historyList tmp( project, currentVersion ); list->push_back( tmp ); } } fclose( fp ); } return *list; }
bool CMOOSNavEngine::SetUpSensorChannels(STRING_LIST sParams,string sToken) { //ok we need to load up rejection settings STRING_LIST::iterator p; for(p = sParams.begin();p!=sParams.end();p++) { string sLine = *p; if(sLine.find(sToken)!=string::npos) { MOOSRemoveChars(sLine," \t"); MOOSChomp(sLine,"="); //LSQ_REJECTION = TheAvtrak : Reject = 3, History = 5,Fail = 0.001 CMOOSSensorChannel NewChannel; string sSensor = MOOSChomp(sLine,":"); string sHistory = MOOSChomp(sLine,","); string sFail = MOOSChomp(sLine,","); MOOSChomp(sHistory,"="); MOOSChomp(sFail,"="); if(sFail.empty() ||sHistory.empty()) { MOOSTrace("error in %s line!\n",sToken.c_str()); return false; } int nDepth = atoi(sHistory.c_str()); if(nDepth>0) { NewChannel.SetHistoryDepth(nDepth); } double dfFail = atof(sFail.c_str()); if(dfFail>0) { NewChannel.SetNoiseLimit(dfFail); } NewChannel.SetName(sSensor); m_SensorChannelMap[sSensor]=NewChannel; } } return true; }
bool CMOOSRemoteLite::MakeCustomKeys() { STRING_LIST sParams; if(m_MissionReader.GetConfiguration(GetAppName(),sParams)) { STRING_LIST::iterator p; for(p = sParams.begin();p!=sParams.end();p++) { string sLine = *p; string sTok,sVal; m_MissionReader.GetTokenValPair(sLine,sTok,sVal); if(MOOSStrCmp(sTok,"CUSTOMKEY")) { MOOSRemoveChars(sVal," "); string sChar = MOOSChomp(sVal,":"); string sKey = MOOSChomp(sVal,"@"); MOOSRemoveChars(sVal,"\""); string sTx = MOOSChomp(sVal,"$"); bool bIsNumeric = MOOSIsNumeric(sTx); bool bAskToConfirm = (sVal == "confirm"); if(!sChar.empty()) { CCustomKey NewKey; NewKey.m_cChar = sChar[0]; NewKey.m_sKey = sKey; NewKey.m_sVal = sTx; NewKey.bIsNumeric = bIsNumeric; NewKey.bAskToConfirm = bAskToConfirm; if(isdigit(NewKey.m_cChar)) { m_CustomKeys[NewKey.m_cChar] = NewKey; } else { MOOSTrace("CMOOSRemote: can only bind custom keys to numeric characters!\n"); } } } } } return true; }
bool DeadManPost::OnStartUp() { AppCastingMOOSApp::OnStartUp(); STRING_LIST sParams; m_MissionReader.EnableVerbatimQuoting(false); if(!m_MissionReader.GetConfiguration(GetAppName(), sParams)) reportConfigWarning("No config block found for " + GetAppName()); STRING_LIST::iterator p; for(p=sParams.begin(); p!=sParams.end(); p++) { string orig = *p; string line = *p; string param = tolower(biteStringX(line, '=')); string value = line; bool handled = false; if(param == "heartbeat_var") { if(!strContainsWhite(value)) { m_heart_var = value; handled = true; } } else if(param == "deadflag") { string varname = biteStringX(value, '='); string varval = value; if(!strContainsWhite(varname) && (varval != "")) { VarDataPair pair(varname, varval, "auto"); m_deadflags.push_back(pair); handled = true; } } else if(param == "post_policy") { string val = tolower(value); if((val=="once") || (val=="repeat") || (val=="reset")) { m_post_policy = val; handled = true; } } else if((param == "max_noheart") && isNumber(value)) { m_max_noheart = atof(value.c_str()); handled = true; } else if(param == "active_at_start") handled = setBooleanOnString(m_active_at_start, value); if(!handled) reportUnhandledConfigWarning(orig); } registerVariables(); return(true); }
bool CLimitBox::GetRegistrations(STRING_LIST &List) { List.push_front("NAV_DEPTH"); List.push_front("NAV_X"); List.push_front("NAV_Y"); //always call base class version CMOOSBehaviour::GetRegistrations(List); return true; }
bool SonarFilter::OnStartUp() { AppCastingMOOSApp::OnStartUp(); STRING_LIST sParams; m_MissionReader.EnableVerbatimQuoting(false); if(!m_MissionReader.GetConfiguration(GetAppName(), sParams)) reportConfigWarning("No config block found for " + GetAppName()); STRING_LIST::iterator p; for(p=sParams.begin(); p!=sParams.end(); p++) { string orig = *p; string line = *p; string param = toupper(biteStringX(line, '=')); string value = line; bool handled = false; if(param == "FILTERLEN") { m_filter_len = atoi(value.c_str()); handled = true; } else if(param == "STDEVLIMIT") { m_std_limit = atof(value.c_str()); handled = true; } else if (param == "SIMSWATHANGLE") { // Convert the angle to radians m_sim_swath_angle = atof(value.c_str()) * M_PI / 180; handled = true; } else if (param == "SONARTYPE") { } if(!handled) reportUnhandledConfigWarning(orig); } AddMOOSVariable("X", "NAV_X", "", 0); AddMOOSVariable("Y", "NAV_Y", "", 0); AddMOOSVariable("Heading", "NAV_HEADING", "", 0); AddMOOSVariable("Depth", "SONAR_DEPTH_M", "", 0); AddMOOSVariable("Depth_Stbd", "SONAR_DEPTH_STBD_M", "", 0); AddMOOSVariable("Depth_Port", "SONAR_DEPTH_PORT_M", "", 0); AddMOOSVariable("SonarWidth", "SONAR_WIDTH", "", 0); AddMOOSVariable("Swath", "", "SWATH_WIDTH", 0); m_nadir_filter = StDevFilter(m_filter_len, m_std_limit, 1/GetAppFreq()); m_port_filter = StDevFilter(m_filter_len, m_std_limit, 1/GetAppFreq()); m_stbd_filter = StDevFilter(m_filter_len, m_std_limit, 1/GetAppFreq()); registerVariables(); return(true); }
bool HazardMgr::OnStartUp() { AppCastingMOOSApp::OnStartUp(); STRING_LIST sParams; m_MissionReader.EnableVerbatimQuoting(true); if(!m_MissionReader.GetConfiguration(GetAppName(), sParams)) reportConfigWarning("No config block found for " + GetAppName()); STRING_LIST::iterator p; for(p=sParams.begin(); p!=sParams.end(); p++) { string orig = *p; string line = *p; string param = tolower(biteStringX(line, '=')); string value = line; bool handled = false; if((param == "swath_width") && isNumber(value)) { m_swath_width_desired = atof(value.c_str()); handled = true; } else if(((param == "sensor_pd") || (param == "pd")) && isNumber(value)) { m_pd_desired = atof(value.c_str()); handled = true; } else if(param == "report_name") { value = stripQuotes(value); m_report_name = value; handled = true; } else if(param == "region") { XYPolygon poly = string2Poly(value); if(poly.is_convex()) m_search_region = poly; handled = true; } if(!handled) reportUnhandledConfigWarning(orig); } m_hazard_set.setSource(m_host_community); m_hazard_set.setName(m_report_name); m_hazard_set.setRegion(m_search_region); m_voted_hazard_set.setSource(m_host_community); m_voted_hazard_set.setName(m_report_name); m_voted_hazard_set.setRegion(m_search_region); registerVariables(); return(true); }
bool CMOOSCommServer::GetClientNames(STRING_LIST &sList) { sList.clear(); SOCKETFD_2_CLIENT_NAME_MAP::iterator p; for(p = m_Socket2ClientMap.begin();p!=m_Socket2ClientMap.end();p++) { sList.push_front(p->second); } return true; }
void CMOOSDB::UpdateDBClientsVar() { STRING_LIST Clients; m_pCommServer->GetClientNames(Clients); std::ostringstream ss; std::copy(Clients.begin(),Clients.end(),ostream_iterator<std::string>(ss,",")); CMOOSMsg DBC(MOOS_NOTIFY,"DB_CLIENTS",ss.str()); DBC.m_sOriginatingCommunity = m_sCommunityName; DBC.m_sSrc = m_sDBName; OnNotify(DBC); }
bool GPS::OnStartUp() { AppCastingMOOSApp::OnStartUp(); STRING_LIST sParams; m_MissionReader.EnableVerbatimQuoting(false); if (!m_MissionReader.GetConfiguration(GetAppName(), sParams)) reportConfigWarning("No config block found for " + GetAppName()); STRING_LIST::iterator p; for (p = sParams.begin(); p != sParams.end(); p++) { string orig = *p; string line = *p; string param = toupper(biteStringX(line, '=')); string value = line; bool handled = false; if (param == "SERIAL_PORT") { m_uart_port = value.c_str(); handled = true; } if (param == "UART_BAUD_RATE") { m_uart_baud_rate = atoi(value.c_str()); handled = true; } if (!handled) reportUnhandledConfigWarning(orig); } registerVariables(); // Init GPS connection m_error = m_serial.open(m_uart_port,m_error); if (m_error.value() != 0.0) { // No error from asio read reportConfigWarning("Serial open error"); } else m_serial.set_option(boost::asio::serial_port_base::baud_rate(m_uart_baud_rate)); //serial.set_option(boost::asio::serial_port_base::character_size()); //serial.set_option(boost::asio::serial_port_base::flow_control()); //serial.set_option(boost::asio::serial_port_base::parity()); //serial.set_option(boost::asio::serial_port_base::stop_bits()); if(!m_serial.is_open()){ reportConfigWarning("Serial port not open"); } return (true); }
bool CMOOSRemoteLite::DoCustomJournal(char cCmd) { CUSTOMJOURNAL_MAP::iterator p; for(p = m_CustomJournals.begin();p!=m_CustomJournals.end();p++) { if(p->second.m_cKey==cCmd) { MOOSTrace("\nJournal Entries for \"%s\" :\n ",p->first.c_str()); STRING_LIST Cpy = p->second.m_Entries; std::copy(Cpy.begin(),Cpy.end(),std::ostream_iterator<std::string>(std::cout,"\n ")); return true; } } return false; }
Triggerconf::ATTRIBUTE_MAP Triggerconf::getConfigItemAttributes (string module, string submodule, string configitem) { ATTRIBUTE_MAP ret; STRING_LIST names = getConfigAttributeNames (module, submodule, configitem); STRING_LIST_ITERATOR begin = names.begin(); STRING_LIST_ITERATOR end = names.end(); for ( ; begin != end; begin++) { string value = getConfigAttributeValue (module, submodule, configitem, *begin); ret.insert (ATTRIBUTE_PAIR (*begin, value)); } // for ( ; begin != end; begin++) return ret; }
void CMOOSDB::UpdateReadWriteSummaryVar() { std::map<std::string,std::list<std::string> > Pub; std::map<std::string,std::list<std::string> > Sub; DBVAR_MAP::iterator p; for(p=m_VarMap.begin();p!=m_VarMap.end();p++) { CMOOSDBVar & rVar = p->second; STRING_SET::iterator w; REGISTER_INFO_MAP::iterator v; std::stringstream ss; for(v = rVar.m_Subscribers.begin();v!=rVar.m_Subscribers.end();v++) Sub[v->second.m_sClientName].push_back(rVar.m_sName); for(w = rVar.m_Writers.begin();w!=rVar.m_Writers.end();w++) Pub[*w].push_back(rVar.m_sName); } STRING_LIST Clients; m_pCommServer->GetClientNames(Clients); STRING_LIST::iterator q; std::ostringstream ss; for(q=Clients.begin();q!=Clients.end();) { ss<<*q<<"="; PrintCollection(Sub[*q],ss,":"); ss<<"&"; PrintCollection(Pub[*q],ss,":"); if(++q!=Clients.end()) ss<<","; } CMOOSMsg DBS(MOOS_NOTIFY,"DB_RWSUMMARY",ss.str()); DBS.m_sSrc = m_sDBName; DBS.m_sOriginatingCommunity = m_sCommunityName; OnNotify(DBS); }
string Triggerconf::untokenize (STRING_LIST path) { STRING_LIST::iterator begin = path.begin(); STRING_LIST::iterator end = path.end(); string ret; for ( ; begin != end; begin++) { if (ret.length () == 0) ret += *begin; else ret += (PATH_DELIMITER + *begin); } return ret; }
bool CThirdPartyTask::GetRegistrations(STRING_LIST &List) { List.push_front(m_sJob); //always call base class version CMOOSBehaviour::GetRegistrations(List); return true; }
bool Gps::OnStartUp() { AppCastingMOOSApp::OnStartUp(); STRING_LIST sParams; m_MissionReader.EnableVerbatimQuoting(false); if (!m_MissionReader.GetValue("GPS_SERIAL_PORT",m_uart_port)) reportConfigWarning("No GPS_SERIAL_PORT config found for " + GetAppName() + "(previously iGps)"); if (!m_MissionReader.GetConfiguration(GetAppName(), sParams)) reportConfigWarning("No config block found for " + GetAppName()); STRING_LIST::iterator p; for (p = sParams.begin(); p != sParams.end(); p++) { string orig = *p; string line = *p; string param = toupper(biteStringX(line, '=')); string value = line; bool handled = false; if (param == "UART_BAUD_RATE") { m_uart_baud_rate = atoi(value.c_str()); handled = true; } if (!handled) reportUnhandledConfigWarning(orig); } registerVariables(); // Init GPS connection // if(serial.is_open()){ // serial.close(); // } m_serial.open(m_uart_port); m_serial.set_option(boost::asio::serial_port_base::baud_rate(m_uart_baud_rate)); //serial.set_option(boost::asio::serial_port_base::character_size()); //serial.set_option(boost::asio::serial_port_base::flow_control()); //serial.set_option(boost::asio::serial_port_base::parity()); //serial.set_option(boost::asio::serial_port_base::stop_bits()); return (true); }
bool SensorViewer::OnStartUp() { AppCastingMOOSApp::OnStartUp(); STRING_LIST sParams; m_MissionReader.EnableVerbatimQuoting(false); STRING_LIST::iterator p; for (p = sParams.begin(); p != sParams.end(); p++) { string orig = *p; string line = *p; string param = toupper(biteStringX(line, '=')); string value = line; bool handled = false; if (param == "SONAR_CONTRAST") { m_sonar_contrast = atof(value.c_str()); handled = true; } else if (param == "SONAR_CONTRAST_MINIKING") { m_sonar_contrast_miniking = atof(value.c_str()); handled = true; } else if (param == "SONAR_CONTRAST_MICRON") { m_sonar_contrast_micron = atof(value.c_str()); handled = true; } if (!handled) reportUnhandledConfigWarning(orig); } registerVariables(); namedWindow("CAMERA SIDE", WINDOW_NORMAL); namedWindow("CAMERA BOTTOM", WINDOW_NORMAL); // namedWindow("SONAR MINIKING", WINDOW_NORMAL); namedWindow("SONAR MICRON", WINDOW_NORMAL); //namedWindow("SONAR", WINDOW_NORMAL); namedWindow("WALL MICRON", WINDOW_NORMAL); // namedWindow("WALL MINIKING", WINDOW_NORMAL); return(true); }
bool CFaceXYPoint::GetRegistrations(STRING_LIST &List) { List.push_back("NAV_X"); List.push_back("NAV_Y"); //always call base class version CMaintainHeading::GetRegistrations(List); return true; }
bool CZPatternTask::GetRegistrations(STRING_LIST &List) { List.push_front("NAV_DEPTH"); List.push_front("NAV_PITCH"); //always call base class version CMOOSBehaviour::GetRegistrations(List); return true; }
bool LoadWatch::OnStartUp() { string directives = "must_have_moosblock=false"; AppCastingMOOSApp::OnStartUpDirectives(directives); STRING_LIST sParams; m_MissionReader.EnableVerbatimQuoting(false); if(!m_MissionReader.GetConfiguration(GetAppName(), sParams)) return(true); STRING_LIST::iterator p; for(p=sParams.begin(); p!=sParams.end(); p++) { string orig = *p; string line = *p; string param = tolower(biteStringX(line, '=')); string value = line; bool handled = false; // THRESH = app=pHelmIvP, gapthresh=1.5 // BREACH_TRIGGER = 1 if(param == "thresh") { handled = handleConfigThresh(value); } else if((param == "breach_trigger") && isNumber(value)) { double dval = atof(value.c_str()); if(dval < 0) dval = 0; m_breach_trigger = (unsigned int)(dval); handled = true; } if(!handled) reportUnhandledConfigWarning(orig); } registerVariables(); return(true); }
BOOL Language::GetAllValueMap(VALUE_MAP &valueMap) const { STRING_LIST nameList; if(GetSectionNames(nameList)) { for(STRING_LIST::iterator ite=nameList.begin();ite!=nameList.end();ite++) { CString strSection = *ite; VALUE_MAP tmpMap; if(GetSectionValueMap(strSection, tmpMap)) { VALUE_MAP::iterator itor_b = tmpMap.begin(); VALUE_MAP::iterator itor_e = tmpMap.end(); for (; itor_b != itor_e; itor_b++) { (void)valueMap.insert(std::make_pair(itor_b->first, itor_b->second)); } } } } return TRUE; }
bool CManualControl::GetRegistrations(STRING_LIST &List) { DOF_MAP::iterator i; for(i=m_ManualDOFs.begin(); i!=m_ManualDOFs.end(); i++) List.push_front((string)"MANUAL_"+i->first); //always call base class version CSGMOOSBehaviour::GetRegistrations(List); return true; }