42 #include "../Attribute.hpp" 43 #include "../FactoryExceptions.hpp" 44 #include "../TaskContext.hpp" 45 #include "../OperationCaller.hpp" 51 using namespace detail;
53 void StateMachineService::createOperationFactory() {
58 DataSource<StateMachinePtr>* ptr = _this.
get();
76 "Step this StateMachine. When paused, step a single instruction or transition evaluation. \n" 77 "When in reactive mode, evaluate transitions and go to a next state, or if none, run handle.");
80 addOperationDS(
"reactive", &
StateMachine::reactive,ptr).doc(
"Enter reactive mode (see requestState() and step() ).\n OperationCaller is done if ready for requestState() or step() method.");
81 addOperationDS(
"requestState", &
StateMachine::requestState,ptr).doc(
"Request to go to a particular state. Will succeed if there exists a valid transition from this state to the requested state.").arg(
"State",
"The state to make the transition to.");
101 replacements[ _this.
get() ] = tmp->_this.get();
106 for ( ConfigurationInterface::map_t::iterator it =
values.begin(); it !=
values.end(); ) {
107 if (dynamic_cast<SendHandleAlias*>(*it)) {
125 statemachine(statem),
128 this->createOperationFactory();
135 if ( statemachine ) {
const std::string & getName() const
Returns the name of this service instance.
boost::shared_ptr< StateMachineService > StateMachineServicePtr
boost::shared_ptr< ParsedStateMachine > ParsedStateMachinePtr
bool isAutomatic() const
Query if the state machine is reacting to events and evaluating transition conditions.
bool inState(const std::string &state) const
Check if the state machine is in a given state.
bool deactivate()
Stop this StateMachine.
bool reset()
Reset the state machine from the final state to the initial state and wait for events or requests...
StateMachineServicePtr copy(ParsedStateMachinePtr newsc, std::map< const base::DataSourceBase *, base::DataSourceBase * > &replacements, bool instantiate)
bool pause()
Pause the state machine.
This class allows storage and retrieval of operations, ports, attributes and properties provided by a...
bool inInitialState() const
Inspect if we are in the initial state.
bool step()
Execute a single action if the state machine is paused or evaluate the transition conditions if the s...
StateMachineService(ParsedStateMachinePtr statemachine, TaskContext *tc)
By constructing this object, a stateMachine can be added to a taskcontext as a Service, with its operations.
const std::string & getCurrentStateName() const
Return name of current state, empty string if not active.
AttributeObjects const & getValues() const
Returns all attributes in this repository.
bool inError() const
Get the error status of this StateMachine.
bool requestState(const std::string &statename)
Request a transition to a given state.
void trace(bool on_off)
Turn log(Debug) messages on or off to track state transitions.
boost::shared_ptr< StateMachine > StateMachinePtr
A class for keeping track of Attribute, Constant and Property objects of a TaskContext.
bool inFinalState() const
Inspect if we are in the final state.
bool activate()
Start this StateMachine.
bool isReactive() const
Query if the state machine is currently reacting only to events.
DataSource< T >::result_t get() const
Return the data as type T.
The TaskContext is the C++ representation of an Orocos component.
Operation< typename internal::GetSignatureDS< Func >::Signature > & addOperationDS(const std::string &name, Func func, internal::DataSource< boost::shared_ptr< ObjT > > *sp, ExecutionThread et=ClientThread)
For internal use only.
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
ConfigurationInterface * copy(std::map< const base::DataSourceBase *, base::DataSourceBase * > &repl, bool instantiate) const
Return a new copy of this repository with the copy operation semantics.
void setOwner(TaskContext *new_owner)
Sets the owning TaskContext that will execute the operations in this service.
A simple, yet very useful DataSource, which keeps a value, and returns it in its get() method...
bool isActive() const
Returns true if the state machine is activated.
bool isPaused() const
Query if the state machine is paused.
bool reactive()
Switch to reactive mode from automatic mode.
bool inTransition() const
Inspect if the StateMachine is performing a state transition.
bool automatic()
Enter automatic mode: evaluating the transition conditions continuously.
bool stop()
Bring the state machine to the safe final state and wait for events or requests.