1
1
#include < iostream>
2
2
#include " corba.hh"
3
3
#include " corba_name_service_client.hh"
4
+ #include < rtt/Activity.hpp>
4
5
#include < rtt/transports/corba/TaskContextProxy.hpp>
5
6
6
7
12
13
13
14
#include < boost/filesystem.hpp>
14
15
#include < rtt/plugin/PluginLoader.hpp>
16
+ #include < rtt/InputPort.hpp>
15
17
16
18
void loadAllPluginsInDir (const std::string &path)
17
19
{
@@ -65,24 +67,36 @@ int main(int argc, char** argv)
65
67
66
68
CorbaAccess::init (argc, argv);
67
69
CorbaAccess *acc = CorbaAccess::instance ();
68
-
69
- corba::NameServiceClient client;
70
70
71
- std::vector<std::string> taskList = client.getTaskContextNames ();
71
+ corba::NameServiceClient client;
72
+
73
+ std::vector<std::string> taskList;
74
+ try {
75
+ taskList = client.getTaskContextNames ();
76
+ } catch (CosNaming::NamingContext::NotFound e)
77
+ {
78
+ std::cout << " Could not get Task Context list." << std::endl;
79
+ exit (EXIT_FAILURE);
80
+ }
72
81
73
82
RTT::base::PortInterface *portReader;
74
-
83
+ RTT::base::InputPortInterface *inputPort;
84
+ RTT::base::OutputPortInterface *outputPort;
75
85
for (std::vector<std::string>::const_iterator it = taskList.begin (); it != taskList.end (); it++)
76
86
{
77
87
std::cout << " Task : " << *it << std::endl;
78
88
79
89
std::string curIOR = client.getIOR (*it);
80
90
// std::cout << "IOR is " << curIOR << std::endl;
81
91
82
- if (*it == " command_server " )
92
+ if (*it == " orogen_default_mirror__Task " )
83
93
{
84
-
94
+
85
95
RTT::corba::TaskContextProxy *proxy = RTT::corba::TaskContextProxy::Create (curIOR, true );
96
+
97
+ proxy->configure ();
98
+ proxy->start ();
99
+
86
100
RTT::DataFlowInterface *flowInterface = proxy->ports ();
87
101
std::vector<RTT::base::PortInterface*> ports = flowInterface->getPorts ();
88
102
std::cout << " Number ports is " << flowInterface->getPorts ().size () << std::endl;
@@ -97,6 +111,12 @@ int main(int argc, char** argv)
97
111
98
112
std::cout << " Port name " << (iface)->getName () << " is input " << (input != 0 )<< " is output" << (output != 0 ) << std::endl;
99
113
}
114
+
115
+ inputPort = dynamic_cast <RTT::base::InputPortInterface *>(proxy->getPort (" input" ));
116
+ outputPort = dynamic_cast <RTT::base::OutputPortInterface *>(proxy->getPort (" output" ));
117
+
118
+ std::cout << " Cast to port " << dynamic_cast <RTT::OutputPort<std::string> *>(outputPort) << std::endl;
119
+
100
120
RTT::TaskContext::PeerList peers = proxy->getPeerList ();
101
121
102
122
std::cout << " Number of peers " << peers.size () << std::endl;
@@ -108,6 +128,49 @@ int main(int argc, char** argv)
108
128
}
109
129
}
110
130
131
+ RTT::OutputPort<std::string> *writer = dynamic_cast <RTT::OutputPort<std::string> *>(inputPort->antiClone ());
132
+ RTT::InputPort<std::string> *reader = dynamic_cast <RTT::InputPort<std::string> *>(outputPort->antiClone ());
133
+
134
+ RTT::TaskContext context (" orocosCpp" );
135
+
136
+ // RTT::Activity* activity_orogen_default_mirror__Task = new RTT::Activity(
137
+ // ORO_SCHED_OTHER,
138
+ // RTT::os::LowestPriority,
139
+ // 0.1,
140
+ // context.engine(),
141
+ // "orogen_default_mirror__Task");
142
+ // RTT::os::Thread* thread_orogen_default_mirror__Task =
143
+ // dynamic_cast<RTT::os::Thread*>(activity_orogen_default_mirror__Task->thread());
144
+ // thread_orogen_default_mirror__Task->setMaxOverrun(-1);
145
+ //
146
+ // context.setActivity(activity_orogen_default_mirror__Task);
147
+ //
148
+ // { RTT::os::Thread* thread = dynamic_cast<RTT::os::Thread*>(activity_orogen_default_mirror__Task);
149
+ // if (thread)
150
+ // thread->setStopTimeout(10);
151
+ // }
152
+
153
+
154
+ context.addPort (*writer);
155
+ context.addPort (*reader);
156
+
157
+
158
+ std::string foo (" FOOOOOOOOOO" );
159
+ writer->connectTo (inputPort);
160
+ reader->connectTo (outputPort);
161
+
162
+
163
+ writer->write (foo);
164
+
165
+ std::string foo2;
166
+
167
+ while (reader->read (foo2) != RTT::NewData)
168
+ {
169
+ usleep (10000 );
170
+ }
171
+
172
+ std::cout << " Resulting sample is " << foo2 << std::endl;
173
+
111
174
// while(true)
112
175
// {
113
176
// portReader;
0 commit comments