test-SV.C

00001 #include "Component/ModelManager.H"
00002 #include "Component/ModelComponent.H"
00003 #include "Component/ModelOptionDef.H"
00004 #include "Robots/SeaBeeIII/StereoVisionI.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 
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("StereoVisionService"); 
00053   
00054   LINFO("Starting StereoVision");
00055   nub::ref<StereoVision> bbc(new StereoVision(0, *itsMgr, "StereoVision1", "StereoVision2"));
00056   LINFO("StereoVision Created");
00057   itsMgr->addSubComponent(bbc);
00058   LINFO("StereoVision Added As Sub Component");
00059   bbc->init(communicator(), itsAdapter); 
00060   LINFO("StereoVision 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 }
00077 
00078 
Generated on Sun May 8 08:06:38 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3