コード例 #1
0
ファイル: NetworkProxy.cpp プロジェクト: 465060874/ice
NetworkProxyPtr
IceInternal::createNetworkProxy(const Ice::PropertiesPtr& properties, ProtocolSupport protocolSupport)
{
    string proxyHost;

    proxyHost = properties->getProperty("Ice.SOCKSProxyHost");
    if(!proxyHost.empty())
    {
#ifdef ICE_OS_WINRT
        throw Ice::InitializationException(__FILE__, __LINE__, "SOCKS proxy not supported with WinRT");
#else
        if(protocolSupport == EnableIPv6)
        {
            throw Ice::InitializationException(__FILE__, __LINE__, "IPv6 only is not supported with SOCKS4 proxies");
        }
        int proxyPort = properties->getPropertyAsIntWithDefault("Ice.SOCKSProxyPort", 1080);
        return new SOCKSNetworkProxy(proxyHost, proxyPort);
#endif
    }

    proxyHost = properties->getProperty("Ice.HTTPProxyHost");
    if(!proxyHost.empty())
    {
#ifdef ICE_OS_WINRT
        throw Ice::InitializationException(__FILE__, __LINE__, "HTTP proxy not supported with WinRT");
#else
        return new HTTPNetworkProxy(proxyHost, properties->getPropertyAsIntWithDefault("Ice.HTTPProxyPort", 1080));
#endif
    }
    
    return 0;
}
コード例 #2
0
ファイル: TrustManager.cpp プロジェクト: updowndown/myffff
TrustManager::TrustManager(const Ice::CommunicatorPtr& communicator) :
    _communicator(communicator)
{
    Ice::PropertiesPtr properties = communicator->getProperties();
    _traceLevel = properties->getPropertyAsInt("IceSSL.Trace.Security");
    string key;
    try
    {
        key = "IceSSL.TrustOnly";
        _all = parse(properties->getProperty(key));
        key = "IceSSL.TrustOnly.Client";
        _client = parse(properties->getProperty(key));
        key = "IceSSL.TrustOnly.Server";
        _allServer = parse(properties->getProperty(key));
        Ice::PropertyDict dict = properties->getPropertiesForPrefix("IceSSL.TrustOnly.Server.");
        for(Ice::PropertyDict::const_iterator p = dict.begin(); p != dict.end(); ++p)
        {
            string name = p->first.substr(string("IceSSL.TrustOnly.Server.").size());
            key = p->first;
            _server[name] = parse(p->second);
        }
    }
    catch(const ParseException& e)
    {
        Ice::PluginInitializationException ex(__FILE__, __LINE__);
        ex.reason = "IceSSL: invalid property " + key  + ":\n" + e.reason;
        throw ex;
    }
}
コード例 #3
0
ファイル: NotifyCacheI.cpp プロジェクト: bradenwu/oce
//---------------------------------------------------------------------------
NoteFactory::NoteFactory() {
	ServiceI& service = ServiceI::instance();
	Ice::PropertiesPtr props = service.getCommunicator()->getProperties();
	_database = props->getProperty("Service."+service.getName()+".Database");
	_databaseOld = props->getProperty("Service."+service.getName()
			+".DatabaseOld");
	_noteTable = props->getProperty("Service."+service.getName()+".NoteTable");
}
コード例 #4
0
ファイル: RegistryI.cpp プロジェクト: bholl/zeroc-ice
Ice::ObjectAdapterPtr
RegistryI::setupAdminSessionFactory(const Ice::ObjectAdapterPtr& registryAdapter, 
                                    const Ice::ObjectPtr& router,
                                    const IceGrid::LocatorPrx& locator)
{
    Ice::PropertiesPtr properties = _communicator->getProperties();

    Ice::ObjectAdapterPtr adapter;
    SessionServantManagerPtr servantManager;
    if(!properties->getProperty("IceGrid.Registry.AdminSessionManager.Endpoints").empty())
    {
        adapter = _communicator->createObjectAdapter("IceGrid.Registry.AdminSessionManager");
        servantManager = new SessionServantManager(adapter, _instanceName, false, getServerAdminCategory(), router, 0);
        adapter->addServantLocator(servantManager, "");
    }

    assert(_reaper);
    _adminSessionFactory = new AdminSessionFactory(servantManager, _database, _reaper, this);

    if(servantManager)
    {
        Identity sessionMgrId;
        sessionMgrId.category = _instanceName;
        sessionMgrId.name = "AdminSessionManager";
        Identity sslSessionMgrId;
        sslSessionMgrId.category = _instanceName;
        sslSessionMgrId.name = "AdminSSLSessionManager";
        if(!_master)
        {
            sessionMgrId.name += "-" + _replicaName;
            sslSessionMgrId.name += "-" + _replicaName;
        }

        adapter->add(new AdminSessionManagerI(_adminSessionFactory), sessionMgrId);
        adapter->add(new AdminSSLSessionManagerI(_adminSessionFactory), sslSessionMgrId);
        
        _wellKnownObjects->add(adapter->createProxy(sessionMgrId), Glacier2::SessionManager::ice_staticId());
        _wellKnownObjects->add(adapter->createProxy(sslSessionMgrId), Glacier2::SSLSessionManager::ice_staticId());
    }

    if(adapter)
    {
        Ice::Identity dummy;
        dummy.name = "dummy";
        _wellKnownObjects->addEndpoint("AdminSessionManager", adapter->createDirectProxy(dummy));
    }

    _adminVerifier = getPermissionsVerifier(registryAdapter,
                                            locator,
                                            "IceGrid.Registry.AdminPermissionsVerifier",
                                            properties->getProperty("IceGrid.Registry.AdminCryptPasswords"));

    _sslAdminVerifier = getSSLPermissionsVerifier(locator, "IceGrid.Registry.AdminSSLPermissionsVerifier");

    return adapter;
}
コード例 #5
0
ファイル: main.cpp プロジェクト: varhub/JdeRobot
int main(int argc, char** argv)
{
    Ice::ObjectPtr viewerPtr;
    //signal(SIGINT,signalHandler);
    Ice::CommunicatorPtr ic;
    try{
        ic = EasyIce::initialize(argc, argv);

        Ice::PropertiesPtr prop = ic->getProperties();
        std::string Endpoints = prop->getProperty("Visualization.Endpoints");

        // Naming Service
        int nsActive = prop->getPropertyAsIntWithDefault("NamingService.Enabled", 0);

        if (nsActive)
        {
            std::string ns_proxy = prop->getProperty("NamingService.Proxy");
            try
            {
                namingService = new jderobot::ns(ic, ns_proxy);
            }
            catch (Ice::ConnectionRefusedException& ex)
            {
                jderobot::Logger::getInstance()->error("Impossible to connect with NameService!");
                exit(-1);
            }
        }

        Ice::ObjectAdapterPtr adapter =ic->createObjectAdapterWithEndpoints("Visualization", Endpoints);
        std::string objPrefix("Visualization.");
        std::string viewerName = prop->getProperty(objPrefix + "Name");
        Ice::ObjectPtr object = new visualization::VisualizationI(objPrefix, ic);

        adapter->add(object, ic->stringToIdentity(viewerName));

        if (namingService)
            namingService->bind(viewerName, Endpoints, object->ice_staticId());


        adapter->activate();
        ic->waitForShutdown();

    }catch (const Ice::Exception& ex) {
        std::cerr << ex<<" 1 " << std::endl;
        exit(-1);
    } catch (const char* msg) {
        std::cerr << msg<< " 2 " << std::endl;
        exit(-1);
    }

}
コード例 #6
0
ファイル: RegistryI.cpp プロジェクト: bholl/zeroc-ice
Ice::ObjectAdapterPtr
RegistryI::setupClientSessionFactory(const Ice::ObjectAdapterPtr& registryAdapter, const IceGrid::LocatorPrx& locator)
{
    Ice::PropertiesPtr properties = _communicator->getProperties();

    Ice::ObjectAdapterPtr adapter;
    SessionServantManagerPtr servantManager;
    if(!properties->getProperty("IceGrid.Registry.SessionManager.Endpoints").empty())
    {
        adapter = _communicator->createObjectAdapter("IceGrid.Registry.SessionManager");
        servantManager = new SessionServantManager(adapter, _instanceName, false, "", 0, 0);
        adapter->addServantLocator(servantManager, "");
    }

    assert(_reaper);
    _timer = new IceUtil::Timer();  // Used for for session allocation timeout.
    _clientSessionFactory = new ClientSessionFactory(servantManager, _database, _timer, _reaper);

    if(servantManager && _master) // Slaves don't support client session manager objects.
    {
        Identity sessionMgrId;
        sessionMgrId.category = _instanceName;
        sessionMgrId.name = "SessionManager";
        Identity sslSessionMgrId;
        sslSessionMgrId.category = _instanceName;
        sslSessionMgrId.name = "SSLSessionManager";

        adapter->add(new ClientSessionManagerI(_clientSessionFactory), sessionMgrId);
        adapter->add(new ClientSSLSessionManagerI(_clientSessionFactory), sslSessionMgrId);

        _wellKnownObjects->add(adapter->createProxy(sessionMgrId), Glacier2::SessionManager::ice_staticId());
        _wellKnownObjects->add(adapter->createProxy(sslSessionMgrId), Glacier2::SSLSessionManager::ice_staticId());
    }

    if(adapter)
    {
        Ice::Identity dummy;
        dummy.name = "dummy";
        _wellKnownObjects->addEndpoint("SessionManager", adapter->createDirectProxy(dummy));
    }

    _clientVerifier = getPermissionsVerifier(registryAdapter,
                                             locator,
                                             "IceGrid.Registry.PermissionsVerifier",
                                             properties->getProperty("IceGrid.Registry.CryptPasswords"));

    _sslClientVerifier = getSSLPermissionsVerifier(locator, "IceGrid.Registry.SSLPermissionsVerifier");

    return adapter;
}
コード例 #7
0
ファイル: controller.cpp プロジェクト: AeroCano/JdeRobot
  Controller::Controller(Ice::PropertiesPtr prop, int w, int h, int nCameras) {
	cameras.resize(nCameras);
    this->gladepath = resourcelocator::findGladeFile("rgbdManualCalibrator.glade");

    this->world = prop->getProperty("rgbdManualCalibrator.World.File");
    //cout << "world es " << this->world << endl;
    this->camOut = prop->getProperty("rgbdManualCalibrator.Camera.FileOut");
	cWidth=w;
	cHeight=h;
    this->drawCenter = false;

    /*Init world and configurations*/
	this->nCameras=nCameras;
    this->init(prop, nCameras);
  }
