本文整理汇总了C++中ice::CommunicatorPtr::propertyToProxy方法的典型用法代码示例。如果您正苦于以下问题:C++ CommunicatorPtr::propertyToProxy方法的具体用法?C++ CommunicatorPtr::propertyToProxy怎么用?C++ CommunicatorPtr::propertyToProxy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ice::CommunicatorPtr
的用法示例。
在下文中一共展示了CommunicatorPtr::propertyToProxy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main (int argc, char* argv[]) {
int status;
Ice::CommunicatorPtr ic;
try {
ic = Ice::initialize(argc, argv);
readArgs(&argc, argv);
// Contact to Encoders
Ice::ObjectPrx Encoders = ic->propertyToProxy("automata.Encoders.Proxy");
if (Encoders == 0)
throw "Could not create proxy with Encoders";
Encodersprx = jderobot::EncodersPrx::checkedCast(Encoders);
if (Encodersprx == 0)
throw "Invalid proxy automata.Encoders.Proxy";
std::cout << "Encoders connected" << std::endl;
// Contact to Motors
Ice::ObjectPrx Motors = ic->propertyToProxy("automata.Motors.Proxy");
if (Motors == 0)
throw "Could not create proxy with Motors";
Motorsprx = jderobot::MotorsPrx::checkedCast(Motors);
if (Motorsprx == 0)
throw "Invalid proxy automata.Motors.Proxy";
std::cout << "Motors connected" << std::endl;
if (displayGui){
automatagui = new AutomataGui(argc, argv);
displayGui = showAutomataGui();
}
pthread_create(&thr_sub_1, NULL, &subautomata_1, NULL);
pthread_create(&thr_sub_2, NULL, &subautomata_2, NULL);
pthread_create(&thr_sub_3, NULL, &subautomata_3, NULL);
pthread_join(thr_sub_1, NULL);
pthread_join(thr_sub_2, NULL);
pthread_join(thr_sub_3, NULL);
if (displayGui)
pthread_join(thr_automatagui, NULL);
} catch ( const Ice::Exception& ex ) {
std::cerr << ex << std::endl;
status = 1;
} catch ( const char* msg ) {
std::cerr << msg << std::endl;
status = 1;
}
if (ic)
ic->destroy();
return status;
}
示例2:
pointcloudClient::pointcloudClient(Ice::CommunicatorPtr ic, std::string prefix) {
// TODO Auto-generated constructor stub
this->prefix=prefix;
Ice::PropertiesPtr prop;
prop = ic->getProperties();
this->refreshRate=0;
int fps=prop->getPropertyAsIntWithDefault(prefix+"Fps",10);
this->cycle=(float)(1/(float)fps)*1000000;
try{
Ice::ObjectPrx basePointCloud = ic->propertyToProxy(prefix+"Proxy");
if (0==basePointCloud){
throw prefix + " Could not create proxy";
}
else {
this->prx = jderobot::pointCloudPrx::checkedCast(basePointCloud);
if (0==this->prx)
throw "Invalid proxy" + prefix;
}
}catch (const Ice::Exception& ex) {
std::cerr << ex << std::endl;
throw "Invalid proxy" + prefix;
}
catch (const char* msg) {
std::cerr << msg << std::endl;
jderobot::Logger::getInstance()->error(prefix + " Not camera provided");
throw "Invalid proxy" + prefix;
}
_done=false;
this->pauseStatus=false;
this->newData=false;
}
示例3:
Actuators::Actuators(Ice::CommunicatorPtr ic)
{
this->ic = ic;
// Contact to MOTORS interface
Ice::ObjectPrx baseMotors = ic->propertyToProxy("introrob.Motors.Proxy");
if (0 == baseMotors){
motorsON = false;
std::cout << "Motors configuration not specified" <<std::endl;
//throw "Could not create proxy with motors";
}else{
// Cast to motors
try{
mprx = jderobot::MotorsPrx::checkedCast(baseMotors);
if (0 == mprx)
throw "Invalid proxy introrob.Motors.Proxy";
motorsON = true;
std::cout << "Motors connected" << std::endl;
}catch (Ice::ConnectionRefusedException& e){
motorsON=false;
std::cout << "Motors inactive" << std::endl;
}
}
motorVout= 0;
motorWout = 0;
motorLout= 0;
}
示例4: initIceConnection
DetectorPrx initIceConnection(const std::string& detectorNameStr,
Ice::Identity& det_cb,
DetectorCallbackHandlerPtr cr)
{
initIce(detectorNameStr);
Ice::PropertiesPtr props = iceComm->getProperties();
std::string proxStr = detectorNameStr + ".Proxy";
DetectorPrx detector = NULL;
try
{
detector = DetectorPrx::checkedCast(
iceComm->propertyToProxy(proxStr)->ice_twoway());
}
catch (const IceUtil::NullHandleException& e)
{
localAndClientMsg( VLogger::ERROR, NULL, "Invalid proxy: '%s'. %s\n",
detectorNameStr.c_str(), e.what());
return NULL;
}
Ice::ObjectAdapterPtr adapter = iceComm->createObjectAdapter("");
det_cb.name = IceUtil::generateUUID();
det_cb.category = "";
adapter->add(cr, det_cb);
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
return detector; // Success
}
示例5: main
int main(int argc, char** argv){
int status;
cameraview::Viewer viewer;
Ice::CommunicatorPtr ic;
jderobot::cameraClient* camRGB;
try{
ic = EasyIce::initialize(argc,argv);
Ice::ObjectPrx base = ic->propertyToProxy("Cameraview.Camera.Proxy");
Ice::PropertiesPtr prop = ic->getProperties();
if (0==base)
throw "Could not create proxy";
camRGB = new jderobot::cameraClient(ic,"Cameraview.Camera.");
if (camRGB == NULL){
throw "Invalid proxy";
}
camRGB->start();
cv::Mat rgb;
while(viewer.isVisible()){
//jderobot::ImageDataPtr data = camRGB->getImageData(format);
camRGB->getImage(rgb);
viewer.display(rgb);
viewer.displayFrameRate(camRGB->getRefreshRate());
}
}catch (const Ice::Exception& ex) {
std::cerr << ex << std::endl;
status = 1;
} catch (const char* msg) {
std::cerr << msg << std::endl;
status = 1;
}
if (ic)
ic->destroy();
camRGB->stop_thread();
delete(camRGB);
return status;
}
示例6: main
int main(int argc, char** argv){
int status;
Ice::CommunicatorPtr ic;
try{
ic = Ice::initialize(argc,argv);
std::string topicName = ic->getProperties()->getProperty("Cameraview_icestorm.Camera.TopicName");
std::cout << "Trying to conect to: " << topicName << std::endl;
Ice::ObjectPrx obj=ic->propertyToProxy("Cameraview_icestorm.Camera.TopicManager");
IceStorm::TopicManagerPrx topicManager=IceStorm::TopicManagerPrx::checkedCast(obj);
std::string objAdapterEndpoint = ic->getProperties()->getProperty("Cameraview_icestorm.Camera.ObjectAdapter");
Ice::ObjectAdapterPtr adapter=ic->createObjectAdapterWithEndpoints("CameraAdapter",objAdapterEndpoint);
ImageConsumerI* imageConsumer = new ImageConsumerI;
Ice::ObjectPrx proxy = adapter->addWithUUID(imageConsumer)->ice_oneway();
IceStorm::TopicPrx topic;
try {
topic = topicManager->retrieve(topicName);
IceStorm::QoS qos;
topic->subscribeAndGetPublisher(qos, proxy);
}
catch (const IceStorm::NoSuchTopic& ex) {
std::cerr << ex << std::endl;
}
adapter->activate();
ic->waitForShutdown();
topic->unsubscribe(proxy);
if (ic)
ic->destroy();
return status;
}catch (const Ice::Exception& ex) {
std::cerr << ex << std::endl;
status = 1;
} catch (const char* msg) {
std::cerr << msg << std::endl;
status = 1;
}
}
示例7: main
int main(int argc, char** argv) {
int status;
cameraview::colorTuner viewer;
Ice::CommunicatorPtr ic;
try {
ic = EasyIce::initialize(argc,argv);
Ice::ObjectPrx base = ic->propertyToProxy("Cameraview.Camera.Proxy");
if (0==base)
throw "Could not create proxy";
/*cast to CameraPrx*/
jderobot::CameraPrx cprx = jderobot::CameraPrx::checkedCast(base);
if (0==cprx)
throw "Invalid proxy";
while(viewer.isVisible()) {
jderobot::ImageDataPtr data = cprx->getImageData(colorspaces::ImageRGB8::FORMAT_RGB8.get()->name);
cv::Mat image = cv::Mat(cv::Size(data->description->width,data->description->height),CV_8UC3,&(data->pixelData[0]));
colorspaces::Image::FormatPtr fmt = colorspaces::Image::Format::searchFormat(data->description->format);
if (!fmt)
throw "Format not supported";
viewer.display(image);
image.release();
}
} catch (const Ice::Exception& ex) {
std::cerr << ex << std::endl;
status = 1;
} catch (const char* msg) {
std::cerr << msg << std::endl;
status = 1;
}
if (ic)
ic->destroy();
return status;
}
示例8: main
int main(int argc, char **argv) {
Ice::CommunicatorPtr ic;
jderobot::cameraClient* camRGB;
try {
ic = EasyIce::initialize(argc, argv);
Ice::ObjectPrx base = ic->propertyToProxy("Cameraview.Camera.Proxy");
Ice::PropertiesPtr prop = ic->getProperties();
if (0==base)
throw "Could not create Proxy\n";
camRGB = new jderobot::cameraClient(ic, "Cameraview.Camera.");
if (camRGB == NULL) {
throw "Invalid Proxy";
} else {
camRGB->start();
std::cout << "Using ICE camera server..";
cv::Mat rgb;
while(1) {
camRGB->getImage(rgb);
if (rgb.rows==0 || rgb.cols==0) continue;
imshow("frame:ICE", rgb);
waitKey(33);
}
}
} catch (const char* msg) {
}
ros::init(argc, argv, "listener");
ros::NodeHandle n,nh;
image_transport::ImageTransport it(nh);
image_transport::Subscriber camera_sub = it.subscribe("cameratopic", 1000, cameracallback);
ros::Subscriber sub = n.subscribe("chatter", 1001, chatterCallback);
ros::spin();
return 0;
}
示例9:
Pose3dIceClient::Pose3dIceClient(Ice::CommunicatorPtr ic, std::string prefix) {
this->prefix=prefix;
Ice::PropertiesPtr prop;
prop = ic->getProperties();
int fps=prop->getPropertyAsIntWithDefault(prefix+".Fps",30);
this->cycle=(float)(1/(float)fps)*1000000;
Ice::ObjectPrx basePose = ic->propertyToProxy(prefix+".Proxy");
if (0==basePose){
this->on = false;
std::cout << prefix + ".Proxy configuration not specified" <<std::endl;
}
else {
try{
this->prx = jderobot::Pose3DPrx::checkedCast(basePose);
if (0 == this->prx){
this->on = false;
std::cout <<"Invalid proxy "+ prefix + ".Proxy" <<std::endl;
}else{
this->on = true;
std::cout << prefix + " connected" << std::endl;
}
}catch (const Ice::ConnectionRefusedException& e) {
std::cout << prefix +" inactive" << std::endl;
}
catch (const Ice::Exception& ex) {
std::cerr << ex << std::endl;
}
}
this->pauseStatus=false;
}
示例10:
cameraClient::cameraClient(Ice::CommunicatorPtr ic, std::string prefix) {
this->prefix=prefix;
Ice::PropertiesPtr prop;
prop = ic->getProperties();
Ice::ObjectPrx baseCamera;
this->refreshRate=0;
this->mImageFormat.empty();
this->newData=false;
int fps=prop->getPropertyAsIntWithDefault(prefix+"Fps",30);
this->cycle=(float)(1/(float)fps)*1000000;
try{
baseCamera = ic->propertyToProxy(prefix+"Proxy");
if (0==baseCamera){
throw prefix + "Could not create proxy with Camera";
}
else {
this->prx= jderobot::CameraPrx::checkedCast(baseCamera);
if (0==this->prx)
throw "Invalid " + prefix + ".Proxy";
}
}catch (const Ice::Exception& ex) {
std::cerr << ex << std::endl;
}
catch (const char* msg) {
std::cerr << msg << std::endl;
LOG(FATAL) << prefix + " Not camera provided";
}
//check if default format is defined
std::string definedFormat=prop->getProperty(prefix+"ImageFormat");
this->mImageFormat = CameraUtils::negotiateDefaultFormat(this->prx,definedFormat);
jderobot::ImageDataPtr data = this->prx->getImageData(this->mImageFormat);
this->size=cv::Size(data->description->width,data->description->height);
_done=false;
this->pauseStatus=false;
}
示例11:
Control::Control(Ice::CommunicatorPtr ic, Shared* sm)
{
/*Obtaining the configuration file (*.cfg) properties such as ports and IP's*/
this->ic = ic;
this->sm = sm;
Ice::PropertiesPtr prop = ic->getProperties();
std::string cam = prop->getPropertyWithDefault("basic_component_qt.Camera1.Proxy", "miss");
if (!boost::iequals(cam , "miss"))
{
/*Creation of a proxy to connect with cameraServer*/
Ice::ObjectPrx base = ic->propertyToProxy("basic_component_qt.Camera1.Proxy");
if (0==base)
throw "Could not create proxy";
/*cast to CameraPrx*/
cprx = jderobot::CameraPrx::checkedCast(base);
if (0==cprx)
throw "Invalid proxy";
cameraOn = true;
/*Get the image data from the camera proxy*/
jderobot::ImageDataPtr data = cprx->getImageData();
/*Create the first image obtained from the camera and stores in the shared memory*/
this->sm->createImage(data);
}
else
{
cameraOn = false;
/*Create an empty image if there is no camera connected*/
this->sm->createEmptyImage();
std::cout << "No camera connected" << std::endl;
}
}
示例12: if
int
run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator1, const Ice::CommunicatorPtr& communicator2)
{
const string proxyProperty = "Echo.Proxy";
EchoPrx echo1 = EchoPrx::checkedCast(communicator1->propertyToProxy(proxyProperty));
if(!echo1)
{
cerr << argv[0] << ": invalid proxy" << endl;
return EXIT_FAILURE;
}
EchoPrx echo2 = EchoPrx::checkedCast(communicator2->propertyToProxy(proxyProperty));
if(!echo2)
{
cerr << argv[0] << ": invalid proxy" << endl;
return EXIT_FAILURE;
}
menu();
string greeting = "Bonne journ\351e";
char c;
do
{
try
{
cout << "==> ";
cin >> c;
if(c == 't')
{
string ret = echo1->echoString(greeting);
cout << "Received (LATIN-1): \"" << IceUtil::escapeString(ret, "") << '\"' << endl;
}
else if(c == 'u')
{
string ret = echo2->echoString(greeting);
cout << "Received (LATIN-1): \"" << IceUtil::escapeString(ret, "") << '\"' << endl;
}
else if(c == 's')
{
echo1->shutdown();
}
else if(c == 'x')
{
// Nothing to do
}
else if(c == '?')
{
menu();
}
else
{
cout << "unknown command `" << c << "'" << endl;
menu();
}
}
catch(const Ice::Exception& ex)
{
cerr << ex << endl;
}
}
while(cin.good() && c != 'x');
return EXIT_SUCCESS;
}
示例13: if
//.........这里部分代码省略.........
// This is an unknown endpoint warning, not a parse exception.
//
//try
//{
// b1 = communicator->stringToProxy("test -f the:facet:tcp");
// test(false);
//}
//catch(const Ice::EndpointParseException&)
//{
//}
try
{
b1 = communicator->stringToProxy("test::tcp");
test(false);
}
catch(const Ice::EndpointParseException&)
{
}
//
// Test for bug ICE-5543: escaped escapes in stringToIdentity
//
Ice::Identity id = { "test", ",X2QNUAzSBcJ_e$AV;E\\" };
Ice::Identity id2 = communicator->stringToIdentity(communicator->identityToString(id));
test(id == id2);
id.name = "test";
id.category = ",X2QNUAz\\SB\\/cJ_e$AV;E\\\\";
id2 = communicator->stringToIdentity(communicator->identityToString(id));
test(id == id2);
cout << "ok" << endl;
cout << "testing propertyToProxy... " << flush;
Ice::PropertiesPtr prop = communicator->getProperties();
string propertyPrefix = "Foo.Proxy";
prop->setProperty(propertyPrefix, "test:default -p 12010");
b1 = communicator->propertyToProxy(propertyPrefix);
test(b1->ice_getIdentity().name == "test" && b1->ice_getIdentity().category.empty() &&
b1->ice_getAdapterId().empty() && b1->ice_getFacet().empty());
string property;
property = propertyPrefix + ".Locator";
test(!b1->ice_getLocator());
prop->setProperty(property, "locator:default -p 10000");
b1 = communicator->propertyToProxy(propertyPrefix);
test(b1->ice_getLocator() && b1->ice_getLocator()->ice_getIdentity().name == "locator");
prop->setProperty(property, "");
property = propertyPrefix + ".LocatorCacheTimeout";
test(b1->ice_getLocatorCacheTimeout() == -1);
prop->setProperty(property, "1");
b1 = communicator->propertyToProxy(propertyPrefix);
test(b1->ice_getLocatorCacheTimeout() == 1);
prop->setProperty(property, "");
// Now retest with an indirect proxy.
prop->setProperty(propertyPrefix, "test");
property = propertyPrefix + ".Locator";
prop->setProperty(property, "locator:default -p 10000");
b1 = communicator->propertyToProxy(propertyPrefix);
test(b1->ice_getLocator() && b1->ice_getLocator()->ice_getIdentity().name == "locator");
prop->setProperty(property, "");
property = propertyPrefix + ".LocatorCacheTimeout";
示例14: main
int main(int argc, char** argv)
{
int status;
// ICE
Ice::CommunicatorPtr ic;
jderobot::cameraClient* camRGB = NULL; // parallelIce RGB Image
jderobot::Pose3DPrx pose3Dprx = 0; // ICE Pose3D proxy
IceUtil::ThreadControl rgbTc; // RGB Image Thread Control
pthread_t thr_gui; // GUI thread
pthread_t thr_camera; // Update Camera thread
pthread_t thr_speed; //speed control
std::string prefix("navigatorCamera"); // Component Prefix
std::string gladeFile; // Path to the glade file
bool guiActivated; // GUI activation flag
bool controlActivated; // Control activation flag
bool speedActivated;
int pose3dFps; // Frequency to update the Pose3D.
long cycle_pose3d; // Time cycle for control the update of Pose3D.
sharer = new navigatorCamera::Sharer();
struct timeval a, b;
long totala, totalb;
long diff;
//--------------------INPUT ARGUMENTS--------------------//
if (argc != 2)
{
std::cerr << "\nUSE: ./" << prefix << " --Ice.Config=" << prefix << ".cfg\n" << std::endl;
return 1;
}
//------------------END INPUT ARGUMENTS------------------//
try
{
//--------------------ICE--------------------//
ic = Ice::initialize(argc,argv);
Ice::PropertiesPtr prop = ic->getProperties();
gladeFile = prop->getPropertyWithDefault(prefix + ".gladeFile", "./" + prefix + ".glade");
guiActivated = prop->getPropertyAsIntWithDefault(prefix + ".guiActivated",1);
controlActivated = prop->getPropertyAsIntWithDefault(prefix + ".controlActivated",0);
speedActivated = prop->getPropertyAsIntWithDefault(prefix + ".speedActivated",0);
pose3dFps = prop->getPropertyAsIntWithDefault(prefix + ".Pose3D.Fps",25);
cycle_pose3d = (long)( (1./(float)pose3dFps) * 1000000); //microseconds
sharer->setTranslationStep(atof(prop->getPropertyWithDefault(prefix + ".TranslationStep","0.1").c_str()));
sharer->setRotationStep(atof(prop->getPropertyWithDefault(prefix + ".RotationStep","0.1").c_str()));
// Contact to RGB Image interface
camRGB = new jderobot::cameraClient(ic, prefix + ".CameraRGB.");
if (camRGB != NULL){
rgbTc = camRGB->start();
}
else{
throw prefix + ": failed to load RGB Camera";
}
// Contact to Pose3D interface
Ice::ObjectPrx basePose3D = ic->propertyToProxy(prefix + ".Pose3D.Proxy");
if ( basePose3D == 0 )
throw "Could not create proxy with Pose3D.";
// Cast to Pose3D
pose3Dprx = jderobot::Pose3DPrx::checkedCast(basePose3D);
if ( pose3Dprx == 0 )
throw std::invalid_argument("Invalid proxy " + prefix + ".Pose3D.Proxy");
//------------------END ICE------------------//
sharer->setGuiVisible(guiActivated);
sharer->setControlActive(controlActivated);
if ( guiActivated )
pthread_create(&thr_gui, NULL, &showGui, static_cast<void *>(&gladeFile));
pthread_create(&thr_camera, NULL, &updateCamera, static_cast<void *>(camRGB));
// Captures Pose3D ICE data.
jderobot::Pose3DDataPtr p3dData = pose3Dprx->getPose3DData();
sharer->setPose3D(p3dData);
if ( speedActivated ) {
pthread_create(&thr_speed, NULL, &updateSpeed, NULL);
}
while ( sharer->getControlActive() || sharer->getGuiVisible() )
{
gettimeofday(&a, NULL);
totala = a.tv_sec * 1000000 + a.tv_usec;
// Update the current Pose3D ICE data.
pose3Dprx->setPose3DData(sharer->getPose3D());
//.........这里部分代码省略.........
示例15: if
int
run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
{
if(argc > 1)
{
fprintf(stderr, "%s: too many arguments", argv[0]);
return EXIT_FAILURE;
}
HelloPrx hello = HelloPrx::checkedCast(communicator->propertyToProxy("Hello.Proxy"));
if(!hello)
{
fprintf(stderr, "%s: invalid proxy\n", argv[0]);
return EXIT_FAILURE;
}
menu();
char c = EOF;
do
{
try
{
printf("==> "); fflush(stdout);
do
{
c = getchar();
}
while(c != EOF && c == '\n');
if(c == 'i')
{
hello->sayHello(0);
}
else if(c == 'd')
{
hello->sayHello_async(new AMI_Hello_sayHelloI, 5000);
}
else if(c == 's')
{
hello->shutdown();
}
else if(c == 'x')
{
// Nothing to do
}
else if(c == '?')
{
menu();
}
else
{
printf("unknown command `%c'\n", c);
menu();
}
}
catch(const Ice::Exception& ex)
{
fprintf(stderr, "%s\n", ex.toString().c_str());
}
}
while(c != EOF && c != 'x');
return EXIT_SUCCESS;
}