19 #include <rtm/idl/OpenRTMSkel.h> 26 #include <coil/stringutil.h> 33 std::cout << std::endl;
34 std::cout <<
"usage: ConnectorCompExt [options].." << std::endl;
35 std::cout << std::endl;
36 std::cout <<
" --flush ";
37 std::cout <<
": Set subscription type flush" << std::endl;
38 std::cout <<
" --new ";
39 std::cout <<
": Set subscription type new" << std::endl;
40 std::cout <<
" --periodic [Hz] ";
41 std::cout <<
": Set subscription type periodic" << std::endl;
42 std::cout <<
" --policy [any] ";
43 std::cout <<
": Set push policy ALL or FIFO or SKIP or NEW" << std::endl;
44 std::cout <<
" --skip [n] ";
45 std::cout <<
": Set skip count 0..n" << std::endl;
46 std::cout << std::endl;
47 std::cout <<
"exsample:" << std::endl;
48 std::cout <<
" ConnectorCompExt --flush" << std::endl;
49 std::cout <<
" ConnectorCompExt --new" << std::endl;
50 std::cout <<
" ConnectorCompExt --new --policy ALL" << std::endl;
51 std::cout <<
" ConnectorCompExt --new --policy SKIP --skip 100" << std::endl;
52 std::cout <<
" ConnectorCompExt --periodic 10" << std::endl;
53 std::cout <<
" ConnectorCompExt --periodic 10 --policy FIFO" << std::endl;
54 std::cout <<
" ConnectorCompExt --periodic 10 --policy NEW" << std::endl;
55 std::cout << std::endl;
58 int main (
int argc,
char** argv)
63 std::string subs_type;
65 std::string push_policy;
66 std::string skip_count;
72 for (
int i = 1; i < argc; ++i)
74 std::string arg(argv[i]);
76 if (arg ==
"--flush") subs_type =
"flush";
77 else if (arg ==
"--new") subs_type =
"new";
78 else if (arg ==
"--periodic")
80 subs_type =
"periodic";
81 if (++i < argc) period = argv[i];
84 else if (arg ==
"--help")
89 else if (arg ==
"--policy")
93 std::string arg2(argv[i]);
97 else push_policy =
"new";
99 else if (arg ==
"--skip")
101 if (++i < argc) skip_count = argv[i];
102 else skip_count =
"0";
110 std::cout <<
"Subscription Type: " << subs_type << std::endl;
112 std::cout <<
"Period: " << period <<
" [Hz]" << std::endl;
113 std::cout <<
"push policy: " << push_policy << std::endl;
114 std::cout <<
"skip count: " << skip_count << std::endl;
117 CORBA::ORB_var orb = CORBA::ORB_init(_argc, _argv);
123 PortServiceList_var pin;
124 PortServiceList_var pout;
130 pin = conin->get_ports();
131 pin[(CORBA::ULong)0]->disconnect_all();
132 assert(pin->length() > 0);
134 ExecutionContextList_var eclisti;
135 eclisti = conin->get_owned_contexts();
136 eclisti[(CORBA::ULong)0]->activate_component(RTObject::_duplicate(conin.
_ptr()));
142 pout = conout->get_ports();
143 pout[(CORBA::ULong)0]->disconnect_all();
144 assert(pout->length() > 0);
146 ExecutionContextList_var eclisto;
147 eclisto = conout->get_owned_contexts();
148 eclisto[(CORBA::ULong)0]->activate_component(RTObject::_duplicate(conout.
_ptr()));
152 ConnectorProfile prof;
153 prof.connector_id =
"";
154 prof.name = CORBA::string_dup(
"connector0");
155 prof.ports.length(2);
156 prof.ports[0] = pin[(CORBA::ULong)0];
157 prof.ports[1] = pout[(CORBA::ULong)0];
172 if (subs_type ==
"periodic" && period !=
"")
176 if (push_policy !=
"")
179 push_policy.c_str()));
180 if (push_policy ==
"skip" && skip_count !=
"")
183 skip_count.c_str()));
186 ret = pin[(CORBA::ULong)0]->connect(prof);
189 std::cout <<
"Connector ID: " << prof.connector_id << std::endl;
197 std::cout << std::endl;
198 std::cout << std::endl;
199 std::cout <<
"0: tick ConsoleIn component" << std::endl;
200 std::cout <<
"1: tick ConsoleOut component" << std::endl;
201 std::cout <<
"2: tick both components" << std::endl;
202 std::cout <<
"cmd? >";
SDOPackage::NameValue newNV(const char *name, Value value)
Create NameValue.
std::string normalize(std::string &str)
Erase the head/tail blank and replace upper case to lower case.
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
CORBA::Object_ptr resolve(const CosNaming::Name &name)
Return object bound on the specified NameComponent.
virtual bool setObject(CORBA::Object_ptr obj)
Set Object.
int main(int argc, char **argv)
CORBA naming service helper class.
NameValue and NVList utility functions.
CORBA sequence utility template functions.
void dump(const SDOPackage::NVList &nv)
Print information configured in NVList as a string type to Standard Outport.
ObjectTypePtr _ptr()
Get Object reference narrowed as ObjectType.
void push_back(CorbaSequence &seq, SequenceElement elem)
Push the new element back to the CORBA sequence.