ifw-fcf  5.0.0-pre2
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
fcf::devmgr::common::Device Class Reference

#include <device.hpp>

Inheritance diagram for fcf::devmgr::common::Device:
fcf::devmgr::common::IDevice TestMyDevice TestShutter fcf::devmgr::actuator::Actuator fcf::devmgr::adc::Adc fcf::devmgr::iodev::IODev fcf::devmgr::motor::Motor fcf::devmgr::piezo::Piezo fcf::devmgr::shutter::Shutter fcf::devmgr::smaract::Smaract testDeviceFacade::TestFailureDevice testDeviceFacade::TestMyDevice

Public Member Functions

 Device (const std::string filename, const std::string name, DataContext &data_ctx)
 Device abstract class constructor. More...
 
virtual ~Device ()
 Default destructor. More...
 
virtual bool IsNotReady () const override
 Check if device is Standby/NotReady. More...
 
virtual bool IsReady () const override
 Check if device is Standby/Ready. More...
 
virtual bool IsOperational () const override
 Check if device is Operational. More...
 
virtual void CheckHwFailure () const override
 Check if device is in failure state. More...
 
virtual bool IsDisabling () const override
 Check if device is disablig. More...
 
virtual void Init () override
 Executes a Init command. More...
 
virtual void Enable () override
 Executes a Enable command. More...
 
virtual void Disable () override
 Executes a Disable command. More...
 
virtual void Stop () override
 Executes a Stop command. More...
 
virtual void Reset () override
 Executes a Reset command. More...
 
virtual void GetStatusBuffer (const std::string &stat_prefix, const DeviceControllerData *const data, std::string &buffer)
 
void GetStatusHeader (const std::string &prefix, const core::dit::did::Did &dictionary, std::shared_ptr< CCfits::FITS > &fits_handle)
 Obtain the status of the device. More...
 
virtual void Simulate (rad::AnyEvent const &last_event) override
 Executes a Simulat. More...
 
virtual void StopSim (rad::AnyEvent const &last_event) override
 Executes a StopSim. More...
 
virtual void Ignore (rad::AnyEvent const &last_event) override
 Executes a Ignore. More...
 
virtual void StopIgn (rad::AnyEvent const &last_event) override
 Executes a StopIgn. More...
 
virtual void HwReset (rad::AnyEvent const &last_event) override
 Executes a hardware reset command. More...
 
virtual void HwInit (rad::AnyEvent const &last_event) override
 Executes a hardware init command. More...
 
virtual void HwEnable (rad::AnyEvent const &last_event) override
 Executes a hardware enable command. More...
 
virtual void HwDisable (rad::AnyEvent const &last_event) override
 Executes a hardware disable command. More...
 
virtual void StartMonitoring () override
 Start device monitoring via OPCUA subscriptions. More...
 
virtual void StopMonitoring () override
 Stop device monitoring. More...
 
virtual std::string GetName () const noexcept override
 Get device id. More...
 
virtual std::string GetLogName () const noexcept
 Get device id for logging purposes. More...
 
virtual std::shared_ptr< fcf::devmgr::common::DeviceLcsIfGetLcsIf () const noexcept
 
virtual std::shared_ptr< fcf::devmgr::common::IDeviceConfigGetConfig () const noexcept
 Get a pointer of device configuration. More...
 
void RegisterComm (std::shared_ptr< protocol::base::IComm > comm_if, protocol::base::Dispatcher<> &failure, protocol::base::Dispatcher<> &normal)
 Register a communication interface object. More...
 
- Public Member Functions inherited from fcf::devmgr::common::IDevice
virtual void CreateObjects (std::shared_ptr< fcf::devmgr::common::IDeviceConfig > config=nullptr)=0
 Create basic objects needed by the device class. More...
 
virtual void UpdateStatus ()=0
 Update internal status by connecting to the LCS. More...
 
virtual void Setup (const std::any &payload)=0
 Executes a setup. More...
 
virtual bool IsSetupActive (const std::any &payload) const =0
 Check if setup is still active. More...
 
virtual void Status (const std::any &payload, std::string &buffer)=0
 Obtain the status of the device. More...
 
virtual void Status (bool end_acq, const core::dit::did::Did &dictionary, std::shared_ptr< CCfits::FITS > &fits_handle)=0
 Obtain the status of the device. More...
 

Protected Member Functions

bool IsMsgForMe (const std::string &id) const noexcept
 Check if received message id is addressed to me. More...
 
void UpdateDb (utils::bat::DbVector &vec)
 Update device database. More...
 
void SetIgnore (bool flag)
 SetIgnore. More...
 
