ncmain.cpp
Go to the documentation of this file.
1 #include <iostream>
2 
3 #include <rtt/os/main.h>
6 
8 #include <rtt/Activity.hpp>
9 #include <rtt/Port.hpp>
10 
11 using namespace std;
12 using namespace Orocos;
13 using namespace RTT;
14 
15 class TestTaskContext
16  : public TaskContext
17 {
18  Property<string> hello;
28  InputPort<double> drport;
29  int i;
30 public:
31  TestTaskContext(std::string name)
32  : TaskContext(name),
33  hello("Hello", "The hello thing", "World"),
34  cwport("cw_port", 'a'),
35  swport("sw_port", 1),
36  iwport("iw_port", 0),
37  fwport("fw_port", 0.0),
38  dwport("dw_port"),
39  crport("cr_port"),
40  srport("sr_port"),
41  irport("ir_port"),
42  frport("fr_port"),
43  drport("dr_port"), i(0)
44  {
45  this->properties()->addProperty( hello );
46  this->ports()->addPort( cwport );
47  this->ports()->addPort( swport );
48  this->ports()->addPort( iwport );
49  this->ports()->addPort( fwport );
50  this->ports()->addPort( dwport );
51  this->ports()->addPort( crport );
52  this->ports()->addPort( srport );
53  this->ports()->addPort( irport );
54  this->ports()->addPort( frport );
55  this->ports()->addPort( drport );
56  // write initial value.
57  std::vector<double> init(10, 5.4528);
58  dwport.write( init );
59  }
60 
61  void updateHook() {
62  cwport.write(i);
63  swport.write(i);
64  iwport.write(i);
65  fwport.write(i);
66  dwport.write( std::vector<double>(10,i) );
67  ++i;
68  }
69 };
70 
71 int ORO_main( int argc, char** argv)
72 {
73  // Set log level more verbose than default,
74  // such that we can see output :
75  if ( Logger::log().getLogLevel() < Logger::Info ) {
76  Logger::log().setLogLevel( Logger::Info );
77  log(Info) << argv[0]
78  << " manually raises LogLevel to 'Info' (5). See also file 'orocos.log'."<<endlog();
79  }
80 
81 
82  NetcdfReporting rc("Reporting");
83  rc.setPeriod(0.01);
84  TestTaskContext gtc("MyPeer");
85  gtc.setPeriod(0.005);
86  TestTaskContext gtc2("MyPeer2");
87  gtc.setPeriod(0.02);
88 
89  TestTaskContext gtc3("MyPeer3");
90  gtc.setPeriod(0.01);
91 
92  rc.addPeer( &gtc );
93  rc.addPeer( &gtc2 );
94  rc.addPeer( &gtc3 );
95  gtc.connectPeers( &gtc2 );
96 
97  TaskBrowser tb( &rc );
98 
99  cout <<endl<< " This demo allows reporting of 3 Components at 100Hz, 200Hz and 50Hz." << endl;
100  cout << " Use 'reportComponent(\"MyPeer\")' and/or 'reportComponent(\"MyPeer2\")'" <<endl;
101  cout << " Then invoke 'start()' and 'stop()'" <<endl;
102  cout << " Other methods (type 'this') are available as well."<<endl;
103 
104  tb.loop();
105 
106  return 0;
107 }
108 
void loop()
Call this method from ORO_main() to process keyboard input and thus startup the TaskBrowser.
InputPort< int > irport
Definition: ncmain.cpp:26
This component allows a text client to browse the peers of a peer RTT::TaskContext and execute comman...
Definition: TaskBrowser.hpp:86
OutputPort< float > fwport
Definition: ncmain.cpp:22
OutputPort< char > cwport
Definition: ncmain.cpp:19
InputPort< float > frport
Definition: ncmain.cpp:27
virtual bool connectPeers(TaskContext *peer)
int ORO_main(int argc, char **argv)
Definition: ncmain.cpp:71
InputPort< short > srport
Definition: ncmain.cpp:25
TestTaskContext(std::string name)
Definition: ncmain.cpp:31
printstream cout
OutputPort< short > swport
Definition: ncmain.cpp:20
OutputPort< int > iwport
Definition: ncmain.cpp:21
WriteStatus write(const T &sample)
basic_ostreams & endl(basic_ostreams &s)
void updateHook()
Definition: ncmain.cpp:61
Info
virtual bool setPeriod(Seconds s)
virtual bool addPeer(TaskContext *peer, std::string alias="")
InputPort< char > crport
Definition: ncmain.cpp:24


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