OpenRTM-aist
2.1.0
Toggle main menu visibility
読み取り中…
検索中…
一致する文字列を見つけられません
RTObjectStateMachine.h
[詳解]
1
// -*- C++ -*-
18
19
#ifndef RTC_IMPL_RTOBJECTSTATEMACHINE_H
20
#define RTC_IMPL_RTOBJECTSTATEMACHINE_H
21
22
#include <cstdlib>
23
#include <
rtm/SystemLogger.h
>
24
#include <coil/TimeMeasure.h>
25
#include <rtm/idl/RTCSkel.h>
26
#include <
rtm/StateMachine.h
>
27
#include <cassert>
28
#include <iostream>
29
#include <atomic>
30
31
#define NUM_OF_LIFECYCLESTATE 4
32
namespace
RTC
33
{
34
class
RTObject_impl;
35
}
// namespace RTC
36
namespace
RTC_impl
37
{
38
using
Ecid
= RTC::ExecutionContextHandle_t;
39
using
ExecContextState
= RTC::LifeCycleState;
40
using
ExecContextStates
=
RTC_Utils::StateHolder<ExecContextState>
;
41
42
class
RTObjectStateMachine
43
{
44
public
:
45
RTObjectStateMachine
(RTC::ExecutionContextHandle_t
id
,
46
RTC::LightweightRTObject_ptr comp);
47
RTObjectStateMachine
(
RTObjectStateMachine
const
&) =
delete
;
48
virtual
~RTObjectStateMachine
();
49
RTObjectStateMachine
&
operator=
(
RTObjectStateMachine
const
&) =
delete
;
50
51
// functions for stored RTObject reference
52
RTC::LightweightRTObject_ptr
getRTObject
();
53
bool
isEquivalent
(RTC::LightweightRTObject_ptr comp);
54
55
RTC::ExecutionContextHandle_t
getExecutionContextHandle
();
56
57
// RTC::ComponentAction operations
58
void
onStartup
();
59
void
onShutdown
();
60
void
onActivated
(
const
ExecContextStates
& st);
61
void
onDeactivated
(
const
ExecContextStates
& st);
62
void
onAborting
(
const
ExecContextStates
& st);
63
void
onError
(
const
ExecContextStates
& st);
64
void
onReset
(
const
ExecContextStates
& st);
65
66
// RTC::DataflowComponentAction
67
void
onExecute
(
const
ExecContextStates
& st);
68
void
onStateUpdate
(
const
ExecContextStates
& st);
69
RTC::ReturnCode_t
onRateChanged
();
70
71
// FsmParticipantAction
72
void
onAction
(
const
ExecContextStates
& st);
73
74
// MultiModeComponentAction
75
void
onModeChanged
(
const
ExecContextStates
& st);
76
77
// Getting state of the context
78
ExecContextState
getState
();
79
ExecContextStates
getStates
();
80
bool
isCurrentState
(
ExecContextState
state);
81
bool
isNextState
(
ExecContextState
state);
82
void
goTo
(
ExecContextState
state);
83
84
// Workers
85
void
workerPreDo
();
86
void
workerDo
();
87
void
workerPostDo
();
88
89
bool
activate
();
90
bool
deactivate
();
91
bool
reset
();
92
93
protected
:
94
void
setComponentAction
(RTC::LightweightRTObject_ptr comp);
95
void
setDataFlowComponentAction
(RTC::LightweightRTObject_ptr comp);
96
void
setFsmParticipantAction
(RTC::LightweightRTObject_ptr comp);
97
void
setMultiModeComponentAction
(RTC::LightweightRTObject_ptr comp);
98
void
updateState
();
99
100
private
:
// member variables
101
RTC::Logger
rtclog;
102
// ExecutionContext id
103
RTC::ExecutionContextHandle_t m_id;
104
// Associated RTObject reference
105
RTC::LightweightRTObject_var m_rtobj;
106
// State machine
107
RTC_Utils::StateMachine
<
ExecContextState
,
108
RTObjectStateMachine
> m_sm;
109
bool
m_ca;
110
bool
m_dfc;
111
bool
m_fsm;
112
bool
m_mode;
113
RTC::ComponentAction_var m_caVar;
114
RTC::DataFlowComponentAction_var m_dfcVar;
115
RTC::FsmParticipantAction_var m_fsmVar;
116
RTC::MultiModeComponentAction_var m_modeVar;
117
RTC::RTObject_impl
* m_rtobjPtr;
118
bool
m_measure;
119
// Component action invoker
120
coil::TimeMeasure m_svtMeasure;
121
coil::TimeMeasure m_refMeasure;
122
std::atomic<bool> m_activation;
123
std::atomic<bool> m_deactivation;
124
std::atomic<bool> m_reset;
125
};
126
}
// namespace RTC_impl
127
128
#endif
// RTC_RTOBJECTSTATEMACHINE_H
StateMachine.h
State machine template class
SystemLogger.h
RT component logger class
RTC::Logger
Logger クラス
Definition
SystemLogger.h:101
RTC::RTObject_impl
RTコンポーネントクラス
Definition
RTObject.h:93
RTC_Utils::StateMachine
状態マシンクラス
Definition
StateMachine.h:267
RTC_impl::RTObjectStateMachine::updateState
void updateState()
RTC_impl::RTObjectStateMachine::onStartup
void onStartup()
RTC_impl::RTObjectStateMachine::workerPreDo
void workerPreDo()
RTC_impl::RTObjectStateMachine::onAction
void onAction(const ExecContextStates &st)
RTC_impl::RTObjectStateMachine::deactivate
bool deactivate()
RTC_impl::RTObjectStateMachine::onRateChanged
RTC::ReturnCode_t onRateChanged()
RTC_impl::RTObjectStateMachine::operator=
RTObjectStateMachine & operator=(RTObjectStateMachine const &)=delete
RTC_impl::RTObjectStateMachine::getStates
ExecContextStates getStates()
RTC_impl::RTObjectStateMachine::onExecute
void onExecute(const ExecContextStates &st)
RTC_impl::RTObjectStateMachine::onDeactivated
void onDeactivated(const ExecContextStates &st)
RTC_impl::RTObjectStateMachine::RTObjectStateMachine
RTObjectStateMachine(RTC::ExecutionContextHandle_t id, RTC::LightweightRTObject_ptr comp)
RTC_impl::RTObjectStateMachine::RTObjectStateMachine
RTObjectStateMachine(RTObjectStateMachine const &)=delete
RTC_impl::RTObjectStateMachine::getRTObject
RTC::LightweightRTObject_ptr getRTObject()
RTC_impl::RTObjectStateMachine::getState
ExecContextState getState()
RTC_impl::RTObjectStateMachine::setFsmParticipantAction
void setFsmParticipantAction(RTC::LightweightRTObject_ptr comp)
RTC_impl::RTObjectStateMachine::goTo
void goTo(ExecContextState state)
RTC_impl::RTObjectStateMachine::onModeChanged
void onModeChanged(const ExecContextStates &st)
RTC_impl::RTObjectStateMachine::onShutdown
void onShutdown()
RTC_impl::RTObjectStateMachine::isEquivalent
bool isEquivalent(RTC::LightweightRTObject_ptr comp)
RTC_impl::RTObjectStateMachine::onAborting
void onAborting(const ExecContextStates &st)
RTC_impl::RTObjectStateMachine::activate
bool activate()
RTC_impl::RTObjectStateMachine::onStateUpdate
void onStateUpdate(const ExecContextStates &st)
RTC_impl::RTObjectStateMachine::workerDo
void workerDo()
RTC_impl::RTObjectStateMachine::setMultiModeComponentAction
void setMultiModeComponentAction(RTC::LightweightRTObject_ptr comp)
RTC_impl::RTObjectStateMachine::setDataFlowComponentAction
void setDataFlowComponentAction(RTC::LightweightRTObject_ptr comp)
RTC_impl::RTObjectStateMachine::setComponentAction
void setComponentAction(RTC::LightweightRTObject_ptr comp)
RTC_impl::RTObjectStateMachine::getExecutionContextHandle
RTC::ExecutionContextHandle_t getExecutionContextHandle()
RTC_impl::RTObjectStateMachine::reset
bool reset()
RTC_impl::RTObjectStateMachine::workerPostDo
void workerPostDo()
RTC_impl::RTObjectStateMachine::onError
void onError(const ExecContextStates &st)
RTC_impl::RTObjectStateMachine::onActivated
void onActivated(const ExecContextStates &st)
RTC_impl::RTObjectStateMachine::onReset
void onReset(const ExecContextStates &st)
RTC_impl::RTObjectStateMachine::~RTObjectStateMachine
virtual ~RTObjectStateMachine()
RTC_impl::RTObjectStateMachine::isNextState
bool isNextState(ExecContextState state)
RTC_impl::RTObjectStateMachine::isCurrentState
bool isCurrentState(ExecContextState state)
RTC_impl
Definition
ExecutionContextProfile.h:29
RTC_impl::ExecContextStates
RTC_Utils::StateHolder< ExecContextState > ExecContextStates
Definition
RTObjectStateMachine.h:40
RTC_impl::Ecid
RTC::ExecutionContextHandle_t Ecid
Definition
RTObjectStateMachine.h:38
RTC_impl::ExecContextState
RTC::LifeCycleState ExecContextState
Definition
RTObjectStateMachine.h:39
RTC
RTコンポーネント
RTC_Utils::StateHolder
状態保持用クラス
Definition
StateMachine.h:58
構築:
1.17.0