ifw-fcf  5.0.0-pre2
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
fcf::devmgr::common::DeviceLcsIf Class Referenceabstract

#include <deviceLcsIf.hpp>

Inheritance diagram for fcf::devmgr::common::DeviceLcsIf:
MyDeviceLcsIf fcf::devmgr::actuator::ActuatorLcsIf fcf::devmgr::adc::AdcLcsIf fcf::devmgr::iodev::IODevLcsIf fcf::devmgr::motor::MotorBaseLcsIf fcf::devmgr::piezo::PiezoLcsIf fcf::devmgr::shutter::ShutterLcsIf testDeviceFacade::MyDeviceLcsIf testDeviceLcsIf::MyDeviceLcsIf

Public Types

enum  {
  STAT_LOCAL = 1 , STAT_ERROR = 2 , STAT_HW_STATUS = 3 , STAT_STATE = 4 ,
  STAT_SUBSTATE = 5
}
 

Public Member Functions

 DeviceLcsIf (std::shared_ptr< IDeviceConfig > config, DataContext &data_ctx)
 DeviceLcsIf constructor. More...
 
virtual void InitObject ()
 Initialize object. More...
 
virtual void RegisterComm (std::shared_ptr< protocol::base::IComm > comm_if, protocol::base::Dispatcher<> &failure, protocol::base::Dispatcher<> &normal)
 Register a communication interface. More...
 
virtual void Connect ()
 Connect to the controller or simulator. More...
 
virtual void Disconnect ()
 Disconnect from the controller of simulator. More...
 
virtual bool IsNotReady () const
 Check if controller is in Standby/NotReady state. More...
 
virtual bool IsReady () const
 Check if controller is in Standby/Ready state. More...
 
virtual bool IsDisabling () const
 Check if controller is in Disabling state. More...
 
virtual bool IsOperational () const
 Check if controller is in Operational. More...
 
virtual bool IsHwFailure () const
 Check if controller is in Hardware Failure. More...
 
virtual void Init ()
 Executes the Init RPC. More...
 
virtual void Enable ()
 Executes the Enable RPC. More...
 
virtual void Disable ()
 Executes the Disable RPC. More...
 
virtual void Stop ()
 Executes the Stop RPC. More...
 
virtual void Reset ()
 Executes the Reset RPC. More...
 
virtual void StartMonitoring ()
 Start monitoring of controller attributes. More...
 
virtual void StopMonitoring ()
 Stop monitoring of controller attributes. More...
 
virtual void ReadStatus (DeviceControllerData &status)
 ReadStatus. More...
 
virtual void Listener (protocol::base::VectorVariant &params)
 Callback for listening controller events. More...
 
virtual std::string GetRpcError (const short error_code) const =0
 Get associated message from the RPC error code. More...
 
virtual std::string GetHwError (int &error_code, const bool update=false)
 Get error message. More...
 
std::string GetMapValue (const std::string &category, const std::string &key) const
 Get mapping value. More...
 
protocol::base::Dispatcher< protocol::base::VectorVariant & > & GetDispatcher ()
 
bool IsConfigLoaded () const
 Check if configuration was loaded. More...
 
bool IsConnected () const
 Check is the communication was established. More...
 
virtual std::shared_ptr< IDeviceConfigGetDeviceConfig () const
 Get a pointer of device configuration. More...
 
const elt::configng::CiiConfigInstanceNamespace & GetCfgInstance () const
 
virtual void GetStates (int &state, int &substate)
 Get states (state and substate) of the controller. More...
 

Protected Member Functions

void LoadConfig ()
 Load the YAML configuration. More...
 
void ExecuteRpc (const std::string &obj, const std::string &proc, protocol::base::VectorVariant &attr_list)
 
int ReadErrorCode ()
 
void StoreUaNames (const std::vector< std::pair< std::string, unsigned int >> &ualist)
 StoreUaNames. More...
 
