OpenRTM-aist  1.2.2
ExecutionContextWorker.h
[詳解]
1 // -*- C++ -*-
19 #ifndef RTC_EXECUTIONCONTEXTWORKER_H
20 #define RTC_EXECUTIONCONTEXTWORKER_H
21 
22 #include <coil/Mutex.h>
23 #include <coil/Condition.h>
24 #include <vector>
25 
26 #include <rtm/idl/RTCSkel.h>
27 #include <rtm/SystemLogger.h>
28 //#include <rtm/StateMachine.h>
29 //#include <rtm/RTObjectStateMachine.h>
30 
31 #define NUM_OF_LIFECYCLESTATE 4
32 
33 #ifdef WIN32
34 #pragma warning( disable : 4290 )
35 #endif
36 
37 namespace RTC
38 {
39  class RTObject_impl;
40 };
41 namespace RTC_impl
42 {
119  {
121 
122  public:
143 
144 
158  virtual ~ExecutionContextWorker(void);
159 
160  //============================================================
161  // Object reference to EC
162  //============================================================
163  void setECRef(RTC::ExecutionContextService_ptr ref);
164  RTC::ExecutionContextService_ptr getECRef();
165 
166  //============================================================
167  // ExecutionContext
168  //============================================================
193  CORBA::Boolean isRunning(void);
194 
222  RTC::ReturnCode_t start(void);
223 
250  RTC::ReturnCode_t stop(void);
251 
252  RTC::ReturnCode_t startThread(void);
253 
254  RTC::ReturnCode_t stopThread(void);
255 
256 
284  RTC::ReturnCode_t rateChanged();
285 
319  RTC::ReturnCode_t activateComponent(RTC::LightweightRTObject_ptr comp,
320  RTObjectStateMachine*& rtobj);
321  RTC::ReturnCode_t waitActivateComplete(RTObjectStateMachine*& rtobj,
322  coil::TimeValue timeout = 1.0,
323  long int cycle = 1000);
356  RTC::ReturnCode_t deactivateComponent(RTC::LightweightRTObject_ptr comp,
357  RTObjectStateMachine*& rtobj);
358  RTC::ReturnCode_t waitDeactivateComplete(RTObjectStateMachine*& rtobj,
359  coil::TimeValue timeout = 1.0,
360  long int cycle = 1000);
361 
393  RTC::ReturnCode_t resetComponent(RTC::LightweightRTObject_ptr com,
394  RTObjectStateMachine*& rtobj);
395  RTC::ReturnCode_t waitResetComplete(RTObjectStateMachine*& rtobj,
396  coil::TimeValue timeout = 1.0,
397  long int cycle = 1000);
398 
425  RTC::LifeCycleState getComponentState(RTC::LightweightRTObject_ptr comp);
426  const char* getStateString(RTC::LifeCycleState state)
427  {
428  const char* st[] = {
429  "CREATED_STATE",
430  "INACTIVE_STATE",
431  "ACTIVE_STATE",
432  "ERROR_STATE"
433  };
434  return state >= RTC::CREATED_STATE && state <= RTC::ERROR_STATE ?
435  st[state] : "";
436  }
480  RTC::ReturnCode_t addComponent(RTC::LightweightRTObject_ptr comp);
481 
508  RTC::ReturnCode_t bindComponent(RTC::RTObject_impl* rtc);
509 
540  RTC::ReturnCode_t removeComponent(RTC::LightweightRTObject_ptr comp);
542 
543  bool isAllCurrentState(RTC::LifeCycleState state);
544  bool isAllNextState(RTC::LifeCycleState state);
545  bool isOneOfCurrentState(RTC::LifeCycleState state);
546  bool isOneOfNextState(RTC::LifeCycleState state);
547 
548  void invokeWorker();
549  void invokeWorkerPreDo();
550  void invokeWorkerDo();
551  void invokeWorkerPostDo();
552 
560  void updateComponentList();
561 
562  //------------------------------------------------------------
563  // member variables
564  protected:
573 
574  RTC::ExecutionContextService_var m_ref;
575 
585  bool m_running;
586 
594  std::vector<RTC_impl::RTObjectStateMachine*> m_comps;
596  std::vector<RTC_impl::RTObjectStateMachine*> m_addedComps;
598  std::vector<RTC_impl::RTObjectStateMachine*> m_removedComps;
600  typedef std::vector<RTC_impl::RTObjectStateMachine*>::iterator CompItr;
601 
602  }; // class PeriodicExecutionContext
603 }; // namespace RTC
604 
605 #ifdef WIN32
606 #pragma warning( default : 4290 )
607 #endif
608 
609 #endif // RTC_PERIODICEXECUTIONCONTEXT_H
RTC_impl::ExecutionContextWorker::isAllNextState
bool isAllNextState(RTC::LifeCycleState state)
RTC_impl::ExecutionContextWorker::~ExecutionContextWorker
virtual ~ExecutionContextWorker(void)
デストラクタ
RTC_impl::LightweightRTObject_ptr
RTC::LightweightRTObject_ptr LightweightRTObject_ptr
Definition: ExecutionContextWorker.h:43
RTC_impl::ExecutionContextWorker
ExecutionContextWorker クラス
Definition: ExecutionContextWorker.h:118
RTC_impl::ExecutionContextWorker::m_mutex
coil::Mutex m_mutex
Definition: ExecutionContextWorker.h:595
RTC_impl::ExecutionContextWorker::updateComponentList
void updateComponentList()
コンポーネントリストの更新
RTC_impl::ExecutionContextWorker::isOneOfNextState
bool isOneOfNextState(RTC::LifeCycleState state)
RTC_impl::ExecutionContextWorker::stopThread
RTC::ReturnCode_t stopThread(void)
RTC_impl::ExecutionContextWorker::stop
RTC::ReturnCode_t stop(void)
ExecutionContext の実行を停止
RTC_impl::ExecutionContextWorker::removeComponent
RTC::ReturnCode_t removeComponent(RTC::LightweightRTObject_ptr comp)
RTコンポーネントを参加者リストから削除する
RTC_impl::LightweightRTObject_var
RTC::LightweightRTObject_var LightweightRTObject_var
Definition: ExecutionContextWorker.h:45
RTC_impl::ExecutionContextWorker::bindComponent
RTC::ReturnCode_t bindComponent(RTC::RTObject_impl *rtc)
コンポーネントをバインドする。
RTC_impl::ExecutionContextWorker::CompItr
std::vector< RTC_impl::RTObjectStateMachine * >::iterator CompItr
Definition: ExecutionContextWorker.h:600
coil::Mutex
Mutex クラス
Definition: Mutex.h:40
RTC_impl
Definition: ExecutionContextProfile.h:34
RTC_impl::ExecutionContextWorker::invokeWorkerPostDo
void invokeWorkerPostDo()
RTC_impl::ExecutionContextWorker::getStateString
const char * getStateString(RTC::LifeCycleState state)
Definition: ExecutionContextWorker.h:426
RTC_impl::ExecutionContextWorker::getECRef
RTC::ExecutionContextService_ptr getECRef()
RTC_impl::ExecutionContextWorker::waitResetComplete
RTC::ReturnCode_t waitResetComplete(RTObjectStateMachine *&rtobj, coil::TimeValue timeout=1.0, long int cycle=1000)
RTC_impl::ExecutionContextWorker::m_addedComps
std::vector< RTC_impl::RTObjectStateMachine * > m_addedComps
Definition: ExecutionContextWorker.h:596
RTC_impl::ExecutionContextWorker::m_comps
std::vector< RTC_impl::RTObjectStateMachine * > m_comps
コンポーネントの参加者リスト
Definition: ExecutionContextWorker.h:594
RTC_impl::ExecutionContextWorker::invokeWorkerDo
void invokeWorkerDo()
RTC_impl::ExecutionContextWorker::m_addedMutex
coil::Mutex m_addedMutex
Definition: ExecutionContextWorker.h:597
RTC::RTObject_impl
RTコンポーネントクラス
Definition: RTObject.h:89
RTC_impl::ExecutionContextWorker::ExecutionContextWorker
ExecutionContextWorker()
デフォルトコンストラクタ
RTC_impl::ExecutionContextWorker::startThread
RTC::ReturnCode_t startThread(void)
RTC_impl::ExecutionContextWorker::isOneOfCurrentState
bool isOneOfCurrentState(RTC::LifeCycleState state)
RTC_impl::ExecutionContextWorker::isRunning
CORBA::Boolean isRunning(void)
ExecutionContext 実行状態確認関数
coil::TimeValue
TimeValue クラス
Definition: TimeValue.h:40
RTC_impl::ExecutionContextWorker::addComponent
RTC::ReturnCode_t addComponent(RTC::LightweightRTObject_ptr comp)
RTコンポーネントを追加する
RTC_impl::ExecutionContextWorker::setECRef
void setECRef(RTC::ExecutionContextService_ptr ref)
RTC_impl::ExecutionContextWorker::m_removedMutex
coil::Mutex m_removedMutex
Definition: ExecutionContextWorker.h:599
RTC_impl::ExecutionContextWorker::invokeWorkerPreDo
void invokeWorkerPreDo()
RTC_impl::ExecutionContextWorker::start
RTC::ReturnCode_t start(void)
ExecutionContext の実行を開始
RTC_impl::ExecutionContextWorker::activateComponent
RTC::ReturnCode_t activateComponent(RTC::LightweightRTObject_ptr comp, RTObjectStateMachine *&rtobj)
RTコンポーネントをアクティブ化する
RTC::Logger
Logger クラス
Definition: SystemLogger.h:99
RTC_impl::ExecutionContextWorker::waitDeactivateComplete
RTC::ReturnCode_t waitDeactivateComplete(RTObjectStateMachine *&rtobj, coil::TimeValue timeout=1.0, long int cycle=1000)
RTC_impl::ExecutionContextWorker::m_ref
RTC::ExecutionContextService_var m_ref
Definition: ExecutionContextWorker.h:574
RTC_impl::ExecutionContextWorker::invokeWorker
void invokeWorker()
RTC_impl::ExecutionContextWorker::resetComponent
RTC::ReturnCode_t resetComponent(RTC::LightweightRTObject_ptr com, RTObjectStateMachine *&rtobj)
RTコンポーネントをリセットする
RTC_impl::ExecutionContextWorker::rtclog
RTC::Logger rtclog
ロガーストリーム
Definition: ExecutionContextWorker.h:572
Mutex.h
coil::Guard< coil::Mutex >
RTC_impl::ExecutionContextWorker::isAllCurrentState
bool isAllCurrentState(RTC::LifeCycleState state)
RTC_impl::ExecutionContextWorker::m_removedComps
std::vector< RTC_impl::RTObjectStateMachine * > m_removedComps
Definition: ExecutionContextWorker.h:598
RTC_impl::RTObjectStateMachine
Definition: RTObjectStateMachine.h:46
RTC_impl::ExecutionContextWorker::waitActivateComplete
RTC::ReturnCode_t waitActivateComplete(RTObjectStateMachine *&rtobj, coil::TimeValue timeout=1.0, long int cycle=1000)
RTC
RTコンポーネント
RTC_impl::ExecutionContextWorker::findComponent
RTObjectStateMachine * findComponent(RTC::LightweightRTObject_ptr comp)
RTC_impl::ExecutionContextWorker::getComponentState
RTC::LifeCycleState getComponentState(RTC::LightweightRTObject_ptr comp)
RTコンポーネントの状態を取得する
SystemLogger.h
RT component logger class
Condition.h
RTC_impl::ExecutionContextWorker::m_running
bool m_running
ExecutionContext の実行状態 true: running, false: stopped
Definition: ExecutionContextWorker.h:585
RTC_impl::ExecutionContextWorker::deactivateComponent
RTC::ReturnCode_t deactivateComponent(RTC::LightweightRTObject_ptr comp, RTObjectStateMachine *&rtobj)
RTコンポーネントを非アクティブ化する
RTC_impl::ExecutionContextWorker::rateChanged
RTC::ReturnCode_t rateChanged()
ExecutionContext の実行周期が変更された