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

Device Configuration class. More...

#include <deviceConfig.hpp>

Inheritance diagram for fcf::devmgr::common::DeviceConfig:
fcf::devmgr::common::IDeviceConfig MyDeviceConfig MyDeviceConfig fcf::devmgr::adc::AdcConfig fcf::devmgr::iodev::IODevConfig fcf::devmgr::motor::MotorBaseConfig fcf::devmgr::piezo::PiezoConfig testDeviceFacade::MyDeviceConfig testDeviceLcsIf::MyDeviceConfig testLamp::MyDeviceConfig testLampConfig::MyDeviceConfig testLampLcsIf::TestLampConfig testShutter::MyDeviceConfig testShutterConfig::MyDeviceConfig testShutterLcsIf::TestShutterConfig

Public Member Functions

 DeviceConfig (const std::string &filename, const std::string &name)
 DeviceConfig constructor. More...
 
 DeviceConfig (const std::string &name)
 DeviceConfig constructor. More...
 
virtual ~DeviceConfig ()
 DeviceConfig destructor. More...
 
bool Init ()
 Initialises a device. More...
 
void InitFromString (std::string config)
 Init the internal configuration from a string. More...
 
void InitFromFile (const std::string &filename)
 Init the internal configuration from a given file. More...
 
virtual void GetConfig (protocol::base::VectorVariant &params) const
 Obtain the list of configuration parameters. More...
 
std::string GetIdentifier () const
 
std::string GetPrefix () const
 
std::string GetAddress () const
 
std::string GetSimAddress () const
 
std::string GetFitsPrefix () const
 Get Fits Prefix. More...
 
std::string GetType () const
 
int GetNamespace () const
 
std::string GetAlias () const
 
std::string GetId () const
 
std::string GetOverview () const
 
std::string GetDescription () const
 
std::string GetName () const noexcept
 
std::string GetLogName () const noexcept
 
std::string GetNodeId (const std::string &attrib) const
 Get node id. More...
 
std::string GetProcId (const std::string &attrib) const
 Get procedure id. More...
 
std::string GetObjId () const
 Get object id. More...
 
virtual void GetConfigList (utils::bat::DbVector &cfg_list, std::string prefix) const
 Get configuration list. More...
 
std::string GetCfgFile () const
 GetCfgFile. More...
 
std::string GetCfgAsString () const
 GetCfgAsString. More...
 
virtual void SetSimulateFlag (const bool flag)
 Set simulation flag. More...
 
virtual void SetIgnoreFlag (const bool flag)
 Set ignore flag. More...
 
virtual bool GetIgnored () const
 Get ignored flag. More...
 
virtual bool GetSimulated () const
 Get simulated flag. More...
 
virtual std::string GetMapFile () const
 Get name of the device mapping file. More...
 
void CheckConfig () const
 Validates the document configuration. More...
 

Protected Member Functions

void MergeConfig (const elt::configng::CiiConfigDocument &doc, bool check=true)
 Merges a configuration file. More...
 
bool GetVariantValue (const elt::configng::CiiConfigInstanceNode node, protocol::base::Variant &value) const
 Obtain the variant value with the correct type. More...
 

Protected Attributes

std::string m_filename
 filename of device configuration file More...
 
std::string m_name
 device identifier More...
 
std::string m_identifier
 Address space identifier. More...
 
std::string m_type
 Device type. More...
 
std::string m_fits_prefix
 
bool m_simulated
 
bool m_ignored
 
std::string m_lcs_prefix
 
std::string m_address
 
std::string m_sim_address
 
std::string m_map_file
 
std::string m_alias
 
int m_lcs_namespace
 
std::unique_ptr< elt::configng::CiiConfigDocument > m_config_doc
 Internal configuration document object. More...
 

Detailed Description

Device Configuration class.

This class manages the configuration of a device. It reads the configuration file and provides the methods to obtain the parameters used by the various classes.

Constructor & Destructor Documentation

◆ DeviceConfig() [1/2]

fcf::devmgr::common::DeviceConfig::DeviceConfig ( const std::string &  filename,
const std::string &  name 
)

DeviceConfig constructor.

Parameters
[in]filenamefilename of the device configuration file.
[in]nameDevice identifier.

◆ DeviceConfig() [2/2]

fcf::devmgr::common::DeviceConfig::DeviceConfig ( const std::string &  name)

DeviceConfig constructor.

Special constructor to be used for special cases, e.g. in GUIs.

See also
InitFromString

◆ ~DeviceConfig()

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

DeviceConfig destructor.

Member Function Documentation

◆ CheckConfig()

