ChimeraTK-DeviceAccess  03.18.00
ChimeraTK::LogicalNameMappingBackend Class Reference

Backend to map logical register names onto real hardware registers. More...

#include <LogicalNameMappingBackend.h>

+ Inheritance diagram for ChimeraTK::LogicalNameMappingBackend:
+ Collaboration diagram for ChimeraTK::LogicalNameMappingBackend:

Classes

struct  SharedAccessor
 Struct holding shared accessors together with a mutex for thread safety. More...
 

Public Types

using AccessorKey = std::pair< DeviceBackend *, RegisterPath >
 Map of target accessors which are potentially shared across our accessors. More...
 
template<typename UserType >
using SharedAccessorMap = std::map< AccessorKey, SharedAccessor< UserType > >
 

Public Member Functions

 LogicalNameMappingBackend (std::string lmapFileName="")
 
void open () override
 Open the device. More...
 
void close () override
 Close the device. More...
 
std::string readDeviceInfo () override
 Return a device information string containing hardware details like the firmware version number or the slot number used by the board. More...
 
RegisterCatalogue getRegisterCatalogue () const override
 Return the register catalogue with detailed information on all registers. More...
 
void setExceptionImpl () noexcept override
 Function to be (optionally) implemented by backends if additional actions are needed when switching to the exception state. More...
 
void activateAsyncRead () noexcept override
 Activate asyncronous read for all transfer elements where AccessMode::wait_for_new_data is set. More...
 
template<typename UserType >
boost::shared_ptr< NDRegisterAccessor< UserType > > getRegisterAccessor_impl (const RegisterPath &registerPathName, size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags, size_t omitPlugins=0)
 
template<typename UserType >
boost::shared_ptr< NDRegisterAccessor< UserType > > getRegisterAccessor_internal (const RegisterPath &registerPathName, size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags)
 
void parse () const
 parse the logical map file, if not yet done More...
 
std::unordered_set< std::string > getTargetDevices () const
 Obtain list of all target devices referenced in the catalogue. More...
 
ChimeraTK::VersionNumber getVersionOnOpen () const
 
- Public Member Functions inherited from ChimeraTK::DeviceBackendImpl
bool isOpen () override
 Return whether a device has been opened or not. More...
 
bool isConnected () final
 Deprecated since 2022-03-03. More...
 
MetadataCatalogue getMetadataCatalogue () const override
 Return the device metadata catalogue. More...
 
void checkActiveException () final
 Function to be called by backends when needing to check for an active exception. More...
 
void setException (const std::string &message) noexcept final
 Set the backend into an exception state. More...
 
bool isFunctional () const noexcept final
 Return whether a device is working as intended, usually this means it is opened and does not have any errors. More...
 
std::string getActiveExceptionMessage () noexcept
 
- Public Member Functions inherited from ChimeraTK::DeviceBackend
virtual ~DeviceBackend ()=default
 Every virtual class needs a virtual desctructor. More...
 
template<typename UserType >
boost::shared_ptr< NDRegisterAccessor< UserType > > getRegisterAccessor (const RegisterPath &registerPathName, size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags)
 Get a NDRegisterAccessor object from the register name. More...
 
 DEFINE_VIRTUAL_FUNCTION_TEMPLATE_VTABLE (getRegisterAccessor_impl, boost::shared_ptr< NDRegisterAccessor< T >>(const RegisterPath &, size_t, size_t, AccessModeFlags))
 

Static Public Member Functions

static boost::shared_ptr< DeviceBackendcreateInstance (std::string address, std::map< std::string, std::string > parameters)
 

Public Attributes

bool hasParsed
 flag if already parsed More...
 
std::string _lmapFileName
 name of the logical map file More...
 
std::map< std::string, boost::shared_ptr< DeviceBackend > > _devices
 map of target devices More...
 
std::map< std::string, std::string > _parameters
 map of parameters passed through the CDD More...
 
BackendRegisterCatalogue< LNMBackendRegisterInfo_catalogue_mutable
 We need to make the catalogue mutable, since we fill it within getRegisterCatalogue() More...
 
bool catalogueCompleted {false}
 Flag whether the catalogue has already been filled with extra information from the target backends. More...
 
TemplateUserTypeMap< SharedAccessorMapsharedAccessorMap
 
std::mutex sharedAccessorMap_mutex
 a mutex to be locked when sharedAccessorMap (the container) is changed More...
 
std::map< std::string, LNMVariable_variables
 Map of variables and constants. More...
 
std::atomic< bool > _asyncReadActive {false}
 Flag storing whether asynchronous read has been activated. More...
 

Friends

template<typename T >
class LNMBackendRegisterAccessor
 
