19 #include <rtm/idl/OpenRTMSkel.h> 26 #include <coil/stringutil.h> 37 std::cout << std::endl;
38 std::cout <<
"usage: ConnectorCompExt [options].." << std::endl;
39 std::cout << std::endl;
40 std::cout <<
" --flush ";
41 std::cout <<
": Set subscription type flush" << std::endl;
42 std::cout <<
" --new ";
43 std::cout <<
": Set subscription type new" << std::endl;
44 std::cout <<
" --periodic [Hz] ";
45 std::cout <<
": Set subscription type periodic" << std::endl;
46 std::cout <<
" --policy [any] ";
47 std::cout <<
": Set push policy ALL or FIFO or SKIP or NEW" << std::endl;
48 std::cout <<
" --skip [n] ";
49 std::cout <<
": Set skip count 0..n" << std::endl;
50 std::cout << std::endl;
51 std::cout <<
"exsample:" << std::endl;
52 std::cout <<
" ConnectorCompExt --flush" << std::endl;
53 std::cout <<
" ConnectorCompExt --new" << std::endl;
54 std::cout <<
" ConnectorCompExt --new --policy ALL" << std::endl;
55 std::cout <<
" ConnectorCompExt --new --policy SKIP --skip 100" << std::endl;
56 std::cout <<
" ConnectorCompExt --periodic 10" << std::endl;
57 std::cout <<
" ConnectorCompExt --periodic 10 --policy FIFO" << std::endl;
58 std::cout <<
" ConnectorCompExt --periodic 10 --policy NEW" << std::endl;
59 std::cout << std::endl;
62 int main (
int argc,
char** argv)
67 std::string subs_type;
69 std::string push_policy;
70 std::string skip_count;
76 for (
int i = 1; i < argc; ++i)
78 std::string arg(argv[i]);
80 if (arg ==
"--flush") subs_type =
"flush";
81 else if (arg ==
"--new") subs_type =
"new";
82 else if (arg ==
"--periodic")
84 subs_type =
"periodic";
85 if (++i < argc) period = argv[i];
88 else if (arg ==
"--help")
93 else if (arg ==
"--policy")
97 std::string arg2(argv[i]);
101 else push_policy =
"new";
103 else if (arg ==
"--skip")
105 if (++i < argc) skip_count = argv[i];
106 else skip_count =
"0";
114 std::cout <<
"Subscription Type: " << subs_type << std::endl;
116 std::cout <<
"Period: " << period <<
" [Hz]" << std::endl;
117 std::cout <<
"push policy: " << push_policy << std::endl;
118 std::cout <<
"skip count: " << skip_count << std::endl;
121 CORBA::ORB_var orb = CORBA::ORB_init(_argc, _argv);
127 PortServiceList_var pin;
128 PortServiceList_var pout;
134 pin = conin->get_ports();
135 pin[(CORBA::ULong)0]->disconnect_all();
136 assert(pin->length() > 0);
138 ExecutionContextList_var eclisti;
139 eclisti = conin->get_owned_contexts();
140 eclisti[(CORBA::ULong)0]->activate_component(RTObject::_duplicate(conin.
_ptr()));
146 pout = conout->get_ports();
147 pout[(CORBA::ULong)0]->disconnect_all();
148 assert(pout->length() > 0);
150 ExecutionContextList_var eclisto;
151 eclisto = conout->get_owned_contexts();
152 eclisto[(CORBA::ULong)0]->activate_component(RTObject::_duplicate(conout.
_ptr()));
156 ConnectorProfile prof;
157 prof.connector_id =
"";
158 prof.name = CORBA::string_dup(
"connector0");
159 prof.ports.length(2);
160 prof.ports[0] = pin[(CORBA::ULong)0];
161 prof.ports[1] = pout[(CORBA::ULong)0];
176 if (subs_type ==
"periodic" && period !=
"")
180 if (push_policy !=
"")
183 push_policy.c_str()));
184 if (push_policy ==
"skip" && skip_count !=
"")
187 skip_count.c_str()));
190 ret = pin[(CORBA::ULong)0]->connect(prof);
193 std::cout <<
"Connector ID: " << prof.connector_id << std::endl;
201 std::cout << std::endl;
202 std::cout << std::endl;
203 std::cout <<
"0: tick ConsoleIn component" << std::endl;
204 std::cout <<
"1: tick ConsoleOut component" << std::endl;
205 std::cout <<
"2: tick both components" << std::endl;
206 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.