ifw-sup  3.0.0-pre3
Public Member Functions | Public Attributes | List of all members
sup::syssup::common::SubsysFacade Class Reference

#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
 

Detailed Description

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.

See also
Subsys

Constructor & Destructor Documentation

◆ SubsysFacade()

sup::syssup::common::SubsysFacade::SubsysFacade ( rad::SMAdapter &  sm,
DataContext data_ctx 
)

Constructor.

Parameters
[in]smReference to the state machine sigleton.
[in]data_ctxreference to data object context

◆ ~SubsysFacade()

sup::syssup::common::SubsysFacade::~SubsysFacade ( )
virtual

~SubsysFacade

Member Function Documentation

◆ AddSubsys()

void sup::syssup::common::SubsysFacade::AddSubsys ( std::unique_ptr< Subsys subsys)

Add a subsystems instance to be managed by the facade.

Parameters
[in]subsysSmart pointer to the subsys.

◆ ClearSubsys()

void sup::syssup::common::SubsysFacade::ClearSubsys ( )

Empty internal subsys map.

◆ Connect()

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.

◆ Disable()

void sup::syssup::common::SubsysFacade::Disable ( rad::SMAdapter &  sm,
rad::ThreadActivity *  activity 
)

Disable all subsystems managed by the Supervisor.

Parameters
[in]smReference to the SM sigleton.
[in]activityPointer to the current activity.
Returns

This methods triggers the move to the Enabling transient substate in the state machine which is executed in a dedicated thread.

◆ DisableAccess()

void sup::syssup::common::SubsysFacade::DisableAccess ( )

Disable Access for all subsystems.

◆ Enable()

void sup::syssup::common::SubsysFacade::Enable ( rad::SMAdapter &  sm,
rad::ThreadActivity *  activity 
)

Enable all subsystems managed by the Supervisor.

Parameters
[in]smReference to the SM sigleton.
[in]activityPointer to the current activity.
Returns

◆ EstimateState()

void sup::syssup::common::SubsysFacade::EstimateState ( std::vector< State::StateEnum > &  states,
std::vector< State::SubstateEnum > &  substates 
)
virtual

EstimateState.

Parameters
stateslist of subsystem states as values
substateslist 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:

  • The minimum substate will be as well the minimum substate with the following exception: if minimum substage is NotReady, Ready or Idle and the substate of the subsystems is any of the transient substates like SettingUp or Recording, the estimated substate will reflect the minimum transient state. The above helps to report the ongoing activities of the managed subsystems.

◆ GetNumSubsys()

const int sup::syssup::common::SubsysFacade::GetNumSubsys ( )

Get the number of subsystems.

Returns
Return the number of subsystems registered in the facade.

◆ GetSubsysNames()

std::string sup::syssup::common::SubsysFacade::GetSubsysNames ( )

Get list of subsystems managed by the Supervisor.

Returns

◆ GetSubsystemStatus()

void sup::syssup::common::SubsysFacade::GetSubsystemStatus ( const std::string &  payload,
std::string &  buffer 
)

Get subsystem status.

Parameters
[in]payloadName of the subsystem
[in,out]bufferReference 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.

◆ Init()

void sup::syssup::common::SubsysFacade::Init ( rad::SMAdapter &  sm,
rad::ThreadActivity *  activity 
)

Init all subsystems managed by the Supervisor.

Parameters
[in]smReference to the SM sigleton.
[in]activityPointer to the current activity.
Returns

This methods triggers the move to the Initialisation transient substate in the state machine which is executed in a dedicated thread.

◆ Recover()

void sup::syssup::common::SubsysFacade::Recover ( rad::SMAdapter &  sm,
rad::ThreadActivity *  activity 
)

Recover all subsystems managed by the Supervisor.

Parameters
[in]smReference to the SM sigleton.
[in]activityPointer to the current activity.
Returns

This methods triggers the move to the Disabling transient substate in the state machine which is executed in a dedicated thread.

◆ Reset()

void sup::syssup::common::SubsysFacade::Reset ( )
virtual

Reset subsystems.

Returns

◆ SetSubsystemConnectionState()

void sup::syssup::common::SubsysFacade::SetSubsystemConnectionState ( std::string  name,
SubsysData::ConnectionEnum  connection 
)

Get subsystem connection state.

Parameters
namesubsystem name
connectionnew connection status

◆ SetSubsystemState()

void sup::syssup::common::SubsysFacade::SetSubsystemState ( std::string  name,
std::string  state 
)

Set the subsystem state.

Parameters
namesubsystem name
statenew state

◆ SetSubsystemStates()

void sup::syssup::common::SubsysFacade::SetSubsystemStates ( std::string  name,
std::string  state,
std::string  substate 
)

Set the subsystem states: state and substate.

Parameters
name
state
substate

◆ SetSubsystemSubstate()

void sup::syssup::common::SubsysFacade::SetSubsystemSubstate ( std::string  name,
std::string  substate 
)

Set the subsystem substate.

Parameters
namesubsystem name
substatenew subtate

◆ Setup()

void sup::syssup::common::SubsysFacade::Setup ( const std::any &  payload)

Executes a setup message.

Parameters
[in]payloadmessage containing the setup payload
Returns

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.

◆ StartMonitoring()

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.

◆ Stop()

void sup::syssup::common::SubsysFacade::Stop ( )
virtual

Abort all subsystems managed by the devmgr.

Returns

◆ SubsysCommand()

template<typename EVENT_TYPE , typename OBJECT >
void sup::syssup::common::SubsysFacade::SubsysCommand ( scxml4cpp::Context *  c,
OBJECT &  obj 
)

Forward request to an specific subsystem.

Parameters
[in]cSM contex
[in]objspecific 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.

◆ UpdateConfiguration()

void sup::syssup::common::SubsysFacade::UpdateConfiguration ( )

Triggers the update of the subsystem configuration.

◆ UpdateHandler()

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.

See also
EstimateEstate

Member Data Documentation

◆ m_disable_replier

SingleReplier<Events::SubsysDisable> sup::syssup::common::SubsysFacade::m_disable_replier

◆ m_enable_replier

SingleReplier<Events::SubsysEnable> sup::syssup::common::SubsysFacade::m_enable_replier

◆ m_init_replier

SingleReplier<Events::SubsysInit> sup::syssup::common::SubsysFacade::m_init_replier

◆ m_reset_replier

SingleReplier<Events::SubsysReset> sup::syssup::common::SubsysFacade::m_reset_replier

The documentation for this class was generated from the following files: