test-SaliencyModule.C
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 "Robots/SeaBeeIII/SaliencyModuleI.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
00033
00034
00035 int port = RobotBrainObjects::RobotBrainPort;
00036 bool connected = false;
00037
00038 while(!connected)
00039 {
00040 try
00041 {
00042 LINFO("Trying Port: %d", port);
00043 sprintf(adapterStr, "default -p %i", port);
00044 itsAdapter = communicator()->createObjectAdapterWithEndpoints("SaliencyModule", adapterStr);
00045 connected = true;
00046 } catch(Ice::SocketException)
00047 {
00048 port++;
00049 }
00050 }
00051
00052
00053 itsMgr = new ModelManager("SaliencyModuleService");
00054
00055 LINFO("Starting SaliencyModule");
00056 nub::ref<SaliencyModuleI> salMod(new SaliencyModuleI(*itsMgr));
00057 itsMgr->addSubComponent(salMod);
00058
00059 salMod->init(communicator(), itsAdapter);
00060
00061 itsMgr->parseCommandLine((const int)argc, (const char**)argv, "", 0, 0);
00062
00063 itsAdapter->activate();
00064
00065 itsMgr->start();
00066
00067 return true;
00068 }
00069
00070
00071 int main(int argc, char** argv) {
00072
00073 RobotBrainServiceService svc;
00074 return svc.main(argc, argv);
00075 }
00076
00077