test-SeaBeeInjector.C

00001 
00002 #include "Component/ModelManager.H"
00003 #include "Component/ModelComponent.H"
00004 #include "Component/ModelOptionDef.H"
00005 #include "Robots/SeaBeeIII/SeaBeeInjector.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(), "MovementControllerMessageTopic");
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("MovementController",
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("MovementControllerService");
00057 
00058   LINFO("Starting MovementController");
00059   nub::ref<SeaBeeInjector> ret(new SeaBeeInjector(0, *itsMgr, "MovementController1", "MovementController2"));
00060   LINFO("MovementController Created");
00061   itsMgr->addSubComponent(ret);
00062   LINFO("MovementController Added As Sub Component");
00063   ret->init(communicator(), itsAdapter);
00064   LINFO("MovementController 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 
Generated on Sun May 8 08:42:07 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3