![]() |
ChimeraTK-DeviceAccess 03.27.00
|
Backend for subdevices which are passed through some register or area of another device (subsequently called target device). More...
#include <SubdeviceBackend.h>
Inheritance diagram for ChimeraTK::SubdeviceBackend:
Collaboration diagram for ChimeraTK::SubdeviceBackend: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. | |
Public Member Functions inherited from ChimeraTK::DeviceBackendImpl | |
| 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 |
| ChimeraTK::VersionNumber | getVersionOnOpen () const override |
| Get the version number which was set during the open process. | |
Public Member Functions inherited from ChimeraTK::DeviceBackend | |
| 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 , registerWindow } |
| using | BusyRegisterKey = std::pair< DeviceBackend *, RegisterPath > |
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 > > | getAreaRegisterAccessor (const RegisterPath ®isterPathName, size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags) |
| getRegisterAccessor implementation for area types | |
| template<typename UserType > | |
| boost::shared_ptr< NDRegisterAccessor< UserType > > | getSynchronisedRegisterAccessor (const RegisterPath ®isterPathName, size_t numberOfWords, size_t wordOffsetInRegister, const AccessModeFlags &flags) |
| getRegisterAccessor implementation for threeRegisters types | |
| template<typename UserType > | |
| boost::shared_ptr< NDRegisterAccessor< UserType > > | getRegisterWindowAccessor (const RegisterPath ®isterPathName, size_t numberOfWords, size_t wordOffsetInRegister, const AccessModeFlags &flags) |
| 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 > | accessorCreationHelper (const NumericAddressedRegisterInfo &info, size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags) |
| template<> | |
| boost::shared_ptr< NDRegisterAccessor< int32_t > > | getAreaRegisterAccessor (const RegisterPath ®isterPathName, size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags) |
Protected Member Functions inherited from ChimeraTK::DeviceBackendImpl | |
| void | setOpenedAndClearException () noexcept |
| Backends should call this function at the end of a (successful) open() call. | |
Protected Attributes | |
| std::shared_ptr< std::mutex > | _mutex |
| Type | _type |
| type of the subdevice | |
| 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 == registerWindow, threeRegisters or twoRegisters: the names of the basic target registers | |
| std::string | _targetWriteData |
| std::string | _targetControl |
| std::map< std::string, std::string > | _parameters |
| currently only used for type == registerWindow: the whole set of parameters | |
| size_t | _sleepTime {100} |
| for type == registerWindow, threeRegisters or twoRegisters: sleep time of polling loop resp. | |
| size_t | _addressToDataDelay {0} |
| for type == registerWindow, threeRegisters or twoRegisters: sleep time between address and data write | |
| size_t | _chipIndex {0} |
| for type == registerWindow: chip index | |
| NumericAddressedRegisterCatalogue | _registerMap |
| map from register names to addresses | |
| MetadataCatalogue | _metadataCatalogue |
Protected Attributes inherited from ChimeraTK::DeviceBackendImpl | |
| std::atomic< bool > | _opened {false} |
| flag if backend is opened | |
| async::DomainsContainer | _asyncDomainsContainer |
| Container for async::Domains to support wait_for_new_data. | |
Static Protected Attributes | |
| static std::map< BusyRegisterKey, std::shared_ptr< std::mutex > > | _mutexes |
| Mutex to protext concurrent access to the target registers. | |
| static std::mutex | _mutexMapMutex |
Friends | |
| class | SubdeviceRegisterAccessor |
| template<typename RegisterRawType , typename WriteDataType > | |
| class | SubdeviceRegisterWindowAccessor |
Additional Inherited Members | |
Public Types inherited from ChimeraTK::DeviceBackend | |
| 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>)
(subdevice?type=regWindow&device=<targetDevice>&address=<addressRegister>&writeData=<writeDataRegister>&busy=<busyRegister>&readRequest=<readRequestRegister>&readData=<readDataRegister>&chipSelectRegister=<chipSelectRegister>&chipIndex=<chipIndex>&map=<mapFile>)The "chipIndex" parameter is optional and defaults to 0. For compatibility with the 3reg-mode, 'data' can be used instead of 'readData', and 'status' instead of 'busy'
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 70 of file SubdeviceBackend.h.
|
protected |
Definition at line 106 of file SubdeviceBackend.h.
|
strongprotected |
| Enumerator | |
|---|---|
| area | |
| threeRegisters | |
| twoRegisters | |
| areaHandshake | |
| registerWindow | |
Definition at line 96 of file SubdeviceBackend.h.
|
explicit |
Definition at line 57 of file SubdeviceBackend.cc.
|
protected |
Definition at line 390 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 584 of file SubdeviceBackend.cc.
|
overridevirtual |
Close the device.
Implements ChimeraTK::DeviceBackend.
Definition at line 256 of file SubdeviceBackend.cc.
|
static |
Definition at line 28 of file SubdeviceBackend.cc.
|
protected |
|
protected |
getRegisterAccessor implementation for area types
Definition at line 362 of file SubdeviceBackend.cc.
|
protected |
Definition at line 458 of file SubdeviceBackend.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 590 of file SubdeviceBackend.cc.
|
overridevirtual |
Return the device metadata catalogue.
Reimplemented from ChimeraTK::DeviceBackendImpl.
Definition at line 270 of file SubdeviceBackend.cc.
|
protected |
Definition at line 277 of file SubdeviceBackend.cc.
|
overridevirtual |
Return the register catalogue with detailed information on all registers.
Implements ChimeraTK::DeviceBackend.
Definition at line 264 of file SubdeviceBackend.cc.
|
protected |
Definition at line 458 of file SubdeviceBackend.cc.
|
protected |
getRegisterAccessor implementation for threeRegisters types
Definition at line 434 of file SubdeviceBackend.cc.
|
inlineprotected |
Definition at line 185 of file SubdeviceBackend.h.
|
inlineprotected |
Definition at line 186 of file SubdeviceBackend.h.
|
protected |
obtain the target backend if not yet done
Definition at line 225 of file SubdeviceBackend.cc.
|
overridevirtual |
Open the device.
Implements ChimeraTK::DeviceBackend.
Definition at line 247 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 78 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 577 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 301 of file SubdeviceBackend.cc.
|
friend |
Definition at line 92 of file SubdeviceBackend.h.
|
friend |
Definition at line 94 of file SubdeviceBackend.h.
|
protected |
for type == registerWindow, threeRegisters or twoRegisters: sleep time between address and data write
Definition at line 143 of file SubdeviceBackend.h.
|
protected |
for type == registerWindow: chip index
Definition at line 146 of file SubdeviceBackend.h.
|
protected |
Definition at line 150 of file SubdeviceBackend.h.
|
protected |
Definition at line 114 of file SubdeviceBackend.h.
|
staticprotected |
Mutex to protext concurrent access to the target registers.
The mutex must be shared with all backends that use the same busy register. There might be multiple instances of the SubdeviceBackend with different ChipIDs.
Definition at line 111 of file SubdeviceBackend.h.
|
staticprotected |
Definition at line 112 of file SubdeviceBackend.h.
|
protected |
currently only used for type == registerWindow: the whole set of parameters
Definition at line 136 of file SubdeviceBackend.h.
|
protected |
map from register names to addresses
Definition at line 149 of file SubdeviceBackend.h.
|
protected |
for type == registerWindow, threeRegisters or twoRegisters: sleep time of polling loop resp.
between operations, in usecs.
Definition at line 140 of file SubdeviceBackend.h.
|
protected |
for type == registerWindow, threeRegisters or twoRegisters: the names of the basic target registers
Definition at line 133 of file SubdeviceBackend.h.
|
protected |
the target device name
Definition at line 123 of file SubdeviceBackend.h.
|
protected |
for type == area: the name of the target register
Definition at line 130 of file SubdeviceBackend.h.
|
protected |
Definition at line 133 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 127 of file SubdeviceBackend.h.
|
protected |
Definition at line 133 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 120 of file SubdeviceBackend.h.
|
protected |
type of the subdevice
Definition at line 117 of file SubdeviceBackend.h.