ifw-fcf  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
fcf::devmgr::common::DeviceFacade Class Reference

#include <deviceFacade.hpp>

Public Member Functions

 DeviceFacade (rad::SMAdapter &sm, IConfig &config, fcf::common::Dispatcher<> &failure, fcf::common::Dispatcher<> &normal)
 
virtual ~DeviceFacade ()
 ~DeviceFacade More...
 
virtual bool Init (rad::SMAdapter &sm, rad::ThreadActivity *activity)
 Init all devices managed by the devmgr. More...
 
virtual bool Enable (rad::SMAdapter &sm, rad::ThreadActivity *activity)
 Enable all devices managed by the devmgr. More...
 
virtual bool Recover (rad::SMAdapter &sm, rad::ThreadActivity *activity)
 Recover all devices managed by the devmgr. More...
 
virtual bool Disable ()
 Disable all devices managed by the devmgr. More...
 
virtual bool Setup (const std::any &payload, rad::ThreadActivity *activity)
 Executes a setup message. More...
 
virtual void Stop ()
 Abort all devices managed by the devmgr. More...
 
virtual void Reset ()
 Reset devices. More...
 
virtual void Status (const std::any &payload, std::string &buffer)
 Get status from devices. More...
 
virtual void Simulate (rad::AnyEvent const &last_event)
 Simulate devices managed by the server. More...
 
virtual void StopSim (rad::AnyEvent const &last_event)
 Stop simulating devices managed by the server. More...
 
virtual void Ignore (rad::AnyEvent const &last_event)
 Ignore devices managed by the server. More...
 
virtual void StopIgn (rad::AnyEvent const &last_event)
 Stop ignoring devices managed by the server. More...
 
virtual void HwReset (rad::AnyEvent const &last_event)
 Reset hardware. More...
 
virtual void HwInit (rad::AnyEvent const &last_event)
 Init hardware. More...
 
virtual void HwEnable (rad::AnyEvent const &last_event)
 Enable hardware. More...
 
virtual void HwDisable (rad::AnyEvent const &last_event)
 Disable hardware. More...
 
virtual std::string DevNames ()
 Get list of managed devices. More...
 
virtual void BeginAcq (rad::AnyEvent const &last_event)
 Begin Acquisition. More...
 
virtual void EndAcq (rad::AnyEvent const &last_event)
 End Acquisition. More...
 
void TriggerInternalEvent (rad::SMAdapter &sm, rad::UniqueEvent &&e)
 Trigger an internal event. More...
 
void AddDevice (std::shared_ptr< IDevice > device)
 Add a device instance to be managed by the facade. More...
 
void ClearDevices ()
 Empty internal device map. More...
 
fcf::common::Dispatcher & GetFailureCB ()
 Get reference to failure CB. More...
 
fcf::common::Dispatcher & GetNormalCB ()
 Get reference to normal CB. More...
 
const int GetNumDevices ()
 Get the number of devices. More...
 

Detailed Description

This class provide a device facade object to allow the devmgr managing easily all the devices under its control. This class relies on a device abstract class that implement all common features of the devices.

See Also
Device

Constructor & Destructor Documentation

fcf::devmgr::common::DeviceFacade::DeviceFacade ( rad::SMAdapter &  sm,
IConfig config,
fcf::common::Dispatcher<> &  failure,
fcf::common::Dispatcher<> &  normal 
)

Constructor.

Parameters
[in]smReference to the state machine sigleton.
[in]configConfig reference object.
[in]failureDispatcher for failure events.
[in]normalDispatcher for normal events.
fcf::devmgr::common::DeviceFacade::~DeviceFacade ( )
virtual

~DeviceFacade

Member Function Documentation

void fcf::devmgr::common::DeviceFacade::AddDevice ( std::shared_ptr< IDevice device)

Add a device instance to be managed by the facade.

Parameters
[in]deviceSmart pointer to the device.
void fcf::devmgr::common::DeviceFacade::BeginAcq ( rad::AnyEvent const &  last_event)
virtual

Begin Acquisition.

Returns

This method collect data from devices at the beginning of the acquisition. It also register the data for defining the name of data product that will be generated at the end of the acquisition

See Also
EndAcq
void fcf::devmgr::common::DeviceFacade::ClearDevices ( )

Empty internal device map.

std::string fcf::devmgr::common::DeviceFacade::DevNames ( )
virtual

Get list of managed devices.

Returns
bool fcf::devmgr::common::DeviceFacade::Disable ( )
virtual

