OpenRTM-aist  1.2.2
RTObjectStateMachine.h
[詳解]
1 // -*- C++ -*-
19 #ifndef RTC_IMPL_RTOBJECTSTATEMACHINE_H
20 #define RTC_IMPL_RTOBJECTSTATEMACHINE_H
21 
22 #include <stdlib.h>
23 #include <rtm/SystemLogger.h>
24 #include <coil/NonCopyable.h>
25 #include <coil/TimeMeasure.h>
26 #include <rtm/idl/RTCSkel.h>
27 #include <rtm/StateMachine.h>
28 #include <assert.h>
29 #include <iostream>
30 
31 #define NUM_OF_LIFECYCLESTATE 4
32 
33 #ifdef WIN32
34 #pragma warning( disable : 4290 )
35 #endif
36 namespace RTC
37 {
38  class RTObject_impl;
39 }
40 namespace RTC_impl
41 {
42  typedef RTC::ExecutionContextHandle_t Ecid;
43  typedef RTC::LifeCycleState ExecContextState;
45 
47  : private coil::NonCopyable
48  {
49  public:
50  RTObjectStateMachine(RTC::ExecutionContextHandle_t id,
52  virtual ~RTObjectStateMachine(void);
53 // RTObjectStateMachine(const RTObjectStateMachine& rtobjsm);
54 // RTObjectStateMachine& operator=(const RTObjectStateMachine& rtobjsm);
55 // void swap(RTObjectStateMachine& rtobjsm) throw();
56 
57  // functions for stored RTObject reference
60 
61  RTC::ExecutionContextHandle_t getExecutionContextHandle();
62 
63  // RTC::ComponentAction operations
64  void onStartup(void);
65  void onShutdown(void);
66  void onActivated(const ExecContextStates& st);
67  void onDeactivated(const ExecContextStates& st);
68  void onAborting(const ExecContextStates& st);
69  void onError(const ExecContextStates& st);
70  void onReset(const ExecContextStates& st);
71 
72  // RTC::DataflowComponentAction
73  void onExecute(const ExecContextStates& st);
74  void onStateUpdate(const ExecContextStates& st);
75  RTC::ReturnCode_t onRateChanged(void);
76 
77  // FsmParticipantAction
78  void onAction(const ExecContextStates& st);
79 
80  // MultiModeComponentAction
81  void onModeChanged(const ExecContextStates& st);
82 
83  // Getting state of the context
86  bool isCurrentState(ExecContextState state);
87  bool isNextState(ExecContextState state);
88  void goTo(ExecContextState state);
89 
90  // Workers
91  void workerPreDo(void);
92  void workerDo(void);
93  void workerPostDo(void);
94 
95  bool activate();
96  bool deactivate();
97  bool reset();
98 
99  protected:
104  void updateState();
105 
106  private: // member variables
107  RTC::Logger rtclog;
108  // ExecutionContext id
109  RTC::ExecutionContextHandle_t m_id;
110  // Associated RTObject reference
112  // State machine
114  RTObjectStateMachine> m_sm;
115  bool m_ca;
116  bool m_dfc;
117  bool m_fsm;
118  bool m_mode;
119  RTC::ComponentAction_var m_caVar;
120  RTC::DataFlowComponentAction_var m_dfcVar;
121  RTC::FsmParticipantAction_var m_fsmVar;
122  RTC::MultiModeComponentAction_var m_modeVar;
123  RTC::RTObject_impl* m_rtobjPtr;
124  bool m_measure;
125 
126  // char dara[1000];
127  // Component action invoker
128  coil::TimeMeasure m_svtMeasure;
129  coil::TimeMeasure m_refMeasure;
130 
131  bool m_activation;
132  bool m_deactivation;
133  bool m_reset;
134  };
135 }; // namespace RTC
136 
137 #ifdef WIN32
138 #pragma warning( default : 4290 )
139 #endif
140 
141 #endif // RTC_RTOBJECTSTATEMACHINE_H
RTC_impl::LightweightRTObject_ptr
RTC::LightweightRTObject_ptr LightweightRTObject_ptr
Definition: ExecutionContextWorker.h:43
coil::NonCopyable
コピー禁止ミックスイン
Definition: NonCopyable.h:53
RTC_impl::RTObjectStateMachine::isNextState
bool isNextState(ExecContextState state)
RTC_impl::RTObjectStateMachine::getExecutionContextHandle
RTC::ExecutionContextHandle_t getExecutionContextHandle()
RTC_impl::RTObjectStateMachine::onReset
void onReset(const ExecContextStates &st)
TimeMeasure.h
Periodic time measurement class
RTC_impl::RTObjectStateMachine::deactivate
bool deactivate()
RTC_impl::LightweightRTObject_var
RTC::LightweightRTObject_var LightweightRTObject_var
Definition: ExecutionContextWorker.h:45
RTC_impl::RTObjectStateMachine::onActivated
void onActivated(const ExecContextStates &st)
RTC_impl
Definition: ExecutionContextProfile.h:34
RTC_impl::RTObjectStateMachine::workerDo
void workerDo(void)
RTC_impl::RTObjectStateMachine::getStates
ExecContextStates getStates(void)
RTC::RTObject_impl
RTコンポーネントクラス
Definition: RTObject.h:89
RTC_impl::RTObjectStateMachine::onStateUpdate
void onStateUpdate(const ExecContextStates &st)
RTC_impl::RTObjectStateMachine::setFsmParticipantAction
void setFsmParticipantAction(const RTC::LightweightRTObject_ptr comp)
RTC_impl::RTObjectStateMachine::onRateChanged
RTC::ReturnCode_t onRateChanged(void)
RTC_impl::RTObjectStateMachine::onError
void onError(const ExecContextStates &st)
RTC_impl::RTObjectStateMachine::onAction
void onAction(const ExecContextStates &st)
RTC_impl::RTObjectStateMachine::reset
bool reset()
RTC_Utils::StateHolder< ExecContextState >
RTC_impl::RTObjectStateMachine::setComponentAction
void setComponentAction(const RTC::LightweightRTObject_ptr comp)
RTC::Logger
Logger クラス
Definition: SystemLogger.h:99
RTC_impl::RTObjectStateMachine::setDataFlowComponentAction
void setDataFlowComponentAction(const RTC::LightweightRTObject_ptr comp)
RTC_impl::RTObjectStateMachine::onStartup
void onStartup(void)
RTC_impl::RTObjectStateMachine::workerPreDo
void workerPreDo(void)
RTC_impl::RTObjectStateMachine::onShutdown
void onShutdown(void)
RTC_impl::RTObjectStateMachine::getRTObject
RTC::LightweightRTObject_ptr getRTObject()
RTC_impl::RTObjectStateMachine::getState
ExecContextState getState(void)
RTC_impl::RTObjectStateMachine::setMultiModeComponentAction
void setMultiModeComponentAction(const RTC::LightweightRTObject_ptr comp)
RTC_impl::RTObjectStateMachine::RTObjectStateMachine
RTObjectStateMachine(RTC::ExecutionContextHandle_t id, RTC::LightweightRTObject_ptr comp)
RTC_impl::RTObjectStateMachine::onDeactivated
void onDeactivated(const ExecContextStates &st)
RTC_impl::RTObjectStateMachine::workerPostDo
void workerPostDo(void)
RTC_impl::Ecid
RTC::ExecutionContextHandle_t Ecid
Definition: RTObjectStateMachine.h:42
coil::TimeMeasure
TimeMeasure クラス
Definition: TimeMeasure.h:49
RTC_impl::RTObjectStateMachine::goTo
void goTo(ExecContextState state)
RTC_impl::RTObjectStateMachine::isEquivalent
bool isEquivalent(RTC::LightweightRTObject_ptr comp)
RTC_impl::RTObjectStateMachine::onModeChanged
void onModeChanged(const ExecContextStates &st)
RTC_impl::RTObjectStateMachine
Definition: RTObjectStateMachine.h:46
RTC_impl::ExecContextState
RTC::LifeCycleState ExecContextState
Definition: RTObjectStateMachine.h:43
RTC
RTコンポーネント
RTC_impl::RTObjectStateMachine::onExecute
void onExecute(const ExecContextStates &st)
RTC_impl::RTObjectStateMachine::~RTObjectStateMachine
virtual ~RTObjectStateMachine(void)
RTC_impl::RTObjectStateMachine::isCurrentState
bool isCurrentState(ExecContextState state)
RTC_impl::ExecContextStates
RTC_Utils::StateHolder< ExecContextState > ExecContextStates
Definition: RTObjectStateMachine.h:44
RTC_impl::RTObjectStateMachine::onAborting
void onAborting(const ExecContextStates &st)
StateMachine.h
State machine template class
RTC_impl::RTObjectStateMachine::activate
bool activate()
SystemLogger.h
RT component logger class
RTC_Utils::StateMachine
状態マシンクラス
Definition: StateMachine.h:264
NonCopyable.h
Non Copyable mixin class
RTC_impl::RTObjectStateMachine::updateState
void updateState()