![]() |
ChimeraTK-DeviceAccess 03.20.00
|
Backend to map logical register names onto real hardware registers. More...
#include <LogicalNameMappingBackend.h>
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. | |
template<typename UserType > | |
using | SharedAccessorMap = std::map< AccessorKey, SharedAccessor< UserType > > |
![]() | |
using | BackendID = std::uintptr_t |
Public Member Functions | |
LogicalNameMappingBackend (std::string lmapFileName="") | |
void | open () override |
Open the device. | |
void | close () override |
Close the device. | |
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. | |
RegisterCatalogue | getRegisterCatalogue () const override |
Return the register catalogue with detailed information on all registers. | |
void | setExceptionImpl () noexcept override |
Function to be (optionally) implemented by backends if additional actions are needed when switching to the exception state. | |
void | activateAsyncRead () noexcept override |
Activate asyncronous read for all transfer elements where AccessMode::wait_for_new_data is set. | |
template<typename UserType > | |
boost::shared_ptr< NDRegisterAccessor< UserType > > | getRegisterAccessor_impl (const RegisterPath ®isterPathName, size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags, size_t omitPlugins=0) |
template<typename UserType > | |
boost::shared_ptr< NDRegisterAccessor< UserType > > | getRegisterAccessor_internal (const RegisterPath ®isterPathName, size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags) |
std::set< DeviceBackend::BackendID > | getInvolvedBackendIDs () override |
Get the backend IDs of all involved backends. | |
void | parse () const |
parse the logical map file, if not yet done | |
std::unordered_set< std::string > | getTargetDevices () const |
Obtain list of all target devices referenced in the catalogue. | |
ChimeraTK::VersionNumber | getVersionOnOpen () const |
![]() | |
bool | isOpen () override |
Return whether a device has been opened or not. | |
bool | isConnected () final |
Deprecated since 2022-03-03. | |
MetadataCatalogue | getMetadataCatalogue () const override |
Return the device metadata catalogue. | |
void | checkActiveException () final |
Function to be called by backends when needing to check for an active exception. | |
void | setException (const std::string &message) noexcept final |
Set the backend into an exception state. | |
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. | |
std::string | getActiveExceptionMessage () noexcept |
![]() | |
virtual | ~DeviceBackend ()=default |
Every virtual class needs a virtual desctructor. | |
template<typename UserType > | |
boost::shared_ptr< NDRegisterAccessor< UserType > > | getRegisterAccessor (const RegisterPath ®isterPathName, size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags) |
Get a NDRegisterAccessor object from the register name. | |
DEFINE_VIRTUAL_FUNCTION_TEMPLATE_VTABLE (getRegisterAccessor_impl, boost::shared_ptr< NDRegisterAccessor< T > >(const RegisterPath &, size_t, size_t, AccessModeFlags)) | |
BackendID | getBackendID () |
Get a unique ID for this backend instance. | |
Static Public Member Functions | |
static boost::shared_ptr< DeviceBackend > | createInstance (std::string address, std::map< std::string, std::string > parameters) |
Public Attributes | |
bool | hasParsed |
flag if already parsed | |
std::string | _lmapFileName |
name of the logical map file | |
std::map< std::string, boost::shared_ptr< DeviceBackend > > | _devices |
map of target devices | |
std::map< std::string, std::string > | _parameters |
map of parameters passed through the CDD | |
BackendRegisterCatalogue< LNMBackendRegisterInfo > | _catalogue_mutable |
We need to make the catalogue mutable, since we fill it within getRegisterCatalogue() | |
bool | catalogueCompleted {false} |
Flag whether the catalogue has already been filled with extra information from the target backends. | |
TemplateUserTypeMap< SharedAccessorMap > | sharedAccessorMap |
std::mutex | sharedAccessorMap_mutex |
a mutex to be locked when sharedAccessorMap (the container) is changed | |
std::map< std::string, LNMVariable > | _variables |
Map of variables and constants. | |
std::atomic< bool > | _asyncReadActive {false} |
Flag storing whether asynchronous read has been activated. | |
Friends | |
template<typename T > | |
class | LNMBackendRegisterAccessor |
template<typename T > | |
class | LNMBackendChannelAccessor |
template<typename T > | |
class | LNMBackendBitAccessor |
template<typename T > | |
class | LNMBackendVariableAccessor |
Additional Inherited Members | |
![]() | |
void | setOpenedAndClearException () noexcept |
Backends should call this function at the end of a (successful) open() call. | |
![]() | |
std::atomic< bool > | _opened {false} |
flag if backend is opened | |
async::DomainsContainer | _asyncDomainsContainer |
Container for async::Domains to support wait_for_new_data. | |
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.
using ChimeraTK::LogicalNameMappingBackend::AccessorKey = std::pair<DeviceBackend*, RegisterPath> |
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 84 of file LogicalNameMappingBackend.h.
using ChimeraTK::LogicalNameMappingBackend::SharedAccessorMap = std::map<AccessorKey, SharedAccessor<UserType> > |
Definition at line 86 of file LogicalNameMappingBackend.h.
|
explicit |
Definition at line 15 of file LogicalNameMappingBackend.cc.
|
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 346 of file LogicalNameMappingBackend.cc.
|
overridevirtual |
Close the device.
Implements ChimeraTK::DeviceBackend.
Definition at line 85 of file LogicalNameMappingBackend.cc.
|
static |
Definition at line 108 of file LogicalNameMappingBackend.cc.
|
overridevirtual |
Get the backend IDs of all involved backends.
For meta backends like the LogicalNameMappingBackend or the SubDeviceBackend this contains the ID of all target backend, in addition to this backend's ID.
Reimplemented from ChimeraTK::DeviceBackendImpl.
Definition at line 414 of file LogicalNameMappingBackend.cc.
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.
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.
|
overridevirtual |
Return the register catalogue with detailed information on all registers.
Implements ChimeraTK::DeviceBackend.
Definition at line 215 of file LogicalNameMappingBackend.cc.
std::unordered_set< std::string > ChimeraTK::LogicalNameMappingBackend::getTargetDevices | ( | ) | const |
Obtain list of all target devices referenced in the catalogue.
Definition at line 398 of file LogicalNameMappingBackend.cc.
ChimeraTK::VersionNumber ChimeraTK::LogicalNameMappingBackend::getVersionOnOpen | ( | ) | const |
Definition at line 408 of file LogicalNameMappingBackend.cc.
|
overridevirtual |
Open the device.
Implements ChimeraTK::DeviceBackend.
Definition at line 46 of file LogicalNameMappingBackend.cc.
void ChimeraTK::LogicalNameMappingBackend::parse | ( | ) | const |
parse the logical map file, if not yet done
Definition at line 22 of file LogicalNameMappingBackend.cc.
|
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.
|
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 305 of file LogicalNameMappingBackend.cc.
|
friend |
Definition at line 103 of file LogicalNameMappingBackend.h.
|
friend |
Definition at line 100 of file LogicalNameMappingBackend.h.
|
friend |
Definition at line 97 of file LogicalNameMappingBackend.h.
|
friend |
Definition at line 106 of file LogicalNameMappingBackend.h.
std::atomic<bool> ChimeraTK::LogicalNameMappingBackend::_asyncReadActive {false} |
Flag storing whether asynchronous read has been activated.
Definition at line 109 of file LogicalNameMappingBackend.h.
|
mutable |
We need to make the catalogue mutable, since we fill it within getRegisterCatalogue()
Definition at line 65 of file LogicalNameMappingBackend.h.
|
mutable |
map of target devices
Definition at line 58 of file LogicalNameMappingBackend.h.
std::string ChimeraTK::LogicalNameMappingBackend::_lmapFileName |
name of the logical map file
Definition at line 55 of file LogicalNameMappingBackend.h.
std::map<std::string, std::string> ChimeraTK::LogicalNameMappingBackend::_parameters |
map of parameters passed through the CDD
Definition at line 61 of file LogicalNameMappingBackend.h.
|
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 94 of file LogicalNameMappingBackend.h.
|
mutable |
Flag whether the catalogue has already been filled with extra information from the target backends.
Definition at line 69 of file LogicalNameMappingBackend.h.
|
mutable |
flag if already parsed
Definition at line 52 of file LogicalNameMappingBackend.h.
TemplateUserTypeMap<SharedAccessorMap> ChimeraTK::LogicalNameMappingBackend::sharedAccessorMap |
Definition at line 87 of file LogicalNameMappingBackend.h.
std::mutex ChimeraTK::LogicalNameMappingBackend::sharedAccessorMap_mutex |
a mutex to be locked when sharedAccessorMap (the container) is changed
Definition at line 89 of file LogicalNameMappingBackend.h.