void StoreAttribute (const std::string key, const protocol::base::Variant &value, int attribute)
 Store the updated into the DB. More...
 

Protected Attributes

std::unique_ptr< elt::configng::CiiConfigDocument > m_config_doc
 Config document for mapping file. More...
 
std::shared_ptr< protocol::base::IComm > m_comm
 Shared pointer to the communication object. More...
 
std::shared_ptr< IDeviceConfigm_config
 Shared pointer to the device config object. More...
 
protocol::base::Dispatcher< protocol::base::VectorVariant & > m_dispatcher
 Dispatcher for managing subscription events. More...
 
protocol::base::Dispatcher m_failure
 Dispatcher for managing failures in the communication. More...
 
protocol::base::Dispatcher m_normal
 Dispatcher for managing recovery of communication failures. More...
 
int m_state {}
 Actual controller state. More...
 
int m_substate {}
 Actual controller substate. More...
 
bool m_local {false}
 Actual local flag. More...
 
bool m_error_code {false}
 Actual error code. More...
 
bool m_config_loaded {false}
 Flag indicating whether the configuration was successfully loaded. More...
 
bool m_connected {false}
 Flag indicating whether the LCS is connected. More...
 
fcf::devmgr::common::DataContextm_data_ctx
 
std::string m_lcs_prefix
 Store the prefix for storing keys in the database. More...
 
std::unordered_map< std::string, short > m_ua_status_map
 
std::vector< std::string > m_ua_monitor_vector
 
std::unordered_map< short, std::string > m_hw_errors
 

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
STAT_LOCAL 
STAT_ERROR 
STAT_HW_STATUS 
STAT_STATE 
STAT_SUBSTATE 

Constructor & Destructor Documentation

◆ DeviceLcsIf()

fcf::devmgr::common::DeviceLcsIf::DeviceLcsIf ( std::shared_ptr< IDeviceConfig config,
DataContext data_ctx 
)
explicit

DeviceLcsIf constructor.

Parameters
configShared pointer to the device configuration.
data_ctxData contex

Member Function Documentation

◆ Connect()

void fcf::devmgr::common::DeviceLcsIf::Connect ( )
virtual

Connect to the controller or simulator.

Exceptions
anexception if an error ocurrs.

This method uses the registered communication interface to establish the connection.

◆ Disable()

void fcf::devmgr::common::DeviceLcsIf::Disable ( )
virtual

Executes the Disable RPC.

Exceptions
anexception if an error ocurrs.

This RPC call shall bring the controller to Standby/Ready state.

Reimplemented in MyDeviceLcsIf, and testDeviceFacade::MyDeviceLcsIf.

◆ Disconnect()

void fcf::devmgr::common::DeviceLcsIf::Disconnect ( )
virtual

Disconnect from the controller of simulator.

This method tries to disconnect from the controller or simulator. In case of error, the class will consider anyway the connection closed.

◆ Enable()

void fcf::devmgr::common::DeviceLcsIf::Enable ( )
virtual

Executes the Enable RPC.

Exceptions
anexception if an error ocurrs.

This RPC call shall bring the controller to Operational state.

Reimplemented in fcf::devmgr::iodev::IODevLcsIf, MyDeviceLcsIf, and testDeviceFacade::MyDeviceLcsIf.

◆ ExecuteRpc()

void fcf::devmgr::common::DeviceLcsIf::ExecuteRpc ( const std::string &  obj,
const std::string &  proc,
protocol::base::VectorVariant &  attr_list 
)
protected

◆ GetCfgInstance()

const elt::configng::CiiConfigInstanceNamespace & fcf::devmgr::common::DeviceLcsIf::GetCfgInstance ( ) const

◆ GetDeviceConfig()

std::shared_ptr< IDeviceConfig > fcf::devmgr::common::DeviceLcsIf::GetDeviceConfig ( ) const
virtual

Get a pointer of device configuration.

Returns
shared pointer of internal configuration object

◆ GetDispatcher()

