taskbrowser/tests/main.cpp
Go to the documentation of this file.
2 
4 #include <rtt/Activity.hpp>
5 #include <rtt/Port.hpp>
6 #include <rtt/os/main.h>
7 
8 using namespace std;
9 using namespace Orocos;
10 using namespace RTT;
11 
12 class TestTaskContext
13  : public RTT::TaskContext
14 {
17  InputPort<double> drport;
18 
19 public:
20  TestTaskContext(std::string name)
21  : RTT::TaskContext(name),
22  hello("Hello", "The hello thing", "World"),
23  dwport("D2Port"),
24  drport("D1Port")
25  {
26  this->properties()->addProperty( hello );
27  this->ports()->addPort( drport );
28  this->ports()->addPort( dwport );
29 
30  std::vector<double> init(10, 1.0);
31  dwport.write(init);
32  }
33 };
34 
35 class TestTaskContext2
36  : public RTT::TaskContext
37 {
39  OutputPort<double> dwport;
41 
42 public:
43  TestTaskContext2(std::string name)
44  : RTT::TaskContext(name),
45  hello("Hello", "The hello thing", "World"),
46  dwport("D1Port"),
47  drport("D2Port")
48  {
49  this->properties()->addProperty( hello );
50  this->ports()->addPort( drport );
51  this->ports()->addPort( dwport );
52 
53  // write initial value.
54  dwport.write( 0.0 );
55  }
56 };
57 
58 int ORO_main( int argc, char** argv)
59 {
60  // Set log level more verbose than default,
61  // such that we can see output :
62  if ( RTT::Logger::log().getLogLevel() < RTT::Logger::Info ) {
64  log(Info) << argv[0] << " manually raises LogLevel to 'Info' (5). See also file 'orocos.log'."<<endlog();
65  }
66 
67  TestTaskContext gtc("MyPeer");
68  TestTaskContext2 gtc2("MyPeer2");
69 
70  TestTaskContext2 gtc3("MySoloPeer");
71 
72  gtc.connectPeers( &gtc2 );
73 
74  TaskBrowser tb( &gtc );
75 
76  log(Info) <<endlog()<< " This demo demonstrates interaction with Components." << endlog();
77  log(Info) << " Use 'enter' and/or 'leave' to go 'inside' or 'outside' a component. " <<endlog();
78  log(Info) << " The inside interface shows the methods and ports of the visited component," <<endlog();
79  log(Info) << " the outside interface show the methods and ports of the TaskBrowser."<<endlog();
80 
81  RTT::Activity act(10, 1.0, gtc.engine());
82 
83  tb.loop();
84 
85  act.stop();
86 
87  return 0;
88 }
89 
void loop()
Call this method from ORO_main() to process keyboard input and thus startup the TaskBrowser.
This component allows a text client to browse the peers of a peer RTT::TaskContext and execute comman...
Definition: TaskBrowser.hpp:86
virtual bool connectPeers(TaskContext *peer)
int ORO_main(int argc, char **argv)
RTT::Property< string > hello
TestTaskContext(std::string name)
WriteStatus write(const T &sample)
RTT::Property< string > hello
Info
static Logger & log()
TestTaskContext2(std::string name)
const ExecutionEngine * engine() const
void setLogLevel(LogLevel ll)


ocl
Author(s): OCL Development Team
autogenerated on Wed Jun 26 2019 19:26:27