Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
deployment
tests
deployment/tests/main.cpp
Go to the documentation of this file.
1
2
#include "
deployment/DeploymentComponent.hpp
"
3
#include "
taskbrowser/TaskBrowser.hpp
"
4
#include <
rtt/InputPort.hpp
>
5
#include <
rtt/os/main.h
>
6
#include <
rtt/RTT.hpp
>
7
#include <vector>
8
9
using namespace
Orocos
;
10
11
class
MyTask
12
:
public
RTT::TaskContext
13
{
14
public
:
15
Property<std::vector<double>
>
limits
;
16
InputPort<double>
p1
;
17
OutputPort<double>
p2
;
18
OutputPort<double>
p3
;
19
Attribute<double>
a
;
20
21
MyTask
(std::string n)
22
:
RTT
::
TaskContext
(n),
23
limits(
"limits"
,
"desc"
,
std
::vector<double>(2) ),
24
p1(
"p1"
),
25
p2(
"p2"
),
26
p3(
"p3"
),
27
a(
"a"
)
28
{
29
this->properties()->addProperty( limits);
30
this->ports()->addPort( p1 );
31
this->ports()->addPort( p2 );
32
this->ports()->addPort( p3 );
33
this->addAttribute( a );
34
limits.
set
()[0] = 10;
35
limits.
set
()[1] = 20;
36
}
37
};
38
39
// creates ports dynamically (ie in configureHook() )
40
class
MyDynamicTask
41
:
public
RTT::TaskContext
42
{
43
public
:
44
InputPort<double>
d1
;
45
OutputPort<double>
d2
;
46
47
MyDynamicTask
(std::string n)
48
:
RTT
::
TaskContext
(n),
49
d1(
"d1"
),
50
d2(
"d2"
)
51
{
52
}
53
virtual
bool
configureHook
()
54
{
55
this->ports()->addPort( d1 );
56
this->ports()->addPort( d2 );
57
return
true
;
58
}
59
};
60
61
class
HelloProvider
62
:
public
RTT::TaskContext
63
{
64
public
:
65
bool
hello
() {
66
RTT::Logger::In
(
"connectOperations Test"
);
67
log(
Info
) <<
"Hello World!"
<< endlog();
68
return
true
;
69
}
70
71
HelloProvider
()
72
:
RTT
::
TaskContext
(
"HelloProvider"
)
73
{
74
this->provides(
"hello_service"
)->
addOperation
(
"hello"
, &
HelloProvider::hello
,
this
);
75
}
76
};
77
78
class
HelloRequester
79
:
public
RTT::TaskContext
80
{
81
public
:
82
RTT::OperationCaller<bool()>
helloworld
;
83
HelloRequester
()
84
:
RTT
::
TaskContext
(
"HelloRequester"
),
85
helloworld(
"helloworld"
)
86
{
87
this->requires()->addOperationCaller(helloworld);
88
}
89
void
virtual
updateHook
() {
90
helloworld();
91
}
92
};
93
94
int
ORO_main
(
int
,
char
**)
95
{
96
RTT::Logger::Instance
()->
setLogLevel
(
RTT::Logger::Info
);
97
int
exit_code = 0;
98
99
MyTask
t1(
"ComponentA"
);
100
MyTask
t2(
"ComponentB"
);
101
MyTask
t3(
"ComponentC"
);
102
MyDynamicTask
t4(
"ComponentD"
);
103
104
HelloProvider
p;
105
HelloRequester
r;
106
107
{
108
DeploymentComponent
dc;
109
dc.
addPeer
( &t1 );
110
dc.
addPeer
( &t2 );
111
dc.
addPeer
( &t3 );
112
dc.
addPeer
( &t4 );
113
dc.
addPeer
( &p );
114
dc.
addPeer
( &r );
115
dc.
kickStart
(
"deployment.cpf"
);
116
117
#if defined(RTT_VERSION_GTE)
118
#if RTT_VERSION_GTE(2,8,99)
119
if
(
RTT::ConnPolicy::Default
().size != 99 ||
120
RTT::ConnPolicy::Default
().buffer_policy !=
RTT::Shared
) {
121
log(
Fatal
) <<
"Default ConnPolicy not set correctly!"
<< endlog();
122
exit_code = 1;
123
}
124
#endif
125
#endif
126
127
TaskBrowser
tb(&dc);
128
tb.
loop
();
129
}
130
return
exit_code;
131
}
OCL::TaskBrowser::loop
void loop()
Call this method from ORO_main() to process keyboard input and thus startup the TaskBrowser.
Definition:
TaskBrowser.cpp:844
HelloRequester::helloworld
RTT::OperationCaller< bool()> helloworld
Definition:
deployment/tests/main.cpp:82
MyTask::p2
OutputPort< double > p2
Definition:
deployment/tests/main.cpp:17
HelloProvider::HelloProvider
HelloProvider()
Definition:
deployment/tests/main.cpp:71
MyTask::p3
OutputPort< double > p3
Definition:
deployment/tests/main.cpp:18
MyTask::MyTask
MyTask(std::string n)
Definition:
deployment/tests/main.cpp:21
OCL::TaskBrowser
This component allows a text client to browse the peers of a peer RTT::TaskContext and execute comman...
Definition:
TaskBrowser.hpp:86
RTT::Logger::Info
Info
MyTask::a
Attribute< double > a
Definition:
deployment/tests/main.cpp:19
Fatal
Fatal
MyDynamicTask
Definition:
deployment/tests/main.cpp:40
RTT::Logger::Instance
static Logger * Instance(std::ostream &str=std::cerr)
std
HelloProvider::hello
bool hello()
Definition:
deployment/tests/main.cpp:65
MyDynamicTask::MyDynamicTask
MyDynamicTask(std::string n)
Definition:
deployment/tests/main.cpp:47
HelloRequester
Definition:
deployment/tests/main.cpp:78
TaskBrowser.hpp
RTT::InputPort< double >
ORO_main
int ORO_main(int, char **)
Definition:
deployment/tests/main.cpp:94
main.h
RTT::OperationCaller< bool()>
OCL::DeploymentComponent::addPeer
bool addPeer(const std::string &from, const std::string &target)
Definition:
DeploymentComponent.cpp:357
Orocos
OCL::DeploymentComponent::kickStart
bool kickStart(const std::string &file_name)
Definition:
DeploymentComponent.cpp:705
RTT::Property
MyDynamicTask::d2
OutputPort< double > d2
Definition:
deployment/tests/main.cpp:45
MyTask::p1
InputPort< double > p1
Definition:
deployment/tests/main.cpp:16
InputPort.hpp
MyTask
Definition:
deployment/tests/main.cpp:11
Info
Info
MyTask::limits
Property< std::vector< double > > limits
Definition:
deployment/tests/main.cpp:15
RTT::Logger::In
OCL::DeploymentComponent
Definition:
DeploymentComponent.hpp:86
RTT::ConnPolicy::Default
static ConnPolicy & Default()
RTT::TaskContext
RTT::OutputPort< double >
DeploymentComponent.hpp
RTT::Property::set
reference_t set()
HelloProvider
Definition:
deployment/tests/main.cpp:61
RTT::Attribute< double >
RTT
MyDynamicTask::configureHook
virtual bool configureHook()
Definition:
deployment/tests/main.cpp:53
RTT.hpp
RTT::TaskContext::addOperation
Operation< Signature > & addOperation(Operation< Signature > &op)
HelloRequester::HelloRequester
HelloRequester()
Definition:
deployment/tests/main.cpp:83
MyDynamicTask::d1
InputPort< double > d1
Definition:
deployment/tests/main.cpp:44
RTT::Shared
Shared
HelloRequester::updateHook
virtual void updateHook()
Definition:
deployment/tests/main.cpp:89
RTT::Logger::setLogLevel
void setLogLevel(LogLevel ll)
ocl
Author(s): OCL Development Team
autogenerated on Wed Jun 26 2019 19:26:27