template<typename T >
class LNMBackendChannelAccessor
 
template<typename T >
class LNMBackendBitAccessor
 
template<typename T >
class LNMBackendVariableAccessor
 

Additional Inherited Members

- Protected Member Functions inherited from ChimeraTK::DeviceBackendImpl
void setOpenedAndClearException () noexcept
 Backends should call this function at the end of a (successful) open() call. More...
 
- Protected Attributes inherited from ChimeraTK::DeviceBackendImpl
std::atomic< bool > _opened {false}
 flag if backend is opened More...
 
async::DomainsContainer _asyncDomainsContainer
 Container for async::Domains to support wait_for_new_data. More...
 

Detailed Description

Backend to map logical register names onto real hardware registers.

See Logical Name Mapping Backend for details.

Definition at line 19 of file LogicalNameMappingBackend.h.

Member Typedef Documentation

◆ AccessorKey

Map of target accessors which are potentially shared across our accessors.

An example is the target accessors of LNMBackendBitAccessor. Multiple instances of LNMBackendBitAccessor referring to different bits of the same register share their target accessor. This sharing is governed by this map.

Definition at line 82 of file LogicalNameMappingBackend.h.

◆ SharedAccessorMap

template<typename UserType >
using ChimeraTK::LogicalNameMappingBackend::SharedAccessorMap = std::map<AccessorKey, SharedAccessor<UserType> >

Definition at line 84 of file LogicalNameMappingBackend.h.

Constructor & Destructor Documentation

◆ LogicalNameMappingBackend()

ChimeraTK::LogicalNameMappingBackend::LogicalNameMappingBackend ( std::string  lmapFileName = "")
explicit

Definition at line 15 of file LogicalNameMappingBackend.cc.

+ Here is the call graph for this function:

Member Function Documentation

◆ activateAsyncRead()

void ChimeraTK::LogicalNameMappingBackend::activateAsyncRead ( )
overridevirtualnoexcept

Activate asyncronous read for all transfer elements where AccessMode::wait_for_new_data is set.

If Device::activateAsyncRead() is called while the device is not opened or has an error, this call has no effect. If it is called when no deactivated transfer element exists, this call also has no effect. When Device::activateAsyncRead() returns, it is not guaranteed that all initial values have been received already.

For more details, see Technical specification: TransferElement B.8.5.

Reimplemented from ChimeraTK::DeviceBackend.

Definition at line 344 of file LogicalNameMappingBackend.cc.

+ Here is the call graph for this function:

◆ close()

void ChimeraTK::LogicalNameMappingBackend::close ( )
overridevirtual

Close the device.

Implements ChimeraTK::DeviceBackend.

Definition at line 85 of file LogicalNameMappingBackend.cc.

+ Here is the call graph for this function:

◆ createInstance()

boost::shared_ptr< DeviceBackend > ChimeraTK::LogicalNameMappingBackend::createInstance ( std::string  address,
std::map< std::string, std::string >  parameters 
)
static

Definition at line 108 of file LogicalNameMappingBackend.cc.

◆ getRegisterAccessor_impl()

template<typename UserType >
boost::shared_ptr< NDRegisterAccessor< UserType > > ChimeraTK::LogicalNameMappingBackend::getRegisterAccessor_impl ( const RegisterPath registerPathName,
size_t  numberOfWords,
size_t  wordOffsetInRegister,
AccessModeFlags  flags,
size_t  omitPlugins = 0 
)

Definition at line 123 of file LogicalNameMappingBackend.cc.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRegisterAccessor_internal()

template<typename UserType >
boost::shared_ptr< NDRegisterAccessor< UserType > > ChimeraTK::LogicalNameMappingBackend::getRegisterAccessor_internal ( const RegisterPath registerPathName,
size_t  numberOfWords,
size_t  wordOffsetInRegister,
AccessModeFlags  flags 
)

Definition at line 149 of file LogicalNameMappingBackend.cc.

+ Here is the call graph for this function:

◆ getRegisterCatalogue()

RegisterCatalogue ChimeraTK::LogicalNameMappingBackend::getRegisterCatalogue ( ) const
overridevirtual

Return the register catalogue with detailed information on all registers.

Implements ChimeraTK::DeviceBackend.

Definition at line 215 of file LogicalNameMappingBackend.cc.

+ Here is the call graph for this function:

◆ getTargetDevices()

std::unordered_set< std::string > ChimeraTK::LogicalNameMappingBackend::getTargetDevices ( ) const

Obtain list of all target devices referenced in the catalogue.

Definition at line 391 of file LogicalNameMappingBackend.cc.

+ Here is the caller graph for this function:

◆ getVersionOnOpen()