void SetSimulation (bool flag)
 SetSimulation. More...
 
void GetPrefix (const std::vector< std::string > prefix_list, std::string &prefix) const
 Get prefix for writing attributes to the DB. More...
 
std::string GetCfgPrefix (const std::vector< std::string > prefix_list) const
 
std::string GetStatPrefix (const std::vector< std::string > prefix_list) const
 
bool CheckNameParam (const std::any &payload)
 Determine whether paramater is included (device name). More...
 
void GetStatusList (utils::bat::DbVector &cfg_list, const DeviceControllerData &status)
 
virtual void WriteConfig ()
 Write configuration into OLDB. More...
 

Protected Attributes

std::string m_filename
 device configuration filename. More...
 
std::string m_name
 device ID. More...
 
DataContextm_data_ctx
 reference to the data context object. More...
 
protocol::base::Dispatcher m_failure
 Dispatcher for managing failures. More...
 
protocol::base::Dispatcher m_normal
 Dispatcher for managing positive events. More...
 
std::shared_ptr< DeviceConfigm_config
 Pointer to configuration object. More...
 
std::shared_ptr< DeviceLcsIfm_lcs_if
 Local Control System Interface. More...
 

Detailed Description

Device abstract class. This class represents the basic implementation of a device class. Most of the device share common properties and behavioural aspects. This class is implementing the common behaviour and defining the basic properties of all device classes.

Constructor & Destructor Documentation

◆ Device()

fcf::devmgr::common::Device::Device ( const std::string  filename,
const std::string  name,
DataContext data_ctx 
)

Device abstract class constructor.

Parameters
[in]filenameFilename of device configuration
[in]nameDevice ID
[in,out]data_ctxReference to the data context object

◆ ~Device()

fcf::devmgr::common::Device::~Device ( )
virtual

Default destructor.

Member Function Documentation

◆ CheckHwFailure()

void fcf::devmgr::common::Device::CheckHwFailure ( ) const
overridevirtual

Check if device is in failure state.

Exceptions
anexception if an error ocurrs.

Implements fcf::devmgr::common::IDevice.

Reimplemented in TestMyDevice.

◆ CheckNameParam()

bool fcf::devmgr::common::Device::CheckNameParam ( const std::any &  payload)
protected

Determine whether paramater is included (device name).

Parameters
payloadPayload of the command, a vector of strings.

If the vector is empty, it will return true. If the vector contains the the id of the device it will also return true otherwise it will return false.

◆ Disable()

void fcf::devmgr::common::Device::Disable ( )
overridevirtual

Executes a Disable command.

Exceptions
anexception if an error ocurrs.

Implements fcf::devmgr::common::IDevice.

Reimplemented in testDeviceFacade::TestFailureDevice, and testDeviceFacade::TestMyDevice.

◆ Enable()

void fcf::devmgr::common::Device::Enable ( )
overridevirtual

Executes a Enable command.

Exceptions
anexception if an error ocurrs.

Implements fcf::devmgr::common::IDevice.

Reimplemented in testDeviceFacade::TestFailureDevice, and testDeviceFacade::TestMyDevice.

◆ GetCfgPrefix()

std::string fcf::devmgr::common::Device::GetCfgPrefix ( const std::vector< std::string >  prefix_list) const
protected

◆ GetConfig()

virtual std::shared_ptr<fcf::devmgr::common::IDeviceConfig> fcf::devmgr::common::Device::GetConfig ( ) const
inlinevirtualnoexcept

Get a pointer of device configuration.

Returns
shared pointer of internal configuration object

Implements fcf::devmgr::common::IDevice.

Reimplemented in TestMyDevice, testDeviceFacade::TestFailureDevice, testDeviceFacade::TestMyDevice, and TestShutter.

◆ GetLcsIf()

virtual std::shared_ptr<fcf::devmgr::common::DeviceLcsIf> fcf::devmgr::common::Device::GetLcsIf ( ) const
inlinevirtualnoexcept
Returns
pointer to lcs interface object.

Implements fcf::devmgr::common::IDevice.

Reimplemented in TestMyDevice, testDeviceFacade::TestFailureDevice, testDeviceFacade::TestMyDevice, and TestShutter.

◆ GetLogName()

virtual std::string fcf::devmgr::common::Device::GetLogName ( ) const
inlinevirtualnoexcept

Get device id for logging purposes.

◆ GetName()

virtual std::string fcf::devmgr::common::Device::GetName ( ) const
inlineoverridevirtualnoexcept

Get device id.

Implements fcf::devmgr::common::IDevice.

◆ GetPrefix()

void fcf::devmgr::common::Device::GetPrefix ( const std::vector< std::string >  prefix_list,
std::string &  prefix 
) const
protected

