25 #include <coil/stringutil.h> 36 std::cout << std::endl;
37 std::cout <<
"usage: ConnectorComp [options].." << std::endl;
38 std::cout << std::endl;
39 std::cout <<
" --port * ";
40 std::cout <<
": Set port no 2809 (default:9876)" << std::endl;
41 std::cout <<
" --origin * ";
42 std::cout <<
": Set origin of connection OUT (default:IN)" << std::endl;
43 std::cout <<
" : Set origin OUT , ConsoleOut -> ConsoleIn" << std::endl;
44 std::cout <<
" : default connection, ConsoleIn -> ConsoleOut" << std::endl;
45 std::cout <<
" --flush ";
46 std::cout <<
": Set subscription type flush (default:flush)" << std::endl;
47 std::cout <<
" --new ";
48 std::cout <<
": Set subscription type new" << std::endl;
49 std::cout <<
" --periodic [Hz] ";
50 std::cout <<
": Set subscription type periodic" << std::endl;
51 std::cout <<
" --policy [any] ";
52 std::cout <<
": Set push policy ALL or FIFO or SKIP or NEW" << std::endl;
53 std::cout <<
" --skip [n] ";
54 std::cout <<
": Set skip count 0..n" << std::endl;
55 std::cout <<
" --endian * ";
56 std::cout <<
": Set endian type Little or Big" << std::endl;
57 std::cout <<
" --buffer : Set buffer configuration" << std::endl;
58 std::cout <<
" --buffer [inport|outport].buffer.[length|[read|write.[policy|timeout]] value" << std::endl;
59 std::cout <<
" policy: [write.full_policy,read.empty_policy]" << std::endl;
60 std::cout <<
" timeout: [write.timeout,read.timeout]" << std::endl;
61 std::cout <<
" value: " << std::endl;
62 std::cout <<
" full_policy: [overwrite, do_nothing, block]" << std::endl;
63 std::cout <<
" empty_policy: [readback, do_nothing, block]" << std::endl;
64 std::cout <<
" timeout: sec (e.g. 1.0)" << std::endl;
65 std::cout <<
" length: The length of the ring buffer. (e.g. 10)" << std::endl;
66 std::cout << std::endl;
67 std::cout <<
"exsample:" << std::endl;
68 std::cout <<
" ConnectorComp --port 2809 --origin OUT" << std::endl;
69 std::cout <<
" ConnectorComp --flush" << std::endl;
70 std::cout <<
" ConnectorComp --new" << std::endl;
71 std::cout <<
" ConnectorComp --new --policy ALL" << std::endl;
72 std::cout <<
" ConnectorComp --new --policy SKIP --skip 100" << std::endl;
73 std::cout <<
" ConnectorComp --periodic 10" << std::endl;
74 std::cout <<
" ConnectorComp --periodic 10 --policy FIFO" << std::endl;
75 std::cout <<
" ConnectorComp --periodic 10 --policy NEW" << std::endl;
76 std::cout <<
" ConnectorComp --flush --endian Little" << std::endl;
77 std::cout <<
" ConnectorComp --buffer inport.buffer.read.empty_policy block \\" << std::endl;
78 std::cout <<
" --buffer inport.buffer.read.timeout 0.1 \\ " << std::endl;
79 std::cout <<
" --buffer inport.buffer.length 10 " << std::endl;
80 std::cout << std::endl;
83 int main (
int argc,
char** argv)
88 std::string subs_type(
"flush");
90 std::string push_policy;
91 std::string skip_count;
93 std::string port_no(
"9876");
94 std::string connect_origin(
"in");
95 std::map<std::string, std::string> buffer_prop;
102 for (
int i = 1; i < argc; ++i)
104 std::string arg(argv[i]);
106 if (arg ==
"--flush") subs_type =
"flush";
107 else if (arg ==
"--new") subs_type =
"new";
108 else if (arg ==
"--periodic")
110 subs_type =
"periodic";
111 if (++i < argc) period = argv[i];
114 else if (arg ==
"--help")
119 else if (arg ==
"--policy")
123 std::string arg2(argv[i]);
127 else push_policy =
"new";
129 else if (arg ==
"--skip")
131 if (++i < argc) skip_count = argv[i];
132 else skip_count =
"0";
135 if (arg ==
"--endian")
139 std::string arg2(argv[i]);
152 if (arg ==
"--origin")
156 std::string arg2(argv[i]);
158 connect_origin = arg2;
161 if (arg ==
"--buffer")
165 std::string key(argv[i]);
167 std::string val(argv[++i]);
169 buffer_prop.insert(std::pair< std::string, std::string >(key,val));
174 CORBA::ORB_var orb = CORBA::ORB_init(_argc, _argv);
175 std::string name_server(
"localhost:");
176 name_server.append(port_no);
180 PortServiceList_var pin;
181 PortServiceList_var pout;
184 std::cout <<
" Name Server: " << name_server << std::endl;
185 std::cout <<
"Subscription Type: " << subs_type << std::endl;
187 std::cout <<
" Period: " << period <<
" [Hz]" << std::endl;
189 std::cout <<
" push policy: " << push_policy << std::endl;
190 std::cout <<
" skip count: " << skip_count << std::endl;
193 std::cout <<
" endian: " << endian << std::endl;
195 if (connect_origin ==
"in")
196 std::cout <<
" connect: ConsoleIn -> ConsoleOut" << std::endl;
198 std::cout <<
" connect: ConsoleOut -> ConsoleIn" << std::endl;
199 std::cout << std::endl;
205 pin = conin->get_ports();
206 pin[(CORBA::ULong)0]->disconnect_all();
207 assert(pin->length() > 0);
209 ExecutionContextList_var eclisti;
210 eclisti = conin->get_owned_contexts();
211 eclisti[(CORBA::ULong)0]->activate_component(RTObject::_duplicate(conin._ptr()));
214 conout.setObject(
naming.resolve(
"ConsoleOut0.rtc"));
216 pout = conout->get_ports();
217 pout[(CORBA::ULong)0]->disconnect_all();
218 assert(pout->length() > 0);
220 ExecutionContextList_var eclisto;
221 eclisto = conout->get_owned_contexts();
222 eclisto[(CORBA::ULong)0]->activate_component(RTObject::_duplicate(conout._ptr()));
225 ConnectorProfile prof;
226 prof.connector_id = (
char*)
"";
227 prof.name = CORBA::string_dup(
"connector0");
228 prof.ports.length(2);
229 prof.ports[0] = pin[(CORBA::ULong)0];
230 prof.ports[1] = pout[(CORBA::ULong)0];
245 if (subs_type ==
"periodic" && period !=
"")
249 if (push_policy !=
"")
252 push_policy.c_str()));
253 if (push_policy ==
"skip" && skip_count !=
"")
256 skip_count.c_str()));
262 std::map<std::string, std::string>::iterator it=buffer_prop.begin();
263 while (it != buffer_prop.end()) {
264 std::string key(
"dataport.");
268 it->second.c_str()));
273 if (connect_origin ==
"in")
275 ret = pin[(CORBA::ULong)0]->connect(prof);
279 ret = pout[(CORBA::ULong)0]->connect(prof);
284 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.