$search
00001 00002 #include "deployment/DeploymentComponent.hpp" 00003 #include "taskbrowser/TaskBrowser.hpp" 00004 #include <rtt/InputPort.hpp> 00005 #include <rtt/os/main.h> 00006 #include <rtt/RTT.hpp> 00007 #include <vector> 00008 00009 using namespace Orocos; 00010 00011 class MyTask 00012 : public RTT::TaskContext 00013 { 00014 public: 00015 Property<std::vector<double> > limits; 00016 InputPort<double> p1; 00017 OutputPort<double> p2; 00018 OutputPort<double> p3; 00019 Attribute<double> a; 00020 00021 MyTask(std::string n) 00022 : RTT::TaskContext(n), 00023 limits("limits","desc", std::vector<double>(2) ), 00024 p1("p1"), 00025 p2("p2"), 00026 p3("p3"), 00027 a("a") 00028 { 00029 this->properties()->addProperty( limits); 00030 this->ports()->addPort( p1 ); 00031 this->ports()->addPort( p2 ); 00032 this->ports()->addPort( p3 ); 00033 this->addAttribute( a ); 00034 limits.set()[0] = 10; 00035 limits.set()[1] = 20; 00036 } 00037 }; 00038 00039 class HelloProvider 00040 : public RTT::TaskContext 00041 { 00042 public: 00043 bool hello() { 00044 RTT::Logger::In("connectOperations Test"); 00045 log(Info) << "Hello World!" << endlog(); 00046 return true; 00047 } 00048 00049 HelloProvider() 00050 : RTT::TaskContext("HelloProvider") 00051 { 00052 this->provides("hello_service")->addOperation("hello", &HelloProvider::hello, this); 00053 } 00054 }; 00055 00056 class HelloRequester 00057 : public RTT::TaskContext 00058 { 00059 public: 00060 RTT::OperationCaller<bool()> helloworld; 00061 HelloRequester() 00062 : RTT::TaskContext("HelloRequester"), 00063 helloworld("helloworld") 00064 { 00065 this->requires()->addOperationCaller(helloworld); 00066 } 00067 void virtual updateHook() { 00068 helloworld(); 00069 } 00070 }; 00071 00072 int ORO_main(int, char**) 00073 { 00074 RTT::Logger::Instance()->setLogLevel(RTT::Logger::Info); 00075 00076 MyTask t1("ComponentA"); 00077 MyTask t2("ComponentB"); 00078 MyTask t3("ComponentC"); 00079 00080 HelloProvider p; 00081 HelloRequester r; 00082 00083 { 00084 DeploymentComponent dc; 00085 dc.addPeer( &t1 ); 00086 dc.addPeer( &t2 ); 00087 dc.addPeer( &t3 ); 00088 dc.addPeer( &p ); 00089 dc.addPeer( &r ); 00090 dc.kickStart("deployment.cpf"); 00091 TaskBrowser tb(&dc); 00092 00093 tb.loop(); 00094 } 00095 return 0; 00096 }