24 typedef sequence<string> EchoList; 25 typedef sequence<float> ValueList; 28 string echo(in string msg); 29 EchoList get_echo_history(); 30 void set_value(in float value); 32 ValueList get_value_history(); 36 myservice_impl_h =
""" 37 #include "MyServiceSkel.h" 39 #ifndef MYSERVICESVC_IMPL_H 40 #define MYSERVICESVC_IMPL_H 43 * Example class implementing IDL interface MyService 45 class MyServiceSVC_impl 46 : public virtual POA_MyService, 47 public virtual PortableServer::RefCountServantBase 50 // Make sure all instances are built on the heap by making the 51 // destructor non-public 52 //virtual ~MyServiceSVC_impl(); 55 // standard constructor 57 virtual ~MyServiceSVC_impl(); 59 // attributes and operations 60 char* echo(const char* msg) 61 throw (CORBA::SystemException); 62 EchoList* get_echo_history() 63 throw (CORBA::SystemException); 64 void set_value(CORBA::Float value) 65 throw (CORBA::SystemException); 66 CORBA::Float get_value() 67 throw (CORBA::SystemException); 68 ValueList* get_value_history() 69 throw (CORBA::SystemException); 74 ValueList m_valueList; 79 #endif // MYSERVICESVC_IMPL_H 82 myservice_impl_cpp =
"""\ 83 #include "MyServiceSVC_impl.h" 84 #include <rtm/CORBA_SeqUtil.h> 90 seq_print() : m_cnt(0) {}; 91 void operator()(T val) 93 std::cout << m_cnt << ": " << val << std::endl; 100 * Example implementational code for IDL interface MyService 102 MyServiceSVC_impl::MyServiceSVC_impl() 104 // Please add extra constructor code here. 108 MyServiceSVC_impl::~MyServiceSVC_impl() 110 // Please add extra destructor code here. 115 * Methods corresponding to IDL attributes and operations 117 char* MyServiceSVC_impl::echo(const char* msg) 118 throw (CORBA::SystemException) 120 CORBA_SeqUtil::push_back(m_echoList, msg); 121 std::cout << "MyService::echo() was called." << std::endl; 122 std::cout << "Message: " << msg << std::endl; 123 return CORBA::string_dup(msg); 126 EchoList* MyServiceSVC_impl::get_echo_history() 127 throw (CORBA::SystemException) 129 std::cout << "MyService::get_echo_history() was called." << std::endl; 130 CORBA_SeqUtil::for_each(m_echoList, seq_print<const char*>()); 133 el = new EchoList(m_echoList); 137 void MyServiceSVC_impl::set_value(CORBA::Float value) 138 throw (CORBA::SystemException) 140 CORBA_SeqUtil::push_back(m_valueList, value); 143 std::cout << "MyService::set_value() was called." << std::endl; 144 std::cout << "Current value: " << m_value << std::endl; 149 CORBA::Float MyServiceSVC_impl::get_value() 150 throw (CORBA::SystemException) 152 std::cout << "MyService::get_value() was called." << std::endl; 153 std::cout << "Current value: " << m_value << std::endl; 158 ValueList* MyServiceSVC_impl::get_value_history() 159 throw (CORBA::SystemException) 161 std::cout << "MyService::get_value_history() was called." << std::endl; 162 CORBA_SeqUtil::for_each(m_valueList, seq_print<CORBA::Float>()); 165 vl = new ValueList(m_valueList); 171 yourservice_idl =
""" 172 interface YourService { 175 void func1(in short val); 176 void func2(inout short val); 177 void func3(out short val); 179 void func4(in long val); 180 void func5(inout long val); 181 void func6(out long val); 183 void func7(in float val); 184 void func8(inout float val); 185 void func9(out float val); 187 void func10(in double val); 188 void func11(inout double val); 189 void func12(out double val); 194 vector_convert_h =
"""\ 201 #include <coil/stringutil.h> 204 std::istream& operator>>(std::istream& is, std::vector<T>& v) 209 sv = coil::split(s ,","); 211 for (int i(0), len(sv.size()); i < len; ++i) 214 if (coil::stringTo(tv, sv[i].c_str())) 225 --module-name=[name] --module-desc="Test RTC for rtc-template" 226 --module-version=1.0.0 --module-vendor=AIST --module-category=Test 227 --module-comp-type=DataFlowComponent --module-act-type=SPORADIC 230 --inport="[ip.name]:[ip.type]" 234 --outport="[op.name]:[op.type]" 238 --[sp.direction]="[sp.port_name]:[sp.inst_name]:[sp.type]" 239 --[sp.direction]-idl="[sp.idl_file]" 243 --config="[cf.name]:[cf.type]:[cf.default]" 250 # this is for only Linux!! 252 rtm_prefix="/usr/local" 253 rtm_exec_prefix="/usr/local" 255 rtm_cflags="-Wall -fPIC -O2 -I../../../../src/lib -I../../../../src/lib/rtm/idl -I../../../../src/lib/coil/include" 256 rtm_libs="-export-dynamic -luuid -ldl -L../../../../src/lib/rtm/.libs -L../../../../src/lib/coil/lib/.libs -lpthread -lomniORB4 -lomnithread -lomniDynamic4 -lRTC -lcoil" 261 rtm_idlflags="-bcxx -Wba -nf" 266 Usage: rtm-config [OPTIONS] 269 [--exec-prefix[=DIR]] 282 if test $# -eq 0; then 287 while test $# -gt 0; do 289 -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; 296 if test $exec_prefix_set = no ; then 304 rtm_exec_prefix=$optarg 341 if test "$echo_prefix" = "yes"; then 345 if test "$echo_exec_prefix" = "yes"; then 346 echo $rtm_exec_prefix 349 if test "$echo_cxx" = "yes"; then 353 if test "$echo_cflags" = "yes"; then 357 if test "$echo_libs" = "yes"; then 361 if test "$echo_libdir" = "yes"; then 365 if test "$echo_orb" = "yes"; then 369 if test "$echo_idlc" = "yes"; then 373 if test "$echo_idlflags" = "yes"; then 380 @set PATH="%RTM_ROOT%\\utils\\rtc-template";%PATH% 381 @set PYTHONPATH="%RTM_ROOT%\\utils\\rtc-template" 383 del /F /Q *.cpp *.h *.hh *.cc *.sln *.vcproj *.vsprops *.yaml 384 del /F /Q copyprops.bat Makefile.* README.* 388 rmdir /Q /S [name]Comp 394 export PYTHONPATH=../../:../../py_helper 395 export RTM_ROOT=../../../../ 396 export PATH=./:../../:../../../rtm-skelwrapper:$PATH 398 rm -rf *.cpp *.h *.hh *.cc *.sln *.vcproj *.vsprops *.yaml 399 rm -rf copyprops.bat Makefile.* README.* 400 rm -rf [name] [name]Comp 407 for %%x in (*.tmp) do copy /y %%x %%~nx 409 echo #include "VectorConvert.h" >> [name].h 417 fname=`basename $tmpname .tmp` 418 cp -f $tmpname $fname 421 echo '#include "VectorConvert.h"' >> [name].h 427 @set PATH="C:\\Program Files\\Microsoft Visual Studio 8\\VC\\vcpackages";%PATH% 429 [for proj in projects] 432 vcbuild [proj]_vc8.sln 438 @set PATH="C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\vcpackages";%PATH% 440 [for proj in projects] 443 vcbuild [proj]_vc9.sln 451 [for proj in projects] 454 #make -f Makefile.[proj] 455 if test -f [proj]Comp; then 456 echo [proj]: OK >> ../build_status 458 echo [proj]: NG >> ../build_status 465 {
"name":
"in00",
"type":
"TimedShort"},
466 {
"name":
"in01",
"type":
"TimedLong"},
467 {
"name":
"in02",
"type":
"TimedUShort"},
468 {
"name":
"in03",
"type":
"TimedULong"},
469 {
"name":
"in04",
"type":
"TimedFloat"},
470 {
"name":
"in05",
"type":
"TimedDouble"},
471 {
"name":
"in06",
"type":
"TimedChar"},
472 {
"name":
"in07",
"type":
"TimedBoolean"},
473 {
"name":
"in08",
"type":
"TimedOctet"},
474 {
"name":
"in09",
"type":
"TimedString"},
475 {
"name":
"in10",
"type":
"TimedShortSeq"},
476 {
"name":
"in11",
"type":
"TimedLongSeq"},
477 {
"name":
"in12",
"type":
"TimedUShortSeq"},
478 {
"name":
"in13",
"type":
"TimedULongSeq"},
479 {
"name":
"in14",
"type":
"TimedFloatSeq"},
480 {
"name":
"in15",
"type":
"TimedDoubleSeq"},
481 {
"name":
"in16",
"type":
"TimedCharSeq"},
482 {
"name":
"in17",
"type":
"TimedBooleanSeq"},
483 {
"name":
"in18",
"type":
"TimedOctetSeq"},
484 {
"name":
"in19",
"type":
"TimedStringSeq"}
488 {
"name":
"out00",
"type":
"TimedShort"},
489 {
"name":
"out01",
"type":
"TimedLong"},
490 {
"name":
"out02",
"type":
"TimedUShort"},
491 {
"name":
"out03",
"type":
"TimedULong"},
492 {
"name":
"out04",
"type":
"TimedFloat"},
493 {
"name":
"out05",
"type":
"TimedDouble"},
494 {
"name":
"out06",
"type":
"TimedChar"},
495 {
"name":
"out07",
"type":
"TimedBoolean"},
496 {
"name":
"out08",
"type":
"TimedOctet"},
497 {
"name":
"out09",
"type":
"TimedString"},
498 {
"name":
"out10",
"type":
"TimedShortSeq"},
499 {
"name":
"out11",
"type":
"TimedLongSeq"},
500 {
"name":
"out12",
"type":
"TimedUShortSeq"},
501 {
"name":
"out13",
"type":
"TimedULongSeq"},
502 {
"name":
"out14",
"type":
"TimedFloatSeq"},
503 {
"name":
"out15",
"type":
"TimedDoubleSeq"},
504 {
"name":
"out16",
"type":
"TimedCharSeq"},
505 {
"name":
"out17",
"type":
"TimedBooleanSeq"},
506 {
"name":
"out18",
"type":
"TimedOctetSeq"},
507 {
"name":
"out19",
"type":
"TimedStringSeq"}
511 {
"name":
"conf_short",
"type":
"short",
513 {
"name":
"conf_int",
"type":
"int",
515 {
"name":
"conf_long",
"type":
"long",
516 "default":
"-12345"},
517 {
"name":
"conf_ushort",
"type":
"unsigned short",
519 {
"name":
"conf_uint",
"type":
"unsigned int",
521 {
"name":
"conf_ulong",
"type":
"unsigned long",
523 {
"name":
"conf_float",
"type":
"float",
524 "default":
"3.14159265"},
525 {
"name":
"conf_double",
"type":
"double",
526 "default":
"0.0000000001"},
527 {
"name":
"conf_string",
"type":
"std::string",
528 "default":
"OpenRTM-aist"},
529 {
"name":
"conf_vshort",
"type":
"std::vector<short>",
530 "default":
"0,1,2,3,4,5,6,7,8,9"},
531 {
"name":
"conf_vint",
"type":
"std::vector<int>",
532 "default":
"9,8,7,6,5,4,3,2,1,0"},
533 {
"name":
"conf_vlong",
"type":
"std::vector<long>",
534 "default":
"0,10,20,30,40,50,60,70,80,90"},
535 {
"name":
"conf_vushort",
"type":
"std::vector<unsigned short>",
537 {
"name":
"conf_vuint",
"type":
"std::vector<unsigned int>",
538 "default":
"0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20"},
539 {
"name":
"conf_vulong",
"type":
"std::vector<unsigned long>",
540 "default":
"0,10000,20000,30000,40000,50000,60000,70000,80000,90000"},
541 {
"name":
"conf_vfloat",
"type":
"std::vector<float>",
542 "default":
"0.1,0.01,0.001,0.0001,0.00001,0.000001,0.0000001,0.00000001"},
543 {
"name":
"conf_vdouble",
"type":
"std::vector<double>",
544 "default":
"1.1,1.01,1.001,1.0001,1.00001,1.000001,1.0000001,1.00000001"}
548 {
"type":
"MyService",
"direction":
"service",
549 "port_name":
"sp0",
"inst_name":
"my0",
550 "idl_file":
"MyService.idl",
"idl_data": myservice_idl,
551 "impl_h": myservice_impl_h,
"impl_cpp": myservice_impl_cpp},
552 {
"type":
"MyService",
"direction":
"consumer",
553 "port_name":
"sp0",
"inst_name":
"my1",
554 "idl_file":
"MyService.idl",
"idl_data": myservice_idl,
555 "impl_h": myservice_impl_h,
"impl_cpp": myservice_impl_cpp},
556 {
"type":
"MyService",
"direction":
"service",
557 "port_name":
"sp1",
"inst_name":
"my2",
558 "idl_file":
"MyService.idl",
"idl_data": myservice_idl,
559 "impl_h": myservice_impl_h,
"impl_cpp": myservice_impl_cpp},
560 {
"type":
"MyService",
"direction":
"consumer",
561 "port_name":
"sp1",
"inst_name":
"my3",
562 "idl_file":
"MyService.idl",
"idl_data": myservice_idl,
563 "impl_h": myservice_impl_h,
"impl_cpp": myservice_impl_cpp},
564 {
"type":
"MyService",
"direction":
"service",
565 "port_name":
"sp2",
"inst_name":
"my4",
566 "idl_file":
"MyService.idl",
"idl_data": myservice_idl,
567 "impl_h": myservice_impl_h,
"impl_cpp": myservice_impl_cpp},
568 {
"type":
"MyService",
"direction":
"consumer",
569 "port_name":
"sp2",
"inst_name":
"my5",
570 "idl_file":
"MyService.idl",
"idl_data": myservice_idl,
571 "impl_h": myservice_impl_h,
"impl_cpp": myservice_impl_cpp},
572 {
"type":
"YourService",
"direction":
"service",
573 "port_name":
"sp0",
"inst_name":
"your0",
574 "idl_file":
"YourService.idl",
"idl_data": yourservice_idl,
575 "impl_h":
None,
"impl_cpp":
None},
576 {
"type":
"YourService",
"direction":
"consumer",
577 "port_name":
"sp0",
"inst_name":
"your1",
578 "idl_file":
"YourService.idl",
"idl_data": yourservice_idl,
579 "impl_h":
None,
"impl_cpp":
None},
580 {
"type":
"YourService",
"direction":
"service",
581 "port_name":
"sp1",
"inst_name":
"your2",
582 "idl_file":
"YourService.idl",
"idl_data": yourservice_idl,
583 "impl_h":
None,
"impl_cpp":
None},
584 {
"type":
"YourService",
"direction":
"consumer",
585 "port_name":
"sp1",
"inst_name":
"your3",
586 "idl_file":
"YourService.idl",
"idl_data": yourservice_idl,
587 "impl_h":
None,
"impl_cpp":
None},
588 {
"type":
"YourService",
"direction":
"service",
589 "port_name":
"sp2",
"inst_name":
"your4",
590 "idl_file":
"YourService.idl",
"idl_data": yourservice_idl,
591 "impl_h":
None,
"impl_cpp":
None},
592 {
"type":
"YourService",
"direction":
"consumer",
593 "port_name":
"sp2",
"inst_name":
"your5",
594 "idl_file":
"YourService.idl",
"idl_data": yourservice_idl,
595 "impl_h":
None,
"impl_cpp":
None}
603 "outports": outports,
604 "svcports": svcports,
609 """works the way a good mkdir should :) 610 - already exists, silently complete 611 - regular file in the way, raise an exception 612 - parent directory(ies) does not exist, make them as well 614 if os.path.isdir(newdir):
616 elif os.path.isfile(newdir):
617 raise OSError(
"a file with the same name as the desired " \
618 "dir, '%s', already exists." % newdir)
620 head, tail = os.path.split(newdir)
621 if head
and not os.path.isdir(head):
628 def __init__(self, ip_num, op_num, sp_num, cf_num):
633 for key
in params.keys():
634 random.shuffle(params[key])
644 dict[
"projects"] = self.
pjnames 645 builds = {
"build.sh": build_sh,
646 "build_vc8.bat": build_vc8_bat,
647 "build_vc9.bat": build_vc9_bat
649 for key
in builds.keys():
659 def dict(self, ip, op, sp, cf):
660 name =
"Sample_%d_%d_%d_%d" % (ip, op, sp, cf)
661 dict = {
"name": name}
662 p = [
"inports",
"outports",
"svcports",
"configs"]
664 for i
in range(len(n)):
665 dict[p[i]] = self.
params[p[i]][0:n[i]]
669 fname = dict[
"name"] +
"/gen.sh" 670 fd = open(fname,
"w")
676 sh_all = head + body + foot
679 os.chmod(fname, 0755)
682 fname = dict[
"name"] +
"/gen.bat" 683 fd = open(fname,
"w")
686 body = body.replace(
"rtc-template",
"rtc-template.py")
690 bat_all = head + body + foot
691 bat_all.replace(
"\r\n",
"\n").replace(
"\n",
"\r\n")
694 os.chmod(fname, 0755)
697 lines = [t
for t
in text.split(
"\n")
if t !=
""]
698 return (mark +
"\n").join(lines)
702 for svc
in dict[
"svcports"]:
703 if not svc[
"idl_file"]
in idls:
704 fname = dict[
"name"] +
"/" + svc[
"idl_file"]
705 fd = open(fname,
"w")
706 fd.write(svc[
"idl_data"])
708 idls.append(svc[
"idl_file"])
710 if svc[
"impl_h"] !=
None:
711 cpp_fname = dict[
"name"] +
"/" + \
712 svc[
"idl_file"].replace(
".idl",
"SVC_impl.cpp.tmp")
713 fd = open(cpp_fname,
"w")
714 fd.write(svc[
"impl_cpp"])
717 h_fname = dict[
"name"] +
"/" + \
718 svc[
"idl_file"].replace(
".idl",
"SVC_impl.h.tmp")
719 fd = open(h_fname,
"w")
720 fd.write(svc[
"impl_h"])
724 fname = dict[
"name"] +
"/" +
"VectorConvert.h.tmp" 725 fd = open(fname,
"w")
726 fd.write(vector_convert_h)
730 fname = dict[
"name"] +
"/rtm-config" 731 fd = open(fname,
"w")
734 os.chmod(fname, 0755)
748 dict = self.
dict(ip, op, sp, cf)
749 self.
mkdir(dict[
"name"])
754 if __name__ ==
"__main__":
755 t =
TestGen([0,1,5],[0,1,5],[0,1,5],[0,1,5])
def create_gen_bat(self, dict)
def create_gen_sh(self, dict)
def __init__(self, ip_num, op_num, sp_num, cf_num)
def craete_build_sh(self)
def add_cmark(self, text, mark)
def create_gen(self, dict)
def create_idl(self, dict)
void append(SDOPackage::NVList &dest, const SDOPackage::NVList &src)
Append an element to NVList.
def create_rtmconfig(self, dict)
def create_vecconv(self, dict)
def dict(self, ip, op, sp, cf)