25 #include <coil/stringutil.h> 32 std::cout << std::endl;
33 std::cout <<
"usage: ConnectorComp [options].." << std::endl;
34 std::cout << std::endl;
35 std::cout <<
" --port * ";
36 std::cout <<
": Set port no 2809 (default:9876)" << std::endl;
37 std::cout <<
" --origin * ";
38 std::cout <<
": Set origin of connection OUT (default:IN)" << std::endl;
39 std::cout <<
" : Set origin OUT , ConsoleOut -> ConsoleIn" << std::endl;
40 std::cout <<
" : default connection, ConsoleIn -> ConsoleOut" << std::endl;
41 std::cout <<
" --flush ";
42 std::cout <<
": Set subscription type flush (default:flush)" << std::endl;
43 std::cout <<
" --new ";
44 std::cout <<
": Set subscription type new" << std::endl;
45 std::cout <<
" --periodic [Hz] ";
46 std::cout <<
": Set subscription type periodic" << std::endl;
47 std::cout <<
" --policy [any] ";
48 std::cout <<
": Set push policy ALL or FIFO or SKIP or NEW" << std::endl;
49 std::cout <<
" --skip [n] ";
50 std::cout <<
": Set skip count 0..n" << std::endl;
51 std::cout <<
" --endian * ";
52 std::cout <<
": Set endian type Little or Big" << std::endl;
53 std::cout <<
" --buffer : Set buffer configuration" << std::endl;
54 std::cout <<
" --buffer [inport|outport].buffer.[length|[read|write.[policy|timeout]] value" << std::endl;
55 std::cout <<
" policy: [write.full_policy,read.empty_policy]" << std::endl;
56 std::cout <<
" timeout: [write.timeout,read.timeout]" << std::endl;
57 std::cout <<
" value: " << std::endl;
58 std::cout <<
" full_policy: [overwrite, do_nothing, block]" << std::endl;
59 std::cout <<
" empty_policy: [readback, do_nothing, block]" << std::endl;
60 std::cout <<
" timeout: sec (e.g. 1.0)" << std::endl;
61 std::cout <<
" length: The length of the ring buffer. (e.g. 10)" << std::endl;
62 std::cout << std::endl;
63 std::cout <<
"exsample:" << std::endl;
64 std::cout <<
" ConnectorComp --port 2809 --origin OUT" << std::endl;
65 std::cout <<
" ConnectorComp --flush" << std::endl;
66 std::cout <<
" ConnectorComp --new" << std::endl;
67 std::cout <<
" ConnectorComp --new --policy ALL" << std::endl;
68 std::cout <<
" ConnectorComp --new --policy SKIP --skip 100" << std::endl;
69 std::cout <<
" ConnectorComp --periodic 10" << std::endl;
70 std::cout <<
" ConnectorComp --periodic 10 --policy FIFO" << std::endl;
71 std::cout <<
" ConnectorComp --periodic 10 --policy NEW" << std::endl;
72 std::cout <<
" ConnectorComp --flush --endian Little" << std::endl;
73 std::cout <<
" ConnectorComp --buffer inport.buffer.read.empty_policy block \\" << std::endl;
74 std::cout <<
" --buffer inport.buffer.read.timeout 0.1 \\ " << std::endl;
75 std::cout <<
" --buffer inport.buffer.length 10 " << std::endl;
76 std::cout << std::endl;
79 int main (
int argc,
char** argv)
84 std::string subs_type(
"flush");
86 std::string push_policy;
87 std::string skip_count;
89 std::string port_no(
"9876");
90 std::string connect_origin(
"in");
91 std::map<std::string, std::string> buffer_prop;
98 for (
int i = 1; i < argc; ++i)
100 std::string arg(argv[i]);
102 if (arg ==
"--flush") subs_type =
"flush";
103 else if (arg ==
"--new") subs_type =
"new";
104 else if (arg ==
"--periodic")
106 subs_type =
"periodic";
107 if (++i < argc) period = argv[i];
110 else if (arg ==
"--help")
115 else if (arg ==
"--policy")
119 std::string arg2(argv[i]);
123 else push_policy =
"new";
125 else if (arg ==
"--skip")
127 if (++i < argc) skip_count = argv[i];
128 else skip_count =
"0";
131 if (arg ==
"--endian")
135 std::string arg2(argv[i]);
148 if (arg ==
"--origin")
152 std::string arg2(argv[i]);
154 connect_origin = arg2;
157 if (arg ==
"--buffer")
161 std::string key(argv[i]);
163 std::string val(argv[++i]);
165 buffer_prop.insert(std::pair< std::string, std::string >(key,val));
170 CORBA::ORB_var orb = CORBA::ORB_init(_argc, _argv);
171 std::string name_server(
"localhost:");
172 name_server.append(port_no);
176 PortServiceList_var pin;
177 PortServiceList_var pout;
180 std::cout <<
" Name Server: " << name_server << std::endl;
181 std::cout <<
"Subscription Type: " << subs_type << std::endl;
183 std::cout <<
" Period: " << period <<
" [Hz]" << std::endl;
185 std::cout <<
" push policy: " << push_policy << std::endl;
186 std::cout <<
" skip count: " << skip_count << std::endl;
189 std::cout <<
" endian: " << endian << std::endl;
191 if (connect_origin ==
"in")
192 std::cout <<
" connect: ConsoleIn -> ConsoleOut" << std::endl;
194 std::cout <<
" connect: ConsoleOut -> ConsoleIn" << std::endl;
195 std::cout << std::endl;
201 pin = conin->get_ports();
202 pin[(CORBA::ULong)0]->disconnect_all();
203 assert(pin->length() > 0);
205 ExecutionContextList_var eclisti;
206 eclisti = conin->get_owned_contexts();
207 eclisti[(CORBA::ULong)0]->activate_component(RTObject::_duplicate(conin._ptr()));
210 conout.setObject(
naming.resolve(
"ConsoleOut0.rtc"));
212 pout = conout->get_ports();
213 pout[(CORBA::ULong)0]->disconnect_all();
214 assert(pout->length() > 0);
216 ExecutionContextList_var eclisto;
217 eclisto = conout->get_owned_contexts();
218 eclisto[(CORBA::ULong)0]->activate_component(RTObject::_duplicate(conout._ptr()));
221 ConnectorProfile prof;
222 prof.connector_id = (
char*)
"";
223 prof.name = CORBA::string_dup(
"connector0");
224 prof.ports.length(2);
225 prof.ports[0] = pin[(CORBA::ULong)0];
226 prof.ports[1] = pout[(CORBA::ULong)0];
241 if (subs_type ==
"periodic" && period !=
"")
245 if (push_policy !=
"")
248 push_policy.c_str()));
249 if (push_policy ==
"skip" && skip_count !=
"")
252 skip_count.c_str()));
258 std::map<std::string, std::string>::iterator it=buffer_prop.begin();
259 while (it != buffer_prop.end()) {
260 std::string key(
"dataport.");
264 it->second.c_str()));
269 if (connect_origin ==
"in")
271 ret = pin[(CORBA::ULong)0]->connect(prof);
275 ret = pout[(CORBA::ULong)0]->connect(prof);
280 std::cout <<
"Connector ID: " << prof.connector_id << std::endl;
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)
virtual bool setObject(CORBA::Object_ptr obj)
Set Object.
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.
int main(int argc, char **argv)
void push_back(CorbaSequence &seq, SequenceElement elem)
Push the new element back to the CORBA sequence.