[openrtm-commit:00006] r403 - in branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist: . test
openrtm at openrtm.org
openrtm at openrtm.org
Sat Apr 9 00:43:56 JST 2011
Author: kurihara
Date: 2011-04-09 00:43:56 +0900 (Sat, 09 Apr 2011)
New Revision: 403
Added:
branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/PortConnectListener.py
branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/SdoServiceAdmin.py
branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/SdoServiceConsumerBase.py
branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/test/test_PortConnectListener.py
branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/test/test_SdoServiceAdmin.py
Modified:
branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/ComponentActionListener.py
branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/NVUtil.py
branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/PortBase.py
branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/SdoConfiguration.py
branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/__init__.py
branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/test/test_ComponentActionListener.py
branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/test/test_ConfigurationListener.py
branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/test/test_ConnectorListener.py
Log:
SdoServiceAdmin and Listener and SdoServiceConsumer have been implemented. refs 2033 refs 2040
Modified: branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/ComponentActionListener.py
===================================================================
--- branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/ComponentActionListener.py 2011-04-08 08:42:39 UTC (rev 402)
+++ branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/ComponentActionListener.py 2011-04-08 15:43:56 UTC (rev 403)
@@ -1100,8 +1100,8 @@
# The PreComponentActionListenerType listener is stored.
# @endif
preaction_num = PreComponentActionListenerType.PRE_COMPONENT_ACTION_LISTENER_NUM
- preaction = [PreComponentActionListenerHolder()
- for i in range(preaction_num)]
+ preaction_ = [PreComponentActionListenerHolder()
+ for i in range(preaction_num)]
##
# @if jp
@@ -1112,8 +1112,8 @@
# The PostComponentActionListenerType listener is stored.
# @endif
postaction_num = PostComponentActionListenerType.POST_COMPONENT_ACTION_LISTENER_NUM
- postaction = [PostComponentActionListenerHolder()
- for i in range(postaction_num)]
+ postaction_ = [PostComponentActionListenerHolder()
+ for i in range(postaction_num)]
##
# @if jp
@@ -1124,8 +1124,8 @@
# The PortActionListenerType listener is stored.
# @endif
portaction_num = PortActionListenerType.PORT_ACTION_LISTENER_NUM
- portaction = [PortActionListenerHolder()
- for i in range(portaction_num)]
+ portaction_ = [PortActionListenerHolder()
+ for i in range(portaction_num)]
##
# @if jp
@@ -1136,5 +1136,5 @@
# The ExecutionContextActionListenerType listener is stored.
# @endif
ecaction_num = ExecutionContextActionListenerType.EC_ACTION_LISTENER_NUM
- ecaction = [ExecutionContextActionListenerHolder()
- for i in range(ecaction_num)]
+ ecaction_ = [ExecutionContextActionListenerHolder()
+ for i in range(ecaction_num)]
Modified: branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/NVUtil.py
===================================================================
--- branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/NVUtil.py 2011-04-08 08:42:39 UTC (rev 402)
+++ branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/NVUtil.py 2011-04-08 15:43:56 UTC (rev 403)
@@ -308,7 +308,11 @@
# @return string value named by name
#
# @endif
-def toString(nv, name):
+def toString(nv, name=None):
+ if not name:
+ str_ = [""]
+ return dump_to_stream(str_, nv)
+
str_value = ""
try:
ret_value = find(nv, name)
@@ -386,6 +390,24 @@
##
# @if jp
+# @brief NVList ¤ËÀßÄꤵ¤ì¤Æ¤¤¤ëÆâÍƤòʸ»úÎó¤È¤·¤Æ½ÐÎϤ¹¤ë¡£
+# @else
+# @brief Print information configured in NVList as a string type
+# @endif
+# std::ostream& dump_to_stream(std::ostream& out, const SDOPackage::NVList& nv)
+def dump_to_stream(out, nv):
+ for i in range(len(nv)):
+ val = any.from_any(nv[i].value, keep_structs=True)
+ if type(val) == str:
+ out[0] += (nv[i].name + ": " + str(nv[i].value) + "\n")
+ else:
+ out[0] += (nv[i].name + ": not a string value \n")
+
+ return out[0]
+
+
+##
+# @if jp
#
# @brief NVList ¤ËÀßÄꤵ¤ì¤Æ¤¤¤ëÆâÍƤòʸ»úÎó¤È¤·¤Æ½ÐÎϤ¹¤ë¡£
#
@@ -399,8 +421,5 @@
#
# @endif
def dump(nv):
- for i in range(len(nv)):
- if type(nv[i].value) == str:
- print nv[i].name, ": ", nv[i].value
- else:
- print nv[i].name, ": not a string value"
+ out = [""]
+ print dump_to_stream(out, nv)
Modified: branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/PortBase.py
===================================================================
--- branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/PortBase.py 2011-04-08 08:42:39 UTC (rev 402)
+++ branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/PortBase.py 2011-04-08 15:43:56 UTC (rev 403)
@@ -166,8 +166,27 @@
self._onDisconnected = None
self._onConnectionLost = None
self._connectionLimit = -1
+ self._portconnListeners = None
+ return
-
+
+ ##
+ # @if jp
+ #
+ # @brief ¥Ç¥¹¥È¥é¥¯¥¿
+ #
+ # ¥Ç¥¹¥È¥é¥¯¥¿¤Ç¤Ï¡¢PortService CORBA ¥ª¥Ö¥¸¥§¥¯¥È¤Î deactivate ¤ò
+ # ¹Ô¤¦¡£deactivate¤ËºÝ¤·¤ÆÎã³°¤òÅꤲ¤ë¤³¤È¤Ï¤Ê¤¤¡£
+ #
+ # @else
+ #
+ # @brief Destructor
+ #
+ # In the destructor, PortService CORBA object is deactivated.
+ # This function never throws exception.
+ #
+ # @endif
+ #
def __del__(self):
self._rtcout.RTC_TRACE("PortBase.__del__()")
try:
@@ -1195,6 +1214,7 @@
self._onPublishInterfaces = on_publish
return
+
##
# @if jp
#
@@ -1406,9 +1426,35 @@
self._onConnectionLost = on_connection_lost
return
+
##
# @if jp
+ # @brief PortConnectListeners ¤Î¥Û¥ë¥À¤ò¥»¥Ã¥È¤¹¤ë
#
+ # ¥Ý¡¼¥È¤ÎÀܳ¤Ë´Ø¤¹¤ë¥ê¥¹¥Ê·²¤òÊÝ»ý¤¹¤ë¥Û¥ë¥À¥¯¥é¥¹¤Ø¤Î¥Ý¥¤¥ó¥¿¤ò
+ # ¥»¥Ã¥È¤¹¤ë¡£¤³¤Î´Ø¿ô¤ÏÄ̾ï¿Æ¤ÎRTObject¤«¤é¸Æ¤Ð¤ì¡¢RTObject¤¬»ý¤Ä
+ # ¥Û¥ë¥À¥¯¥é¥¹¤Ø¤Î¥Ý¥¤¥ó¥¿¤¬¥»¥Ã¥È¤µ¤ì¤ë¡£
+ #
+ # @param portconnListeners PortConnectListeners ¥ª¥Ö¥¸¥§¥¯¥È¤Î¥Ý¥¤¥ó¥¿
+ #
+ # @else
+ # @brief Setting PortConnectListener holder
+ #
+ # This operation sets a functor that is called when connection
+ # of this port does lost.
+ #
+ # @param on_connection_lost a pointer to ConnectionCallback's subclasses
+ #
+ # @endif
+ #
+ # void setPortConnectListenerHolder(PortConnectListeners* portconnListeners);
+ def setPortConnectListenerHolder(self, portconnListeners):
+ return
+
+
+ ##
+ # @if jp
+ #
# @brief Interface ¾ðÊó¤ò¸ø³«¤¹¤ë(¥µ¥Ö¥¯¥é¥¹¼ÂÁõÍÑ)
#
# ¤³¤Î¥ª¥Ú¥ì¡¼¥·¥ç¥ó¤Ï¡¢notify_connect() ½èÍý¥·¡¼¥±¥ó¥¹¤Î»Ï¤á¤Ë¥³¡¼¥ë
@@ -2208,7 +2254,94 @@
return True
+ #inline void onNotifyConnect(const char* portname,
+ # RTC::ConnectorProfile& profile)
+ def onNotifyConnect(self, portname, profile):
+ if self._portconnListeners != None:
+ type = OpenRTM_aist.PortConnectListenerType.ON_NOTIFY_CONNECT
+ self._portconnListeners.portconnect_[type].notify(portname, profile)
+ return
+
+ #inline void onNotifyDisconnect(const char* portname,
+ # RTC::ConnectorProfile& profile)
+ def onNotifyDisconnect(self, portname, profile):
+ if self._portconnListeners != None:
+ type = OpenRTM_aist.PortConnectListenerType.ON_NOTIFY_DISCONNECT
+ self._portconnListeners.portconnect_[type].notify(portname, profile)
+ return
+
+
+ #inline void onUnsubscribeInterfaces(const char* portname,
+ # RTC::ConnectorProfile& profile)
+ def onUnsubscribeInterfaces(self, portname, profile):
+ if self._portconnListeners != None:
+ type = OpenRTM_aist.PortConnectListenerType.ON_UNSUBSCRIBE_INTERFACES
+ self._portconnListeners.portconnect_[type].notify(portname, profile)
+ return
+
+
+ #inline void onPublishInterfaces(const char* portname,
+ # RTC::ConnectorProfile& profile,
+ # ReturnCode_t ret)
+ def onPublishInterfaces(self, portname, profile, ret):
+ if self._portconnListeners != None:
+ type = OpenRTM_aist.PortConnectRetListenerType.ON_UNSUBSCRIBE_INTERFACES
+ self._portconnListeners.portconnret_[type].notify(portname, profile, ret)
+ return
+
+
+ #inline void onConnectNextport(const char* portname,
+ # RTC::ConnectorProfile& profile,
+ # ReturnCode_t ret)
+ def onConnectNextport(self, portname, profile, ret):
+ if self._portconnListeners != None:
+ type = OpenRTM_aist.PortConnectRetListenerType.ON_CONNECT_NEXTPORT
+ self._portconnListeners.portconnret_[type].notify(portname, profile, ret)
+ return
+
+
+ #inline void onSubscribeInterfaces(const char* portname,
+ # RTC::ConnectorProfile& profile,
+ # ReturnCode_t ret)
+ def onSubscribeInterfaces(self, portname, profile, ret):
+ if self._portconnListeners != None:
+ type = OpenRTM_aist.PortConnectRetListenerType.ON_SUBSCRIBE_INTERFACES
+ self._portconnListeners.portconnret_[type].notify(portname, profile, ret)
+ return
+
+
+ #inline void onConnected(const char* portname,
+ # RTC::ConnectorProfile& profile,
+ # ReturnCode_t ret)
+ def onConnected(self, portname, profile, ret):
+ if self._portconnListeners != None:
+ type = OpenRTM_aist.PortConnectRetListenerType.ON_CONNECTED
+ self._portconnListeners.portconnret_[type].notify(portname, profile, ret)
+ return
+
+
+ #inline void onDisconnectNextport(const char* portname,
+ # RTC::ConnectorProfile& profile,
+ # ReturnCode_t ret)
+ def onDisconnectNextport(self, portname, profile, ret):
+ if self._portconnListeners != None:
+ type = OpenRTM_aist.PortConnectRetListenerType.ON_DISCONNECT_NEXT
+ self._portconnListeners.portconnret_[type].notify(portname, profile, ret)
+ return
+
+
+ #inline void onDisconnected(const char* portname,
+ # RTC::ConnectorProfile& profile,
+ # ReturnCode_t ret)
+ def onDisconnected(self, portname, profile, ret):
+ if self._portconnListeners != None:
+ type = OpenRTM_aist.PortConnectRetListenerType.ON_DISCONNECTED
+ self._portconnListeners.portconnret_[type].notify(portname, profile, ret)
+ return
+
+
+
#============================================================
# Functor
#============================================================
Added: branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/PortConnectListener.py
===================================================================
--- branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/PortConnectListener.py (rev 0)
+++ branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/PortConnectListener.py 2011-04-08 15:43:56 UTC (rev 403)
@@ -0,0 +1,551 @@
+#!/usr/bin/env python
+# -*- coding: euc-jp -*-
+
+##
+# @file PortConnectListener.py
+# @brief port's internal action listener classes
+# @date $Date$
+# @author Noriaki Ando <n-ando at aist.go.jp> and Shinji Kurihara
+#
+# Copyright (C) 2011
+# Intelligent Systems Research Institute,
+# National Institute of
+# Advanced Industrial Science and Technology (AIST), Japan
+# All rights reserved.
+
+
+#============================================================
+
+##
+# @if jp
+# @brief PortConnectListener ¤Î¥¿¥¤¥×
+#
+# - ON_NOTIFY_CONNECT: notify_connect() ´Ø¿ôÆâ¸Æ¤Ó½Ð¤·Ä¾¸å
+# - ON_NOTIFY_DISCONNECT: notify_disconnect() ¸Æ¤Ó½Ð¤·Ä¾¸å
+# - ON_UNSUBSCRIBE_INTERFACES: notify_disconnect() Æâ¤ÎIF¹ØÆɲò½ü»þ
+#
+# @else
+# @brief The types of ConnectorDataListener
+#
+# - ON_NOTIFY_CONNECT: right after entering into notify_connect()
+# - ON_NOTIFY_DISCONNECT: right after entering into notify_disconnect()
+# - ON_UNSUBSCRIBE_INTERFACES: unsubscribing IF in notify_disconnect()
+#
+# @endif
+class PortConnectListenerType:
+ """
+ """
+
+ ON_NOTIFY_CONNECT = 0
+ ON_NOTIFY_DISCONNECT = 1
+ ON_UNSUBSCRIBE_INTERFACES = 2
+ PORT_CONNECT_LISTENER_NUM = 3
+
+ def __init__(self):
+ pass
+
+
+
+##
+# @if jp
+# @class PortConnectListener ¥¯¥é¥¹
+# @brief PortConnectListener ¥¯¥é¥¹
+#
+# ³Æ¥¢¥¯¥·¥ç¥ó¤ËÂбþ¤¹¤ë¥æ¡¼¥¶¡¼¥³¡¼¥É¤¬¸Æ¤Ð¤ì¤ëľÁ°¤Î¥¿¥¤¥ß¥ó¥°
+# ¤Ç¥³¡¼¥ë¤µ¤ì¤ë¥ê¥¹¥Ê¥¯¥é¥¹¤Î´ðÄ쥯¥é¥¹¡£
+#
+# - ON_NOTIFY_CONNECT: notify_connect() ´Ø¿ôÆâ¸Æ¤Ó½Ð¤·Ä¾¸å
+# - ON_NOTIFY_DISCONNECT: notify_disconnect() ¸Æ¤Ó½Ð¤·Ä¾¸å
+# - ON_UNSUBSCRIBE_INTERFACES: notify_disconnect() Æâ¤ÎIF¹ØÆɲò½ü»þ
+#
+# @else
+# @class PortConnectListener class
+# @brief PortConnectListener class
+#
+# This class is abstract base class for listener classes that
+# provides callbacks for various events in rtobject.
+#
+# - ON_NOTIFY_CONNECT: right after entering into notify_connect()
+# - ON_NOTIFY_DISCONNECT: right after entering into notify_disconnect()
+# - ON_UNSUBSCRIBE_INTERFACES: unsubscribing IF in notify_disconnect()
+#
+# @endif
+class PortConnectListener:
+ """
+ """
+
+ def __init__(self):
+ pass
+
+ ##
+ # @if jp
+ #
+ # @brief PortConnectListenerType ¤òʸ»úÎó¤ËÊÑ´¹
+ #
+ # PortConnectListenerType ¤òʸ»úÎó¤ËÊÑ´¹¤¹¤ë
+ #
+ # @param type ÊÑ´¹ÂÐ¾Ý PortConnectListenerType
+ #
+ # @return ʸ»úÎóÊÑ´¹·ë²Ì
+ #
+ # @else
+ #
+ # @brief Convert PortConnectListenerType into the string.
+ #
+ # Convert PortConnectListenerType into the string.
+ #
+ # @param type The target PortConnectListenerType for transformation
+ #
+ # @return Trnasformation result of string representation
+ #
+ # @endif
+ #static const char* toString(PortConnectListenerType type);
+ def toString(type):
+ typeString = ["ON_NOTIFY_CONNECT",
+ "ON_NOTIFY_DISCONNECT",
+ "ON_UNSUBSCRIBE_INTERFACES",
+ "ON_UPDATE_CONFIG_PARAM",
+ ""]
+
+ if type < ConfigurationParamListenerType.CONFIG_PARAM_LISTENER_NUM:
+ return typeString[type]
+
+ return "";
+
+ toString = staticmethod(toString)
+
+
+ ##
+ # @if jp
+ # @brief ¥Ç¥¹¥È¥é¥¯¥¿
+ # @else
+ # @brief Destructor
+ # @endif
+ def __del__(self):
+ pass
+
+
+ ##
+ # @if jp
+ #
+ # @brief ²¾ÁÛ¥³¡¼¥ë¥Ð¥Ã¥¯´Ø¿ô
+ #
+ # PortConnectListener ¤Î¥³¡¼¥ë¥Ð¥Ã¥¯´Ø¿ô
+ #
+ # @else
+ #
+ # @brief Virtual Callback function
+ #
+ # This is a the Callback function for PortConnectListener.
+ #
+ # @endif
+ #virtual void operator()(const char* portname,
+ # RTC::ConnectorProfile& profile) = 0;
+ def __call__(self, portname, profile):
+ return
+
+
+
+#============================================================
+##
+# @if jp
+# @brief PortConnectRetListenerType ¤Î¥¿¥¤¥×
+#
+# - ON_CONNECT_NEXTPORT: notify_connect() Ãæ¤Î¥«¥¹¥±¡¼¥É¸Æ¤Ó½Ð¤·Ä¾¸å
+# - ON_SUBSCRIBE_INTERFACES: notify_connect() Ãæ¤Î¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¹ØÆÉľ¸å
+# - ON_CONNECTED: nofity_connect() Àܳ½èÍý´°Î»»þ¤Ë¸Æ¤Ó½Ð¤µ¤ì¤ë
+# - ON_DISCONNECT_NEXT: notify_disconnect() Ãæ¤Ë¥«¥¹¥±¡¼¥É¸Æ¤Ó½Ð¤·Ä¾¸å
+# - ON_DISCONNECTED: notify_disconnect() ¥ê¥¿¡¼¥ó»þ
+#
+# @else
+# @brief The types of PortConnectRetListenerType
+#
+# - ON_CONNECT_NEXTPORT: after cascade-call in notify_connect()
+# - ON_SUBSCRIBE_INTERFACES: after IF subscribing in notify_connect()
+# - ON_CONNECTED: completed nofity_connect() connection process
+# - ON_DISCONNECT_NEXT: after cascade-call in notify_disconnect()
+# - ON_DISCONNECTED: completed notify_disconnect() disconnection
+#
+# @endif
+class PortConnectRetListenerType:
+ """
+ """
+
+ ON_PUBLISH_INTERFACES = 0
+ ON_CONNECT_NEXTPORT = 1
+ ON_SUBSCRIBE_INTERFACES = 2
+ ON_CONNECTED = 3
+ ON_DISCONNECT_NEXT = 4
+ ON_DISCONNECTED = 5
+ PORT_CONNECT_RET_LISTENER_NUM = 6
+
+ def __init__(self):
+ pass
+
+
+
+##
+# @if jp
+# @class PortConnectRetListener ¥¯¥é¥¹
+# @brief PortConnectRetListener ¥¯¥é¥¹
+#
+# ³Æ¥¢¥¯¥·¥ç¥ó¤ËÂбþ¤¹¤ë¥æ¡¼¥¶¡¼¥³¡¼¥É¤¬¸Æ¤Ð¤ì¤ëľÁ°¤Î¥¿¥¤¥ß¥ó¥°
+# ¤Ç¥³¡¼¥ë¤µ¤ì¤ë¥ê¥¹¤Ê¥¯¥é¥¹¤Î´ðÄ쥯¥é¥¹¡£
+#
+# - ON_PUBLISH_INTERFACES: notify_connect() Ãæ¤Î¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¸ø³«Ä¾¸å
+# - ON_CONNECT_NEXTPORT: notify_connect() Ãæ¤Î¥«¥¹¥±¡¼¥É¸Æ¤Ó½Ð¤·Ä¾¸å
+# - ON_SUBSCRIBE_INTERFACES: notify_connect() Ãæ¤Î¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¹ØÆÉľ¸å
+# - ON_CONNECTED: nofity_connect() Àܳ½èÍý´°Î»»þ¤Ë¸Æ¤Ó½Ð¤µ¤ì¤ë
+# - ON_DISCONNECT_NEXT: notify_disconnect() Ãæ¤Ë¥«¥¹¥±¡¼¥É¸Æ¤Ó½Ð¤·Ä¾¸å
+# - ON_DISCONNECTED: notify_disconnect() ¥ê¥¿¡¼¥ó»þ
+#
+# @else
+# @class PortConnectRetListener class
+# @brief PortConnectRetListener class
+#
+# This class is abstract base class for listener classes that
+# provides callbacks for various events in rtobject.
+#
+# - ON_CONNECT_NEXTPORT: after cascade-call in notify_connect()
+# - ON_SUBSCRIBE_INTERFACES: after IF subscribing in notify_connect()
+# - ON_CONNECTED: completed nofity_connect() connection process
+# - ON_DISCONNECT_NEXT: after cascade-call in notify_disconnect()
+# - ON_DISCONNECTED: completed notify_disconnect() disconnection
+#
+# @endif
+class PortConnectRetListener:
+ """
+ """
+
+ def __init__(self):
+ pass
+
+
+ ##
+ # @if jp
+ #
+ # @brief PortConnectRetListenerType ¤òʸ»úÎó¤ËÊÑ´¹
+ #
+ # PortConnectRetListenerType ¤òʸ»úÎó¤ËÊÑ´¹¤¹¤ë
+ #
+ # @param type ÊÑ´¹ÂÐ¾Ý PortConnectRetListenerType
+ #
+ # @return ʸ»úÎóÊÑ´¹·ë²Ì
+ #
+ # @else
+ #
+ # @brief Convert PortConnectRetListenerType into string.
+ #
+ # Convert PortConnectRetListenerType into string.
+ #
+ # @param type The target PortConnectRetListenerType for transformation
+ #
+ # @return Trnasformation result of string representation
+ #
+ # @endif
+ #static const char* toString(PortConnectRetListenerType type);
+ def toString(type):
+ return
+ toString = staticmethod(toString)
+
+
+ ##
+ # @if jp
+ # @brief ¥Ç¥¹¥È¥é¥¯¥¿
+ # @else
+ # @brief Destructor
+ # @endif
+ def __del__(self):
+ pass
+
+
+ ##
+ # @if jp
+ #
+ # @brief ²¾ÁÛ¥³¡¼¥ë¥Ð¥Ã¥¯´Ø¿ô
+ #
+ # PortConnectRetListener ¤Î¥³¡¼¥ë¥Ð¥Ã¥¯´Ø¿ô
+ #
+ # @else
+ #
+ # @brief Virtual Callback function
+ #
+ # This is a the Callback function for PortConnectRetListener.
+ #
+ # @endif
+ #virtual void operator()(const char* portname,
+ # RTC::ConnectorProfile& profile,
+ # ReturnCode_t ret) = 0;
+ def __call__(self, portname, profile, ret):
+ pass
+
+
+
+class Entry:
+ def __init__(self,listener, autoclean):
+ self.listener = listener
+ self.autoclean = autoclean
+ return
+
+#============================================================
+##
+# @if jp
+# @class PortConnectListenerHolder
+# @brief PortConnectListener ¥Û¥ë¥À¥¯¥é¥¹
+#
+# Ê£¿ô¤Î PortConnectListener ¤òÊÝ»ý¤·´ÉÍý¤¹¤ë¥¯¥é¥¹¡£
+#
+# @else
+# @class PortConnectListenerHolder
+# @brief PortConnectListener holder class
+#
+# This class manages one ore more instances of
+# PortConnectListener class.
+#
+# @endif
+class PortConnectListenerHolder:
+ """
+ """
+
+ ##
+ # @if jp
+ # @brief ¥³¥ó¥¹¥È¥é¥¯¥¿
+ # @else
+ # @brief Constructor
+ # @endif
+ def __init__(self):
+ self._listeners = []
+ return
+
+
+ ##
+ # @if jp
+ # @brief ¥Ç¥¹¥È¥é¥¯¥¿
+ # @else
+ # @brief Destructor
+ # @endif
+ def __del__(self):
+ pass
+
+
+ ##
+ # @if jp
+ #
+ # @brief ¥ê¥¹¥Ê¡¼¤ÎÄɲÃ
+ #
+ # ¥ê¥¹¥Ê¡¼¤òÄɲ乤롣
+ #
+ # @param listener Äɲ乤ë¥ê¥¹¥Ê
+ # @param autoclean true:¥Ç¥¹¥È¥é¥¯¥¿¤Çºï½ü¤¹¤ë,
+ # false:¥Ç¥¹¥È¥é¥¯¥¿¤Çºï½ü¤·¤Ê¤¤
+ # @else
+ #
+ # @brief Add the listener.
+ #
+ # This method adds the listener.
+ #
+ # @param listener Added listener
+ # @param autoclean true:The listener is deleted at the destructor.,
+ # false:The listener is not deleted at the destructor.
+ # @endif
+ #void addListener(PortConnectListener* listener, bool autoclean);
+ def addListener(self, listener, autoclean):
+ return
+
+
+ ##
+ # @if jp
+ #
+ # @brief ¥ê¥¹¥Ê¡¼¤Îºï½ü
+ #
+ # ¥ê¥¹¥Ê¤òºï½ü¤¹¤ë¡£
+ #
+ # @param listener ºï½ü¤¹¤ë¥ê¥¹¥Ê
+ # @else
+ #
+ # @brief Remove the listener.
+ #
+ # This method removes the listener.
+ #
+ # @param listener Removed listener
+ # @endif
+ #void removeListener(PortConnectListener* listener);
+ def removeListener(self, listener):
+ return
+
+
+ ##
+ # @if jp
+ #
+ # @brief ¥ê¥¹¥Ê¡¼¤ØÄÌÃΤ¹¤ë
+ #
+ # ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë¥ê¥¹¥Ê¤Î¥³¡¼¥ë¥Ð¥Ã¥¯¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤¹¡£
+ #
+ # @param info ConnectorInfo
+ # @else
+ #
+ # @brief Notify listeners.
+ #
+ # This calls the Callback method of the registered listener.
+ #
+ # @param info ConnectorInfo
+ # @endif
+ #void notify(const char* portname, RTC::ConnectorProfile& profile);
+ def notify(self, portname, profile):
+ pass
+
+
+
+##
+# @if jp
+# @class PortConnectRetListenerHolder
+# @brief PortConnectRetListener ¥Û¥ë¥À¥¯¥é¥¹
+#
+# Ê£¿ô¤Î PortConnectRetListener ¤òÊÝ»ý¤·´ÉÍý¤¹¤ë¥¯¥é¥¹¡£
+#
+# @else
+# @class PortConnectRetListenerHolder
+# @brief PortConnectRetListener holder class
+#
+# This class manages one ore more instances of
+# PortConnectRetListener class.
+#
+# @endif
+class PortConnectRetListenerHolder:
+ """
+ """
+
+ ##
+ # @if jp
+ # @brief ¥³¥ó¥¹¥È¥é¥¯¥¿
+ # @else
+ # @brief Constructor
+ # @endif
+ #PortConnectRetListenerHolder();
+ def __init__(self):
+ self._listeners = []
+ return
+
+
+ ##
+ # @if jp
+ # @brief ¥Ç¥¹¥È¥é¥¯¥¿
+ # @else
+ # @brief Destructor
+ # @endif
+ def __del__(self):
+ pass
+
+
+ ##
+ # @if jp
+ #
+ # @brief ¥ê¥¹¥Ê¡¼¤ÎÄɲÃ
+ #
+ # ¥ê¥¹¥Ê¡¼¤òÄɲ乤롣
+ #
+ # @param listener Äɲ乤ë¥ê¥¹¥Ê
+ # @param autoclean true:¥Ç¥¹¥È¥é¥¯¥¿¤Çºï½ü¤¹¤ë,
+ # false:¥Ç¥¹¥È¥é¥¯¥¿¤Çºï½ü¤·¤Ê¤¤
+ # @else
+ #
+ # @brief Add the listener.
+ #
+ # This method adds the listener.
+ #
+ # @param listener Added listener
+ # @param autoclean true:The listener is deleted at the destructor.,
+ # false:The listener is not deleted at the destructor.
+ # @endif
+ #void addListener(PortConnectRetListener* listener, bool autoclean);
+ def addListener(self, listener, autoclean):
+ return
+
+
+ ##
+ # @if jp
+ #
+ # @brief ¥ê¥¹¥Ê¡¼¤Îºï½ü
+ #
+ # ¥ê¥¹¥Ê¤òºï½ü¤¹¤ë¡£
+ #
+ # @param listener ºï½ü¤¹¤ë¥ê¥¹¥Ê
+ # @else
+ #
+ # @brief Remove the listener.
+ #
+ # This method removes the listener.
+ #
+ # @param listener Removed listener
+ # @endif
+ #void removeListener(PortConnectRetListener* listener);
+ def removeListener(self, listener):
+ return
+
+
+ ##
+ # @if jp
+ #
+ # @brief ¥ê¥¹¥Ê¡¼¤ØÄÌÃΤ¹¤ë
+ #
+ # ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë¥ê¥¹¥Ê¤Î¥³¡¼¥ë¥Ð¥Ã¥¯¥á¥½¥Ã¥É¤ò¸Æ¤Ó½Ð¤¹¡£
+ #
+ # @param info ConnectorInfo
+ # @param cdrdata ¥Ç¡¼¥¿
+ # @else
+ #
+ # @brief Notify listeners.
+ #
+ # This calls the Callback method of the registered listener.
+ #
+ # @param info ConnectorInfo
+ # @param cdrdata Data
+ # @endif
+ #void notify(const char* portname, RTC::ConnectorProfile& profile,
+ # ReturnCode_t ret);
+ def notify(self, portname, profile, ret):
+ return
+
+
+
+##
+# @if jp
+# @class PortConnectListeners
+# @brief PortConnectListeners ¥¯¥é¥¹
+#
+#
+# @else
+# @class PortConnectListeners
+# @brief PortConnectListeners class
+#
+#
+# @endif
+class PortConnectListeners:
+ """
+ """
+
+ def __init__(self):
+ pass
+
+
+ ##
+ # @if jp
+ # @brief PortConnectListenerType ¥ê¥¹¥ÊÇÛÎó
+ # PortConnectListenerType ¥ê¥¹¥Ê¤ò³ÊǼ
+ # @else
+ # @brief PortConnectListenerType listener array
+ # The PortConnectListenerType listener is stored.
+ # @endif
+ portconnect_num = PortConnectListenerType.PORT_CONNECT_LISTENER_NUM
+ portconnect_ = [PortConnectListenerHolder() for i in range(portconnect_num)]
+
+ ##
+ # @if jp
+ # @brief PortConnectRetType¥ê¥¹¥ÊÇÛÎó
+ # PortConnectRetType¥ê¥¹¥Ê¤ò³ÊǼ
+ # @else
+ # @brief PortConnectRetType listener array
+ # The PortConnectRetType listener is stored.
+ # @endif
+ portconnret_num = PortConnectRetListenerType.PORT_CONNECT_RET_LISTENER_NUM
+ portconnret_ = [PortConnectRetListenerHolder() for i in range(portconnret_num)]
Modified: branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/SdoConfiguration.py
===================================================================
--- branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/SdoConfiguration.py 2011-04-08 08:42:39 UTC (rev 402)
+++ branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/SdoConfiguration.py 2011-04-08 15:43:56 UTC (rev 403)
@@ -173,15 +173,19 @@
# ¥³¥ó¥¹¥È¥é¥¯¥¿
#
# @param self
- # @param configsets ConfigurationSetList
+ # @param configAdmin ConfigurationSetList
+ # @param sdoServiceAdmin SdoServiceAdmin
#
# @else
# @brief class constructor
# @param self
- # @param configsets ConfigurationSetList
+ # @param configAdmin ConfigurationSetList
+ # @param sdoServiceAdmin SdoServiceAdmin
#
# @endif
- def __init__(self, configsets):
+ # Configuration_impl(RTC::ConfigAdmin& configAdmin,
+ # RTC::SdoServiceAdmin& sdoServiceAdmin);
+ def __init__(self, configAdmin, sdoServiceAdmin):
"""
\var self._deviceProfile SDO DeviceProfile with mutex lock
"""
@@ -197,9 +201,11 @@
self._parameters = []
self._params_mutex = threading.RLock()
- self._configsets = configsets
+ self._configsets = configAdmin
self._config_mutex = threading.RLock()
+ self._sdoservice = sdoServiceAdmin
+
"""
\var self._organizations SDO OrganizationList
"""
@@ -324,24 +330,12 @@
raise SDOPackage.InvalidParameter("sProfile is empty.")
try:
- if not sProfile.id:
- prof = sProfile
- prof.id = self.getUUID()
- OpenRTM_aist.CORBA_SeqUtil.push_back(self._serviceProfiles, prof)
- return True
-
- index = OpenRTM_aist.CORBA_SeqUtil.find(self._serviceProfiles,
- self.service_id(sProfile.id))
- if index >= 0:
- OpenRTM_aist.CORBA_SeqUtil.erase(self._serviceProfiles, index)
-
- OpenRTM_aist.CORBA_SeqUtil.push_back(self._serviceProfiles, sProfile)
- return True
+ return self._sdoservice.addSdoServiceConsumer(sProfile)
except:
self._rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception())
raise SDOPackage.InternalError("Configuration.add_service_profile")
- return True
+ return False
##
@@ -442,12 +436,12 @@
raise SDOPackage.InvalidParameter("id is empty.")
try:
- OpenRTM_aist.CORBA_SeqUtil.erase_if(self._serviceProfiles, self.service_id(id_))
+ return self._sdoservice.removeSdoServiceConsumer(id_)
except:
self._rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception())
raise SDOPackage.InternalError("Configuration.remove_service_profile")
- return True
+ return False
##
@@ -797,8 +791,14 @@
guard = OpenRTM_aist.ScopedLock(self._config_mutex)
- if not self._configsets.haveConfig(config_id):
- raise SDOPackage.InternalError("No such ConfigurationSet")
+ try:
+ if not self._configsets.haveConfig(config_id):
+ self._rtcout.RTC_ERROR("No such ConfigurationSet")
+ raise SDOPackage.InternalError("No such ConfigurationSet")
+ except:
+ self._rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception())
+ raise SDOPackage.InternalError("Unknown exception")
+
configset = self._configsets.getConfigurationSet(config_id)
Added: branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/SdoServiceAdmin.py
===================================================================
--- branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/SdoServiceAdmin.py (rev 0)
+++ branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/SdoServiceAdmin.py 2011-04-08 15:43:56 UTC (rev 403)
@@ -0,0 +1,332 @@
+#!/usr/bin/env python
+# -*- coding: euc-jp -*-
+
+##
+# @file SdoServiceAdmin.py
+# @brief SDO service administration class
+# @date $Date$
+# @author Noriaki Ando <n-ando at aist.go.jp> and Shinji Kurihara
+#
+# Copyright (C) 2011
+# Intelligent Systems Research Institute,
+# National Institute of
+# Advanced Industrial Science and Technology (AIST), Japan
+# All rights reserved.
+
+import copy
+import threading
+import OpenRTM_aist
+
+
+##
+# @if jp
+#
+# @class SDO service administration class
+# @brief SDO service ´ÉÍý¥¯¥é¥¹
+#
+# ¤³¤Î¥¯¥é¥¹¤Ï¡¢SDO Service ¤ò´ÉÍý¤¹¤ë¤¿¤á¤Î¥¯¥é¥¹¤Ç¤¢¤ë¡£SDO
+# Service ¤Ï OMG SDO Specification ¤Ë¤ª¤¤¤ÆÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡¢SDO¤¬ÆÃÄê
+# ¤Îµ¡Ç½¤Î¤¿¤á¤ËÄ󶡤ޤ¿Í׵᤹¤ë¥µ¡¼¥Ó¥¹¤Î°ì¤Ä¤Ç¤¢¤ë¡£¾ÜºÙ¤Ï»ÅÍͤˤª
+# ¤¤¤ÆÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤¤¤¬¡¢ËÜ¥¯¥é¥¹¤Ç¤Ï°Ê²¼¤Î¤è¤¦¤Ë¿¶¤ëÉñ¤¦¥µ¡¼¥Ó¥¹¤Ç
+# ¤¢¤ë¤â¤Î¤È¤·¡¢¤³¤ì¤é¤ò´ÉÍý¤¹¤ë¤¿¤á¤Î¥¯¥é¥¹¤¬ËÜ¥¯¥é¥¹¤Ç¤¢¤ë¡£
+#
+# SDO Service ¤Ë¤ª¤¤¤Æ¤Ï¡¢SDO/RTC¤Ë½êͤµ¤ì¡¢¤¢¤ë¼ï¤Î¥µ¡¼¥Ó¥¹¤òÄó¶¡
+# ¤¹¤ë¤â¤Î¤ò SDO Service Provider¡¢Â¾¤ÎSDO/RTC¤ä¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬Äó
+# ¶¡¤¹¤ë¥µ¡¼¥Ó¥¹¥ª¥Ö¥¸¥§¥¯¥È¤Î»²¾È¤ò¼õ¤±¼è¤ê¡¢¤½¤ì¤é¤Îµ¡Ç½¤òÍøÍѤ¹¤ë
+# ¤â¤Î¤ò¡¢SDO Service Consumer ¤È¸Æ¤Ö¡£
+#
+# SDO Service Provider ¤Ï¾¤Î¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤«¤é¸Æ¤Ð¤ì¡¢SDO/RTCÆâÉô
+# ¤Îµ¡Ç½¤Ë¥¢¥¯¥»¥¹¤¹¤ë¤¿¤á¤ËÍѤ¤¤é¤ì¤ë¡£Â¾¤ÎSDO/RTC¤Þ¤¿¤Ï¥¢¥×¥ê¥±¡¼
+# ¥·¥ç¥ó¤Ï¡¢
+#
+# - SDO::get_service_profiles ()
+# - SDO::get_service_profile (in UniqueIdentifier id)
+# - SDO::get_sdo_service (in UniqueIdentifier id)
+#
+# ¤Î¤¤¤º¤ì¤«¤Î¥ª¥Ú¥ì¡¼¥·¥ç¥ó¤Ë¤è¤ê¡¢ServiceProfile ¤Þ¤¿¤Ï SDO
+# Service ¤Î»²¾È¤ò¼èÆÀ¤·¡¢µ¡Ç½¤òÍøÍѤ¹¤ë¤¿¤á¤Î¥ª¥Ú¥ì¡¼¥·¥ç¥ó¤ò¸Æ¤Ó½Ð
+# ¤¹¡£Â¾¤ÎSDO/RTC¤Þ¤¿¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¾å¤Ç¤Î»²¾È¤ÎÇË´þ¤ÏǤ°Õ¤Î¥¿¥¤
+# ¥ß¥ó¥°¤Ç¹Ô¤ï¤ì¡¢¥µ¡¼¥Ó¥¹Äó¶¡Â¦¤Ç¤Ï¡¢¤É¤³¤«¤é¤É¤ì¤À¤±»²¾È¤µ¤ì¤Æ¤¤¤ë
+# ¤«¤ÏÃΤ뤳¤È¤Ï¤Ç¤¤Ê¤¤¡£°ìÊý¤Ç¡¢SDO/RTC¦¤â¡¢Ç¤°Õ¤Î¥¿¥¤¥ß¥ó¥°¤Ç¥µ¡¼
+# ¥Ó¥¹¤ÎÄ󶡤òÄä»ß¤¹¤ë¤³¤È¤â¤Ç¤¤ë¤¿¤á¡¢¥µ¡¼¥Ó¥¹¤ÎÍøÍѦ¤Ç¤Ï¡¢¾ï¤Ë
+# ¥µ¡¼¥Ó¥¹¤¬ÍøÍѤǤ¤ë¤È¤Ï¸Â¤é¤Ê¤¤¤â¤Î¤È¤·¤Æ¥µ¡¼¥Ó¥¹¥ª¥Ú¥ì¡¼¥·¥ç¥ó¤ò
+# ¸Æ¤Ó½Ð¤¹É¬Íפ¬¤¢¤ë¡£
+#
+# °ìÊý¡¢SDO Service Consumer ¤ÏÅö³ºSDO/RTC°Ê³°¤ÎSDO/RTC¤Þ¤¿¤Ï¥¢¥×¥ê
+# ¥±¡¼¥·¥ç¥ó¤¬¥µ¡¼¥Ó¥¹¤Î¼ÂÂΤò»ý¤Á¡¢Åö³ºSDO/RTC¤Ë¥ª¥Ö¥¸¥§¥¯¥È»²¾È¤ò
+# ´Þ¤à¥×¥í¥Õ¥¡¥¤¥ë¤òÍ¿¤¨¤ë¤³¤È¤Ç¡¢SDO/RTC¦¤«¤é¥µ¡¼¥Ó¥¹¥ª¥Ú¥ì¡¼¥·¥ç
+# ¥ó¤¬¸Æ¤Ð¤ì³°Éô¤ÎSDO/RTC¤Þ¤¿¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬Ä󶡤¹¤ëµ¡Ç½¤òÍøÍÑ
+# ¤Ç¤¤ë¡£¤Þ¤¿¡¢¥ª¥Ö¥¶¡¼¥ÐŪ¤Ê¥ª¥Ö¥¸¥§¥¯¥È¤òÍ¿¤¨¤ë¤³¤È¤Ç¡¢SDO/RTC¦
+# ¤«¤é¤Î¥³¡¼¥ë¥Ð¥Ã¥¯¤ò¼Â¸½¤¹¤ë¤¿¤á¤Ë¤âÍøÍѤ¹¤ë¤³¤È¤¬¤Ç¤¤ë¡£¥³¥ó¥·¥å¡¼
+# ¥Þ¤Ï¡¢¥×¥í¥Ð¥¤¥À¤È¤Ï°Û¤Ê¤ê¡¢SDO Configuration¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤«¤é
+# Äɲᢺï½ü¤¬¹Ô¤ï¤ì¤ë¡£´ØÏ¢¤¹¤ë¥ª¥Ú¥ì¡¼¥·¥ç¥ó¤Ï°Ê²¼¤Î¤È¤ª¤ê¤Ç¤¢¤ë¡£
+#
+# - Configuration::add_service_profile (in ServiceProfile sProfile)
+# - Configuration::remove_service_profile (in UniqueIdentifier id)
+#
+# ³°Éô¤ÎSDO/RTC¤Þ¤¿¤Ï¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¡¢¼«¿È¤¬»ý¤ÄSDO Servcie
+# Provider ¤Î»²¾È¤òID¤ª¤è¤Óinterface type¡¢¥×¥í¥Ñ¥Æ¥£¤È¤È¤â¤Ë
+# ServcieProfile ¤Ë¥»¥Ã¥È¤·¤¿¤¦¤¨¤Ç¡¢add_service_profile() ¤Î°ú¿ô¤È
+# ¤·¤ÆÍ¿¤¨¤ë¤³¤È¤Ç¡¢Åö³ºSDO/RTC¤Ë¥µ¡¼¥Ó¥¹¤òÍ¿¤¨¤ë¡£¤³¤ÎºÝ¡¢ID¤ÏUUID
+# ¤Ê¤É°ì°Õ¤ÊID¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£¤Þ¤¿¡¢ºï½ü¤¹¤ëºÝ¤Ë¤ÏID¤Ë¤è¤êÂоݤÈ
+# ¤¹¤ëServiceProfile¤òõº÷¤¹¤ë¤¿¤á¡¢¥µ¡¼¥Ó¥¹Äó¶¡Â¦¤Ç¤Ïºï½ü»þ¤Þ¤ÇID¤ò
+# ÊÝ»ý¤·¤Æ¤ª¤«¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
+#
+#
+#
+#
+#
+# @since 1.1.0
+#
+# @else
+#
+# @class SDO service administration class
+# @brief SDO service administration class
+#
+#
+# @since 1.1.0
+#
+# @endif
+class SdoServiceAdmin:
+ """
+ """
+
+
+ ##
+ # @if jp
+ # @brief ¥³¥ó¥¹¥È¥é¥¯¥¿
+ # ¥³¥ó¥¹¥È¥é¥¯¥¿
+ # @param
+ #
+ # @else
+ # @brief Constructor
+ # Constructor
+ # @param
+ # @endif
+ # SdoServiceAdmin(::RTC::RTObject_impl& rtobj);
+ def __init__(self, rtobj):
+ self._rtobj = rtobj
+ self._consumerTypes = []
+ self._allConsumerAllowed = True
+
+ ##
+ # @if jp
+ # @brief Lock ÉÕ¤ SDO ServiceProfileList
+ # @else
+ # @brief SDO ServiceProfileList with mutex lock
+ # @endif
+ self._providerProfiles = []
+ self._provider_mutex = threading.RLock()
+
+ ##
+ # @if jp
+ # @brief Lock ÉÕ¤ SDO ServiceProfileList
+ # @else
+ # @brief SDO ServiceProfileList with mutex lock
+ # @endif
+ self._consumers = []
+ self._consumer_mutex = threading.RLock()
+
+ ##
+ # @if jp
+ # @brief logger
+ # @else
+ # @brief logger
+ # @endif
+ self._rtcout = OpenRTM_aist.Manager.instance().getLogbuf("SdoServiceAdmin")
+
+ self._rtcout.RTC_TRACE("SdoServiceAdmin::SdoServiceAdmin(%s)",
+ rtobj.getProperties().getProperty("instance_name"))
+
+ # getting consumer types from RTC's properties
+ prop = copy.deepcopy(self._rtobj.getProperties())
+ constypes = prop.getProperty("sdo_service.consumer_types")
+ self._consumerTypes = [s.strip() for s in constypes.split(",")]
+ self._rtcout.RTC_DEBUG("sdo_service.consumer_types: %s",
+ str(OpenRTM_aist.flatten(self._consumerTypes)))
+
+ # If types include '[Aa][Ll][Ll]', all types allowed in this RTC
+ for ctype in self._consumerTypes:
+ tmp = ctype.lower()
+ if tmp == "all":
+ self._allConsumerAllowed = True
+ self._rtcout.RTC_DEBUG("sdo_service.consumer_types: ALL")
+
+ return
+
+
+ ##
+ # @if jp
+ # @brief ²¾Áۥǥ¹¥È¥é¥¯¥¿
+ # ²¾Áۥǥ¹¥È¥é¥¯¥¿¡£
+ #
+ # @else
+ # @brief Virtual destractor
+ # Virtual destractor.
+ # @endif
+ def __del__(self):
+ return
+
+
+ ##
+ # @if jp
+ # @brief Service Consumer Factory ¤òÅÐÏ¿¤¹¤ë
+ #
+ # @else
+ # @brief Add Service Consumer Factory
+ # @endif
+ # bool addSdoServiceConsumerFactory();
+ def addSdoServiceConsumerFactory(self):
+ return False
+
+
+ ##
+ # @if jp
+ # @brief Service Consumer Factory ¤òºï½ü¤¹¤ë
+ #
+ # @else
+ # @brief Remove Service Consumer Factory
+ # @endif
+ # bool removeSdoServiceConsumerFactory();
+ def removeSdoServiceConsumerFactory(self):
+ return False
+
+
+ ##
+ # @if jp
+ # @brief Service Consumer ¤òÄɲ乤ë
+ #
+ # @else
+ # @brief Add Service Consumer
+ # @endif
+ # bool addSdoServiceConsumer(const SDOPackage::ServiceProfile& sProfile);
+ def addSdoServiceConsumer(self, sProfile):
+ self._rtcout.RTC_TRACE("addSdoServiceConsumer(IFR = %s)",
+ sProfile.interface_type)
+ profile = copy.deepcopy(sProfile)
+
+ # Not supported consumer type -> error return
+ if not self.isAllowedConsumerType(sProfile):
+ self._rtcout.RTC_ERROR("Not supported consumer type. %s", profile.id)
+ return False
+
+ if not self.isExistingConsumerType(sProfile):
+ self._rtcout.RTC_ERROR("type %s already exists.", profile.id)
+ return False
+
+ if str(profile.id) == "":
+ self._rtcout.RTC_WARN("No id specified. It should be given by clients.")
+ return False
+
+ # re-initialization
+ guard = OpenRTM_aist.ScopedLock(self._consumer_mutex)
+ id = str(sProfile.id)
+ for i in range(len(self._consumers)):
+ if id == str(self._consumers[i].getProfile().id):
+ self._rtcout.RTC_INFO("Existing consumer is reinitilized.")
+ self._rtcout.RTC_DEBUG("Propeteis are: %s",
+ NVUtil.toString(sProfile.properties))
+ return self._consumers[i].reinit(sProfile)
+ del guard
+
+ # new pofile
+ factory = OpenRTM_aist.SdoServiceConsumerFactory.instance()
+ ctype = str(profile.interface_type)
+ consumer = factory.createObject(ctype)
+ if consumer == None:
+ self._rtcout.RTC_ERROR("Hmm... consumer must be created.")
+ return False
+
+ # initialize
+ if not consumer.init(self._rtobj, sProfile):
+ self._rtcout.RTC_WARN("SDO service initialization was failed.")
+ self._rtcout.RTC_DEBUG("id: %s", str(sProfile.id))
+ self._rtcout.RTC_DEBUG("IFR: %s", str(sProfile.interface_type))
+ self._rtcout.RTC_DEBUG("properties: %s", OpenRTM_aist.NVUtil.toString(sProfile.properties))
+ factory.deleteObject(consumer)
+ self._rtcout.RTC_INFO("SDO consumer was deleted by initialization failure")
+ return False
+
+ # store consumer
+ guard = OpenRTM_aist.ScopedLock(self._consumer_mutex)
+ self._consumers.append(consumer)
+ del guard
+
+ return True
+
+
+ ##
+ # @if jp
+ # @brief Service Consumer ¤òºï½ü¤¹¤ë
+ #
+ # @else
+ # @brief Remove Service Consumer
+ # @endif
+ # bool removeSdoServiceConsumer(const char* id);
+ def removeSdoServiceConsumer(self, id):
+ if id == None or id[0] == '\0':
+ self._rtcout.RTC_ERROR("removeSdoServiceConsumer(): id is invalid.")
+ return False
+
+ self._rtcout.RTC_TRACE("removeSdoServiceConsumer(id = %s)", id)
+
+ guard = OpenRTM_aist.ScopedLock(self._consumer_mutex)
+ strid = id
+
+ for (idx,cons) in enumerate(self._consumers):
+ if strid == str(cons.getProfile().id):
+ cons.finalize()
+ del self._consumers[idx]
+ factory = OpenRTM_aist.SdoServiceConsumerFactory.instance()
+ factory.deleteObject(cons)
+ self._rtcout.RTC_INFO("SDO service has been deleted: %s", id)
+ return True
+
+ self._rtcout.RTC_WARN(("Specified SDO consumer not found: %s", id))
+ return False
+
+
+ ##
+ # @if jp
+ # @brief µö²Ä¤µ¤ì¤¿¥µ¡¼¥Ó¥¹·¿¤«¤É¤¦¤«Ä´¤Ù¤ë
+ #
+ # @else
+ # @brief If it is allowed service type
+ # @endif
+ # bool isAllowedConsumerType(const SDOPackage::ServiceProfile& sProfile);
+ def isAllowedConsumerType(self, sProfile):
+ if self._allConsumerAllowed:
+ return True
+
+ for i in range(len(self._consumerTypes)):
+ if self._consumerTypes[i] == str(sProfile.interface_type):
+ self._rtcout.RTC_DEBUG("%s is supported SDO service.", str(sProfile.interface_type))
+ return True
+ self._rtcout.RTC_WARN("Consumer type is not supported: %s", str(sProfile.interface_type))
+ return False
+
+
+ ##
+ # @if jp
+ # @brief ¸ºß¤¹¤ë¥µ¡¼¥Ó¥¹·¿¤«¤É¤¦¤«Ä´¤Ù¤ë
+ #
+ # @else
+ # @brief If it is existing service type
+ # @endif
+ # bool isExistingConsumerType(const SDOPackage::ServiceProfile& sProfile);
+ def isExistingConsumerType(self, sProfile):
+ factory = OpenRTM_aist.SdoServiceConsumerFactory.instance()
+ consumerTypes = factory.getIdentifiers()
+ for i in range(len(consumerTypes)):
+ if consumerTypes[i] == str(sProfile.interface_type):
+ self._rtcout.RTC_DEBUG("%s exists in the SDO service factory.", str(sProfile.interface_type))
+ self._rtcout.RTC_PARANOID("Available SDO serices in the factory: %s", str(OpenRTM_aist.flatten(consumerTypes)))
+ return True
+ self._rtcout.RTC_WARN("No available SDO service in the factory: %s",
+ str(sProfile.interface_type))
+ return False
+
+
+ # const std::string getUUID() const;
+ def getUUID(self):
+ return str(OpenRTM_aist.uuid1())
Added: branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/SdoServiceConsumerBase.py
===================================================================
--- branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/SdoServiceConsumerBase.py (rev 0)
+++ branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/SdoServiceConsumerBase.py 2011-04-08 15:43:56 UTC (rev 403)
@@ -0,0 +1,81 @@
+#!/usr/bin/env python
+# -*- coding: euc-jp -*-
+
+##
+# @file SdoServiceConsumerBase.py
+# @brief SDO service consumer base class and its factory
+# @date $Date$
+# @author Noriaki Ando <n-ando at aist.go.jp> and Shinji Kurihara
+#
+# Copyright (C) 2011
+# Intelligent Systems Research Institute,
+# National Institute of
+# Advanced Industrial Science and Technology (AIST), Japan
+# All rights reserved.
+
+import SDOPackage
+import OpenRTM_aist
+
+
+##
+# @if jp
+#
+# SdoServiceConsumerFactory&
+# factory(SdoServiceConsumerFactory.instance());
+#
+# factory.addFactory(toRepositoryId<IDL Type>(),
+# Creator< SdoServiceConsumerBase,
+# your_sdo_service_consumer_subclass>,
+# Destructor< SdoServiceConsumerBase,
+# your_sdo_service_consumer_subclass>);
+#
+# @else
+#
+#
+#
+# @endif
+class SdoServiceConsumerBase:
+ """
+ """
+
+ def __init__(self):
+ pass
+
+ # virtual bool init(RTObject_impl& rtobj,
+ # const SDOPackage::ServiceProfile& profile) = 0;
+ def init(self, rtobj, profile):
+ pass
+
+
+ # virtual bool reinit(const SDOPackage::ServiceProfile& profile) = 0;
+ def reinit(self, profile):
+ pass
+
+
+ # virtual const SDOPackage::ServiceProfile& getProfile() const = 0;
+ def getProfile(self):
+ pass
+
+ # virtual void finalize() = 0;
+ def finalize(self):
+ pass
+
+sdoserviceconsumerfactory = None
+
+class SdoServiceConsumerFactory(OpenRTM_aist.Factory,SdoServiceConsumerBase):
+ def __init__(self):
+ OpenRTM_aist.Factory.__init__(self)
+ return
+
+ def __del__(self):
+ pass
+
+ def instance():
+ global sdoserviceconsumerfactory
+
+ if sdoserviceconsumerfactory is None:
+ sdoserviceconsumerfactory = SdoServiceConsumerFactory()
+
+ return sdoserviceconsumerfactory
+
+ instance = staticmethod(instance)
Modified: branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/__init__.py
===================================================================
--- branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/__init__.py 2011-04-08 08:42:39 UTC (rev 402)
+++ branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/__init__.py 2011-04-08 15:43:56 UTC (rev 403)
@@ -64,6 +64,9 @@
from uuid import *
from SdoConfiguration import *
from SdoOrganization import *
+from SdoServiceConsumerBase import *
+from SdoServiceAdmin import *
+from ConfigurationListener import *
from PeriodicECSharedComposite import *
from RTCUtil import *
from OutPortBase import *
@@ -78,6 +81,7 @@
from InPortPushConnector import *
from OutPort import *
from PortCallBack import *
+from PortConnectListener import *
from CorbaPort import *
from OutPortConnector import *
from OutPortCorbaCdrConsumer import *
Modified: branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/test/test_ComponentActionListener.py
===================================================================
--- branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/test/test_ComponentActionListener.py 2011-04-08 08:42:39 UTC (rev 402)
+++ branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/test/test_ComponentActionListener.py 2011-04-08 15:43:56 UTC (rev 403)
@@ -194,36 +194,36 @@
def test_PreComponentActionListenerHolder(self):
preactions = ComponentActionListeners()
listener = MockPreComponentActionListener()
- preactions.preaction[0].addListener(listener,True)
- preactions.preaction[0].notify("test precomp ec_id")
- preactions.preaction[0].removeListener(listener)
+ preactions.preaction_[0].addListener(listener,True)
+ preactions.preaction_[0].notify("test precomp ec_id")
+ preactions.preaction_[0].removeListener(listener)
return
def test_PostComponentActionListenerHolder(self):
postactions = ComponentActionListeners()
listener = MockPostComponentActionListener()
- postactions.postaction[0].addListener(listener,True)
- postactions.postaction[0].notify("test postcomp ec_id",True)
- postactions.postaction[0].removeListener(listener)
+ postactions.postaction_[0].addListener(listener,True)
+ postactions.postaction_[0].notify("test postcomp ec_id",True)
+ postactions.postaction_[0].removeListener(listener)
return
def test_PortActionListenerHolder(self):
portactions = ComponentActionListeners()
listener = MockPortActionListener()
- portactions.portaction[0].addListener(listener,True)
- portactions.portaction[0].notify("test port pprof")
- portactions.portaction[0].removeListener(listener)
+ portactions.portaction_[0].addListener(listener,True)
+ portactions.portaction_[0].notify("test port pprof")
+ portactions.portaction_[0].removeListener(listener)
return
def test_ExecutionContextActionListenerHolder(self):
ecactions = ComponentActionListeners()
listener = MockExecutionContextActionListener()
- ecactions.ecaction[0].addListener(listener,True)
- ecactions.ecaction[0].notify("test ec ec_id")
- ecactions.ecaction[0].removeListener(listener)
+ ecactions.ecaction_[0].addListener(listener,True)
+ ecactions.ecaction_[0].notify("test ec ec_id")
+ ecactions.ecaction_[0].removeListener(listener)
return
############### test #################
if __name__ == '__main__':
- unittest.main()
+ unittest.main()
Modified: branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/test/test_ConfigurationListener.py
===================================================================
--- branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/test/test_ConfigurationListener.py 2011-04-08 08:42:39 UTC (rev 402)
+++ branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/test/test_ConfigurationListener.py 2011-04-08 15:43:56 UTC (rev 403)
@@ -99,7 +99,7 @@
return
def test_ConfigurationSetListenerHolder(self):
- configsets = ConfigurationListeners()
+ configsetss = ConfigurationListeners()
listener = MockConfigurationSetListener()
configsets.configset_[0].addListener(listener,True)
prop = OpenRTM_aist.Properties(defaults_str=config_set)
Modified: branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/test/test_ConnectorListener.py
===================================================================
--- branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/test/test_ConnectorListener.py 2011-04-08 08:42:39 UTC (rev 402)
+++ branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/test/test_ConnectorListener.py 2011-04-08 15:43:56 UTC (rev 403)
@@ -1,12 +1,12 @@
#!/usr/bin/env python
# -*- Python -*-
+##
+# @file test_ConnectorListener.py
+# @brief test for connector listener class
+# @date $Date: 2010/01/06 $
+# @author Shinji Kurihara
#
-# \file test_ConnectorListener.py
-# \brief test for connector listener class
-# \date $Date: 2010/01/06 $
-# \author Shinji Kurihara
-#
# Copyright (C) 2010
# Task-intelligence Research Group,
# Intelligent Systems Research Institute,
Added: branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/test/test_PortConnectListener.py
===================================================================
--- branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/test/test_PortConnectListener.py (rev 0)
+++ branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/test/test_PortConnectListener.py 2011-04-08 15:43:56 UTC (rev 403)
@@ -0,0 +1,119 @@
+#!/usr/bin/env python
+# -*- Python -*-
+
+##
+# @file test_PortConnectListener.py
+# @brief test for port connector listener class
+# @date $Date: 2011/03/18 $
+# @author Shinji Kurihara
+#
+# Copyright (C) 2011
+# Intelligent Systems Research Institute,
+# National Institute of
+# Advanced Industrial Science and Technology (AIST), Japan
+# All rights reserved.
+
+
+import sys
+sys.path.insert(1,"../")
+
+import unittest
+import OpenRTM_aist
+from PortConnectListener import *
+
+import RTC, RTC__POA
+import OpenRTM
+
+from omniORB import *
+from omniORB import any
+
+class MockPortConnectListener(PortConnectListener):
+ def __init__(self):
+ PortConnectListener.__init__(self)
+ return
+
+ def __call__(self,portname,profile):
+ return
+
+
+class MockPortConnectRetListener(PortConnectRetListener):
+ def __init__(self):
+ PortConnectRetListener.__init__(self)
+ return
+
+ def __call__(self,portname,profile,ret):
+ return
+
+
+
+class TestListener(unittest.TestCase):
+ def setUp(self):
+ return
+
+ def tearDown(self):
+ OpenRTM_aist.Manager.instance().shutdownManager()
+ return
+
+ def test_PortConnectListener_toString(self):
+ self.assertEqual("ON_NOTIFY_CONNECT",
+ PortConnectListener.toString(
+ PortConnectListenerType.ON_NOTIFY_CONNECT))
+
+ self.assertEqual("ON_NOTIFY_DISCONNECT",
+ PortConnectListener.toString(
+ PortConnectListenerType.ON_NOTIFY_DISCONNECT))
+
+ self.assertEqual("ON_UNSUBSCRIBE_INTERFACES",
+ PortConnectListener.toString(
+ PortConnectListenerType.ON_UNSUBSCRIBE_INTERFACES))
+ return
+
+
+ def test_PortConnectRetListener_toString(self):
+ self.assertEqual("ON_PUBLISH_INTERFACES",
+ PortConnectRetListener.toString(
+ PortConnectRetListenerType.ON_PUBLISH_INTERFACES))
+
+ self.assertEqual("ON_CONNECT_NEXTPORT",
+ PortConnectRetListener.toString(
+ PortConnectRetListenerType.ON_CONNECT_NEXTPORT))
+
+ self.assertEqual("ON_SUBSCRIBE_INTERFACES",
+ PortConnectRetListener.toString(
+ PortConnectRetListenerType.ON_SUBSCRIBE_INTERFACES))
+
+ self.assertEqual("ON_CONNECTED",
+ PortConnectRetListener.toString(
+ PortConnectRetListenerType.ON_CONNECTED))
+
+ self.assertEqual("ON_DISCONNECT_NEXT",
+ PortConnectRetListener.toString(
+ PortConnectRetListenerType.ON_DISCONNECT_NEXT))
+
+ self.assertEqual("ON_DISCONNECTED",
+ PortConnectRetListener.toString(
+ PortConnectRetListenerType.ON_DISCONNECTED))
+ return
+
+
+ def test_PortConnectListenerHolder(self):
+ portconlisteners = PortConnectListeners()
+ listener = MockPortConnectListener()
+ portconlisteners.portconnect_[0].addListener(listener,True)
+ portconlisteners.portconnect_[0].notify("port_name",None)
+ portconlisteners.portconnect_[0].removeListener(listener)
+ return
+
+ def test_PortConnectRetListenerHolder(self):
+ portconretlisteners = PortConnectRetListeners()
+ listener = MockPortConnectRetListener()
+ portconretlisteners.portconnret_[0].addListener(listener,True)
+ portconretlisteners.portconnret_[0].notify("port_name",None)
+ portconretlisteners.portconnret_[0].removeListener(listener)
+ return
+
+
+############### test #################
+if __name__ == '__main__':
+ unittest.main()
+
Added: branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/test/test_SdoServiceAdmin.py
===================================================================
--- branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/test/test_SdoServiceAdmin.py (rev 0)
+++ branches/RELENG_1_0/OpenRTM-aist-Python/OpenRTM_aist/test/test_SdoServiceAdmin.py 2011-04-08 15:43:56 UTC (rev 403)
@@ -0,0 +1,139 @@
+#!/usr/bin/env python
+# -*- coding: euc-jp -*-
+
+##
+# @file test_SdoServiceAdmin.py
+# @brief test for SdoServiceAdmin class
+# @date $Date$
+# @author Shinji Kurihara
+#
+# Copyright (C) 2011
+# Intelligent Systems Research Institute,
+# National Institute of
+# Advanced Industrial Science and Technology (AIST), Japan
+# All rights reserved.
+
+import sys
+sys.path.insert(1, "../")
+
+import unittest
+from SdoServiceAdmin import *
+import OpenRTM_aist
+import SDOPackage,SDOPackage__POA
+from omniORB import CORBA, PortableServer
+from omniORB import any
+
+
+class MockRTC(OpenRTM_aist.RTObject_impl):
+ def __init__(self):
+ self._orb = CORBA.ORB_init()
+ self._poa = self._orb.resolve_initial_references("RootPOA")
+ OpenRTM_aist.RTObject_impl.__init__(self, orb=self._orb, poa=self._poa)
+ pass
+
+
+class SDOServiceMock(SDOPackage__POA.SDOService):
+ def __init__(self):
+ pass
+
+class MockSdoServiceConsumer(OpenRTM_aist.SdoServiceConsumerBase):
+ """
+ """
+
+ def __init__(self):
+ OpenRTM_aist.SdoServiceConsumerBase.__init__(self)
+ return
+
+ def reinit(self, profile):
+ pass
+
+ def getProfile(self):
+ any_val = any.to_any("3.14159")
+ nv = SDOPackage.NameValue("PROPERTIES NAME 0", any_val)
+ sprof = SDOPackage.ServiceProfile("test id","INTERFACE_TYPE",[nv],SDOServiceMock())
+ return sprof
+
+
+class TestListener(unittest.TestCase):
+ def setUp(self):
+ return
+
+
+ def tearDown(self):
+ OpenRTM_aist.Manager.instance().shutdownManager()
+ return
+
+
+ def test_addSdoServiceConsumerFactory(self):
+ sdoadmin = SdoServiceAdmin(MockRTC())
+ self.assertEqual(sdoadmin.addSdoServiceConsumerFactory(),False)
+ return
+
+
+ def test_removeSdoServiceConsumerFactory(self):
+ sdoadmin = SdoServiceAdmin(MockRTC())
+ self.assertEqual(sdoadmin.removeSdoServiceConsumerFactory(),False)
+ return
+
+
+ def test_addSdoServiceConsumer(self):
+ any_val = any.to_any("3.14159")
+ nv = SDOPackage.NameValue("PROPERTIES NAME 0", any_val)
+ sprof = SDOPackage.ServiceProfile("ID 0","INTERFACE_TYPE",[nv],SDOServiceMock())
+ sdoadmin = SdoServiceAdmin(MockRTC())
+ self.assertEqual(sdoadmin.addSdoServiceConsumer(sprof),False)
+ return
+
+
+ def test_removeSdoServiceConsumer(self):
+ any_val = any.to_any("3.14159")
+ nv = SDOPackage.NameValue("PROPERTIES NAME 0", any_val)
+ sprof = SDOPackage.ServiceProfile("test id","INTERFACE_TYPE",[nv],SDOServiceMock())
+ sdoadmin = SdoServiceAdmin(MockRTC())
+ self.assertEqual(sdoadmin.addSdoServiceConsumer(sprof),False)
+ sdoadmin._consumers.append(MockSdoServiceConsumer())
+ self.assertEqual(sdoadmin.removeSdoServiceConsumer("test id"),True)
+ self.assertEqual(sdoadmin.addSdoServiceConsumer(sprof),False)
+ sdoadmin._consumers.append(MockSdoServiceConsumer())
+ self.assertEqual(sdoadmin.removeSdoServiceConsumer("test id2"),False)
+ return
+
+
+ def test_isAllowedConsumerType(self):
+ sdoadmin = SdoServiceAdmin(MockRTC())
+ any_val = any.to_any("3.14159")
+ nv = SDOPackage.NameValue("PROPERTIES NAME 0", any_val)
+ sprof = SDOPackage.ServiceProfile("test id","INTERFACE_TYPE",[nv],SDOServiceMock())
+ self.assertEqual(sdoadmin.isAllowedConsumerType(sprof),True)
+ sdoadmin._allConsumerAllowed = False
+ self.assertEqual(sdoadmin.isAllowedConsumerType(sprof),False)
+ sdoadmin._consumerTypes = ["type0","type1","type2","INTERFACE_TYPE"]
+ self.assertEqual(sdoadmin.isAllowedConsumerType(sprof),True)
+ sdoadmin._consumerTypes = ["type0","type1","type2"]
+ self.assertEqual(sdoadmin.isAllowedConsumerType(sprof),False)
+ return
+
+
+ def test_isExistingConsumerType(self):
+ factory = OpenRTM_aist.SdoServiceConsumerFactory.instance()
+ factory.addFactory("test_factory",OpenRTM_aist.SdoServiceConsumerBase,OpenRTM_aist.Delete)
+ sdoadmin = SdoServiceAdmin(MockRTC())
+ any_val = any.to_any("3.14159")
+ nv = SDOPackage.NameValue("PROPERTIES NAME 0", any_val)
+ sprof = SDOPackage.ServiceProfile("test id","INTERFACE_TYPE",[nv],SDOServiceMock())
+ self.assertEqual(sdoadmin.isExistingConsumerType(sprof),False)
+ factory.addFactory("INTERFACE_TYPE",OpenRTM_aist.SdoServiceConsumerBase,OpenRTM_aist.Delete)
+ self.assertEqual(sdoadmin.isExistingConsumerType(sprof),True)
+ return
+
+
+ def test_getUUID(self):
+ sdoadmin = SdoServiceAdmin(MockRTC())
+ self.assertNotEqual(sdoadmin.getUUID(),"")
+ self.assertNotEqual(sdoadmin.getUUID(),None)
+ return
+
+
+############### test #################
+if __name__ == '__main__':
+ unittest.main()
More information about the openrtm-commit
mailing list