MOOS 0.2375
|
00001 00002 // 00003 // MOOS - Mission Oriented Operating Suite 00004 // 00005 // A suit of Applications and Libraries for Mobile Robotics Research 00006 // Copyright (C) 2001-2005 Massachusetts Institute of Technology and 00007 // Oxford University. 00008 // 00009 // This software was written by Paul Newman and others 00010 // at MIT 2001-2002 and Oxford University 2003-2005. 00011 // email: pnewman@robots.ox.ac.uk. 00012 // 00013 // This file is part of a MOOS Basic (Common) Application. 00014 // 00015 // This program is free software; you can redistribute it and/or 00016 // modify it under the terms of the GNU General Public License as 00017 // published by the Free Software Foundation; either version 2 of the 00018 // License, or (at your option) any later version. 00019 // 00020 // This program is distributed in the hope that it will be useful, 00021 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00023 // General Public License for more details. 00024 // 00025 // You should have received a copy of the GNU General Public License 00026 // along with this program; if not, write to the Free Software 00027 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00028 // 02111-1307, USA. 00029 // 00031 // OverallTimeOut.cpp: implementation of the COverallTimeOut class. 00032 // 00034 00035 #include "OverallTimeOut.h" 00036 00038 // Construction/Destruction 00040 00041 COverallTimeOut::COverallTimeOut() 00042 { 00043 m_bInitialised = false; 00044 m_dfTimeRemaining = -1; 00045 } 00046 00047 COverallTimeOut::~COverallTimeOut() 00048 { 00049 00050 } 00051 00052 bool COverallTimeOut::Initialise() 00053 { 00054 bool bFoundEndMission = false; 00055 00056 //need to check on the FinishFlag = EndMission being present 00057 STRING_LIST::iterator p; 00058 for(p = m_CompleteFlags.begin(); p != m_CompleteFlags.end(); p++) 00059 { 00060 string sFlag = *p; 00061 MOOSToUpper(sFlag); 00062 00063 if(sFlag == "ENDMISSION") 00064 bFoundEndMission = true; 00065 } 00066 00067 if(!bFoundEndMission) 00068 DebugNotify("OverallTimeOut does not fire EndMission, but it should\n"); 00069 00070 m_bInitialised = true; 00071 00072 return m_bInitialised; 00073 } 00074 00075 //this task does not require input 00076 bool COverallTimeOut::RegularMailDelivery(double dfTimeNow) 00077 { 00078 00079 return true; 00080 00081 } 00082 00083 bool COverallTimeOut::OnTimeOut() 00084 { 00085 OnEvent("OverallTimeOut Complete"); 00086 return CMOOSBehaviour::OnTimeOut(); 00087 } 00088 00089 bool COverallTimeOut::Run(CPathAction &DesiredAction) 00090 { 00091 00092 if(!m_bInitialised) 00093 { 00094 Initialise(); 00095 } 00096 00097 SetTime(MOOSTime()); 00098 00099 double dfTimeElapsed = GetTimeNow() - m_dfStartTime; 00100 00101 m_dfTimeRemaining = m_dfTimeOut - dfTimeElapsed; 00102 00103 return true; 00104 } 00105 00106 bool COverallTimeOut::GetNotifications(MOOSMSG_LIST & List) 00107 { 00108 if(m_bActive) 00109 { 00110 CMOOSMsg Msg(MOOS_NOTIFY, 00111 "MISSION_TIME_REMAINING", 00112 m_dfTimeRemaining); 00113 00114 List.push_back(Msg); 00115 } 00116 00117 return CMOOSBehaviour::GetNotifications(List); 00118 } 00119 00120 bool COverallTimeOut::SetParam(string sParam, string sVal) 00121 { 00122 00123 MOOSToUpper(sParam); 00124 MOOSToUpper(sVal); 00125 00126 00127 if(!CMOOSBehaviour::SetParam(sParam,sVal)) 00128 { 00129 } 00130 00131 00132 return true; 00133 00134 }