10 #ifndef NDSSTATEMACHINEIMPL_H
11 #define NDSSTATEMACHINEIMPL_H
15 #include "nds3/impl/nodeImpl.h"
20 template <
typename T>
class PVDelegateInImpl;
198 void writeLocalState(
const timespec& timestamp,
const std::int32_t& value);
238 #endif // NDSSTATEMACHINEIMPL_H
std::shared_ptr< PVDelegateInImpl< std::int32_t > > m_pGetStatePV
Delegate PV to which the local state change is pushed.
Definition: stateMachineImpl.h:231
void executeTransitionThread(const state_t initialState, const state_t finalState, stateChange_t transitionFunction)
Thread function executed for asynchronous state machines. Calls executeTransition() and catches its e...
timespec m_stateTimestamp
The timestamp of the last local state change.
Definition: stateMachineImpl.h:222
bool m_bAsync
If true then the state transitions happen in another thread (held by m_transitionThread) ...
Definition: stateMachineImpl.h:216
virtual void getGlobalState(timespec *pTimestamp, state_t *pState) const
Return the global state. The global state takes into consideration the states of the children of the ...
stateChange_t m_start
Delegate function for the start transition.
Definition: stateMachineImpl.h:226
void readGlobalState(timespec *pTimestamp, std::int32_t *pValue)
Delegate function called to read the current global state.
bool canChange(const state_t newState) const
Check if the transition to the new state is legal and is not denied by the delegate function...
stateChange_t m_switchOn
Delegate function for the switch-on transition.
Definition: stateMachineImpl.h:224
This is the base class for objects that interact with specific control systems and has to be allocate...
Definition: factoryBaseImpl.h:51
void executeTransition(const state_t initialState, const state_t finalState, stateChange_t transitionFunction)
Execute the state transition. May be called from a separate thread.
virtual void initialize(FactoryBaseImpl &controlSystem)
Register the PVs and set the local state to state_t::off.
StateMachineImpl(bool bAsync, stateChange_t switchOnFunction, stateChange_t switchOffFunction, stateChange_t startFunction, stateChange_t stopFunction, stateChange_t recoverFunction, allowChange_t allowStateChangeFunction)
Construct the StateMachineImpl class.
void writeLocalState(const timespec ×tamp, const std::int32_t &value)
Delegate function called to set the local state.
stateChange_t m_recover
Delegate function for the recover transition.
Definition: stateMachineImpl.h:228
Represents a node (channel or channelGroup in the old NDS) which can contain other nodes...
Definition: nodeImpl.h:29
static std::string getStateName(const state_t state)
Returns the human readable name for the requested state.
bool isAllowedTransition(const state_t currentState, const state_t newState) const
Returns true if the transition between two states is legal (does not check the delegate function allo...
std::function< bool(const state_t, const state_t, const state_t)> allowChange_t
Definition for a function called to allow or deny a state transition.
Definition: definitions.h:271
virtual state_t getLocalState() const
Return the local state. The local state does not reflect the state of the children.
std::mutex m_lockTransitionThread
Lock the access to m_transitionThread.
Definition: stateMachineImpl.h:219
allowChange_t m_allowChange
Delegate function for the Allow-Change function.
Definition: stateMachineImpl.h:229
stateChange_t m_stop
Delegate function for the stop transition.
Definition: stateMachineImpl.h:227
std::function< void()> stateChange_t
Definition for the function executed during the state transition.
Definition: definitions.h:254
state_t m_localState
The local state.
Definition: stateMachineImpl.h:221
Defines all the enumeration and common types used across the NDS library.
virtual void deinitialize()
Wait for pending transitions to terminate and deregister the PVs.
void setState(const state_t newState)
Instructs the state machine to start the transition to another state.
Implements the state machine.
Definition: stateMachineImpl.h:27
stateChange_t m_switchOff
Delegate function for the switch-off transition.
Definition: stateMachineImpl.h:225
bool isIntermediateState(const state_t newState) const
Returns true if the specified state is an intermediate state (not settable directly with setState())...
std::vector< std::string > parameters_t
List of strings passed as parameters to nodes' commands.
Definition: definitions.h:204
void readLocalState(timespec *pTimestamp, std::int32_t *pValue)
Delegate function called to read the local state.
state_t
Available states, ordered by priority (lowest to higher).
Definition: definitions.h:36
parameters_t commandSetState(const state_t state, const parameters_t ¶meters)
Delegate function for the commands that set the node's state.
std::thread m_transitionThread
Thread that is used to execute the state transition when bAsync is true in the constructor.
Definition: stateMachineImpl.h:218