Go to the documentation of this file.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 int i;
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"), i(0)
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 void updateHook() {
00062 cwport.write(i);
00063 swport.write(i);
00064 iwport.write(i);
00065 fwport.write(i);
00066 dwport.write( std::vector<double>(10,i) );
00067 ++i;
00068 }
00069 };
00070
00071 int ORO_main( int argc, char** argv)
00072 {
00073
00074
00075 if ( Logger::log().getLogLevel() < Logger::Info ) {
00076 Logger::log().setLogLevel( Logger::Info );
00077 log(Info) << argv[0]
00078 << " manually raises LogLevel to 'Info' (5). See also file 'orocos.log'."<<endlog();
00079 }
00080
00081
00082 NetcdfReporting rc("Reporting");
00083 rc.setPeriod(0.01);
00084 TestTaskContext gtc("MyPeer");
00085 gtc.setPeriod(0.005);
00086 TestTaskContext gtc2("MyPeer2");
00087 gtc.setPeriod(0.02);
00088
00089 TestTaskContext gtc3("MyPeer3");
00090 gtc.setPeriod(0.01);
00091
00092 rc.addPeer( >c );
00093 rc.addPeer( >c2 );
00094 rc.addPeer( >c3 );
00095 gtc.connectPeers( >c2 );
00096
00097 TaskBrowser tb( &rc );
00098
00099 cout <<endl<< " This demo allows reporting of 3 Components at 100Hz, 200Hz and 50Hz." << endl;
00100 cout << " Use 'reportComponent(\"MyPeer\")' and/or 'reportComponent(\"MyPeer2\")'" <<endl;
00101 cout << " Then invoke 'start()' and 'stop()'" <<endl;
00102 cout << " Other methods (type 'this') are available as well."<<endl;
00103
00104 tb.loop();
00105
00106 return 0;
00107 }
00108