main.cpp
Go to the documentation of this file.
00001 #include "taskbrowser/TaskBrowser.hpp"
00002 
00003 #include <rtt/extras/SlaveActivity.hpp>
00004 #include <rtt/Activity.hpp>
00005 #include <rtt/Port.hpp>
00006 #include <rtt/os/main.h>
00007 
00008 using namespace std;
00009 using namespace Orocos;
00010 using namespace RTT;
00011 
00012 class TestTaskContext
00013     : public RTT::TaskContext
00014 {
00015     RTT::Property<string> hello;
00016     OutputPort<std::vector<double> > dwport;
00017     InputPort<double> drport;
00018 
00019 public:
00020     TestTaskContext(std::string name)
00021         : RTT::TaskContext(name),
00022           hello("Hello", "The hello thing", "World"),
00023           dwport("D2Port"),
00024           drport("D1Port")
00025     {
00026         this->properties()->addProperty( hello );
00027         this->ports()->addPort( drport );
00028         this->ports()->addPort( dwport );
00029 
00030         std::vector<double> init(10, 1.0);
00031         dwport.write(init);
00032     }
00033 };
00034 
00035 class TestTaskContext2
00036     : public RTT::TaskContext
00037 {
00038     RTT::Property<string> hello;
00039     OutputPort<double> dwport;
00040     InputPort<std::vector<double> > drport;
00041 
00042 public:
00043     TestTaskContext2(std::string name)
00044         : RTT::TaskContext(name),
00045           hello("Hello", "The hello thing", "World"),
00046           dwport("D1Port"),
00047           drport("D2Port")
00048     {
00049         this->properties()->addProperty( hello );
00050         this->ports()->addPort( drport );
00051         this->ports()->addPort( dwport );
00052 
00053         // write initial value.
00054         dwport.write( 0.0 );
00055     }
00056 };
00057 
00058 int ORO_main( int argc, char** argv)
00059 {
00060     // Set log level more verbose than default,
00061     // such that we can see output :
00062     if ( RTT::Logger::log().getLogLevel() < RTT::Logger::Info ) {
00063         RTT::Logger::log().setLogLevel( RTT::Logger::Info );
00064         log(Info) << argv[0] << " manually raises LogLevel to 'Info' (5). See also file 'orocos.log'."<<endlog();
00065     }
00066 
00067     TestTaskContext gtc("MyPeer");
00068     TestTaskContext2 gtc2("MyPeer2");
00069 
00070     TestTaskContext2 gtc3("MySoloPeer");
00071 
00072     gtc.connectPeers( &gtc2 );
00073 
00074     TaskBrowser tb( &gtc );
00075 
00076     log(Info) <<endlog()<< "  This demo demonstrates interaction with Components." << endlog();
00077     log(Info) << "  Use 'enter' and/or 'leave' to go 'inside' or 'outside' a component. " <<endlog();
00078     log(Info) << "  The inside interface shows the methods and ports of the visited component," <<endlog();
00079     log(Info) << "  the outside interface show the methods and ports of the TaskBrowser."<<endlog();
00080 
00081     RTT::Activity act(10, 1.0, gtc.engine());
00082 
00083     tb.loop();
00084 
00085     act.stop();
00086 
00087     return 0;
00088 }
00089 


ocl
Author(s): OCL Development Team
autogenerated on Thu Jan 2 2014 11:38:08