Ejemplo n.º 1
0
/** A convenience function that creates the callback,
 *  collects results, and makes them available in the
 *  return argument.
 */
ResultSet cvac::detect(
                    const std::string& algorithm,
                    const cvac::RunSet& runset,
                    const cvac::FilePath& model,
                    const cvac::DetectorProperties* detprops )
{
  // Connect to detector
  Ice::Identity det_cb;
  CallbackHandlerI *cr = new CallbackHandlerI();
  DetectorPrx detector = initIceConnection( algorithm, det_cb, cr );
  if(NULL == detector.get())
  {
    localAndClientMsg( VLogger::ERROR, NULL, "Could not connect to CVAC Ice Services" );
    return ResultSet();
  }
  cvac::DetectorProperties dprops;
  // If user did not supply any detector properties then provide default one.
  if (NULL == detprops)
  {
      // need to initialize detector properties to their defaults
      dprops = detector->getDetectorProperties();   
      detprops = &dprops;
  }

  try
    {	
      detector->process(det_cb, runset, model, *detprops);
    }
  catch (const Ice::Exception& ex)
    {
      throw ex;
    }

  iceComm->shutdown();  // Shut down at the end of either branch
  return cr->rs;
}
Ejemplo n.º 2
0
 /// usage:
    ///IceBoxTestClientApp.exe <detector> <directory>
    /// <detector>: The name of the detector (found in the config.client file)
    /// <directory>: The full path to a folder containing images to process
    /// Returns 0 on success ('EXIT_SUCCESS'), and 1 on failure ('EXIT_FAILURE')
DetectorPrx ClientApp::initIceConnection(std::string detectorNameStr)
{  // Connect to the Ice Service
	Ice::PropertiesPtr props = communicator()->getProperties();
    std::string proxStr = detectorNameStr + ".Proxy";
    DetectorPrx detector = NULL;
    try
    {
        detector = DetectorPrx::checkedCast(
                               communicator()->propertyToProxy(proxStr)->ice_twoway());
    }
    catch (const IceUtil::NullHandleException& e)
    {
       localAndClientMsg(VLogger::WARN, NULL, "Invalid proxy: '%s'. %s\n", 
               detectorNameStr.c_str(), e.what());
       return NULL;
    }

    Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("");
    ident.name = IceUtil::generateUUID();
    ident.category = "";
    DetectorCallbackHandlerPtr cr = new CallbackHandlerI(appData);
    adapter->add(cr, ident);
    adapter->activate();
    detector->ice_getConnection()->setAdapter(adapter);    

    // note that we need an ObjectAdapter to permit bidirectional communication
    // if we want to get past firewalls without Glacier2

    localAndClientMsg(VLogger::DEBUG, NULL, "IceBox test client: created callbackHandler proxy\n");
                
    if(!detector)
    {
		localAndClientMsg(VLogger::WARN, NULL, "%s: invalid proxy \n", appName());
		return NULL;
    }
    else
		return detector;  // Success

#if 0
    Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("");
    Ice::Identity ident;
    ident.name = IceUtil::generateUUID();
    ident.category = "";
    CallbackReceiverPtr cr = new CallbackReceiverI;
    adapter->add(cr, ident);
    adapter->activate();
    detector->ice_getConnection()->setAdapter(adapter);
    printf("about to call addClient\n");
//    RunSet runSet;
//    detector->process(ident, runSet);
    detector->addClient(ident);
    printf("just called addClient\n");
    communicator()->waitForShutdown();

    return 0;
#elif 0
    Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("");
    Ice::Identity ident;
    ident.name = IceUtil::generateUUID();
    ident.category = "";
    DetectorCallbackHandlerPtr cr = new CallbackHandlerI;
    adapter->add(cr, ident);
    adapter->activate();
    detector->ice_getConnection()->setAdapter(adapter);
    printf("about to call process\n");
    RunSet runSet;
    detector->process(ident, runSet);
//    detector->addClient(ident);
    printf("just called process\n");
    communicator()->waitForShutdown();

    return 0;
#endif

}