Get prefix for writing attributes to the DB.

Parameters
prefix_listList of intermediate prefix values.
prefixString containing the formatted prefix.

◆ GetStatPrefix()

std::string fcf::devmgr::common::Device::GetStatPrefix ( const std::vector< std::string >  prefix_list) const
protected

◆ GetStatusBuffer()

void fcf::devmgr::common::Device::GetStatusBuffer ( const std::string &  stat_prefix,
const DeviceControllerData *const  data,
std::string &  buffer 
)
virtual

◆ GetStatusHeader()

void fcf::devmgr::common::Device::GetStatusHeader ( const std::string &  prefix,
const core::dit::did::Did &  dictionary,
std::shared_ptr< CCfits::FITS > &  fits_handle 
)

Obtain the status of the device.

Parameters
prefixPrefix for the status
dictionaryReference to the dictionary object
fits_handlePointer to the CCFITS object

This method will obtain the data from each device and add the corresponding meta-data to the CCfits object. If the end_acq is not true it will just register the start of the acquisition.

◆ GetStatusList()

void fcf::devmgr::common::Device::GetStatusList ( utils::bat::DbVector &  cfg_list,
const DeviceControllerData status 
)
protected

◆ HwDisable()

void fcf::devmgr::common::Device::HwDisable ( rad::AnyEvent const last_event)
overridevirtual

Executes a hardware disable command.

Parameters
[in]last_eventpayload of the hw disable message
Exceptions
anexception if an error ocurrs.

Implements fcf::devmgr::common::IDevice.

◆ HwEnable()

void fcf::devmgr::common::Device::HwEnable ( rad::AnyEvent const last_event)
overridevirtual

Executes a hardware enable command.

Parameters
[in]last_eventpayload of the hw enable message
Exceptions
anexception if an error ocurrs.

Implements fcf::devmgr::common::IDevice.

◆ HwInit()

void fcf::devmgr::common::Device::HwInit ( rad::AnyEvent const last_event)
overridevirtual

Executes a hardware init command.

Parameters
[in]last_eventpayload of the hw init message
Exceptions
anexception if an error ocurrs.

Implements fcf::devmgr::common::IDevice.

◆ HwReset()

void fcf::devmgr::common::Device::HwReset ( rad::AnyEvent const last_event)
overridevirtual

Executes a hardware reset command.

Parameters
[in]last_eventpayload of the hw reset message
Exceptions
anexception if an error ocurrs.

Implements fcf::devmgr::common::IDevice.

◆ Ignore()

void fcf::devmgr::common::Device::Ignore ( rad::AnyEvent const last_event)
overridevirtual

Executes a Ignore.

Parameters
[in]last_eventcontains the payload of the Ignore message.
Exceptions
anexception if an error ocurrs.

Implements fcf::devmgr::common::IDevice.

◆ Init()

void fcf::devmgr::common::Device::Init ( )
overridevirtual

Executes a Init command.

Returns
true if command is successfully executed, false otherwise.
Exceptions
anexception if an error ocurrs.

Implements fcf::devmgr::common::IDevice.

Reimplemented in testDeviceFacade::TestFailureDevice, and testDeviceFacade::TestMyDevice.

◆ IsDisabling()

bool fcf::devmgr::common::Device::IsDisabling ( ) const
overridevirtual

Check if device is disablig.

Returns
true if device is disabling, false otherwise

Implements fcf::devmgr::common::IDevice.

Reimplemented in TestMyDevice, and testDeviceFacade::TestMyDevice.

◆ IsMsgForMe()

bool fcf::devmgr::common::Device::IsMsgForMe ( const std::string &  id) const
inlineprotectednoexcept

Check if received message id is addressed to me.

Parameters
[in]idmessage id
Returns
true is message id matches own device id, false otherwise.

◆ IsNotReady()

bool fcf::devmgr::common::Device::IsNotReady ( ) const
overridevirtual

Check if device is Standby/NotReady.

Returns
true is device is Standby/NotReady, false otherwise

Implements fcf::devmgr::common::IDevice.

Reimplemented in TestMyDevice, testDeviceFacade::TestFailureDevice, and testDeviceFacade::TestMyDevice.

◆ IsOperational()

bool fcf::devmgr::common::Device::IsOperational ( ) const
overridevirtual

Check if device is Operational.

Returns
true is device is Operational, false otherwise

Implements fcf::devmgr::common::IDevice.

◆ IsReady()

bool fcf::devmgr::common::Device::IsReady ( ) const
overridevirtual

Check if device is Standby/Ready.

