AceSmartSoft API Documentation
|
Master part of state pattern. More...
#include <smartState.hh>
Public Member Functions | |
StateMaster (SmartComponent *component) | |
Constructor (not wired with service provider and not exposed as port). More... | |
virtual | ~StateMaster () |
Destructor. More... | |
Smart::StatusCode | blocking (const bool b) |
Allow or abort and reject blocking calls. More... | |
Smart::StatusCode | setWaitState (const std::string &state, const std::string &server, const std::string &service="state") |
Blocking call to change the main state. More... | |
Smart::StatusCode | getCurrentMainState (std::string &MainState, const std::string &server, const std::string &service="state") |
Blocking call which returns the currently active main state. More... | |
Smart::StatusCode | getAllMainStates (std::list< std::string > &MainStates, const std::string &server, const std::string &service="state") |
Blocking call which returns a list of valid main states. More... | |
Smart::StatusCode | getSubStates (const std::string &MainState, std::list< std::string > &SubStates, const std::string &server, const std::string &service="state") |
Blocking call which returns a list of substates assigned to the specified main state. More... | |
Master part of state pattern.
The configuration class provides priorized mutexes for protecting configurations. Normally, a complex robotic system requires a lot of different components which can not all run at the same time. Depending on the current task to be executed and depending on the available ressources, one has to be able to activate and deactivate components and activities within components. One the one hand deactivation should be done in such a way that the component can perform cleanup tasks. On the other hand a component must still be interruptable even if it is pending in a blocking call because the corresponding server has already been deactivated.
The configuration class therefore provides mechanisms for graceful activation and deactivation of sets of activities within components.
As is explained in the specification of the state pattern, one can activate one mainstate at a time. A mainstate can however comprise several substates which are all active at the same time. A master can only set mainstates whereas the slave can only acquire substates. This allows the simple management of sets of concurrent activities.
For a complete description see the printed documentation and further details in third example.
SmartACE::StateMaster::StateMaster | ( | SmartComponent * | component | ) |
Constructor (not wired with service provider and not exposed as port).
add()/remove() and connect()/disconnect() can always be used to change the status of the instance. Instance is not connected to a service provider and is not exposed as port wireable from outside the component.
(Currently exception not thrown)
component | management class of the component |
|
virtual |
Destructor.
Smart::StatusCode SmartACE::StateMaster::blocking | ( | const bool | b | ) |
Allow or abort and reject blocking calls.
If blocking is set to false all blocking calls return with SMART_CANCELLED. This can be used to abort blocking calls.
b | (blocking) true/false |
Smart::StatusCode SmartACE::StateMaster::getAllMainStates | ( | std::list< std::string > & | MainStates, |
const std::string & | server, | ||
const std::string & | service = "state" |
||
) |
Blocking call which returns a list of valid main states.
MainStates | contain all valid main states of the server (slave) |
server | allows to define the slave from which all the mainstates are returned |
service | is an optional parameter in case the slave has a different service name than "state" (mostly for backwards compatibility) |
Smart::StatusCode SmartACE::StateMaster::getCurrentMainState | ( | std::string & | MainState, |
const std::string & | server, | ||
const std::string & | service = "state" |
||
) |
Blocking call which returns the currently active main state.
Is only for convenience and is not necessary since the master always knows what has been configured.
MainState | is set to the current main state as returned by the server (slave) |
server | allows to define the slave from which the currently active mainstate is returned |
service | is an optional parameter in case the slave has a different service name than "state" (mostly for backwards compatibility) |
Smart::StatusCode SmartACE::StateMaster::getSubStates | ( | const std::string & | MainState, |
std::list< std::string > & | SubStates, | ||
const std::string & | server, | ||
const std::string & | service = "state" |
||
) |
Blocking call which returns a list of substates assigned to the specified main state.
MainState | is the mainstate to which we want to get the list of substates |
SubStates | is set to the returned list of substates |
server | allows to define the slave from which all the substates (for the given mainstate) are returned |
service | is an optional parameter in case the slave has a different service name than "state" (mostly for backwards compatibility) |
Smart::StatusCode SmartACE::StateMaster::setWaitState | ( | const std::string & | state, |
const std::string & | server, | ||
const std::string & | service = "state" |
||
) |
Blocking call to change the main state.
state |
|
server | allows to define the slave for the state-change |
service | is an optional parameter in case the slave has a different service name than "state" (mostly for backwards compatibility) |