ChimeraTK-DeviceAccess
03.18.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. 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 ®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) |
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 ®isterPathName, 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< DeviceBackend > | createInstance (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< SharedAccessorMap > | sharedAccessorMap |
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... | |
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 82 of file LogicalNameMappingBackend.h.
using ChimeraTK::LogicalNameMappingBackend::SharedAccessorMap = std::map<AccessorKey, SharedAccessor<UserType> > |
Definition at line 84 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 344 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.
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 391 of file LogicalNameMappingBackend.cc.
ChimeraTK::VersionNumber ChimeraTK::LogicalNameMappingBackend::getVersionOnOpen | ( | ) | const |
Definition at line 401 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 303 of file LogicalNameMappingBackend.cc.
|
friend |
Definition at line 101 of file LogicalNameMappingBackend.h.
|
friend |
Definition at line 98 of file LogicalNameMappingBackend.h.
|
friend |
Definition at line 95 of file LogicalNameMappingBackend.h.
|
friend |
Definition at line 104 of file LogicalNameMappingBackend.h.
std::atomic<bool> ChimeraTK::LogicalNameMappingBackend::_asyncReadActive {false} |
Flag storing whether asynchronous read has been activated.
Definition at line 107 of file LogicalNameMappingBackend.h.
|
mutable |
We need to make the catalogue mutable, since we fill it within getRegisterCatalogue()
Definition at line 63 of file LogicalNameMappingBackend.h.
|
mutable |
map of target devices
Definition at line 56 of file LogicalNameMappingBackend.h.
std::string ChimeraTK::LogicalNameMappingBackend::_lmapFileName |
name of the logical map file
Definition at line 53 of file LogicalNameMappingBackend.h.
std::map<std::string, std::string> ChimeraTK::LogicalNameMappingBackend::_parameters |
map of parameters passed through the CDD
Definition at line 59 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 92 of file LogicalNameMappingBackend.h.
|
mutable |
Flag whether the catalogue has already been filled with extra information from the target backends.
Definition at line 67 of file LogicalNameMappingBackend.h.
|
mutable |
flag if already parsed
Definition at line 50 of file LogicalNameMappingBackend.h.
TemplateUserTypeMap<SharedAccessorMap> ChimeraTK::LogicalNameMappingBackend::sharedAccessorMap |
Definition at line 85 of file LogicalNameMappingBackend.h.
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.