ifw-sup
3.0.0-pre3
|
#include <subsysFacade.hpp>
Public Member Functions | |
SubsysFacade (rad::SMAdapter &sm, DataContext &data_ctx) | |
virtual | ~SubsysFacade () |
~SubsysFacade More... | |
void | Connect () |
Connect. More... | |
void | StartMonitoring () |
StartMonitoring. More... | |
void | Init (rad::SMAdapter &sm, rad::ThreadActivity *activity) |
Init all subsystems managed by the Supervisor. More... | |
void | Enable (rad::SMAdapter &sm, rad::ThreadActivity *activity) |
Enable all subsystems managed by the Supervisor. More... | |
void | Disable (rad::SMAdapter &sm, rad::ThreadActivity *activity) |
Disable all subsystems managed by the Supervisor. More... | |
void | Recover (rad::SMAdapter &sm, rad::ThreadActivity *activity) |
Recover all subsystems managed by the Supervisor. More... | |
void | DisableAccess () |
Disable Access for all subsystems. More... | |
void | Setup (const std::any &payload) |
Executes a setup message. More... | |
virtual void | Stop () |
Abort all subsystems managed by the devmgr. More... | |
virtual void | Reset () |
Reset subsystems. More... | |
template<typename EVENT_TYPE , typename OBJECT > | |
void | SubsysCommand (scxml4cpp::Context *c, OBJECT &obj) |
Forward request to an specific subsystem. More... | |
void | UpdateConfiguration () |
Triggers the update of the subsystem configuration. More... | |
void | UpdateHandler () |
Triggers the update of the estimated state/substate. More... | |
virtual void | EstimateState (std::vector< State::StateEnum > &states, std::vector< State::SubstateEnum > &substates) |
EstimateState. More... | |
void | SetSubsystemConnectionState (std::string name, SubsysData::ConnectionEnum connection) |
Get subsystem connection state. More... | |
void | SetSubsystemState (std::string name, std::string state) |
Set the subsystem state. More... | |
void | SetSubsystemStates (std::string name, std::string state, std::string substate) |
Set the subsystem states: state and substate. More... | |
void | SetSubsystemSubstate (std::string name, std::string substate) |
Set the subsystem substate. More... | |
void | GetSubsystemStatus (const std::string &payload, std::string &buffer) |
Get subsystem status. More... | |
void | AddSubsys (std::unique_ptr< Subsys > subsys) |
Add a subsystems instance to be managed by the facade. More... | |
void | ClearSubsys () |
Empty internal subsys map. More... | |
const int | GetNumSubsys () |
Get the number of subsystems. More... | |
std::string | GetSubsysNames () |
Get list of subsystems managed by the Supervisor. More... | |
Public Attributes | |
SingleReplier< Events::SubsysInit > | m_init_replier |
SingleReplier< Events::SubsysEnable > | m_enable_replier |
SingleReplier< Events::SubsysDisable > | m_disable_replier |
SingleReplier< Events::SubsysReset > | m_reset_replier |
This class provides a facade object to allow the supervisor managing easily all the subsystems under its control. This class relies on a subsystem abstract class that implement all common features of the subsystems.
sup::syssup::common::SubsysFacade::SubsysFacade | ( | rad::SMAdapter & | sm, |
DataContext & | data_ctx | ||
) |
Constructor.
[in] | sm | Reference to the state machine sigleton. |
[in] | data_ctx | reference to data object context |
|
virtual |
~SubsysFacade
void sup::syssup::common::SubsysFacade::AddSubsys | ( | std::unique_ptr< Subsys > | subsys | ) |
Add a subsystems instance to be managed by the facade.
[in] | subsys | Smart pointer to the subsys. |
void sup::syssup::common::SubsysFacade::ClearSubsys | ( | ) |
Empty internal subsys map.
void sup::syssup::common::SubsysFacade::Connect | ( | ) |
Connect.
This methods establishes the connection to subsystems via the CII MAL and updates its internal status. This method is blocking and it will wait until timeout is reached. The timeout is a configurable parameter (waittout). The timeout should be small, normally around 500 msecs.
For all connected subsystems, it will send the GetStatus to update the subsystem status.
This method shall be called once at the beginning of the application. Once the replies from GetStatus are received, this method will call the callback to update the estimated state/substate.
void sup::syssup::common::SubsysFacade::Disable | ( | rad::SMAdapter & | sm, |
rad::ThreadActivity * | activity | ||
) |
Disable all subsystems managed by the Supervisor.
[in] | sm | Reference to the SM sigleton. |
[in] | activity | Pointer to the current activity. |
This methods triggers the move to the Enabling transient substate in the state machine which is executed in a dedicated thread.
void sup::syssup::common::SubsysFacade::DisableAccess | ( | ) |
Disable Access for all subsystems.
void sup::syssup::common::SubsysFacade::Enable | ( | rad::SMAdapter & | sm, |
rad::ThreadActivity * | activity | ||
) |
Enable all subsystems managed by the Supervisor.
[in] | sm | Reference to the SM sigleton. |
[in] | activity | Pointer to the current activity. |
|
virtual |
EstimateState.
states | list of subsystem states as values |
substates | list of subsystem substates as values |
This is a virtual method to estimate the overall state/substate of the Supervisor based on the individual subsystem contributions.
This method will update the internal estimated state and substate based on the algorith that will take as input the list of states and substates of the subsystems. Projects may provide its own method to estimate the global state/substates.
Criteria:
The overall state corresponds to the minimum state within all managed subsystems.
The overal substate is obtained according to the following:
const int sup::syssup::common::SubsysFacade::GetNumSubsys | ( | ) |
Get the number of subsystems.
std::string sup::syssup::common::SubsysFacade::GetSubsysNames | ( | ) |
Get list of subsystems managed by the Supervisor.
void sup::syssup::common::SubsysFacade::GetSubsystemStatus | ( | const std::string & | payload, |
std::string & | buffer | ||
) |
Get subsystem status.
[in] | payload | Name of the subsystem |
[in,out] | buffer | Reference to the output buffer |
In the name of the subsystem is empty, the method will return the status of all subsystems registerd in the facade.
void sup::syssup::common::SubsysFacade::Init | ( | rad::SMAdapter & | sm, |
rad::ThreadActivity * | activity | ||
) |
Init all subsystems managed by the Supervisor.
[in] | sm | Reference to the SM sigleton. |
[in] | activity | Pointer to the current activity. |
This methods triggers the move to the Initialisation transient substate in the state machine which is executed in a dedicated thread.
void sup::syssup::common::SubsysFacade::Recover | ( | rad::SMAdapter & | sm, |
rad::ThreadActivity * | activity | ||
) |
Recover all subsystems managed by the Supervisor.
[in] | sm | Reference to the SM sigleton. |
[in] | activity | Pointer to the current activity. |
This methods triggers the move to the Disabling transient substate in the state machine which is executed in a dedicated thread.
|
virtual |
Reset subsystems.
void sup::syssup::common::SubsysFacade::SetSubsystemConnectionState | ( | std::string | name, |
SubsysData::ConnectionEnum | connection | ||
) |
Get subsystem connection state.
name | subsystem name |
connection | new connection status |
void sup::syssup::common::SubsysFacade::SetSubsystemState | ( | std::string | name, |
std::string | state | ||
) |
Set the subsystem state.
name | subsystem name |
state | new state |
void sup::syssup::common::SubsysFacade::SetSubsystemStates | ( | std::string | name, |
std::string | state, | ||
std::string | substate | ||
) |
Set the subsystem states: state and substate.
name | |
state | |
substate |
void sup::syssup::common::SubsysFacade::SetSubsystemSubstate | ( | std::string | name, |
std::string | substate | ||
) |
Set the subsystem substate.
name | subsystem name |
substate | new subtate |
void sup::syssup::common::SubsysFacade::Setup | ( | const std::any & | payload | ) |
Executes a setup message.
[in] | payload | message containing the setup payload |
This method takes care of forwarding the setup message to all subsyss registered in the facade.
The subsys facade class handles subsyss sequentialy. In case of an error, the setup will finish immediately. The subsys facade does not know the internals of each subsys, it just forward the message blindly to all subsystems. Each subsystem class is responsible of handling the parameters defined in the setup message.
This is a blocking operation since settings of parameters is expected to be fast.
void sup::syssup::common::SubsysFacade::StartMonitoring | ( | ) |
StartMonitoring.
This method triggers the subscription of the status per each subsystem. The subscription is done following the pub/sub endpoints registerd for each subsystem in the configuration.
|
virtual |
Abort all subsystems managed by the devmgr.
void sup::syssup::common::SubsysFacade::SubsysCommand | ( | scxml4cpp::Context * | c, |
OBJECT & | obj | ||
) |
Forward request to an specific subsystem.
[in] | c | SM contex |
[in] | obj | specific object managing the replies of the futures. |
This method is used to generalize the asynchronous sending of requests to individual subsystems. It supports the following event types:
Events::SubsysInit Events::SubsysEnable Events::SubsysDisable Events::SubsysReset
If the event type is not known it will through an exception. The method forward the requests only to the system with access flag enabled and with internal scope. If a subsystem is not available, at the time the request is received, then this subsystem is ignored.
This method defines a lambda function that will be executed with the future continuation.
Each request object is stored in a map associated with an UUID. Once the reply is received from the subsystem. The request is obtained from the map using the UUID and the reply is sent to the originator. Then, the entry in map is removed.
void sup::syssup::common::SubsysFacade::UpdateConfiguration | ( | ) |
Triggers the update of the subsystem configuration.
void sup::syssup::common::SubsysFacade::UpdateHandler | ( | ) |
Triggers the update of the estimated state/substate.
This callback is called whenever a new subscription is received by any of the subsystems.
SingleReplier<Events::SubsysDisable> sup::syssup::common::SubsysFacade::m_disable_replier |
SingleReplier<Events::SubsysEnable> sup::syssup::common::SubsysFacade::m_enable_replier |
SingleReplier<Events::SubsysInit> sup::syssup::common::SubsysFacade::m_init_replier |
SingleReplier<Events::SubsysReset> sup::syssup::common::SubsysFacade::m_reset_replier |