test-Retina.C

00001 
00002 #include "Component/ModelManager.H"
00003 #include "Component/ModelComponent.H"
00004 #include "Component/ModelOptionDef.H"
00005 #include "Robots/RobotBrain/RetinaI.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   LINFO("Creating Topic!");
00033   //Create the topics
00034 //  SimEventsUtils::createTopic(communicator(), "RetinaMessageTopic");
00035 
00036   //Create the adapter
00037   int port = RobotBrainObjects::RobotBrainPort;
00038   bool connected = false;
00039   LDEBUG("Opening Connection");
00040 
00041   while(!connected)
00042   {
00043     try
00044     {
00045       LINFO("Trying Port:%d", port);
00046       sprintf(adapterStr, "default -p %i", port);
00047       itsAdapter = communicator()->createObjectAdapterWithEndpoints("Retina",
00048           adapterStr);
00049       connected = true;
00050     }
00051     catch(Ice::SocketException)
00052     {
00053       port++;
00054     }
00055   }
00056 
00057   //Create the manager and its objects
00058         itsMgr = new ModelManager("RetinaService");
00059 
00060   LINFO("Starting Retina");
00061   nub::ref<RetinaI> ret(new RetinaI(0, *itsMgr, "Retina1", "Retina2"));
00062   LINFO("Retina Created");
00063   itsMgr->addSubComponent(ret);
00064   LINFO("Retina Added As Sub Component");
00065   ret->init(communicator(), itsAdapter);
00066   LINFO("Retina Inited");
00067 
00068   itsMgr->parseCommandLine((const int)argc, (const char**)argv, "", 0, 0);
00069 
00070   itsAdapter->activate();
00071 
00072   itsMgr->start();
00073 
00074   return true;
00075 }
00076 
00077 // ######################################################################
00078 int main(int argc, char** argv) {
00079 
00080   LINFO("Creating Service...");
00081   RobotBrainServiceService svc;
00082   LINFO("Service Created...");
00083   return svc.main(argc, argv);
00084 }
00085 
00086 
Generated on Sun May 8 08:41:32 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3