[openrtm-commit:02555] r811 - trunk/OpenRTM-aist-Python/OpenRTM_aist
openrtm @ openrtm.org
openrtm @ openrtm.org
2017年 4月 4日 (火) 19:08:06 JST
Author: miyamoto
Date: 2017-04-04 19:08:06 +0900 (Tue, 04 Apr 2017)
New Revision: 811
Modified:
trunk/OpenRTM-aist-Python/OpenRTM_aist/RTCUtil.py
Log:
[incompat,newfunc,->RELENG_1_2] add instantiateDataType.
Modified: trunk/OpenRTM-aist-Python/OpenRTM_aist/RTCUtil.py
===================================================================
--- trunk/OpenRTM-aist-Python/OpenRTM_aist/RTCUtil.py 2017-04-03 04:26:59 UTC (rev 810)
+++ trunk/OpenRTM-aist-Python/OpenRTM_aist/RTCUtil.py 2017-04-04 10:08:06 UTC (rev 811)
@@ -16,7 +16,7 @@
# All rights reserved.
from omniORB import CORBA
-
+import omniORB
import RTC
import OpenRTM
@@ -112,3 +112,54 @@
def isMultiModeObject(obj):
mmc = obj._narrow(RTC.MultiModeObject)
return not CORBA.is_nil(mmc)
+
+
+
+
+#########################################################################
+# F U N C T I O N S
+#
+# DataType for CORBA
+#
+def instantiateDataType(dtype):
+ if isinstance(dtype, int) : desc = [dtype]
+ elif isinstance(dtype, tuple) : desc = dtype
+ else :
+ desc=omniORB.findType(dtype._NP_RepositoryId)
+
+ if desc[0] in [omniORB.tcInternal.tv_alias ]: return instantiateDataType(desc[2])
+
+ if desc[0] in [omniORB.tcInternal.tv_short,
+ omniORB.tcInternal.tv_long,
+ omniORB.tcInternal.tv_ushort,
+ omniORB.tcInternal.tv_ulong,
+ omniORB.tcInternal.tv_boolean,
+ omniORB.tcInternal.tv_char,
+ omniORB.tcInternal.tv_octet,
+ omniORB.tcInternal.tv_longlong,
+ omniORB.tcInternal.tv_enum
+ ]: return 0
+
+ if desc[0] in [omniORB.tcInternal.tv_float,
+ omniORB.tcInternal.tv_double,
+ omniORB.tcInternal.tv_longdouble
+ ]: return 0.0
+
+ if desc[0] in [omniORB.tcInternal.tv_sequence,
+ omniORB.tcInternal.tv_array,
+ ]: return []
+
+
+ if desc[0] in [omniORB.tcInternal.tv_string ]: return ""
+ if desc[0] in [omniORB.tcInternal.tv_wstring,
+ omniORB.tcInternal.tv_wchar
+ ]: return u""
+
+ if desc[0] == omniORB.tcInternal.tv_struct:
+ arg = []
+ for i in range(4, len(desc), 2):
+ attr = desc[i]
+ attr_type = desc[i+1]
+ arg.append(instantiateDataType(attr_type))
+ return desc[1](*arg)
+ return None
\ No newline at end of file
openrtm-commit メーリングリストの案内