protocol::base::Dispatcher< protocol::base::VectorVariant & > & fcf::devmgr::common::DeviceLcsIf::GetDispatcher ( )

◆ GetHwError()

std::string fcf::devmgr::common::DeviceLcsIf::GetHwError ( int &  error_code,
const bool  update = false 
)
virtual

Get error message.

Parameters
error_codeInput error code
updateFlag that indicate to read the error code.
Returns
error message associated to the error code read from the PLC.

This methods does a read to the PLC to obtain the error code.

Reimplemented in testDeviceLcsIf::MyDeviceLcsIf, MyDeviceLcsIf, and testDeviceFacade::MyDeviceLcsIf.

◆ GetMapValue()

std::string fcf::devmgr::common::DeviceLcsIf::GetMapValue ( const std::string &  category,
const std::string &  key 
) const

Get mapping value.

Parameters
categoryattribute category
keyattribute key
Returns
string contaning the mapping value

This method delivers the attribute name at the controller (mapping). This is obtained from the mapping file and based on the category and key given. This mapping string represents the OPCUA name in the address space of the device.

The mapping file is a generalization of the address space of a particular type of device.

◆ GetRpcError()

virtual std::string fcf::devmgr::common::DeviceLcsIf::GetRpcError ( const short  error_code) const
pure virtual

◆ GetStates()

void fcf::devmgr::common::DeviceLcsIf::GetStates ( int &  state,
int &  substate 
)
virtual

Get states (state and substate) of the controller.

Parameters
[in,out]statestate of the controller
[in,out]substatesubstate of the controller

This is a generic method to read the state and substate attributes of the controller. The value of these attributes might be different depending of the device.

Reimplemented in fcf::devmgr::iodev::IODevLcsIf.

◆ Init()

void fcf::devmgr::common::DeviceLcsIf::Init ( )
virtual

Executes the Init RPC.

Exceptions
anexception if an error ocurrs.

Reimplemented in fcf::devmgr::adc::AdcLcsIf, MyDeviceLcsIf, and testDeviceFacade::MyDeviceLcsIf.

◆ InitObject()

void fcf::devmgr::common::DeviceLcsIf::InitObject ( )
virtual

Initialize object.

Exceptions
anexception if an error ocurrs.

This method carries out basic object initialization. It is done in a separate method to allow overriden this functionality in children classes.

Reimplemented in fcf::devmgr::smaract::SmaractLcsIf, fcf::devmgr::shutter::ShutterLcsIf, fcf::devmgr::piezo::PiezoLcsIf, fcf::devmgr::motor::MotorLcsIf, fcf::devmgr::lamp::LampLcsIf, fcf::devmgr::iodev::IODevLcsIf, fcf::devmgr::drot::DrotLcsIf, fcf::devmgr::adc::AdcLcsIf, and fcf::devmgr::actuator::ActuatorLcsIf.

◆ IsConfigLoaded()

bool fcf::devmgr::common::DeviceLcsIf::IsConfigLoaded ( ) const

Check if configuration was loaded.

Returns
true when configuration was loaded, false otherwise.

◆ IsConnected()

bool fcf::devmgr::common::DeviceLcsIf::IsConnected ( ) const

Check is the communication was established.

Returns
true when is connected, false otherwise.

◆ IsDisabling()

bool fcf::devmgr::common::DeviceLcsIf::IsDisabling ( ) const
virtual

Check if controller is in Disabling state.

Returns
true if condit// System headersion is met, false otherwise.

This is method is needed when Enabling a device. Sometimes a device is still disabling from the previous action and device must wait before attempting to enable again.

◆ IsHwFailure()

bool fcf::devmgr::common::DeviceLcsIf::IsHwFailure ( ) const
virtual

Check if controller is in Hardware Failure.

Returns
true if condition is met, false otherwise.

Sometimes the controller may enter into a failure state triggerd by a hardware error. The controller will enter into a specific state to signal this condition. This method is checking if this condition is met.