Returns
true is device is Standby/Ready, false otherwise

Implements fcf::devmgr::common::IDevice.

Reimplemented in TestMyDevice, testDeviceFacade::TestFailureDevice, and testDeviceFacade::TestMyDevice.

◆ RegisterComm()

void fcf::devmgr::common::Device::RegisterComm ( std::shared_ptr< protocol::base::IComm >  comm_if,
protocol::base::Dispatcher<> &  failure,
protocol::base::Dispatcher<> &  normal 
)
virtual

Register a communication interface object.

Parameters
[in]comm_ifshared pointer to the communication interface object
[in]failuredispatcher object for failure events
[in]normaldispatcher object for recovery of failure events.

This method register a particular communication interface. Most of the devices will use OPCUA but there might be several implementations so with this method one can register an interface that has been created previously and registered in the communication factory.

See also
iComm
commFactory
commMaker

Implements fcf::devmgr::common::IDevice.

Reimplemented in TestMyDevice, testDeviceFacade::TestFailureDevice, testDeviceFacade::TestMyDevice, and TestShutter.

◆ Reset()

void fcf::devmgr::common::Device::Reset ( )
overridevirtual

Executes a Reset command.

Exceptions
anexception if an error ocurrs.

Implements fcf::devmgr::common::IDevice.

Reimplemented in TestMyDevice, testDeviceFacade::TestFailureDevice, testDeviceFacade::TestMyDevice, and TestShutter.

◆ SetIgnore()

void fcf::devmgr::common::Device::SetIgnore ( bool  flag)
protected

SetIgnore.

Parameters
flag

◆ SetSimulation()

void fcf::devmgr::common::Device::SetSimulation ( bool  flag)
protected

SetSimulation.

Parameters
flag

◆ Simulate()

void fcf::devmgr::common::Device::Simulate ( rad::AnyEvent const last_event)
overridevirtual

Executes a Simulat.

Parameters
[in]last_eventcontains the payload of the Simulat message.
Exceptions
anexception if an error ocurrs.

Implements fcf::devmgr::common::IDevice.

◆ StartMonitoring()

void fcf::devmgr::common::Device::StartMonitoring ( )
overridevirtual

Start device monitoring via OPCUA subscriptions.

Implements fcf::devmgr::common::IDevice.

◆ Stop()

void fcf::devmgr::common::Device::Stop ( )
overridevirtual

Executes a Stop command.

Exceptions
anexception if an error ocurrs.

Implements fcf::devmgr::common::IDevice.

◆ StopIgn()

void fcf::devmgr::common::Device::StopIgn ( rad::AnyEvent const last_event)
overridevirtual

Executes a StopIgn.

Parameters
[in]last_eventcontains the payload of the StopIgn message.
Exceptions
anexception if an error ocurrs.

Implements fcf::devmgr::common::IDevice.

◆ StopMonitoring()

void fcf::devmgr::common::Device::StopMonitoring ( )
overridevirtual

Stop device monitoring.

Implements fcf::devmgr::common::IDevice.

◆ StopSim()

void fcf::devmgr::common::Device::StopSim ( rad::AnyEvent const last_event)
overridevirtual

Executes a StopSim.

Parameters
[in]last_eventcontains the payload of the StopSim message.
Exceptions
anexception if an error ocurrs.

Implements fcf::devmgr::common::IDevice.

◆ UpdateDb()

void fcf::devmgr::common::Device::UpdateDb ( utils::bat::DbVector &  vec)
protected

Update device database.

Parameters
attr_vectorList of attributes with their values.

◆ WriteConfig()

void fcf::devmgr::common::Device::WriteConfig ( )
protectedvirtual

Write configuration into OLDB.

Implements fcf::devmgr::common::IDevice.

Member Data Documentation

◆ m_config

std::shared_ptr<DeviceConfig> fcf::devmgr::common::Device::m_config
protected

Pointer to configuration object.

◆ m_data_ctx

DataContext& fcf::devmgr::common::Device::m_data_ctx
protected

reference to the data context object.

◆ m_failure

protocol::base::Dispatcher fcf::devmgr::common::Device::m_failure
protected

Dispatcher for managing failures.

◆ m_filename

std::string fcf::devmgr::common::Device::m_filename
protected

device configuration filename.

◆ m_lcs_if

std::shared_ptr<DeviceLcsIf> fcf::devmgr::common::Device::m_lcs_if
protected

Local Control System Interface.

◆ m_name

std::string fcf::devmgr::common::Device::m_name
protected

device ID.

◆ m_normal

protocol::base::Dispatcher fcf::devmgr::common::Device::m_normal
protected

Dispatcher for managing positive events.


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