[Jderobot-admin] jderobot-r1207 - trunk/src/stable/libs/parallelIce
rocapal en jderobot.org
rocapal en jderobot.org
Lun Mar 24 18:24:52 CET 2014
Author: rocapal
Date: 2014-03-24 18:24:52 +0100 (Mon, 24 Mar 2014)
New Revision: 1207
Modified:
trunk/src/stable/libs/parallelIce/cameraClient.cpp
trunk/src/stable/libs/parallelIce/cameraClient.h
trunk/src/stable/libs/parallelIce/pointcloudClient.cpp
trunk/src/stable/libs/parallelIce/pointcloudClient.h
Log:
#202 Added new constructor to string proxy and added stop_thread call
Modified: trunk/src/stable/libs/parallelIce/cameraClient.cpp
===================================================================
--- trunk/src/stable/libs/parallelIce/cameraClient.cpp 2014-03-24 09:47:37 UTC (rev 1206)
+++ trunk/src/stable/libs/parallelIce/cameraClient.cpp 2014-03-24 17:24:52 UTC (rev 1207)
@@ -25,7 +25,7 @@
namespace jderobot {
cameraClient::cameraClient(Ice::CommunicatorPtr ic, std::string prefix, bool debug) {
- // TODO Auto-generated constructor stubcameraClient* client = new cameraClient;
+
this->prefix=prefix;
this->debug=debug;
Ice::PropertiesPtr prop;
@@ -61,6 +61,45 @@
this->pauseStatus=false;
}
+cameraClient::cameraClient(Ice::CommunicatorPtr ic, std::string prefix, bool debug, std::string proxy){
+
+ this->prefix=prefix;
+ this->debug=debug;
+ Ice::PropertiesPtr prop;
+ prop = ic->getProperties();
+ Ice::ObjectPrx baseCamera;
+ this->refreshRate=0;
+
+
+ int fps=prop->getPropertyAsIntWithDefault(prefix+"Fps",10);
+ this->cycle=(float)(1/(float)fps)*1000000;
+
+ try{
+ baseCamera = ic->stringToProxy(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;
+ jderobot::Logger::getInstance()->error(prefix + " Not camera provided");
+ }
+
+ jderobot::ImageDataPtr data = this->prx->getImageData();
+
+ this->size=cv::Size(data->description->width,data->description->height);
+ _done=false;
+ this->pauseStatus=false;
+}
+
cameraClient::~cameraClient() {
// TODO Auto-generated destructor stub
_done=true;
@@ -130,7 +169,7 @@
int rate =(int)(1000000/(IceUtil::Time::now().toMicroSeconds() - last.toMicroSeconds()));
totalRefreshRate = totalRefreshRate + rate;
- this->refreshRate= totalRefreshRate / iterIndex;
+ this->refreshRate= totalRefreshRate / iterIndex;
last=IceUtil::Time::now();
if (iterIndex == INT_MAX)
@@ -142,6 +181,11 @@
}
}
+void cameraClient::stop_thread()
+{
+ _done = true;
+}
+
cv::Mat cameraClient::getImage(){
cv::Mat local;
this->controlMutex.lock();
Modified: trunk/src/stable/libs/parallelIce/cameraClient.h
===================================================================
--- trunk/src/stable/libs/parallelIce/cameraClient.h 2014-03-24 09:47:37 UTC (rev 1206)
+++ trunk/src/stable/libs/parallelIce/cameraClient.h 2014-03-24 17:24:52 UTC (rev 1207)
@@ -38,6 +38,7 @@
class cameraClient: public IceUtil::Thread {
public:
cameraClient(Ice::CommunicatorPtr ic, std::string prefix, bool debug);
+ cameraClient(Ice::CommunicatorPtr ic, std::string prefix, bool debug, std::string proxy);
virtual ~cameraClient();
virtual void run();
@@ -47,6 +48,7 @@
void pause();
void resume();
void reset();
+ void stop_thread();
bool getPause(){return pauseStatus;};
cv::Size getSize(){return size;};
Modified: trunk/src/stable/libs/parallelIce/pointcloudClient.cpp
===================================================================
--- trunk/src/stable/libs/parallelIce/pointcloudClient.cpp 2014-03-24 09:47:37 UTC (rev 1206)
+++ trunk/src/stable/libs/parallelIce/pointcloudClient.cpp 2014-03-24 17:24:52 UTC (rev 1207)
@@ -55,6 +55,38 @@
}
+pointcloudClient::pointcloudClient(Ice::CommunicatorPtr ic, std::string prefix, bool debug, std::string proxy)
+{
+ this->prefix=prefix;
+ this->debug= debug;
+ 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->stringToProxy(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;
+ }
+ catch (const char* msg) {
+ std::cerr << msg << std::endl;
+ jderobot::Logger::getInstance()->error(prefix + " Not camera provided");
+ }
+ _done=false;
+ this->pauseStatus=false;
+}
+
pointcloudClient::~pointcloudClient() {
// TODO Auto-generated destructor stub
this->_done=true;
@@ -71,6 +103,9 @@
this->controlMutex.unlock();
}
+void pointcloudClient::stop_thread(){
+ _done = true;
+}
void pointcloudClient::run(){
Modified: trunk/src/stable/libs/parallelIce/pointcloudClient.h
===================================================================
--- trunk/src/stable/libs/parallelIce/pointcloudClient.h 2014-03-24 09:47:37 UTC (rev 1206)
+++ trunk/src/stable/libs/parallelIce/pointcloudClient.h 2014-03-24 17:24:52 UTC (rev 1207)
@@ -37,6 +37,8 @@
class pointcloudClient: public IceUtil::Thread {
public:
pointcloudClient(Ice::CommunicatorPtr ic, std::string prefix, bool debug);
+ pointcloudClient(Ice::CommunicatorPtr ic, std::string prefix, bool debug, std::string proxy);
+
virtual ~pointcloudClient();
virtual void run();
@@ -46,6 +48,7 @@
void resume();
bool getPause(){return pauseStatus;};
+ void stop_thread();
private:
std::string prefix;
More information about the Jderobot-admin
mailing list