This method reads the substate attribute from the PLC.

Reimplemented in fcf::devmgr::iodev::IODevLcsIf.

◆ IsNotReady()

bool fcf::devmgr::common::DeviceLcsIf::IsNotReady ( ) const
virtual

Check if controller is in Standby/NotReady state.

Returns
true if condition is met, false otherwise.

Reimplemented in fcf::devmgr::lamp::LampLcsIf, fcf::devmgr::actuator::ActuatorLcsIf, and fcf::devmgr::iodev::IODevLcsIf.

◆ IsOperational()

bool fcf::devmgr::common::DeviceLcsIf::IsOperational ( ) const
virtual

Check if controller is in Operational.

Returns
true if condition is met, false otherwise.

Reimplemented in fcf::devmgr::actuator::ActuatorLcsIf, fcf::devmgr::shutter::ShutterLcsIf, and fcf::devmgr::iodev::IODevLcsIf.

◆ IsReady()

bool fcf::devmgr::common::DeviceLcsIf::IsReady ( ) const
virtual

Check if controller is in Standby/Ready state.

Returns
true if condition is met, false otherwise.

Reimplemented in fcf::devmgr::actuator::ActuatorLcsIf, fcf::devmgr::shutter::ShutterLcsIf, and fcf::devmgr::iodev::IODevLcsIf.

◆ Listener()

void fcf::devmgr::common::DeviceLcsIf::Listener ( protocol::base::VectorVariant &  params)
virtual

Callback for listening controller events.

Parameters
paramslist of paramaters to be monitored.

Abstract method to be implemented by specific classes.

Reimplemented in fcf::devmgr::smaract::SmaractLcsIf, fcf::devmgr::piezo::PiezoLcsIf, fcf::devmgr::motor::MotorLcsIf, fcf::devmgr::lamp::LampLcsIf, fcf::devmgr::iodev::IODevLcsIf, fcf::devmgr::drot::DrotLcsIf, fcf::devmgr::adc::AdcLcsIf, fcf::devmgr::actuator::ActuatorLcsIf, MyDeviceLcsIf, and testDeviceFacade::MyDeviceLcsIf.

◆ LoadConfig()

void fcf::devmgr::common::DeviceLcsIf::LoadConfig ( )
protected

Load the YAML configuration.

Exceptions
std::runtime_errorin case of error

◆ ReadErrorCode()

int fcf::devmgr::common::DeviceLcsIf::ReadErrorCode ( )
protected

◆ ReadStatus()

void fcf::devmgr::common::DeviceLcsIf::ReadStatus ( DeviceControllerData status)
virtual

ReadStatus.

Parameters
status

◆ RegisterComm()

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

Register a communication interface.

Parameters
comm_ifshared pointer to the communication interface
failuredispatcher for failure events
normaldispatcher for recovering failure events

The communication object have to be created before using this class and registered using this method.

The constructor create a callback for the internal dispatcher and loads the configuration.

◆ Reset()

void fcf::devmgr::common::DeviceLcsIf::Reset ( )
virtual

Executes the Reset RPC.

Exceptions
anexception if an error ocurrs.

This RPC call shall bring the controller to Standby/NotReady state.

◆ StartMonitoring()

void fcf::devmgr::common::DeviceLcsIf::StartMonitoring ( )
virtual

Start monitoring of controller attributes.

Exceptions
anexception if an error ocurrs.

This methods take cares of registering the attributes that will be monitored by the communication class. Most of the communication will be OPCUA and this monitoring means OPCUA subscription.

Reimplemented in fcf::devmgr::iodev::IODevLcsIf, testDeviceLcsIf::MyDeviceLcsIf, MyDeviceLcsIf, and testDeviceFacade::MyDeviceLcsIf.

◆ Stop()

void fcf::devmgr::common::DeviceLcsIf::Stop ( )
virtual

Executes the Stop RPC.

Exceptions
anexception if an error ocurrs.

This RPC call stop any ongoing action of the controller.

