Skip to content
This repository has been archived by the owner on Feb 21, 2021. It is now read-only.

Commit

Permalink
#201 Included namingService support to cameraserver
Browse files Browse the repository at this point in the history
  • Loading branch information
chanfr committed Oct 26, 2015
1 parent a3c5d4b commit 502e385
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/stable/components/cameraserver/CMakeLists.txt
Expand Up @@ -22,4 +22,5 @@ TARGET_LINK_LIBRARIES(cameraserver
${ZLIB_LIBRARIES}
logger
crypto
ns
)
2 changes: 2 additions & 0 deletions src/stable/components/cameraserver/cameraserver.cfg
Expand Up @@ -18,3 +18,5 @@ CameraSrv.Camera.0.ImageHeight=480
# If you want a mirror image, set to 1
CameraSrv.Camera.0.Mirror=1

NamingService.Enabled=1
NamingService.Proxy=NamingServiceJdeRobot:default -h 0.0.0.0 -p 10000
25 changes: 25 additions & 0 deletions src/stable/components/cameraserver/cameraserver.cpp
Expand Up @@ -44,6 +44,8 @@
#include <log/Logger.h>
#include <jderobotutil/CameraHandler.h>
#include <jderobotutil/CameraTask.h>
#include <ns/ns.h>


namespace cameraserver{

Expand Down Expand Up @@ -162,6 +164,10 @@ class CameraI: public jderobot::CameraHandler {

} //namespace


jderobot::ns* namingService = NULL;


int main(int argc, char** argv)
{
std::vector<Ice::ObjectPtr> cameras;
Expand Down Expand Up @@ -192,6 +198,23 @@ int main(int argc, char** argv)

std::string Endpoints = prop->getProperty("CameraSrv.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);
}
}

int nCameras = prop->getPropertyAsInt("CameraSrv.NCameras");
cameras.resize(nCameras);
Ice::ObjectAdapterPtr adapter =ic->createObjectAdapterWithEndpoints("CameraServer", Endpoints);
Expand All @@ -205,6 +228,8 @@ int main(int argc, char** argv)

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

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

}
adapter->activate();
Expand Down

0 comments on commit 502e385

Please sign in to comment.