ifw-fcf
5.0.0-pre2
|
Sensor Local Control System (LCS) Interface (IF) class. More...
#include <iodevLcsIf.hpp>
Public Types | |
enum | { STAT_LOCAL = 1 , STAT_ERROR = 2 , STAT_STATE = 3 , STAT_SUBSTATE = 4 , STAT_CHANNEL = 10 } |
![]() | |
enum | { STAT_LOCAL = 1 , STAT_ERROR = 2 , STAT_HW_STATUS = 3 , STAT_STATE = 4 , STAT_SUBSTATE = 5 } |
Public Member Functions | |
IODevLcsIf (std::shared_ptr< fcf::devmgr::common::IDeviceConfig > config, fcf::devmgr::common::DataContext &data_ctx) | |
IODevLcsIf constructor. More... | |
virtual | ~IODevLcsIf () |
Default destructor. More... | |
virtual void | InitObject () |
Initialize object. More... | |
void | GetStates (int &state, int &substate) override |
Get states (state and substate) of the controller. More... | |
void | Enable () override |
Executes the Enable RPC. More... | |
void | Stop () override |
Executes the Stop RPC. More... | |
virtual bool | IsReady () const |
Check if controller is in Standby/Ready state. More... | |
virtual bool | IsNotReady () const |
Check if controller is in Standby/NotReady state. More... | |
virtual bool | IsOperational () const |
Check if controller is in Operational. More... | |
bool | IsHwFailure () const |
Check if Sensor is in hardware error. More... | |
void | WriteOutputs (const protocol::base::VectorVariant &channel_list) |
void | SetOutputs (const protocol::base::VectorVariant &channel_list) |
void | StartMonitoring () |
Start monitoring of controller attributes. More... | |
void | StopMonitoring () |
Stop monitoring of controller attributes. More... | |
virtual void | ReadStatus (IODevControllerData &status) |
Read status from the controller. More... | |
void | Listener (protocol::base::VectorVariant ¶ms) |
Callback to manage changes on the monitored items. More... | |
virtual std::string | GetRpcError (const short error_code) const |
![]() | |
DeviceLcsIf (std::shared_ptr< IDeviceConfig > config, DataContext &data_ctx) | |
DeviceLcsIf constructor. 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 | IsDisabling () const |
Check if controller is in Disabling state. More... | |
virtual void | Init () |
Executes the Init RPC. More... | |
virtual void | Disable () |
Executes the Disable RPC. More... | |
virtual void | Reset () |
Executes the Reset RPC. More... | |
virtual void | ReadStatus (DeviceControllerData &status) |
ReadStatus. 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< IDeviceConfig > | GetDeviceConfig () const |
Get a pointer of device configuration. More... | |
const elt::configng::CiiConfigInstanceNamespace & | GetCfgInstance () const |
Additional Inherited Members | |
![]() | |
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... | |
![]() | |
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< IDeviceConfig > | m_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::DataContext & | m_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 |
Sensor Local Control System (LCS) Interface (IF) class.
This class manages the Sensor connection to the LCS encapsulating all basic communication with the controller or the simulator.
Each RPC call is synchronous but it only starts the action in the controller. The controller will return successfully if the action can be started, not that the action was completed.
The completion of the action must be monitored by reading the status of the controller but this is out of the scope of this class.
fcf::devmgr::iodev::IODevLcsIf::IODevLcsIf | ( | std::shared_ptr< fcf::devmgr::common::IDeviceConfig > | config, |
fcf::devmgr::common::DataContext & | data_ctx | ||
) |
IODevLcsIf constructor.
[in,out] | config | Shared pointer to the device configuration. |
[in,out] | data_ctx | Reference to the data context object. |
[in] | initialise | Flag to control the initialization. This flag is used when using child classes. |
[in] | with_publisher | Flag to be used in unit tests to avoid crash of CII. |
|
inlinevirtual |
Default destructor.
|
overridevirtual |
Executes the Enable RPC.
an | exception if an error ocurrs. |
This RPC call shall bring the controller to Operational state.
Reimplemented from fcf::devmgr::common::DeviceLcsIf.
|
virtual |
error_code | Error code |
Implements fcf::devmgr::common::DeviceLcsIf.
|
overridevirtual |
Get states (state and substate) of the controller.
[in,out] | state | state of the controller |
[in,out] | substate | substate 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 from fcf::devmgr::common::DeviceLcsIf.
|
virtual |
Initialize object.
an | exception 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 from fcf::devmgr::common::DeviceLcsIf.
|
virtual |
Check if Sensor is in hardware error.
Reimplemented from fcf::devmgr::common::DeviceLcsIf.
|
virtual |
Check if controller is in Standby/NotReady state.
Reimplemented from fcf::devmgr::common::DeviceLcsIf.
|
virtual |
Check if controller is in Operational.
Reimplemented from fcf::devmgr::common::DeviceLcsIf.
|
virtual |
Check if controller is in Standby/Ready state.
Reimplemented from fcf::devmgr::common::DeviceLcsIf.
|
virtual |
Callback to manage changes on the monitored items.
[in] | params | Vector containing the list of atributes that have changed |
This method implement the actions associated to the events originated from the monitoring of attributes.
This method is storing in the database the values that have changed. It also publish the events for the clients via zeroMQ.
Reimplemented from fcf::devmgr::common::DeviceLcsIf.
|
virtual |
Read status from the controller.
status | structure containing the status of the controller. |
an | exception if an error ocurrs. |
void fcf::devmgr::iodev::IODevLcsIf::SetOutputs | ( | const protocol::base::VectorVariant & | channel_list | ) |
|
virtual |
Start monitoring of controller attributes.
an | exception 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 from fcf::devmgr::common::DeviceLcsIf.
|
overridevirtual |
Executes the Stop RPC.
an | exception if an error ocurrs. |
This RPC call stop any ongoing action of the controller.
The specific behaviour will depend on the controller.
Reimplemented from fcf::devmgr::common::DeviceLcsIf.
|
virtual |
Stop monitoring of controller attributes.
This method will inform the communication interface to stop monitoring the IODev attributes.
Reimplemented from fcf::devmgr::common::DeviceLcsIf.
void fcf::devmgr::iodev::IODevLcsIf::WriteOutputs | ( | const protocol::base::VectorVariant & | channel_list | ) |