Skip to content

Commit 3e5dffc

Browse files
Janosch MachowinskiJanosch Machowinski
Janosch Machowinski
authored and
Janosch Machowinski
committed
got simple test case working
1 parent bc62a37 commit 3e5dffc

File tree

1 file changed

+69
-6
lines changed

1 file changed

+69
-6
lines changed

src/Main.cpp

+69-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <iostream>
22
#include "corba.hh"
33
#include "corba_name_service_client.hh"
4+
#include <rtt/Activity.hpp>
45
#include <rtt/transports/corba/TaskContextProxy.hpp>
56

67

@@ -12,6 +13,7 @@
1213

1314
#include <boost/filesystem.hpp>
1415
#include <rtt/plugin/PluginLoader.hpp>
16+
#include <rtt/InputPort.hpp>
1517

1618
void loadAllPluginsInDir(const std::string &path)
1719
{
@@ -65,24 +67,36 @@ int main(int argc, char** argv)
6567

6668
CorbaAccess::init(argc, argv);
6769
CorbaAccess *acc = CorbaAccess::instance();
68-
69-
corba::NameServiceClient client;
7070

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+
}
7281

7382
RTT::base::PortInterface *portReader;
74-
83+
RTT::base::InputPortInterface *inputPort;
84+
RTT::base::OutputPortInterface *outputPort;
7585
for(std::vector<std::string>::const_iterator it = taskList.begin(); it != taskList.end(); it++)
7686
{
7787
std::cout << "Task : " << *it << std::endl;
7888

7989
std::string curIOR = client.getIOR(*it);
8090
// std::cout << "IOR is " << curIOR << std::endl;
8191

82-
if(*it == "command_server")
92+
if(*it == "orogen_default_mirror__Task")
8393
{
84-
94+
8595
RTT::corba::TaskContextProxy *proxy = RTT::corba::TaskContextProxy::Create(curIOR, true);
96+
97+
proxy->configure();
98+
proxy->start();
99+
86100
RTT::DataFlowInterface *flowInterface = proxy->ports();
87101
std::vector<RTT::base::PortInterface*> ports = flowInterface->getPorts();
88102
std::cout << "Number ports is " << flowInterface->getPorts().size() << std::endl;
@@ -97,6 +111,12 @@ int main(int argc, char** argv)
97111

98112
std::cout << "Port name " << (iface)->getName() << " is input " << (input != 0)<< " is output" << (output != 0) << std::endl;
99113
}
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+
100120
RTT::TaskContext::PeerList peers = proxy->getPeerList();
101121

102122
std::cout << "Number of peers " << peers.size() << std::endl;
@@ -108,6 +128,49 @@ int main(int argc, char** argv)
108128
}
109129
}
110130

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+
111174
// while(true)
112175
// {
113176
// portReader;

0 commit comments

Comments
 (0)