InPortConnector.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -*- coding: euc-jp -*-
00003 
00004 ##
00005 # @file InPortConnector.py
00006 # @brief InPortConnector base class
00007 # @date $Date$
00008 # @author Noriaki Ando <n-ando@aist.go.jp> and Shinji Kurihara
00009 #
00010 # Copyright (C) 2009
00011 #     Noriaki Ando
00012 #     Task-intelligence Research Group,
00013 #     Intelligent Systems Research Institute,
00014 #     National Institute of
00015 #         Advanced Industrial Science and Technology (AIST), Japan
00016 #     All rights reserved.
00017 #
00018 
00019 import OpenRTM_aist
00020 import RTC
00021 
00022 
00023 ##
00024 # @if jp
00025 # @class InPortConnector
00026 # @brief InPortConnector 基底クラス
00027 #
00028 # InPort の Push/Pull 各種 Connector を派生させるための
00029 # 基底クラス。
00030 #
00031 # @since 1.0.0
00032 #
00033 # @else
00034 # @class InPortConnector
00035 # @brief InPortConnector base class
00036 #
00037 # The base class to derive subclasses for InPort's Push/Pull Connectors
00038 #
00039 # @since 1.0.0
00040 #
00041 # @endif
00042 #
00043 class InPortConnector(OpenRTM_aist.ConnectorBase):
00044   """
00045   """
00046 
00047   ##
00048   # @if jp
00049   # @brief コンストラクタ
00050   # @else
00051   # @brief Constructor
00052   # @endif
00053   #
00054   # InPortConnector(ConnectorInfo& info,
00055   #                 CdrBufferBase* buffer);
00056   def __init__(self, info, buffer):
00057     self._rtcout = OpenRTM_aist.Manager.instance().getLogbuf("InPortConnector")
00058     self._profile = info
00059     self._buffer = buffer
00060     self._dataType = None
00061     self._endian = None
00062     
00063 
00064   ##
00065   # @if jp
00066   # @brief デストラクタ
00067   # @else
00068   # @brief Destructor
00069   # @endif
00070   #
00071   def __del__(self):
00072     pass
00073 
00074 
00075   ##
00076   # @if jp
00077   # @brief ConnectorInfo 取得
00078   #
00079   # Connector ConnectorInfo を取得する
00080   #
00081   # @else
00082   # @brief Getting ConnectorInfo
00083   #
00084   # This operation returns ConnectorInfo
00085   #
00086   # @endif
00087   #
00088   # const ConnectorInfo& profile();
00089   def profile(self):
00090     self._rtcout.RTC_TRACE("profile()")
00091     return self._profile
00092 
00093 
00094   ##
00095   # @if jp
00096   # @brief Connector ID 取得
00097   #
00098   # Connector ID を取得する
00099   #
00100   # @else
00101   # @brief Getting Connector ID
00102   #
00103   # This operation returns Connector ID
00104   #
00105   # @endif
00106   #
00107   # const char* id();
00108   def id(self):
00109     self._rtcout.RTC_TRACE("id() = %s", self.profile().id)
00110     return self.profile().id
00111 
00112 
00113   ##
00114   # @if jp
00115   # @brief Connector 名取得
00116   #
00117   # Connector 名を取得する
00118   #
00119   # @else
00120   # @brief Getting Connector name
00121   #
00122   # This operation returns Connector name
00123   #
00124   # @endif
00125   #
00126   # const char* name();
00127   def name(self):
00128     self._rtcout.RTC_TRACE("name() = %s", self.profile().name)
00129     return self.profile().name
00130 
00131 
00132   ##
00133   # @if jp
00134   # @brief 接続解除関数
00135   #
00136   # Connector が保持している接続を解除する
00137   #
00138   # @else
00139   # @brief Disconnect connection
00140   #
00141   # This operation disconnect this connection
00142   #
00143   # @endif
00144   #
00145   # virtual ReturnCode disconnect() = 0;
00146   def disconnect(self):
00147     pass
00148 
00149   ##
00150   # @if jp
00151   # @brief Buffer を所得する
00152   #
00153   # Connector が保持している Buffer を返す
00154   #
00155   # @else
00156   # @brief Getting Buffer
00157   #
00158   # This operation returns this connector's buffer
00159   #
00160   # @endif
00161   #
00162   # virtual CdrBufferBase* getBuffer();
00163   def getBuffer(self):
00164     return self._buffer
00165 
00166   ##
00167   # @if jp
00168   # @brief read 関数
00169   #
00170   # Buffer からデータを InPort へ read する関数
00171   #
00172   # @else
00173   # @brief Destructor
00174   #
00175   # The read function to read data from buffer to InPort
00176   #
00177   # @endif
00178   #
00179   # virtual ReturnCode read(cdrMemoryStream& data) = 0;
00180   def read(self, data):
00181     pass
00182 
00183   # void setConnectorInfo(ConnectorInfo profile);
00184   def setConnectorInfo(self, profile):
00185     self._profile = profile
00186 
00187     if self._profile.properties.hasKey("serializer"):
00188       endian = self._profile.properties.getProperty("serializer.cdr.endian")
00189       if not endian:
00190         self._rtcout.RTC_ERROR("InPortConnector.setConnectorInfo(): endian is not supported.")
00191         return RTC.RTC_ERROR
00192         
00193       endian = OpenRTM_aist.split(endian, ",") # Maybe endian is ["little","big"]
00194       endian = OpenRTM_aist.normalize(endian) # Maybe self._endian is "little" or "big"
00195 
00196       if endian == "little":
00197         self._endian = True
00198       elif endian == "big":
00199         self._endian = False
00200       else:
00201         self._endian = None
00202             
00203     else:
00204       self._endian = True # little endian
00205 
00206     return RTC.RTC_OK
00207 
00208 
00209 
00210   # template<class DataType>
00211   # void setDataTyep(DataType data);
00212   def setDataType(self, data):
00213     self._dataType = data


openrtm_aist_python
Author(s): Shinji Kurihara
autogenerated on Thu Aug 27 2015 14:17:28