00001 00002 #include "Component/ModelManager.H" 00003 #include "Component/ModelComponent.H" 00004 #include "Component/ModelOptionDef.H" 00005 #include "Robots/SeaBeeIII/LoggerModule.H" 00006 #include <Ice/Ice.h> 00007 #include <Ice/Service.h> 00008 #include "Ice/RobotSimEvents.ice.H" 00009 #include "Ice/RobotBrainObjects.ice.H" 00010 #include "Ice/SimEventsUtils.H" 00011 #include "Ice/IceImageUtils.H" 00012 00013 00014 class RobotBrainServiceService : public Ice::Service { 00015 protected: 00016 virtual bool start(int, char* argv[]); 00017 virtual bool stop() { 00018 if (itsMgr) 00019 delete itsMgr; 00020 return true; 00021 } 00022 00023 private: 00024 Ice::ObjectAdapterPtr itsAdapter; 00025 ModelManager *itsMgr; 00026 }; 00027 00028 bool RobotBrainServiceService::start(int argc, char* argv[]) 00029 { 00030 char adapterStr[255]; 00031 00032 //Create the topics 00033 // SimEventsUtils::createTopic(communicator(), "LoggerModuleMessageTopic"); 00034 00035 //Create the adapter 00036 int port = RobotBrainObjects::RobotBrainPort; 00037 bool connected = false; 00038 00039 while(!connected) 00040 { 00041 try 00042 { 00043 LINFO("Trying Port:%d", port); 00044 sprintf(adapterStr, "default -p %i", port); 00045 itsAdapter = communicator()->createObjectAdapterWithEndpoints("LoggerModule", 00046 adapterStr); 00047 connected = true; 00048 } 00049 catch(Ice::SocketException) 00050 { 00051 port++; 00052 } 00053 } 00054 00055 //Create the manager and its objects 00056 itsMgr = new ModelManager("LoggerModuleService"); 00057 00058 LINFO("Starting LoggerModule"); 00059 nub::ref<LoggerModule> ret(new LoggerModule(0, *itsMgr, "LoggerModule1", "MovementController2")); 00060 LINFO("LoggerModule Created"); 00061 itsMgr->addSubComponent(ret); 00062 LINFO("LoggerModule Added As Sub Component"); 00063 ret->init(communicator(), itsAdapter); 00064 LINFO("LoggerModule Inited"); 00065 00066 itsMgr->parseCommandLine((const int)argc, (const char**)argv, "", 0, 0); 00067 00068 itsAdapter->activate(); 00069 00070 itsMgr->start(); 00071 00072 return true; 00073 } 00074 00075 // ###################################################################### 00076 int main(int argc, char** argv) { 00077 00078 RobotBrainServiceService svc; 00079 return svc.main(argc, argv); 00080 } 00081 00082