void fcf::devmgr::common::DeviceConfig::CheckConfig ( ) const

Validates the document configuration.

Exceptions
std::runtime_errorin case check reported issues.

◆ GetAddress()

std::string fcf::devmgr::common::DeviceConfig::GetAddress ( ) const
virtual
Returns
device address

Implements fcf::devmgr::common::IDeviceConfig.

◆ GetAlias()

std::string fcf::devmgr::common::DeviceConfig::GetAlias ( ) const
virtual
Returns
namespace

Implements fcf::devmgr::common::IDeviceConfig.

◆ GetCfgAsString()

std::string fcf::devmgr::common::DeviceConfig::GetCfgAsString ( ) const
virtual

GetCfgAsString.

Returns

Implements fcf::devmgr::common::IDeviceConfig.

◆ GetCfgFile()

std::string fcf::devmgr::common::DeviceConfig::GetCfgFile ( ) const

GetCfgFile.

Returns

◆ GetConfig()

void fcf::devmgr::common::DeviceConfig::GetConfig ( protocol::base::VectorVariant &  params) const
virtual

Obtain the list of configuration parameters.

Parameters
[in,out]paramsoutput vector with the list of config parameters

This methods prepare a vector with all the configuration parameters of a device with the purpose to write it into the controller. Only attributes that are scalars are considered here.

Warning
: vectors are ignored since they are still not supported in the OPCUA interface
Exceptions
runtimeerror in case of bad casting.

Implements fcf::devmgr::common::IDeviceConfig.

Reimplemented in fcf::devmgr::motor::MotorConfig, fcf::devmgr::iodev::IODevConfig, and fcf::devmgr::adc::AdcConfig.

◆ GetConfigList()

void fcf::devmgr::common::DeviceConfig::GetConfigList ( utils::bat::DbVector &  cfg_list,
std::string  prefix 
) const
virtual

Get configuration list.

Parameters
cfg_listList of all configuration parameters.
prefixPrefix to be added to the attributes names.

This method returs the complete of configuration parameters handled by this class. This method is used to dump the list into the DB.

Reimplemented in fcf::devmgr::motor::MotorConfig, fcf::devmgr::motor::MotorBaseConfig, fcf::devmgr::iodev::IODevConfig, and fcf::devmgr::adc::AdcConfig.

◆ GetDescription()

std::string fcf::devmgr::common::DeviceConfig::GetDescription ( ) const
Returns
namespace

◆ GetFitsPrefix()

std::string fcf::devmgr::common::DeviceConfig::GetFitsPrefix ( ) const

Get Fits Prefix.

◆ GetId()

std::string fcf::devmgr::common::DeviceConfig::GetId ( ) const
Returns
namespace

◆ GetIdentifier()

std::string fcf::devmgr::common::DeviceConfig::GetIdentifier ( ) const
virtual
Returns
addres space identifier

Implements fcf::devmgr::common::IDeviceConfig.

◆ GetIgnored()

bool fcf::devmgr::common::DeviceConfig::GetIgnored ( ) const
virtual

Get ignored flag.

Implements fcf::devmgr::common::IDeviceConfig.

◆ GetLogName()

std::string fcf::devmgr::common::DeviceConfig::GetLogName ( ) const
inlinenoexcept
Returns
device name for logging purposes

◆ GetMapFile()

std::string fcf::devmgr::common::DeviceConfig::GetMapFile ( ) const
virtual

◆ GetName()

std::string fcf::devmgr::common::DeviceConfig::GetName ( ) const
inlinevirtualnoexcept
Returns
device name

Implements fcf::devmgr::common::IDeviceConfig.

◆ GetNamespace()

int fcf::devmgr::common::DeviceConfig::GetNamespace ( ) const
virtual
Returns
namespace

Implements fcf::devmgr::common::IDeviceConfig.

◆ GetNodeId()

std::string fcf::devmgr::common::DeviceConfig::GetNodeId ( const std::string &  attrib) const
virtual

Get node id.

Parameters
[in]attribattribute to build the node id
Returns
Node id of the attribute given

The NodeId is composed by the following: <namespace>,<prefix>.<attribute>

Implements fcf::devmgr::common::IDeviceConfig.

◆ GetObjId()

std::string fcf::devmgr::common::DeviceConfig::GetObjId ( ) const
virtual

Get object id.

Returns
string with object id

This method returns the address space prefix for executing RPC calls.

<namespace>,<prefix>

Implements fcf::devmgr::common::IDeviceConfig.

◆ GetOverview()

std::string fcf::devmgr::common::DeviceConfig::GetOverview ( ) const
Returns
namespace

◆ GetPrefix()