ChimeraTK::VersionNumber ChimeraTK::LogicalNameMappingBackend::getVersionOnOpen ( ) const

Definition at line 401 of file LogicalNameMappingBackend.cc.

◆ open()

void ChimeraTK::LogicalNameMappingBackend::open ( )
overridevirtual

Open the device.

Implements ChimeraTK::DeviceBackend.

Definition at line 46 of file LogicalNameMappingBackend.cc.

+ Here is the call graph for this function:

◆ parse()

void ChimeraTK::LogicalNameMappingBackend::parse ( ) const

parse the logical map file, if not yet done

Definition at line 22 of file LogicalNameMappingBackend.cc.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readDeviceInfo()

std::string ChimeraTK::LogicalNameMappingBackend::readDeviceInfo ( )
inlineoverridevirtual

Return a device information string containing hardware details like the firmware version number or the slot number used by the board.

The format and contained information of this string is completely backend implementation dependent, so the string may only be printed to the user as an informational output. Do not try to parse this string or extract information from it programmatically.

Implements ChimeraTK::DeviceBackend.

Definition at line 27 of file LogicalNameMappingBackend.h.

◆ setExceptionImpl()

void ChimeraTK::LogicalNameMappingBackend::setExceptionImpl ( )
overridevirtualnoexcept

Function to be (optionally) implemented by backends if additional actions are needed when switching to the exception state.

Reimplemented from ChimeraTK::DeviceBackendImpl.

Definition at line 303 of file LogicalNameMappingBackend.cc.

+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ LNMBackendBitAccessor

template<typename T >
friend class LNMBackendBitAccessor
friend

Definition at line 101 of file LogicalNameMappingBackend.h.

◆ LNMBackendChannelAccessor

template<typename T >
friend class LNMBackendChannelAccessor
friend

Definition at line 98 of file LogicalNameMappingBackend.h.

◆ LNMBackendRegisterAccessor

template<typename T >
friend class LNMBackendRegisterAccessor
friend

Definition at line 95 of file LogicalNameMappingBackend.h.

◆ LNMBackendVariableAccessor

template<typename T >
friend class LNMBackendVariableAccessor
friend

Definition at line 104 of file LogicalNameMappingBackend.h.

Member Data Documentation

◆ _asyncReadActive

std::atomic<bool> ChimeraTK::LogicalNameMappingBackend::_asyncReadActive {false}

Flag storing whether asynchronous read has been activated.

Definition at line 107 of file LogicalNameMappingBackend.h.

◆ _catalogue_mutable

BackendRegisterCatalogue<LNMBackendRegisterInfo> ChimeraTK::LogicalNameMappingBackend::_catalogue_mutable
mutable

We need to make the catalogue mutable, since we fill it within getRegisterCatalogue()

Definition at line 63 of file LogicalNameMappingBackend.h.

◆ _devices

std::map<std::string, boost::shared_ptr<DeviceBackend> > ChimeraTK::LogicalNameMappingBackend::_devices
mutable

map of target devices

Definition at line 56 of file LogicalNameMappingBackend.h.

◆ _lmapFileName

std::string ChimeraTK::LogicalNameMappingBackend::_lmapFileName

name of the logical map file

Definition at line 53 of file LogicalNameMappingBackend.h.

◆ _parameters

std::map<std::string, std::string> ChimeraTK::LogicalNameMappingBackend::_parameters

map of parameters passed through the CDD

Definition at line 59 of file LogicalNameMappingBackend.h.

◆ _variables

std::map<std::string , LNMVariable> ChimeraTK::LogicalNameMappingBackend::_variables
mutable

Map of variables and constants.

This map contains the mpl tables with the actual values and a mutex for each of them. It has to be mutable as the parse function must be const.

Definition at line 92 of file LogicalNameMappingBackend.h.

◆ catalogueCompleted

bool ChimeraTK::LogicalNameMappingBackend::catalogueCompleted {false}
mutable

Flag whether the catalogue has already been filled with extra information from the target backends.

Definition at line 67 of file LogicalNameMappingBackend.h.

◆ hasParsed

bool ChimeraTK::LogicalNameMappingBackend::hasParsed
mutable

flag if already parsed

Definition at line 50 of file LogicalNameMappingBackend.h.

◆ sharedAccessorMap

TemplateUserTypeMap<SharedAccessorMap> ChimeraTK::LogicalNameMappingBackend::sharedAccessorMap

Definition at line 85 of file LogicalNameMappingBackend.h.

◆ sharedAccessorMap_mutex

std::mutex ChimeraTK::LogicalNameMappingBackend::sharedAccessorMap_mutex

a mutex to be locked when sharedAccessorMap (the container) is changed

Definition at line 87 of file LogicalNameMappingBackend.h.


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