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