std::string fcf::devmgr::common::DeviceConfig::GetPrefix ( ) const
virtual
Returns
device prefix

Implements fcf::devmgr::common::IDeviceConfig.

◆ GetProcId()

std::string fcf::devmgr::common::DeviceConfig::GetProcId ( const std::string &  attrib) const
virtual

Get procedure id.

Parameters
[in]attribattribute to build the node id
Returns
string with procedure id

The procedure id is the NodeId for RPC calls and it is composed by the following:

<namespace>,<prefix>#<attribute>

Implements fcf::devmgr::common::IDeviceConfig.

◆ GetSimAddress()

std::string fcf::devmgr::common::DeviceConfig::GetSimAddress ( ) const
virtual
Returns
device simulation address

Implements fcf::devmgr::common::IDeviceConfig.

◆ GetSimulated()

bool fcf::devmgr::common::DeviceConfig::GetSimulated ( ) const
virtual

Get simulated flag.

Implements fcf::devmgr::common::IDeviceConfig.

◆ GetType()

std::string fcf::devmgr::common::DeviceConfig::GetType ( ) const
virtual
Returns
device type

Implements fcf::devmgr::common::IDeviceConfig.

◆ GetVariantValue()

bool fcf::devmgr::common::DeviceConfig::GetVariantValue ( const elt::configng::CiiConfigInstanceNode  node,
protocol::base::Variant &  value 
) const
protected

Obtain the variant value with the correct type.

Parameters
[in]nodeConfiguration node
[in]valueVariant value to be filled up

This methods fill the variant with the value obtained from the node according to the respective type.

Warning
: ONLY few data types are considered due to the current limitation of the interface with OPCUA.
Exceptions
runtimeerror in case of bad casting.

◆ Init()

bool fcf::devmgr::common::DeviceConfig::Init ( )

Initialises a device.

Returns
true if initialisation finished without error, false otherwise.

◆ InitFromFile()

void fcf::devmgr::common::DeviceConfig::InitFromFile ( const std::string &  filename)

Init the internal configuration from a given file.

Parameters
filenameThis method is to be used in special cases only. The standard way is to use the proper constructor that will initialize automaticaly the internal configuration with the configuration file using method Init.
See also
Init

◆ InitFromString()

void fcf::devmgr::common::DeviceConfig::InitFromString ( std::string  config)

Init the internal configuration from a string.

Parameters
configThis method is to be used in special cases, for instance by GUIs where the configuration can be obtained from the server as a string. With this method you can avoid accessing directly to the filesystem which might be hidden by Nomad.

◆ MergeConfig()

void fcf::devmgr::common::DeviceConfig::MergeConfig ( const elt::configng::CiiConfigDocument &  doc,
bool  check = true 
)
protected

Merges a configuration file.

Parameters
docConfig document object to be validated.
checkFlag to verify after the merge.
Exceptions
std::runtime_errorin case check reported issues.

◆ SetIgnoreFlag()

void fcf::devmgr::common::DeviceConfig::SetIgnoreFlag ( const bool  flag)
virtual

Set ignore flag.

Implements fcf::devmgr::common::IDeviceConfig.

◆ SetSimulateFlag()

void fcf::devmgr::common::DeviceConfig::SetSimulateFlag ( const bool  flag)
virtual

Set simulation flag.

Implements fcf::devmgr::common::IDeviceConfig.

Member Data Documentation

◆ m_address

std::string fcf::devmgr::common::DeviceConfig::m_address
protected

◆ m_alias

std::string fcf::devmgr::common::DeviceConfig::m_alias
protected

◆ m_config_doc

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

Internal configuration document object.

◆ m_filename

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

filename of device configuration file

◆ m_fits_prefix

std::string fcf::devmgr::common::DeviceConfig::m_fits_prefix
protected

◆ m_identifier

std::string fcf::devmgr::common::DeviceConfig::m_identifier
protected

Address space identifier.

◆ m_ignored

bool fcf::devmgr::common::DeviceConfig::m_ignored
protected

◆ m_lcs_namespace

int fcf::devmgr::common::DeviceConfig::m_lcs_namespace
protected

◆ m_lcs_prefix

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

◆ m_map_file

std::string fcf::devmgr::common::DeviceConfig::m_map_file
protected

◆ m_name

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

device identifier

◆ m_sim_address

std::string fcf::devmgr::common::DeviceConfig::m_sim_address
protected

◆ m_simulated

bool fcf::devmgr::common::DeviceConfig::m_simulated
protected

◆ m_type

std::string fcf::devmgr::common::DeviceConfig::m_type
protected

Device type.


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