コード例 #8
0
ファイル: StreamEndpointI.cpp プロジェクト: ming-hai/ice
IceObjC::Instance::Instance(const Ice::CommunicatorPtr& com, Short type, const string& protocol, bool secure) :
    ProtocolInstance(com, type, protocol, secure),
    _voip(com->getProperties()->getPropertyAsIntWithDefault("Ice.Voip", 0) > 0),
    _communicator(com),
    _proxySettings(0)
{
    const Ice::PropertiesPtr properties = com->getProperties();

    //
    // Proxy settings
    //
    _proxyHost = properties->getProperty("Ice.SOCKSProxyHost");
    if(!_proxyHost.empty())
    {
#if TARGET_IPHONE_SIMULATOR != 0
        throw Ice::FeatureNotSupportedException(__FILE__, __LINE__, "SOCKS proxy not supported");
#endif
        _proxySettings.reset(CFDictionaryCreateMutable(0, 3, &kCFTypeDictionaryKeyCallBacks,
                                                       &kCFTypeDictionaryValueCallBacks));

        _proxyPort = properties->getPropertyAsIntWithDefault("Ice.SOCKSProxyPort", 1080);

        UniqueRef<CFStringRef> host(toCFString(_proxyHost));
        CFDictionarySetValue(_proxySettings.get(), kCFStreamPropertySOCKSProxyHost, host.get());

        UniqueRef<CFNumberRef> port(CFNumberCreate(0, kCFNumberSInt32Type, &_proxyPort));
        CFDictionarySetValue(_proxySettings.get(), kCFStreamPropertySOCKSProxyPort, port.get());

        CFDictionarySetValue(_proxySettings.get(), kCFStreamPropertySOCKSVersion, kCFStreamSocketSOCKSVersion4);
    }
}
コード例 #9
0
ファイル: Server.cpp プロジェクト: pedia/zeroc-ice
int
Server::run(int argc, char* argv[])
{
    Ice::PropertiesPtr properties = communicator()->getProperties();

    Ice::StringSeq args = Ice::argsToStringSeq(argc, argv);
    args = properties->parseCommandLineOptions("Test", args);
    Ice::stringSeqToArgs(args, argc, argv);

    string name = properties->getProperty("Ice.ProgramName");

    Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Server");
    adapter->add(new TestI(properties), communicator()->stringToIdentity("allocatable"));
    adapter->add(new TestI(properties), communicator()->stringToIdentity("nonallocatable"));
    adapter->add(new TestI(properties), communicator()->stringToIdentity("allocatable1"));
    adapter->add(new TestI(properties), communicator()->stringToIdentity("allocatable2"));
    adapter->add(new TestI(properties), communicator()->stringToIdentity("allocatable3"));
    adapter->add(new TestI(properties), communicator()->stringToIdentity("allocatable4"));
    adapter->add(new TestI(properties), communicator()->stringToIdentity("allocatable11"));
    adapter->add(new TestI(properties), communicator()->stringToIdentity("allocatable21"));
    adapter->add(new TestI(properties), communicator()->stringToIdentity("allocatable31"));
    adapter->add(new TestI(properties), communicator()->stringToIdentity("allocatable41"));

    shutdownOnInterrupt();
    try
    {
        adapter->activate();
    }
    catch(const Ice::ObjectAdapterDeactivatedException&)
    {
    }
    communicator()->waitForShutdown();
    ignoreInterrupt();
    return EXIT_SUCCESS;
}
コード例 #10
0
ファイル: NodeI.cpp プロジェクト: chenbk85/ice
NodeI::NodeI(const Ice::ObjectAdapterPtr& adapter,
             NodeSessionManager& sessions,
             const ActivatorPtr& activator,
             const IceUtil::TimerPtr& timer,
             const TraceLevelsPtr& traceLevels,
             const NodePrx& proxy,
             const string& name,
             const UserAccountMapperPrx& mapper,
             const string& instanceName) :
    _communicator(adapter->getCommunicator()),
    _adapter(adapter),
    _sessions(sessions),
    _activator(activator),
    _timer(timer),
    _traceLevels(traceLevels),
    _name(name),
    _proxy(proxy),
    _redirectErrToOut(false),
    _allowEndpointsOverride(false),
    _waitTime(0),
    _instanceName(instanceName),
    _userAccountMapper(mapper),
    _platform("IceGrid.Node", _communicator, _traceLevels),
    _fileCache(new FileCache(_communicator)),
    _serial(1),
    _consistencyCheckDone(false)
{
    Ice::PropertiesPtr props = _communicator->getProperties();

    const_cast<string&>(_dataDir) = _platform.getDataDir();
    const_cast<string&>(_serversDir) = _dataDir + "/servers";
    const_cast<string&>(_tmpDir) = _dataDir + "/tmp";
    const_cast<Ice::Int&>(_waitTime) = props->getPropertyAsIntWithDefault("IceGrid.Node.WaitTime", 60);
    const_cast<string&>(_outputDir) = props->getProperty("IceGrid.Node.Output");
    const_cast<bool&>(_redirectErrToOut) = props->getPropertyAsInt("IceGrid.Node.RedirectErrToOut") > 0;
    const_cast<bool&>(_allowEndpointsOverride) = props->getPropertyAsInt("IceGrid.Node.AllowEndpointsOverride") > 0;

    //
    // Parse the properties override property.
    //
    vector<string> overrides = props->getPropertyAsList("IceGrid.Node.PropertiesOverride");
    if(!overrides.empty())
    {
        for(vector<string>::iterator p = overrides.begin(); p != overrides.end(); ++p)
        {
            if(p->find("--") != 0)
            {
                *p = "--" + *p;
            }
        }

        Ice::PropertiesPtr p = Ice::createProperties();
        p->parseCommandLineOptions("", overrides);
        Ice::PropertyDict propDict = p->getPropertiesForPrefix("");
        for(Ice::PropertyDict::const_iterator q = propDict.begin(); q != propDict.end(); ++q)
        {
            _propertiesOverride.push_back(createProperty(q->first, q->second));
        }
    }
}
コード例 #11
0
string cvac::getCVACDataDir(const string &detectorNameStr)
{
  initIce(detectorNameStr);
  Ice::PropertiesPtr props = iceComm->getProperties();
  std::string dataDir = props->getProperty("CVAC.DataDir");
  return dataDir;
}
コード例 #12
0
ファイル: IceApp.cpp プロジェクト: veter-team/cockpit
IceApp::sensorinfo_t 
IceApp::connectToSensor(const std::string &sensor_name) const
{
  Ice::PropertiesPtr props = this->communicator()->getProperties();
  Ice::LoggerPtr log = this->communicator()->getLogger();

  try
    {
      log->print(string("Connecting to ") + sensor_name + " sensor");
      const string prop_name = sensor_name + ".proxy";
      string sensor_str_proxy = props->getProperty(prop_name);
      sensors::SensorGroupPrx sensor_prx;
      if(sensor_str_proxy.empty())
	log->warning(prop_name 
		     + string(" property is not set. No ")
		     + sensor_name + ".");
      else
	{
	  Ice::ObjectPrx objprx = 
	    this->communicator()->stringToProxy(sensor_str_proxy);
	  sensor_prx = sensors::SensorGroupPrx::checkedCast(objprx);
	  if(!sensor_prx)
	    log->warning(string("Can not connect to ")
			 + sensor_name 
			 + string(" sensor. No ")
			 + sensor_name + ".");
	  else
	    {
	      string msg = "Connected to sensor group ";
	      log->print(msg + sensor_name);
	      sensors::SensorDescriptionSeq descr = 
		sensor_prx->getSensorDescription();
	      for(sensors::SensorDescriptionSeq::const_iterator d = descr.begin();
		  d != descr.end(); ++d)
		{
		  ostringstream os;
		  os << "  Vendor id: " << d->vendorid << endl;
		  os << "  Description: " << d->description << endl;
		  os << "  Id: " << d->id << endl;
		  os << "  Min value: " << d->minvalue << endl;
		  os << "  Max value: " << d->maxvalue << endl;
		  os << "  Recommended refresh rate, Hz: " << d->refreshrate;
		  log->print(os.str());
		}
	      return make_pair(sensor_prx, descr);
	    }
	}
    }
  catch(const Ice::Exception& ex)
    {
      ostringstream os;
      os << "Can not connect to " << sensor_name << " sensor. No "
	 << sensor_name + ".\n";
      ex.ice_print(os);
      log->warning(os.str());
    }

  return make_pair(sensors::SensorGroupPrx(), 
		   sensors::SensorDescriptionSeq());
}
コード例 #13
0
ファイル: RegistryI.cpp プロジェクト: updowndown/myffff
bool
RegistryI::setupUserAccountMapper(const Ice::ObjectAdapterPtr& registryAdapter)
{
    Ice::PropertiesPtr properties = _communicator->getProperties();

    //
    // Setup file user account mapper object if the property is set.
    //
    string userAccountFileProperty = properties->getProperty("IceGrid.Registry.UserAccounts");
    if(!userAccountFileProperty.empty())
    {
        try
        {
            Identity mapperId;
            mapperId.category = _instanceName;
            mapperId.name = "RegistryUserAccountMapper";
            if(!_master)
            {
                mapperId.name += "-" + _replicaName;
            }
            registryAdapter->add(new FileUserAccountMapperI(userAccountFileProperty), mapperId);
            _wellKnownObjects->add(registryAdapter->createProxy(mapperId), UserAccountMapper::ice_staticId());
        }
        catch(const std::string& msg)
        {
            Error out(_communicator->getLogger());
            out << msg;
            return false;
        }
    }
    return true;
}
コード例 #14
0
int YKTServer::run( int argc, char* argv[] )
{
  Ice::PropertiesPtr properties = communicator()->getProperties();

  Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter( "YKT" );

  Ice::Identity id = communicator()->stringToIdentity( properties->getProperty("Identity") );
  transfer::CallServerPtr callserver = new Server(_currentCtx);
  //adapter->add( new Server( _currentCtx ),  );
  adapter->add( callserver, id );

  adapter->activate();

  //Ice::PropertiesPtr prop = communicator()->getProperties();
  string port = properties->getPropertyWithDefault( "queue.port", "10010" );
  string maxcount = properties->getPropertyWithDefault( "queue.processcount", "5" );

  std::size_t iport = atoi( port.c_str() );
  std::size_t imax = atoi( maxcount.c_str() );

  queue_manager_inst::get()->update_properties( properties );
  LOG(INFO,"start signal handler");
  signal(SIGINT,signal_handler);
  signal(SIGTERM,signal_handler);//kill 命令的捕获
  if( queue_manager_inst::get()->start( iport ) )
  {
    return -1;
  }
  communicator()->waitForShutdown();
  queue_manager_inst::get()->stop();
  return EXIT_SUCCESS;
}
コード例 #15
0
ファイル: BowICEI.cpp プロジェクト: CVML/CVAC
// Client verbosity
void BowICEI::initialize( DetectorDataArchive* dda,
                          const ::cvac::FilePath &file,
                          const::Ice::Current &current)
{
    // Set CVAC verbosity according to ICE properties
    Ice::PropertiesPtr props = (current.adapter->getCommunicator()->getProperties());
    string verbStr = props->getProperty("CVAC.ServicesVerbosity");
    if (!verbStr.empty())
        getVLogger().setLocalVerbosityLevel( verbStr );

    // Since constructor only called on service start and destroy
    // can be called.  We need to make sure we have it
    if (pBowCV == NULL)
        pBowCV = new bowCV(this);

    // Get the default CVAC data directory as defined in the config file
    std::string connectName = getClientConnectionName(current);
    std::string clientName = mServiceMan->getSandbox()->createClientName(mServiceMan->getServiceName(),
                             connectName);
    std::string clientDir = mServiceMan->getSandbox()->createClientDir(clientName);

    string zipfilepath;
    if (fInitialized == false)
    {   // We are initializing for the first time so load the configModelFileName
        if (configModelFileName.empty() && file.filename.empty())
        {
            localAndClientMsg(VLogger::ERROR, callbackPtr, "No trained model available, aborting.\n" );
            return;
        }
        if (configModelFileName.empty() == false)
        {
            if (file.filename.empty() == false )
            {
                localAndClientMsg(VLogger::WARN , callbackPtr, "Detector Preconfigured with a model file so ignoring passed in model %s.\n",
                                  file.filename.c_str() );
            }
            if (pathAbsolute(configModelFileName))
                zipfilepath = configModelFileName;
            else
                zipfilepath = m_CVAC_DataDir + "/" + configModelFileName;
        }
    } else if (configModelFileName.empty() == false)
    {
        if (file.filename.empty() == false)
        {
            localAndClientMsg(VLogger::WARN , callbackPtr, "Detector Preconfigured with a model file so ignoring passed in model %s.\n",
                              file.filename.c_str() );
        }
        return;
    }
    if (configModelFileName.empty())
        zipfilepath = getFSPath(file, m_CVAC_DataDir);
    dda->unarchive(zipfilepath, clientDir);

    // add the CVAC.DataDir root path and initialize from dda
    fInitialized = pBowCV->detect_initialize( dda );
    if (!fInitialized)
        localAndClientMsg(VLogger::WARN, callbackPtr,"Failed to run CV detect_initialize\n");
}
コード例 #16
0
ファイル: laseri.cpp プロジェクト: Diegojnb/JdeRobot
	LaserI::LaserI(Ice::PropertiesPtr prop)
	{
		std::string model = prop->getProperty("Laser.Model");
		
		if ("Hokuyo"==model || "hokuyo"==model){
	        std::string deviceId = prop->getProperty("Laser.DeviceId");
			double min = (double)prop->getPropertyAsInt("Laser.MinAng");
			double max = (double)prop->getPropertyAsInt("Laser.MaxAng");
			int clustering = prop->getPropertyAsInt("Laser.Clustering");
            int faceup = prop->getPropertyAsInt("Laser.FaceUp");
			double min_ang = min*M_PI/180;
			double max_ang = max*M_PI/180;
            this->manager = new hokuyo::HokuyoManager(deviceId, min_ang, max_ang, clustering, -1, faceup);
		}else{
			throw std::invalid_argument( model + " laser is not allowed" );
		}
	}
