![]() |
ChimeraTK-DeviceAccess 03.20.00
|
Backend for subdevices which are passed through some register or area of another device (subsequently called target device). More...
#include <SubdeviceBackend.h>
Public Member Functions | |
SubdeviceBackend (std::map< std::string, std::string > parameters) | |
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. | |
MetadataCatalogue | getMetadataCatalogue () const override |
Return the device metadata catalogue. | |
std::set< DeviceBackend::BackendID > | getInvolvedBackendIDs () override |
Get the backend IDs of all involved backends. | |
![]() | |
bool | isOpen () override |
Return whether a device has been opened or not. | |
bool | isConnected () final |
Deprecated since 2022-03-03. | |
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) |
Protected Types | |
enum class | Type { area , threeRegisters , twoRegisters , areaHandshake } |
Protected Member Functions | |
void | verifyRegisterAccessorSize (const NumericAddressedRegisterInfo &info, size_t &numberOfWords, size_t wordOffsetInRegister, bool enforceAlignment) |
Check consistency of the passed sizes and offsets against the information in the map file Will adjust numberOfWords to the default value if 0. | |
template<typename UserType > | |
boost::shared_ptr< NDRegisterAccessor< UserType > > | getRegisterAccessor_impl (const RegisterPath ®isterPathName, size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags) |
DEFINE_VIRTUAL_FUNCTION_TEMPLATE_VTABLE_FILLER (SubdeviceBackend, getRegisterAccessor_impl, 4) | |
template<typename UserType > | |
boost::shared_ptr< NDRegisterAccessor< UserType > > | getRegisterAccessor_area (const RegisterPath ®isterPathName, size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags) |
getRegisterAccessor implemenation for area types | |
template<typename UserType > | |
boost::shared_ptr< NDRegisterAccessor< UserType > > | getRegisterAccessor_synchronized (const RegisterPath ®isterPathName, size_t numberOfWords, size_t wordOffsetInRegister, const AccessModeFlags &flags) |
getRegisterAccessor implemenation for threeRegisters types | |
void | obtainTargetBackend () |
obtain the target backend if not yet done | |
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. | |
bool | needAreaParam () |
bool | needStatusParam () |
boost::shared_ptr< SubdeviceRegisterAccessor > | getRegisterAccessor_helper (const NumericAddressedRegisterInfo &info, size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags) |
template<> | |
boost::shared_ptr< NDRegisterAccessor< int32_t > > | getRegisterAccessor_area (const RegisterPath ®isterPathName, size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags) |
template<> | |
boost::shared_ptr< NDRegisterAccessor< int32_t > > | getRegisterAccessor_synchronized (const RegisterPath ®isterPathName, size_t numberOfWords, size_t wordOffsetInRegister, const AccessModeFlags &flags) |
![]() | |
void | setOpenedAndClearException () noexcept |
Backends should call this function at the end of a (successful) open() call. | |
Protected Attributes | |
std::mutex | mutex |
Mutex to deal with concurrent access to the device. | |
Type | type |
type of the subdeivce | |
size_t | timeout {10000} |
timeout (in milliseconds), used in threeRegisters to throw a runtime_error if status register stuck at 1 | |
std::string | targetAlias |
the target device name | |
boost::shared_ptr< ChimeraTK::DeviceBackend > | targetDevice |
The target device backend itself. | |
std::string | targetArea |
for type == area: the name of the target register | |
std::string | targetAddress |
for type == threeRegisters or twoRegisters: the name of the target registers | |
std::string | targetData |
std::string | targetControl |
size_t | sleepTime {100} |
for type == threeRegisters or twoRegisters: sleep time of polling loop resp. between operations, in usecs. | |
size_t | addressToDataDelay {0} |
for type == threeRegisters or twoRegisters: sleep time between address and data write | |
NumericAddressedRegisterCatalogue | _registerMap |
map from register names to addresses | |
MetadataCatalogue | _metadataCatalogue |
![]() | |
std::atomic< bool > | _opened {false} |
flag if backend is opened | |
async::DomainsContainer | _asyncDomainsContainer |
Container for async::Domains to support wait_for_new_data. | |
Friends | |
class | SubdeviceRegisterAccessor |
Additional Inherited Members | |
![]() | |
using | BackendID = std::uintptr_t |
Backend for subdevices which are passed through some register or area of another device (subsequently called target device).
The subdevice is close to a numeric addressed backend and has a map file of the same format (but BARs other than 0 are not supported). The target device may be of any type.
The sdm URI syntax for setting up the subdevice depends on the protocol used to pass through the registers. The following pass-trough types are supported:
(subdevice?type=area&device=<targetDevice>&area=<targetRegister>&map=mapFile>)
(subdevice?type=3regs&device=<targetDevice>&address=<addressRegister>&data=<dataRegister>&status=<statusRegister>&sleep=<usecs>&map=<mapFile>)The sleep parameter is optional and defaults to 100 usecs. It sets the polling interval for the status register in microseconds. Another optional parameter "dataDelay" can be used to configure an additional delay in microseconds between the write of the address and the data registers (defaults to 0 usecs).
(subdevice?type=areaHandshake&device=<targetDevice>&area=<targetRegister>&map=mapFile&status=<statusRegister>&sleep=<usecs>)
Example: We like to use the register "APP.0.EXT_PZ16M" of the device with the alias name "TCK7_0" in our dmap file as a target and the file piezo_pz16m_acc1_r0.mapp as a map file. The file contains addresses relative to the beginning of the register "APP.0.EXT_PZ16M". The URI then looks like this:
(subdevice?type=area&device=TCK7_0&area=APP.0.EXT_PZ16M&map=piezo_pz16m_acc1_r0.mapp)
Definition at line 57 of file SubdeviceBackend.h.
|
strongprotected |
Enumerator | |
---|---|
area | |
threeRegisters | |
twoRegisters | |
areaHandshake |
Definition at line 81 of file SubdeviceBackend.h.
|
explicit |
Definition at line 52 of file SubdeviceBackend.cc.
|
overrideprotectedvirtualnoexcept |
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 545 of file SubdeviceBackend.cc.
|
overridevirtual |
Close the device.
Implements ChimeraTK::DeviceBackend.
Definition at line 189 of file SubdeviceBackend.cc.
|
static |
Definition at line 23 of file SubdeviceBackend.cc.
|
protected |
|
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 551 of file SubdeviceBackend.cc.
|
overridevirtual |
Return the device metadata catalogue.
Reimplemented from ChimeraTK::DeviceBackendImpl.
Definition at line 203 of file SubdeviceBackend.cc.
|
protected |
getRegisterAccessor implemenation for area types
Definition at line 391 of file SubdeviceBackend.cc.
|
protected |
Definition at line 464 of file SubdeviceBackend.cc.
|
protected |
Definition at line 421 of file SubdeviceBackend.cc.
|
protected |
Definition at line 309 of file SubdeviceBackend.cc.
|
protected |
getRegisterAccessor implemenation for threeRegisters types
Definition at line 464 of file SubdeviceBackend.cc.
|
protected |
Definition at line 464 of file SubdeviceBackend.cc.
|
overridevirtual |
Return the register catalogue with detailed information on all registers.
Implements ChimeraTK::DeviceBackend.
Definition at line 197 of file SubdeviceBackend.cc.
|
inlineprotected |
Definition at line 149 of file SubdeviceBackend.h.
|
inlineprotected |
Definition at line 150 of file SubdeviceBackend.h.
|
protected |
obtain the target backend if not yet done
Definition at line 172 of file SubdeviceBackend.cc.
|
overridevirtual |
Open the device.
Implements ChimeraTK::DeviceBackend.
Definition at line 180 of file SubdeviceBackend.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 65 of file SubdeviceBackend.h.
|
overrideprotectedvirtualnoexcept |
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 538 of file SubdeviceBackend.cc.
|
protected |
Check consistency of the passed sizes and offsets against the information in the map file Will adjust numberOfWords to the default value if 0.
Definition at line 330 of file SubdeviceBackend.cc.
|
friend |
Definition at line 79 of file SubdeviceBackend.h.
|
protected |
Definition at line 119 of file SubdeviceBackend.h.
|
protected |
map from register names to addresses
Definition at line 118 of file SubdeviceBackend.h.
|
protected |
for type == threeRegisters or twoRegisters: sleep time between address and data write
Definition at line 115 of file SubdeviceBackend.h.
|
protected |
Mutex to deal with concurrent access to the device.
Definition at line 90 of file SubdeviceBackend.h.
|
protected |
for type == threeRegisters or twoRegisters: sleep time of polling loop resp. between operations, in usecs.
Definition at line 112 of file SubdeviceBackend.h.
|
protected |
for type == threeRegisters or twoRegisters: the name of the target registers
Definition at line 109 of file SubdeviceBackend.h.
|
protected |
the target device name
Definition at line 99 of file SubdeviceBackend.h.
|
protected |
for type == area: the name of the target register
Definition at line 106 of file SubdeviceBackend.h.
|
protected |
Definition at line 109 of file SubdeviceBackend.h.
|
protected |
Definition at line 109 of file SubdeviceBackend.h.
|
protected |
The target device backend itself.
We are using directly a backend since we want to obtain NDRegisterAccessors which we can directly return in getRegisterAccessor_impl().
Definition at line 103 of file SubdeviceBackend.h.
|
protected |
timeout (in milliseconds), used in threeRegisters to throw a runtime_error if status register stuck at 1
Definition at line 96 of file SubdeviceBackend.h.
|
protected |
type of the subdeivce
Definition at line 93 of file SubdeviceBackend.h.