Disable all devices managed by the devmgr.

Returns
bool fcf::devmgr::common::DeviceFacade::Enable ( rad::SMAdapter &  sm,
rad::ThreadActivity *  activity 
)
virtual

Enable all devices managed by the devmgr.

Parameters
[in]smReference to the SM sigleton.
[in]activityPointer to the current activity.
Returns
void fcf::devmgr::common::DeviceFacade::EndAcq ( rad::AnyEvent const &  last_event)
virtual

End Acquisition.

This method collect data from devices at the end of the acquisition and it creates the data product FITS file including the meta-data for all devices currently managed by the server.

The filename follows the following convention:

<prefix>_<dp_id>_<fcs_id>.fits

The information for the filename is defined by the BeginAcq method.

See Also
BeginAcq
fcf::common::Dispatcher & fcf::devmgr::common::DeviceFacade::GetFailureCB ( )

Get reference to failure CB.

Returns
fcf::common::Dispatcher & fcf::devmgr::common::DeviceFacade::GetNormalCB ( )

Get reference to normal CB.

Returns
const int fcf::devmgr::common::DeviceFacade::GetNumDevices ( )

Get the number of devices.

Returns
Return the number of devices registered in the facade.
void fcf::devmgr::common::DeviceFacade::HwDisable ( rad::AnyEvent const &  last_event)
virtual

Disable hardware.

Returns
void fcf::devmgr::common::DeviceFacade::HwEnable ( rad::AnyEvent const &  last_event)
virtual

Enable hardware.

Returns
void fcf::devmgr::common::DeviceFacade::HwInit ( rad::AnyEvent const &  last_event)
virtual

Init hardware.

Returns
void fcf::devmgr::common::DeviceFacade::HwReset ( rad::AnyEvent const &  last_event)
virtual

Reset hardware.

Returns
void fcf::devmgr::common::DeviceFacade::Ignore ( rad::AnyEvent const &  last_event)
virtual

Ignore devices managed by the server.

bool fcf::devmgr::common::DeviceFacade::Init ( rad::SMAdapter &  sm,
rad::ThreadActivity *  activity 
)
virtual

Init all devices managed by the devmgr.

Returns
bool fcf::devmgr::common::DeviceFacade::Recover ( rad::SMAdapter &  sm,
rad::ThreadActivity *  activity 
)
virtual

Recover all devices managed by the devmgr.

Parameters
[in]smReference to the SM sigleton.
[in]activityPointer to the current activity.
Returns
void fcf::devmgr::common::DeviceFacade::Reset ( )
virtual

Reset devices.

Returns
bool fcf::devmgr::common::DeviceFacade::Setup ( const std::any &  payload,
rad::ThreadActivity *  activity 
)
virtual

Executes a setup message.

Parameters
[in]payloadmessage containing the setup payload
[in]activitypointer to the thread
Returns
true if the execution was succesful, false otherwise.

This method takes care of forwarding the setup message to all devices registered in the facade. Once the setup is successfully executed, the method waits until the action is finished or an error occurs.

The device facade class handles devices sequentially. In case of an error, the setup will finish immediately. The device facade does not know the internals of each device, it just forward the message blindly to all devices. Each device class is responsible of handling the parameters and actions defined in the setup message, as well as determining when the action is finished.

The setup will be stopped whenever the thread (activity) will be stopped.

void fcf::devmgr::common::DeviceFacade::Simulate ( rad::AnyEvent const &  last_event)
virtual

Simulate devices managed by the server.

void fcf::devmgr::common::DeviceFacade::Status ( const std::any &  payload,
std::string &  buffer 
)
virtual

Get status from devices.

Parameters
payloadStatus message object
bufferBuffer where the status will be written
void fcf::devmgr::common::DeviceFacade::Stop ( )
virtual

Abort all devices managed by the devmgr.

Returns
void fcf::devmgr::common::DeviceFacade::StopIgn ( rad::AnyEvent const &  last_event)
virtual

Stop ignoring devices managed by the server.

void fcf::devmgr::common::DeviceFacade::StopSim ( rad::AnyEvent const &  last_event)
virtual

Stop simulating devices managed by the server.

void fcf::devmgr::common::DeviceFacade::TriggerInternalEvent ( rad::SMAdapter &  sm,
rad::UniqueEvent &&  e 
)

Trigger an internal event.

Parameters
[in]smReference to the SM sigleton.
[in]eEvent to be triggered.
Returns

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