コード例 #17
0
ファイル: IceApp.cpp プロジェクト: veter-team/cockpit
IceApp::actuatorinfo_t 
IceApp::connectToActuator(const std::string &actuator_name) const
{
  Ice::PropertiesPtr props = this->communicator()->getProperties();
  Ice::LoggerPtr log = this->communicator()->getLogger();

  try
    {
      log->print(string("Connecting to ") + actuator_name + " actuators");
      const string prop_name = actuator_name + ".proxy";
      string actuator_str_proxy = props->getProperty(prop_name);
      actuators::ActuatorGroupPrx actuator_prx;
      if(actuator_str_proxy.empty())
	log->warning(prop_name 
		     + string(" property is not set. No ")
		     + actuator_name + ".");
      else
	{
	  Ice::ObjectPrx objprx = 
	    this->communicator()->stringToProxy(actuator_str_proxy);
	  actuator_prx = 
	    actuators::ActuatorGroupPrx::checkedCast(objprx);
	  if(!actuator_prx)
	    log->warning(string("Can not connect to ")
			 + actuator_name 
			 + string(" actuator. No ")
			 + actuator_name + ".");
	  else
	    {
	      string msg = "Connected to actuator group ";
	      log->print(msg + actuator_name);
	      actuators::ActuatorDescriptionSeq descr = 
		actuator_prx->getActuatorDescription();
	      for(actuators::ActuatorDescriptionSeq::const_iterator d = descr.begin();
		  d != descr.end(); ++d)
		{
		  ostringstream os;
		  os << "  Vendor id: " << d->vendorid << endl;
		  os << "  Description: " << d->description << endl;
		  os << "  Id: " << d->id << endl;
		  log->print(os.str());
		}
	      return make_pair(actuator_prx, descr);
	    }
	}
    }
  catch(const Ice::Exception &ex)
    {
      std::ostringstream os;
      os << "Can not connect to actuator " + actuator_name + ".\n";
      ex.ice_print(os);
      log->warning(os.str());
    }

  return make_pair(actuators::ActuatorGroupPrx(), 
		   actuators::ActuatorDescriptionSeq());
}
コード例 #18
0
ファイル: Server.cpp プロジェクト: bholl/zeroc-ice
int
Server::run(int argc, char* argv[])
{
    if(argc > 1)
    {
        cerr << appName() << ": too many arguments" << endl;
        return EXIT_FAILURE;
    }

    Ice::PropertiesPtr properties = communicator()->getProperties();
    Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Hello");
    Ice::Identity id = communicator()->stringToIdentity(properties->getProperty("Identity"));
    Demo::HelloPtr hello = new HelloI(properties->getProperty("Ice.ProgramName"));
    adapter->add(hello, id);
    adapter->activate();
    communicator()->waitForShutdown();
    return EXIT_SUCCESS;
}
コード例 #19
0
ファイル: LookupI.cpp プロジェクト: pedia/zeroc-ice
LookupI::LookupI(const LocatorRegistryIPtr& registry, const LookupPrx& lookup, const Ice::PropertiesPtr& properties) : 
    _registry(registry), 
    _lookup(lookup), 
    _timeout(IceUtil::Time::milliSeconds(properties->getPropertyAsIntWithDefault("IceDiscovery.Timeout", 300))),
    _retryCount(properties->getPropertyAsIntWithDefault("IceDiscovery.RetryCount", 3)),
    _latencyMultiplier(properties->getPropertyAsIntWithDefault("IceDiscovery.LatencyMultiplier", 1)),
    _domainId(properties->getProperty("IceDiscovery.DomainId")),
    _timer(IceInternal::getInstanceTimer(lookup->ice_getCommunicator()))
{
}
コード例 #20
0
ファイル: Client.cpp プロジェクト: matzk/CVAC
int ClientApp::initializeDetector(DetectorPrx detector)
{
	DetectorData detectorData;
	localAndClientMsg(VLogger::DEBUG, NULL, "Client using Detector-name: %s\n", detector->ice_getIdentity().name.c_str());
	detectorData.type = ::cvac::FILE;
	
	// If a detector dat file was passed then use that instead of getting it from the config file
	if (m_detectorData.length() > 0)
	{
		detectorData.file.directory.relativePath = getFilePath(m_detectorData);
		detectorData.file.filename = getFileName(m_detectorData);
	}
	else
	{ // Determine which data files to pass as detector data based on .DetectorFilename in 'config.client'
		std::string filenameStr = m_detectorName + ".DetectorFilename";
		Ice::PropertiesPtr props = communicator()->getProperties();
		std::string filename = props->getProperty(filenameStr);
		
		if (filename.length() == 0)
		{
			localAndClientMsg(VLogger::WARN, NULL, "No .DetectorFilename pair found for %s.\n", m_detectorName.c_str());
			return EXIT_FAILURE;
		}
		
		if ((filename.length() > 1 && filename[1] == ':' )||
			filename[0] == '/' ||
			filename[0] == '\\')
		{  // absolute path
			int idx = filename.find_last_of('/');
			detectorData.file.directory.relativePath = filename.substr(0, idx);
			detectorData.file.filename = filename.substr(idx+1, filename.length() - idx);
		}
		else
		{ //Add the current directory
			detectorData.file.directory.relativePath = "detectors";
			detectorData.file.filename = filename;
		}
	}
	try
	{
		localAndClientMsg(VLogger::INFO, NULL, "Initializing detector with relativePath: %s\n", detectorData.file.directory.relativePath.c_str());
		localAndClientMsg(VLogger::INFO, NULL, "Initializing detector with filename: %s\n", detectorData.file.filename.c_str());
		detector->initialize(5, detectorData);
		localAndClientMsg(VLogger::DEBUG, NULL, "IceBox test client: initialized the detector\n");
	}
	catch (const Ice::Exception& ex)
	{
		localAndClientMsg(VLogger::WARN, NULL, "Ice- name():  %s\n", ex.ice_name().c_str());
		localAndClientMsg(VLogger::WARN, NULL, "Ice- stackTrace(): \n%s\n", ex.ice_stackTrace().c_str());
		localAndClientMsg(VLogger::WARN, NULL, "%s\n", ex.what());
		return EXIT_FAILURE;
	}

  return EXIT_SUCCESS;
}
コード例 #21
0
ファイル: CascadeDetectI.cpp プロジェクト: sgsun9/CVAC
// Client verbosity
bool CascadeDetectI::initialize( const DetectorProperties& detprops,
                                 const FilePath& model,
                                 const Current& current)
{
  // Create DetectorPropertiesI class to allow the user to modify detection
  // parameters
  mDetectorProps = new DetectorPropertiesI();

  // Get the default CVAC data directory as defined in the config file
  localAndClientMsg(VLogger::DEBUG, NULL, "Initializing CascadeDetector...\n");
  Ice::PropertiesPtr iceprops = (current.adapter->getCommunicator()->getProperties());
  string verbStr = iceprops->getProperty("CVAC.ServicesVerbosity");
  if (!verbStr.empty())
  {
    getVLogger().setLocalVerbosityLevel( verbStr );
  }

  if(model.filename.empty())
  {
    if (!gotModel)
    {
        localAndClientMsg(VLogger::ERROR, callback, "No trained model available, aborting.\n" );
        return false;
    }
    // ok, go on with pre-configured model
  }
  else
  {
    if (gotModel)
    {
        localAndClientMsg(VLogger::WARN , callback, "Detector Preconfigured with a model file so ignoring passed in model %s.\n",
                          model.filename.c_str() );
    }else
    {
        string modelfile = getFSPath( model, m_CVAC_DataDir );
        localAndClientMsg( VLogger::DEBUG_1, NULL, "initializing with %s\n", modelfile.c_str());
        bool res = readModelFile( modelfile, current );
        if (!res)
        {
          localAndClientMsg(VLogger::ERROR, callback,
                        "Failed to initialize because explicitly specified trained model "
                        "cannot be found or loaded: %s\n", modelfile.c_str());
          return false;
        }
    }
  }

  localAndClientMsg(VLogger::INFO, NULL, "CascadeDetector initialized.\n");
  // Set the default window size to what the cascade was trained as.
  // User can override this by passing in properties in the process call.
  cv::Size orig = cascade->getOriginalWindowSize(); // Default to size trained with
  mDetectorProps->nativeWindowSize.width = orig.width;
  mDetectorProps->nativeWindowSize.height = orig.height;
  return true;
}
コード例 #22
0
ファイル: Service.cpp プロジェクト: hadoop835/ice
void
ServiceI::start(const string& name,
                const CommunicatorPtr& communicator,
                const StringSeq&)
{
    Ice::PropertiesPtr properties = communicator->getProperties();
    Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter(name);
    Ice::ObjectPtr object = new TestI(adapter, properties);
    adapter->add(object, stringToIdentity(properties->getProperty(name + ".Identity")));
    adapter->activate();
}
コード例 #23
0
ファイル: kinect2Server.cpp プロジェクト: AeroCano/JdeRobot
	CameraRGB(std::string& propertyPrefix, const Ice::PropertiesPtr propIn)
      : prefix(propertyPrefix),
	imageFmt(),
	imageDescription(new jderobot::ImageDescription()),
	cameraDescription(new jderobot::CameraDescription()),
	replyTask()
	{
	Ice::PropertiesPtr prop = propIn;


	//fill cameraDescription
	cameraDescription->name = prop->getProperty(prefix+"Name");
	if (cameraDescription->name.size() == 0)
		jderobot::Logger::getInstance()->warning( "Camera name not configured" );

	cameraDescription->shortDescription = prop->getProperty(prefix + "ShortDescription");

	//fill imageDescription
	imageDescription->width = prop->getPropertyAsIntWithDefault(prefix+"width",5);;
	imageDescription->height = prop->getPropertyAsIntWithDefault(prefix+"height",5);;


	int fps = prop->getPropertyAsIntWithDefault(prefix+"fps",5);
	//we use formats according to colorspaces
	std::string fmtStr = prop->getPropertyWithDefault(prefix+"Format","ImageRGB8");//default format YUY2
	imageFmt = colorspaces::Image::Format::searchFormat(fmtStr);
	if (!imageFmt)
		jderobot::Logger::getInstance()->warning( "Format " + fmtStr + " unknown" );
	imageDescription->size = imageDescription->width * imageDescription->height * CV_ELEM_SIZE(imageFmt->cvType);
	imageDescription->format = imageFmt->name;

	// Set the formats allowed
	mFormats.push_back(colorspaces::ImageRGB8::FORMAT_RGB8.get()->name);



	jderobot::Logger::getInstance()->info( "Starting thread for camera: " + cameraDescription->name );
	replyTask = new ReplyTask(this,fps, mFormats[0]);

	this->control=replyTask->start();//my own thread
	}
コード例 #24
0
ファイル: AdminI.cpp プロジェクト: zmyer/ice
ApplicationDescriptor
AdminI::getDefaultApplicationDescriptor(const Current& current) const
{
    Ice::PropertiesPtr properties = current.adapter->getCommunicator()->getProperties();
    string path = properties->getProperty("IceGrid.Registry.DefaultTemplates");
    if(path.empty())
    {
        throw DeploymentException("no default templates configured, you need to set "
                                  "IceGrid.Registry.DefaultTemplates in the IceGrid registry configuration.");
    }

    ApplicationDescriptor desc;
    try
    {
        desc = DescriptorParser::parseDescriptor(path, current.adapter->getCommunicator());
    }
    catch(const IceXML::ParserException& ex)
    {
        throw DeploymentException("can't parse default templates:\n" + ex.reason());
    }
    desc.name = "";
    if(!desc.nodes.empty())
    {
        Ice::Warning warn(_traceLevels->logger);
        warn << "default application descriptor:\nnode definitions are not allowed.";
        desc.nodes.clear();
    }
    if(!desc.distrib.icepatch.empty() || !desc.distrib.directories.empty())
    {
        Ice::Warning warn(_traceLevels->logger);
        warn << "default application descriptor:\ndistribution is not allowed.";
        desc.distrib = DistributionDescriptor();
    }
    if(!desc.replicaGroups.empty())
    {
        Ice::Warning warn(_traceLevels->logger);
        warn << "default application descriptor:\nreplica group definitions are not allowed.";
        desc.replicaGroups.clear();
    }
    if(!desc.description.empty())
    {
        Ice::Warning warn(_traceLevels->logger);
        warn << "default application descriptor:\ndescription is not allowed.";
        desc.description = "";
    }
    if(!desc.variables.empty())
    {
        Ice::Warning warn(_traceLevels->logger);
        warn << "default application descriptor:\nvariable definitions are not allowed.";
        desc.variables.clear();
    }
    return desc;
}
コード例 #25
0
ファイル: loader.cpp プロジェクト: AeroCano/JdeRobot
Ice::PropertiesPtr
initializeProperties(Ice::StringSeq args, Ice::PropertiesPtr properties){
    properties->parseIceCommandLineOptions(args);
    std::string iceconfigs = properties->getProperty("Ice.Config");
    if (!iceconfigs.empty()){
        for (std::string iceconfig : std::split(iceconfigs, ","))
            loadIceConfig(iceconfig, properties);
    }
    properties->parseCommandLineOptions("", args);

    return properties;
}
コード例 #26
0
ファイル: basic_server.cpp プロジェクト: AeroCano/JdeRobot
int main(int argc, char** argv){


	killed=false;
	struct sigaction sigIntHandler;

   sigIntHandler.sa_handler = exitApplication;
   sigemptyset(&sigIntHandler.sa_mask);
   sigIntHandler.sa_flags = 0;

   sigaction(SIGINT, &sigIntHandler, NULL);

	Ice::PropertiesPtr prop;
	std::string componentPrefix("myComponent");

	
	

	try{
			ic = Ice::initialize(argc,argv);
			prop = ic->getProperties();
	}
	catch (const Ice::Exception& ex) {
			std::cerr << ex << std::endl;
			return 1;
	}
	catch (const char* msg) {
			std::cerr <<"Error :" << msg << std::endl;
			return 1;
	}

	std::string Endpoints = prop->getProperty(componentPrefix + ".Endpoints");
	Ice::ObjectAdapterPtr adapter =ic->createObjectAdapterWithEndpoints(componentPrefix, Endpoints);

	// for each interface:

	std::string objPrefix="myInterface";
	std::string Name = "pointcloud1";
	std::cout << "Creating pointcloud1 " << Name << std::endl;
	interface1 = new myClassI();
	adapter->add(interface1, ic->stringToIdentity(Name));

	//starting the adapter
	adapter->activate();
	ic->waitForShutdown();

	if (!killed)
		exitApplication(1);
   
   return 0;

}
コード例 #27
0
ファイル: TrustManager.cpp プロジェクト: Jonavin/ice
TrustManager::TrustManager(const Ice::CommunicatorPtr& communicator) :
    _communicator(communicator)
{
    Ice::PropertiesPtr properties = communicator->getProperties();
    _traceLevel = properties->getPropertyAsInt("IceSSL.Trace.Security");
    string key;
    try
    {
        key = "IceSSL.TrustOnly";
        parse(properties->getProperty(key), _rejectAll, _acceptAll);
        key = "IceSSL.TrustOnly.Client";
        parse(properties->getProperty(key), _rejectClient, _acceptClient);
        key = "IceSSL.TrustOnly.Server";
        parse(properties->getProperty(key), _rejectAllServer, _acceptAllServer);
        Ice::PropertyDict dict = properties->getPropertiesForPrefix("IceSSL.TrustOnly.Server.");
        for(Ice::PropertyDict::const_iterator p = dict.begin(); p != dict.end(); ++p)
        {
            string name = p->first.substr(string("IceSSL.TrustOnly.Server.").size());
            key = p->first;
            list<DistinguishedName> reject, accept;
            parse(p->second, reject, accept);
            if(!reject.empty())
            {
                _rejectServer[name] = reject;
            }
            if(!accept.empty())
            {
                _acceptServer[name] = accept;
            }
        }
    }
    catch(const ParseException& e)
    {
        Ice::PluginInitializationException ex(__FILE__, __LINE__);
        ex.reason = "IceSSL: invalid property " + key  + ":\n" + e.reason;
        throw ex;
    }
}
コード例 #28
0
ファイル: Client.cpp プロジェクト: 2008hatake/zeroc-ice
int
main(int argc, char* argv[])
{
    ifstream in("./config/configPath");
    if(!in)
    {
        test(false);
    }
    
    if(!getline(in, configPath))
    {
        test(false);
    }
    try
    {
        cout << "testing load properties from UTF-8 path... " << flush;
        Ice::PropertiesPtr properties = Ice::createProperties();
        properties->load(configPath);
        test(properties->getProperty("Ice.Trace.Network") == "1");
        test(properties->getProperty("Ice.Trace.Protocol") == "1");       
        test(properties->getProperty("Config.Path") == configPath);
        test(properties->getProperty("Ice.ProgramName") == "PropertiesClient");
        cout << "ok" << endl;
    }
    catch(const Ice::Exception& ex)
    {
        cerr << ex << endl;
        return EXIT_FAILURE;
    }
    
    cout << "testing load properties from UTF-8 path using Ice::Application... " << flush;
    Client c;
    c.main(argc, argv, configPath.c_str());
    cout << "ok" << endl;
    
    try
    {
        //
        // Try to load multiple config files.
        //
        cout << "testing using Ice.Config with multiple config files... " << flush;
        Ice::PropertiesPtr properties;
        Ice::StringSeq args;
        args.push_back("--Ice.Config=config/config.1, config/config.2, config/config.3");
        IceUtilInternal::ArgVector a(args);
        properties = Ice::createProperties(a.argc, a.argv);
        test(properties->getProperty("Config1") == "Config1");
        test(properties->getProperty("Config2") == "Config2");
        test(properties->getProperty("Config3") == "Config3");
        cout << "ok" << endl;
    }
    catch(const Ice::Exception& ex)
    {
        cerr << ex << endl;
        return EXIT_FAILURE;
    }
    return EXIT_SUCCESS;
}
コード例 #29
0
ファイル: imagei.cpp プロジェクト: JdeRobot4Air/v4l2server
CameraI::CameraI(std::string propertyPrefix, Ice::CommunicatorPtr ic)
      : prefix(propertyPrefix),
        imageConsumer(),
        rpc_mode(false),
        format() {

    std::cout << "Constructor CameraI -> " << propertyPrefix << std::endl;

    imageDescription = new jderobot::ImageDescription();
    cameraDescription = new jderobot::CameraDescription();

    Ice::PropertiesPtr prop = ic->getProperties();

    /* Fill cameraDescription */
    cameraDescription->name = prop->getPropertyWithDefault(prefix + "Name", "");
    cameraDescription->shortDescription = prop->getPropertyWithDefault(
        prefix + "ShortDescription", "");
    cameraDescription->streamingUri = prop->getPropertyWithDefault(
        prefix + "StreamingUri", "");

    /* Fill imageDescription */
    format->width = imageDescription->width = prop->getPropertyAsIntWithDefault(
        prefix + "ImageWidth", 320);
    format->height = imageDescription->height = prop
        ->getPropertyAsIntWithDefault(prefix + "ImageHeight", 240);

    /* We need to translate V4L2 formats to colorspaces string format */
    std::string fmtStr = prop->getPropertyWithDefault(prefix + "Format",
                                                      "RGB8");
    /* We only supports those formats that we could resolve to V4L2 */
    // convert colorspaces to V4L2 and throw error if we don't know it
    format->format = "YUYV";

    /*********************************************************************
     imageDescription->size = imageDescription->width * imageDescription->height
     * CV_ELEM_SIZE(imageFmt->cvType);
     imageDescription->format = imageFmt->name;
     ***********************************************************************/

    /* Get camera device */
    device_name = prop->getProperty(prefix + "Uri");
    fps = prop->getPropertyAsIntWithDefault(prefix + "fps", 10);

    std::cout << "Device name: " << device_name << std::endl;

    camera = new v4l2::Camera(device_name, format, fps);

    replyTask = new ReplyTask(this);
    replyTask->start();  // my own thread
  }
