InPortCorbaConsumer.py

説明を見る。
00001 #!/usr/bin/env python
00002 # -*- coding: euc-jp -*-
00003 
00004 ##
00005 # @file  InPortCorbaConsumer.py
00006 # @brief InPortCorbaConsumer class
00007 # @date  $Date: 2007/09/20 $
00008 # @author Noriaki Ando <n-ando@aist.go.jp> and Shinji Kurihara
00009 #
00010 # Copyright (C) 2006-2008
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 from omniORB import CORBA
00020 from omniORB import any
00021 import sys
00022 import traceback
00023 
00024 import RTC, RTC__POA
00025 import OpenRTM
00026 
00027 
00028 ##
00029 # @if jp
00030 #
00031 # @class InPortCorbaConsumer
00032 #
00033 # @brief InPortCorbaConsumer クラス
00034 #
00035 # 通信手段に CORBA を利用した入力ポートコンシューマの実装クラス。
00036 #
00037 # @param DataType 本ポートにて扱うデータ型
00038 #
00039 # @since 0.4.0
00040 #
00041 # @else
00042 # @class InPortCorbaConsumer
00043 # @brief InPortCorbaConsumer class
00044 # @endif
00045 class InPortCorbaConsumer(OpenRTM.InPortConsumer,OpenRTM.CorbaConsumer):
00046   """
00047   """
00048 
00049 
00050 
00051   ##
00052   # @if jp
00053   # @brief コンストラクタ
00054   #
00055   # コンストラクタ
00056   #
00057   # @param self
00058   # @param buffer_ 当該コンシューマに割り当てるバッファオブジェクト
00059   # @param consumer Consumer オブジェクト(デフォルト値:None)
00060   #
00061   # @else
00062   # @brief Constructor
00063   # @endif
00064   def __init__(self, buffer_, consumer=None):
00065     if consumer:
00066       OpenRTM.CorbaConsumer.__init__(self, consumer=consumer)
00067       self._buffer = consumer._buffer
00068       return
00069     
00070     OpenRTM.CorbaConsumer.__init__(self)
00071     self._buffer = buffer_
00072 
00073 
00074   ##
00075   # @if jp
00076   # @brief 代入演算子
00077   #
00078   # 代入演算子
00079   #
00080   # @param self
00081   # @param consumer 代入元 InPortCorbaConsumer オブジェクト
00082   #
00083   # @return 代入結果
00084   #
00085   # @else
00086   #
00087   # @endif
00088   def equal_operator(self, consumer):
00089     if self == consumer:
00090       return self
00091 
00092     self._buffer = consumer._buffer
00093 
00094 
00095   ##
00096   # @if jp
00097   # @brief バッファへのデータ書込
00098   #
00099   # バッファにデータを書き込む
00100   #
00101   # @param self
00102   # @param data 書込対象データ
00103   #
00104   # @else
00105   #
00106   # @endif
00107   def put(self, data):
00108     tmp = any.to_any(data)
00109     obj = self._ptr()._narrow(RTC.InPortAny)
00110     obj.put(tmp)
00111 
00112 
00113   ##
00114   # @if jp
00115   # @brief バッファからのデータ取出
00116   #
00117   # バッファからデータを取り出して送出する。
00118   #
00119   # @param self
00120   #
00121   # @else
00122   #
00123   # @endif
00124   def push(self):
00125     data = [None]
00126     self._buffer.read(data)
00127     tmp = any.to_any(data[0])
00128 
00129     if self._ptr() is None:
00130       return
00131 
00132     obj = self._ptr()._narrow(RTC.InPortAny)
00133 
00134     # 本当はエラー処理をすべき
00135     if CORBA.is_nil(obj):
00136       return
00137     try:
00138       obj.put(tmp)
00139     except:
00140       # オブジェクトが無効になったらdisconnectすべき
00141       traceback.print_exception(*sys.exec_info())
00142       return
00143 
00144 
00145   ##
00146   # @if jp
00147   # @brief コピーの生成
00148   #
00149   # 当該InPortCorbaConsumerオブジェクトの複製を生成する。
00150   #
00151   # @param self
00152   #
00153   # @return コピーされたInPortCorbaConsumerオブジェクト
00154   #
00155   # @else
00156   #
00157   # @endif
00158   def clone(self):
00159     return OpenRTM.InPortCorbaConsumer(self, consumer=self)
00160 
00161 
00162   ##
00163   # @if jp
00164   # @brief データ送信通知への登録
00165   #
00166   # 指定されたプロパティに基づいて、データ送出通知の受け取りに登録する。
00167   #
00168   # @param self
00169   # @param properties 登録情報
00170   #
00171   # @return 登録処理結果(登録成功:true、登録失敗:false)
00172   #
00173   # @else
00174   #
00175   # @endif
00176   def subscribeInterface(self, properties):
00177     if not OpenRTM.NVUtil.isStringValue(properties,
00178                       "dataport.dataflow_type",
00179                       "Push"):
00180       return False
00181 
00182     index = OpenRTM.NVUtil.find_index(properties,
00183                       "dataport.corba_any.inport_ref")
00184 
00185     if index < 0:
00186       return False
00187 
00188     obj = None
00189     try:
00190       obj = any.from_any(properties[index].value,keep_structs=True)
00191     except:
00192       return False
00193 
00194     if not CORBA.is_nil(obj):
00195       self.setObject(obj)
00196       return True
00197 
00198     return False
00199 
00200 
00201   ##
00202   # @if jp
00203   # @brief データ送信通知からの登録解除(サブクラス実装用)
00204   #
00205   # データ送出通知の受け取りから登録を解除する。<BR>
00206   # ※サブクラスでの実装参照用
00207   #
00208   # @param self
00209   # @param properties 登録解除情報
00210   #
00211   # @else
00212   #
00213   # @endif
00214   def unsubscribeInterface(self, properties):
00215     pass

OpenRTMに対してMon Mar 17 15:11:05 2008に生成されました。  doxygen 1.5.4