00001 #include <iostream>
00002
00003 #include <rtt/os/main.h>
00004 #include <reporting/NetcdfReporting.hpp>
00005 #include <taskbrowser/TaskBrowser.hpp>
00006
00007 #include <rtt/extras/SlaveActivity.hpp>
00008 #include <rtt/Activity.hpp>
00009 #include <rtt/Port.hpp>
00010
00011 using namespace std;
00012 using namespace Orocos;
00013 using namespace RTT;
00014
00015 class TestTaskContext
00016 : public TaskContext
00017 {
00018 Property<string> hello;
00019 OutputPort<char> cwport;
00020 OutputPort<short> swport;
00021 OutputPort<int> iwport;
00022 OutputPort<float> fwport;
00023 OutputPort<std::vector<double> > dwport;
00024 InputPort<char> crport;
00025 InputPort<short> srport;
00026 InputPort<int> irport;
00027 InputPort<float> frport;
00028 InputPort<double> drport;
00029
00030 public:
00031 TestTaskContext(std::string name)
00032 : TaskContext(name),
00033 hello("Hello", "The hello thing", "World"),
00034 cwport("cw_port", 'a'),
00035 swport("sw_port", 1),
00036 iwport("iw_port", 0),
00037 fwport("fw_port", 0.0),
00038 dwport("dw_port"),
00039 crport("cr_port"),
00040 srport("sr_port"),
00041 irport("ir_port"),
00042 frport("fr_port"),
00043 drport("dr_port")
00044 {
00045 this->properties()->addProperty( hello );
00046 this->ports()->addPort( cwport );
00047 this->ports()->addPort( swport );
00048 this->ports()->addPort( iwport );
00049 this->ports()->addPort( fwport );
00050 this->ports()->addPort( dwport );
00051 this->ports()->addPort( crport );
00052 this->ports()->addPort( srport );
00053 this->ports()->addPort( irport );
00054 this->ports()->addPort( frport );
00055 this->ports()->addPort( drport );
00056
00057 std::vector<double> init(10, 5.4528);
00058 dwport.write( init );
00059 }
00060 };
00061
00062 class TestTaskContext2
00063 : public TaskContext
00064 {
00065 Property<string> hello;
00066 OutputPort<char> cwport;
00067 OutputPort<short> swport;
00068 OutputPort<int> iwport;
00069 OutputPort<float> fwport;
00070 OutputPort<double> dwport;
00071 InputPort<char> crport;
00072 InputPort<short> srport;
00073 InputPort<int> irport;
00074 InputPort<float> frport;
00075
00076 public:
00077 TestTaskContext2(std::string name)
00078 : TaskContext(name),
00079 hello("Hello", "The hello thing", "World"),
00080 cwport("cw_port", 'b'),
00081 swport("sw_port", 1),
00082 iwport("iw_port", 0),
00083 fwport("fw_port", 0.0),
00084 dwport("dw_port"),
00085 crport("cr_port"),
00086 srport("sr_port"),
00087 irport("ir_port"),
00088 frport("fr_port")
00089 {
00090 this->properties()->addProperty( hello );
00091 this->ports()->addPort( cwport );
00092 this->ports()->addPort( swport );
00093 this->ports()->addPort( iwport );
00094 this->ports()->addPort( fwport );
00095 this->ports()->addPort( dwport );
00096 this->ports()->addPort( crport );
00097 this->ports()->addPort( srport );
00098 this->ports()->addPort( irport );
00099 this->ports()->addPort( frport );
00100 }
00101 };
00102
00103 int ORO_main( int argc, char** argv)
00104 {
00105
00106
00107 if ( Logger::log().getLogLevel() < Logger::Info ) {
00108 Logger::log().setLogLevel( Logger::Info );
00109 log(Info) << argv[0]
00110 << " manually raises LogLevel to 'Info' (5). See also file 'orocos.log'."<<endlog();
00111 }
00112
00113
00114 Activity act(10, 0.1);
00115 NetcdfReporting rc("Reporting");
00116 TestTaskContext gtc("MyPeer");
00117 TestTaskContext2 gtc2("MyPeer2");
00118
00119 TestTaskContext2 gtc3("MySoloPeer");
00120
00121 rc.addPeer( >c );
00122 rc.addPeer( >c2 );
00123 rc.addPeer( >c3 );
00124 gtc.connectPeers( >c2 );
00125
00126 TaskBrowser tb( &rc );
00127
00128 act.run( rc.engine() );
00129
00130 cout <<endl<< " This demo allows reporting of Components." << endl;
00131 cout << " Use 'reportComponent(\"MyPeer\")' and/or 'reportComponent(\"MyPeer2\")'" <<endl;
00132 cout << " Then invoke 'start()' and 'stop()'" <<endl;
00133 cout << " Other methods (type 'this') are available as well."<<endl;
00134
00135 tb.loop();
00136
00137 act.stop();
00138
00139 return 0;
00140 }
00141