コード例 #30
0
ファイル: RegistryI.cpp プロジェクト: updowndown/myffff
void
RegistryI::setupAdminSessionFactory(const Ice::ObjectAdapterPtr& registryAdapter, 
                                    const Ice::ObjectAdapterPtr& sessionManagerAdapter,
                                    const IceGrid::LocatorPrx& locator,
                                    bool nowarn)
{
    assert(_reaper);
    _adminSessionFactory = new AdminSessionFactory(sessionManagerAdapter, _database, _reaper, this);

    if(sessionManagerAdapter)
    {
        Identity adminSessionMgrId;
        adminSessionMgrId.category = _instanceName;
        adminSessionMgrId.name = "AdminSessionManager";
        Identity sslAdmSessionMgrId;
        sslAdmSessionMgrId.category = _instanceName;
        sslAdmSessionMgrId.name = "AdminSSLSessionManager";
        if(!_master)
        {
            adminSessionMgrId.name += "-" + _replicaName;
            sslAdmSessionMgrId.name += "-" + _replicaName;
        }

        sessionManagerAdapter->add(new AdminSessionManagerI(_adminSessionFactory), adminSessionMgrId);
        sessionManagerAdapter->add(new AdminSSLSessionManagerI(_adminSessionFactory), sslAdmSessionMgrId);
        
        _wellKnownObjects->add(sessionManagerAdapter->createProxy(adminSessionMgrId), 
                               Glacier2::SessionManager::ice_staticId());
        _wellKnownObjects->add(sessionManagerAdapter->createProxy(sslAdmSessionMgrId), 
                               Glacier2::SSLSessionManager::ice_staticId());
    }

    Ice::PropertiesPtr properties = _communicator->getProperties();

    _adminVerifier = getPermissionsVerifier(registryAdapter,
                                            locator,
                                            "IceGrid.Registry.AdminPermissionsVerifier",
                                            properties->getProperty("IceGrid.Registry.AdminCryptPasswords"),
                                            nowarn);

    _sslAdminVerifier =
        getSSLPermissionsVerifier(locator, 
                                  "IceGrid.Registry.AdminSSLPermissionsVerifier", 
                                  nowarn);
}