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 at MIT 2001-2002 and Oxford 00010 // University 2003-2005. email: pnewman@robots.ox.ac.uk. 00011 // 00012 // This file is part of a MOOS Core Component. 00013 // 00014 // This program is free software; you can redistribute it and/or 00015 // modify it under the terms of the GNU General Public License as 00016 // published by the Free Software Foundation; either version 2 of the 00017 // License, or (at your option) any later version. 00018 // 00019 // This program is distributed in the hope that it will be useful, 00020 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00022 // General Public License for more details. 00023 // 00024 // You should have received a copy of the GNU General Public License 00025 // along with this program; if not, write to the Free Software 00026 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00027 // 02111-1307, USA. 00028 // 00030 // MOOSDB.h: interface for the CMOOSDB class. 00031 // 00033 00034 #if !defined(MOOSDBH) 00035 #define MOOSDBH 00036 00037 00038 #include "MOOSDBVar.h" 00039 #include <string> 00040 #include <map> 00041 using namespace std; 00042 00043 typedef map<string,MOOSMSG_LIST> MOOSMSG_LIST_STRING_MAP; 00044 typedef map<string,CMOOSDBVar> DBVAR_MAP; 00045 00046 00047 #define DEFAULT_MOOS_SERVER_PORT 9000 00048 00051 class CMOOSDB 00052 { 00053 public: 00054 bool OnDisconnect(string & sClient); 00055 00058 static bool OnRxPktCallBack(const std::string & sClient, MOOSMSG_LIST & MsgLstRx,MOOSMSG_LIST & MsgLstTx, void * pParam); 00059 00061 static bool OnDisconnectCallBack(string & sClient,void * pParam); 00062 00065 bool OnRxPkt(const std::string & sClient,MOOSMSG_LIST & MsgLstRx,MOOSMSG_LIST & MsgLstTx); 00066 00069 bool Run(const std::string & sMissionFile="" ); 00070 00072 long GetDBPort(){return m_nPort;}; 00073 00074 CMOOSDB(); 00075 virtual ~CMOOSDB(); 00076 00077 protected: 00078 00079 bool OnClearRequested(CMOOSMsg & Msg, MOOSMSG_LIST & MsgTxList); 00080 void Var2Msg(CMOOSDBVar & Var, CMOOSMsg &Msg); 00081 bool AddMessageToClientBox(const string &sClient,CMOOSMsg & Msg); 00082 bool VariableExists(const string & sVar); 00083 bool DoVarLookup(CMOOSMsg & Msg, MOOSMSG_LIST &MsgTxList); 00084 00089 bool OnServerAllRequested(CMOOSMsg & Msg, MOOSMSG_LIST & MsgTxList); 00090 bool OnProcessSummaryRequested(CMOOSMsg &Msg, MOOSMSG_LIST &MsgTxList); 00091 bool OnVarSummaryRequested(CMOOSMsg &Msg, MOOSMSG_LIST &MsgTxList); 00092 00093 void UpdateDBTimeVars(); 00094 void UpdateDBClientsVar(); 00095 bool DoServerRequest(CMOOSMsg & Msg, MOOSMSG_LIST & MsgTxList); 00096 CMOOSDBVar & GetOrMakeVar(CMOOSMsg & Msg); 00097 bool OnRegister(CMOOSMsg & Msg); 00098 bool OnUnRegister(CMOOSMsg &Msg); 00099 bool OnNotify(CMOOSMsg & Msg); 00100 bool ProcessMsg(CMOOSMsg & MsgRx,MOOSMSG_LIST & MsgLstTx); 00101 double GetStartTime(){return m_dfStartTime;} 00102 private: 00103 CMOOSCommServer m_CommServer; 00104 string m_sDBName; 00105 string m_sCommunityName; 00106 CMOOSFileReader m_MissionReader; 00107 long m_nPort; 00108 double m_dfStartTime; 00109 00110 00113 MOOSMSG_LIST_STRING_MAP m_HeldMailMap; 00114 DBVAR_MAP m_VarMap; 00115 00116 private: 00117 void LogStartTime(); 00118 }; 00119 00120 #endif