deployment/tests/main.cpp
Go to the documentation of this file.
1 
4 #include <rtt/InputPort.hpp>
5 #include <rtt/os/main.h>
6 #include <rtt/RTT.hpp>
7 #include <vector>
8 
9 using namespace Orocos;
10 
11 class MyTask
12  : public RTT::TaskContext
13 {
14 public:
20 
21  MyTask(std::string n)
22  : RTT::TaskContext(n),
23  limits("limits","desc", std::vector<double>(2) ),
24  p1("p1"),
25  p2("p2"),
26  p3("p3"),
27  a("a")
28  {
29  this->properties()->addProperty( limits);
30  this->ports()->addPort( p1 );
31  this->ports()->addPort( p2 );
32  this->ports()->addPort( p3 );
33  this->addAttribute( a );
34  limits.set()[0] = 10;
35  limits.set()[1] = 20;
36  }
37 };
38 
39 // creates ports dynamically (ie in configureHook() )
41 : public RTT::TaskContext
42 {
43 public:
46 
47  MyDynamicTask(std::string n)
48  : RTT::TaskContext(n),
49  d1("d1"),
50  d2("d2")
51  {
52  }
53  virtual bool configureHook()
54  {
55  this->ports()->addPort( d1 );
56  this->ports()->addPort( d2 );
57  return true;
58  }
59 };
60 
62  : public RTT::TaskContext
63 {
64 public:
65  bool hello() {
66  RTT::Logger::In("connectOperations Test");
67  log(Info) << "Hello World!" << endlog();
68  return true;
69  }
70 
72  : RTT::TaskContext("HelloProvider")
73  {
74  this->provides("hello_service")->addOperation("hello", &HelloProvider::hello, this);
75  }
76 };
77 
79  : public RTT::TaskContext
80 {
81 public:
84  : RTT::TaskContext("HelloRequester"),
85  helloworld("helloworld")
86  {
87  this->requires()->addOperationCaller(helloworld);
88  }
89  void virtual updateHook() {
90  helloworld();
91  }
92 };
93 
94 int ORO_main(int, char**)
95 {
97  int exit_code = 0;
98 
99  MyTask t1("ComponentA");
100  MyTask t2("ComponentB");
101  MyTask t3("ComponentC");
102  MyDynamicTask t4("ComponentD");
103 
104  HelloProvider p;
105  HelloRequester r;
106 
107  {
109  dc.addPeer( &t1 );
110  dc.addPeer( &t2 );
111  dc.addPeer( &t3 );
112  dc.addPeer( &t4 );
113  dc.addPeer( &p );
114  dc.addPeer( &r );
115  dc.kickStart("deployment.cpf");
116 
117 #if defined(RTT_VERSION_GTE)
118 #if RTT_VERSION_GTE(2,8,99)
119  if (RTT::ConnPolicy::Default().size != 99 ||
120  RTT::ConnPolicy::Default().buffer_policy != RTT::Shared) {
121  log(Fatal) << "Default ConnPolicy not set correctly!" << endlog();
122  exit_code = 1;
123  }
124 #endif
125 #endif
126 
127  TaskBrowser tb(&dc);
128  tb.loop();
129  }
130  return exit_code;
131 }
void loop()
Call this method from ORO_main() to process keyboard input and thus startup the TaskBrowser.
RTT::OperationCaller< bool()> helloworld
OutputPort< double > p2
OutputPort< double > p3
MyTask(std::string n)
This component allows a text client to browse the peers of a peer RTT::TaskContext and execute comman...
Definition: TaskBrowser.hpp:86
Attribute< double > a
Fatal
static Logger * Instance(std::ostream &str=std::cerr)
MyDynamicTask(std::string n)
int ORO_main(int, char **)
bool addPeer(const std::string &from, const std::string &target)
bool kickStart(const std::string &file_name)
OutputPort< double > d2
InputPort< double > p1
Info
Property< std::vector< double > > limits
static ConnPolicy & Default()
reference_t set()
virtual bool configureHook()
Operation< Signature > & addOperation(Operation< Signature > &op)
InputPort< double > d1
virtual void updateHook()
void setLogLevel(LogLevel ll)


ocl
Author(s): OCL Development Team
autogenerated on Mon Mar 23 2020 04:47:19