[Jderobot-admin] jderobot-r943 - in trunk: . src/components src/components/basic_server

frivas en jderobot.org frivas en jderobot.org
Mar Jul 16 13:21:14 CEST 2013


Author: frivas
Date: 2013-07-16 13:20:14 +0200 (Tue, 16 Jul 2013)
New Revision: 943

Added:
   trunk/src/components/basic_server/
   trunk/src/components/basic_server/CMakeLists.txt
   trunk/src/components/basic_server/basic_server.cfg
   trunk/src/components/basic_server/basic_server.cpp
   trunk/src/components/basic_server/myInterface.ice
Modified:
   trunk/CMakeLists.txt
Log:
a?\195?\177adido componente basic_server


Modified: trunk/CMakeLists.txt
===================================================================
--- trunk/CMakeLists.txt	2013-07-16 08:07:43 UTC (rev 942)
+++ trunk/CMakeLists.txt	2013-07-16 11:20:14 UTC (rev 943)
@@ -27,7 +27,7 @@
 		cameraview			recorder
 		cameraview_icestorm  kinectViewer        
 		wiimoteClient
-		       colortuner replayController
+		       colortuner replayController basic_server
 
 
 		

Added: trunk/src/components/basic_server/CMakeLists.txt
===================================================================
--- trunk/src/components/basic_server/CMakeLists.txt	                        (rev 0)
+++ trunk/src/components/basic_server/CMakeLists.txt	2013-07-16 11:20:14 UTC (rev 943)
@@ -0,0 +1,21 @@
+
+
+
+add_custom_command(OUTPUT myInterface.cpp myInterface.h
+                   COMMAND slice2cpp myInterface.ice
+	)
+
+SET( SOURCE_FILES  basic_server.cpp myInterface.cpp)
+
+
+include_directories(
+    ${INTERFACES_CPP_DIR}
+    ${LIBS_DIR}
+    ${CMAKE_CURRENT_SOURCE_DIR}
+)
+
+add_executable (basic_server  ${SOURCE_FILES})
+
+TARGET_LINK_LIBRARIES(basic_server 
+	${ZeroCIce_LIBRARIES}    	
+)

Added: trunk/src/components/basic_server/basic_server.cfg
===================================================================
--- trunk/src/components/basic_server/basic_server.cfg	                        (rev 0)
+++ trunk/src/components/basic_server/basic_server.cfg	2013-07-16 11:20:14 UTC (rev 943)
@@ -0,0 +1,35 @@
+#without registry
+myComponent.Endpoints=default -h 0.0.0.0 -p 9998
+#with registry
+#cameras configuration
+myComponent.NCameras=1
+myComponent.PlayerDetection=1
+myComponent.Width=320
+myComponent.Height=240
+myComponent.Fps=20
+
+#camera 1
+myComponent.deviceId=0
+myComponent.CameraRGB.Name=cameraA
+myComponent.CameraRGB.Format=RGB8
+myComponent.CameraRGB.fps=10
+myComponent.CameraRGB.PlayerDetection=0
+
+#myComponent.calibration=./config/camRGB
+myComponent.CameraDEPTH.Name=cameraB
+myComponent.CameraDEPTH.Format=RGB8
+myComponent.CameraDEPTH.fps=10
+myComponent.CameraDEPTH.PlayerDetection=0
+
+myComponent.PointCloud.Name=pointcloud1
+
+
+
+#Other components
+myComponent.CameraRGB=1
+myComponent.CameraDEPTH=1
+myComponent.pointCloudActive=1
+myComponent.pointCloud.Fps=10
+myComponent.Pose3DMotorsActive=0
+myComponent.KinectLedsActive=0
+

Added: trunk/src/components/basic_server/basic_server.cpp
===================================================================
--- trunk/src/components/basic_server/basic_server.cpp	                        (rev 0)
+++ trunk/src/components/basic_server/basic_server.cpp	2013-07-16 11:20:14 UTC (rev 943)
@@ -0,0 +1,133 @@
+#include <Ice/Ice.h>
+#include <IceUtil/IceUtil.h>
+#include "myInterface.h"
+#include <signal.h>
+
+
+
+
+class myClassI: virtual public jderobot::myInterface {
+	public:
+	myClassI()
+	{
+
+		//...............
+		replyTask = new ReplyTask();
+		this->control=replyTask->start();//my own thread
+	}
+
+	~myClassI(){
+		this->replyTask->destroy();
+		this->control.join();
+	}
+
+	virtual void test(const Ice::Current&){
+
+	}
+
+
+	
+	private:
+		class ReplyTask: public IceUtil::Thread{
+		public:
+			ReplyTask():_done(false){
+
+		  }
+
+		virtual void run(){
+			while(!(_done)){
+				//thread code
+				std::cout << "running" << std::endl;
+				usleep(100000);
+			}
+		}
+
+		virtual void destroy(){
+			this->_done=true;
+		}
+		private:
+		bool _done;
+		};
+
+	typedef IceUtil::Handle<ReplyTask> ReplyTaskPtr;
+	ReplyTaskPtr replyTask;
+    IceUtil::ThreadControl control;
+	
+
+};
+
+
+Ice::CommunicatorPtr ic;
+bool killed;
+myClassI* interface1;
+
+
+void exitApplication(int s){
+
+	killed=true;
+
+	if (interface1 != NULL)
+		delete interface1;
+
+	ic->shutdown();
+	exit(0);
+}
+
+
+
+
+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;
+
+}
+
+	
+

Added: trunk/src/components/basic_server/myInterface.ice
===================================================================
--- trunk/src/components/basic_server/myInterface.ice	                        (rev 0)
+++ trunk/src/components/basic_server/myInterface.ice	2013-07-16 11:20:14 UTC (rev 943)
@@ -0,0 +1,8 @@
+
+
+module jderobot{  
+
+	interface myInterface{
+		void test();
+	};
+};



More information about the Jderobot-admin mailing list