The specific behaviour will depend on the controller.

Reimplemented in fcf::devmgr::iodev::IODevLcsIf.

◆ StopMonitoring()

void fcf::devmgr::common::DeviceLcsIf::StopMonitoring ( )
virtual

Stop monitoring of controller attributes.

Exceptions
anexception if an error ocurrs.

This method will inform the communication interface to stop monitoring the shutter attributes. All OPCUA subscriptions will be removed.

Reimplemented in fcf::devmgr::iodev::IODevLcsIf, testDeviceLcsIf::MyDeviceLcsIf, MyDeviceLcsIf, and testDeviceFacade::MyDeviceLcsIf.

◆ StoreAttribute()

void fcf::devmgr::common::DeviceLcsIf::StoreAttribute ( const std::string  key,
const protocol::base::Variant &  value,
int  attribute 
)
protected

Store the updated into the DB.

Parameters
keyKey used to store the new value.
valueVariant value to be published.
attributeCode of the attribute changed

This method store the value into the OLDB.

◆ StoreUaNames()

void fcf::devmgr::common::DeviceLcsIf::StoreUaNames ( const std::vector< std::pair< std::string, unsigned int >> &  ualist)
protected

StoreUaNames.

Parameters
ualistBuild a map with the real OPCUA names. The purpose of this map is know which attributes are associate with events received from the PLC. These events are generated from the NodeId.

Member Data Documentation

◆ m_comm

std::shared_ptr<protocol::base::IComm> fcf::devmgr::common::DeviceLcsIf::m_comm
protected

Shared pointer to the communication object.

◆ m_config

std::shared_ptr<IDeviceConfig> fcf::devmgr::common::DeviceLcsIf::m_config
protected

Shared pointer to the device config object.

◆ m_config_doc

std::unique_ptr<elt::configng::CiiConfigDocument> fcf::devmgr::common::DeviceLcsIf::m_config_doc
protected

Config document for mapping file.

◆ m_config_loaded

bool fcf::devmgr::common::DeviceLcsIf::m_config_loaded {false}
protected

Flag indicating whether the configuration was successfully loaded.

◆ m_connected

bool fcf::devmgr::common::DeviceLcsIf::m_connected {false}
protected

Flag indicating whether the LCS is connected.

◆ m_data_ctx

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

◆ m_dispatcher

protocol::base::Dispatcher<protocol::base::VectorVariant&> fcf::devmgr::common::DeviceLcsIf::m_dispatcher
protected

Dispatcher for managing subscription events.

◆ m_error_code

bool fcf::devmgr::common::DeviceLcsIf::m_error_code {false}
protected

Actual error code.

◆ m_failure

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

Dispatcher for managing failures in the communication.

◆ m_hw_errors

std::unordered_map<short, std::string> fcf::devmgr::common::DeviceLcsIf::m_hw_errors
protected

◆ m_lcs_prefix

std::string fcf::devmgr::common::DeviceLcsIf::m_lcs_prefix
protected

Store the prefix for storing keys in the database.

this map is used to convert NodeId received by the OPCUA notifications to an index value to avoid comparing strings to each notification.

◆ m_local

bool fcf::devmgr::common::DeviceLcsIf::m_local {false}
protected

Actual local flag.

◆ m_normal

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

Dispatcher for managing recovery of communication failures.

◆ m_state

int fcf::devmgr::common::DeviceLcsIf::m_state {}
protected

Actual controller state.

◆ m_substate

int fcf::devmgr::common::DeviceLcsIf::m_substate {}
protected

Actual controller substate.

◆ m_ua_monitor_vector

std::vector<std::string> fcf::devmgr::common::DeviceLcsIf::m_ua_monitor_vector
protected

◆ m_ua_status_map

std::unordered_map<std::string, short> fcf::devmgr::common::DeviceLcsIf::m_ua_status_map
protected

This vector is used to prepare in advance the list of node_ids that will be monitored per device.


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