ChimeraTK-DeviceAccess
03.18.00
|
#include <ExceptionDummyBackend.h>
Public Member Functions | |
ExceptionDummy (std::string const &mapFileName) | |
DEFINE_VIRTUAL_FUNCTION_OVERRIDE_VTABLE (DummyBackendBase, getRegisterAccessor_impl, boost::shared_ptr< NDRegisterAccessor< T >>(const RegisterPath &, size_t, size_t, AccessModeFlags)) | |
void | open () override |
Open the device. More... | |
void | closeImpl () override |
This closes the device, clears all internal registers, read-only settings and callback functions. More... | |
void | read (uint64_t bar, uint64_t address, int32_t *data, size_t sizeInBytes) override |
Read function to be implemented by backends. More... | |
void | write (uint64_t bar, uint64_t address, int32_t const *data, size_t sizeInBytes) override |
Write function to be implemented by backends. More... | |
void | triggerPush (RegisterPath path, VersionNumber v={}) |
Function to trigger sending values for push-type variables. More... | |
size_t | getWriteOrder (const RegisterPath &path) |
Function to obtain the write order number of a register. More... | |
size_t | getWriteCount (const RegisterPath &path) |
Function to obtain the number of writes of a register since the creation of the backend. More... | |
void | activateAsyncRead () noexcept override |
Activate asyncronous read for all transfer elements where AccessMode::wait_for_new_data is set. More... | |
void | setExceptionImpl () noexcept override |
Function to be (optionally) implemented by backends if additional actions are needed when switching to the exception state. More... | |
bool | asyncReadActivated () |
Function to test whether async read transfers are activated. More... | |
void | setValidity (RegisterPath path, DataValidity val) |
Use decorator to overwrite returned data validity of individual (poll-type) variables. More... | |
DataValidity | getValidity (RegisterPath path) |
Query map for overwritten data validities. More... | |
Public Member Functions inherited from ChimeraTK::DummyBackend | |
DummyBackend (const std::string &mapFileName) | |
~DummyBackend () override=default | |
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... | |
DummyRegisterRawAccessor | getRawAccessor (const std::string &module, const std::string ®ister_name) |
Get a raw accessor to the underlying memory with the convenience of using register names. More... | |
VersionNumber | triggerInterrupt (uint32_t interruptNumber) override |
Simulate the arrival of an interrupt. More... | |
void | read ([[maybe_unused]] uint8_t bar,[[maybe_unused]] uint32_t address,[[maybe_unused]] int32_t *data,[[maybe_unused]] size_t sizeInBytes) final |
You cannot override the read version with 32 bit address any more. More... | |
void | write ([[maybe_unused]] uint8_t bar,[[maybe_unused]] uint32_t address,[[maybe_unused]] int32_t const *data,[[maybe_unused]] size_t sizeInBytes) final |
You cannot override the write version with 32 bit address any more. More... | |
Public Member Functions inherited from ChimeraTK::DummyBackendBase | |
DummyBackendBase (std::string const &mapFileName) | |
~DummyBackendBase () override=default | |
size_t | minimumTransferAlignment ([[maybe_unused]] uint64_t bar) const override |
Determines the supported minimum alignment for any read/write requests. More... | |
DEFINE_VIRTUAL_FUNCTION_OVERRIDE_VTABLE (NumericAddressedBackend, getRegisterAccessor_impl, boost::shared_ptr< NDRegisterAccessor< T >>(const RegisterPath &, size_t, size_t, AccessModeFlags)) | |
void | read ([[maybe_unused]] uint8_t bar, [[maybe_unused]] uint32_t address, [[maybe_unused]] int32_t *data, [[maybe_unused]] size_t sizeInBytes) final |
You cannot override the read version with 32 bit address any more. More... | |
void | write ([[maybe_unused]] uint8_t bar, [[maybe_unused]] uint32_t address, [[maybe_unused]] int32_t const *data, [[maybe_unused]] size_t sizeInBytes) final |
You cannot override the write version with 32 bit address any more. More... | |
bool | barIndexValid ([[maybe_unused]] uint64_t bar) override |
All bars are valid in dummies. More... | |
std::map< uint64_t, size_t > | getBarSizesInBytesFromRegisterMapping () const |
Determines the size of each bar because the DummyBackends allocate memory per bar. More... | |
template<typename UserType > | |
boost::shared_ptr< NDRegisterAccessor< UserType > > | getRegisterAccessor_impl (const RegisterPath ®isterPathName, size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags) |
Specific override which allows to create "DUMMY_INTEERRUPT_X" accessors. More... | |
Public Member Functions inherited from ChimeraTK::NumericAddressedBackend | |
NumericAddressedBackend (const std::string &mapFileName="", std::unique_ptr< NumericAddressedRegisterCatalogue > registerMapPointer=std::make_unique< NumericAddressedRegisterCatalogue >()) | |
~NumericAddressedBackend () override=default | |
virtual bool | barIndexValid (uint64_t bar) |
Function to be implemented by the backends. More... | |
virtual bool | canMergeRequests () const |
Determines whether the backend supports merging of requests (read or write) More... | |
RegisterCatalogue | getRegisterCatalogue () const override |
Return the register catalogue with detailed information on all registers. More... | |
MetadataCatalogue | getMetadataCatalogue () const override |
Return the device metadata catalogue. More... | |
NumericAddressedRegisterInfo | getRegisterInfo (const RegisterPath ®isterPathName) |
getRegisterInfo returns a NumericAddressedRegisterInfo object for the given register. More... | |
void | activateAsyncRead () noexcept override |
Activate asyncronous read for all transfer elements where AccessMode::wait_for_new_data is set. More... | |
void | close () final |
Deactivates all asynchronous accessors and calls closeImpl(). More... | |
virtual std::future< void > | activateSubscription (uint32_t interruptNumber, boost::shared_ptr< async::DomainImpl< std::nullptr_t >> asyncDomain) |
Activate/create the subscription for a given interrupt (for instance by starting the according interrupt handling thread). More... | |
void | setExceptionImpl () noexcept override |
Turn off the internal variable which remembers that async is active. More... | |
template<typename BackendSpecificUserType > | |
std::pair< BackendSpecificUserType, VersionNumber > | getAsyncDomainInitialValue (size_t asyncDomainId) |
Get the initial value for a certain async::Domain. More... | |
template<typename BackendSpecificUserType > | |
std::pair< BackendSpecificUserType, VersionNumber > | getAsyncDomainInitialValue ([[maybe_unused]] size_t asyncDomainId) |
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... | |
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) |
Static Public Member Functions inherited from ChimeraTK::DummyBackend | |
static boost::shared_ptr< DeviceBackend > | createInstance (std::string address, std::map< std::string, std::string > parameters) |
Static Public Member Functions inherited from ChimeraTK::DummyBackendBase | |
static void | checkSizeIsMultipleOfWordSize (size_t sizeInBytes) |
template<typename T , typename... Args> | |
static boost::shared_ptr< DeviceBackend > | returnInstance ([[maybe_unused]] const std::string &instanceId, Args &&... arguments) |
Backward compatibility: Leftover from the time when the dummy managed it's own map to return the same instance multiple times, and still allow to use the same map file with different instances. More... | |
Public Attributes | |
std::mutex | _pushDecoratorsMutex |
Mutex to protect data structures for push decorators. More... | |
std::map< RegisterPath, std::list< boost::weak_ptr< ExceptionDummyPushDecoratorBase > > > | _pushDecorators |
Map of active ExceptionDummyPushDecorator. Protected by _pushDecoratorMutex. More... | |
std::map< RegisterPath, VersionNumber > | _pushVersions |
Map of version numbers to use in push decorators. Protected by _pushDecoratorMutex. More... | |
bool | _activateNewPushAccessors {false} |
Flag is toggled by activateAsyncRead (true), setException (false) and close (false). More... | |
std::mutex | _registerValiditiesMutex |
mutex to protect map _registerValidities More... | |
std::map< RegisterPath, DataValidity > | _registerValidities |
This map is used for setting individual (poll-type) variables to DataValidity=faulty. More... | |
std::map< std::pair< uint64_t, uint64_t >, std::atomic< size_t > > | _writeOrderMap |
Map used allow determining order of writes by tests. Map key is pair of bar and address. More... | |
std::atomic< size_t > | _writeOrderCounter {0} |
Global counter for order numbers going into _writeOrderMap. More... | |
std::map< std::pair< uint64_t, uint64_t >, std::atomic< size_t > > | _writeCounterMap |
Map used allow determining number of writes of a specific register by tests. Map key is pair of bar and address. More... | |
Public Attributes inherited from ChimeraTK::DummyBackendBase | |
std::atomic< bool > | throwExceptionOpen {false} |
std::atomic< bool > | throwExceptionRead {false} |
std::atomic< bool > | throwExceptionWrite {false} |
std::atomic< size_t > | throwExceptionCounter {0} |
Additional Inherited Members | |
Protected Member Functions inherited from ChimeraTK::DummyBackend | |
void | resizeBarContents () |
void | runWriteCallbackFunctionsForAddressRange (AddressRange addressRange) |
std::list< boost::function< void(void)> > | findCallbackFunctionsForAddressRange (AddressRange addressRange) |
void | setReadOnly (uint64_t bar, uint64_t address, size_t sizeInWords) |
void | setReadOnly (AddressRange addressRange) |
bool | isReadOnly (uint64_t bar, uint64_t address) const |
void | setWriteCallbackFunction (AddressRange addressRange, boost::function< void(void)> const &writeCallbackFunction) |
bool | isWriteRangeOverlap (AddressRange firstRange, AddressRange secondRange) |
returns true if the ranges overlap and at least one of the overlapping registers can be written More... | |
void | writeRegisterWithoutCallback (uint64_t bar, uint64_t address, int32_t data) |
Not write-protected function for internal use only. More... | |
Protected Member Functions inherited from ChimeraTK::DeviceBackendImpl | |
void | setOpenedAndClearException () noexcept |
Backends should call this function at the end of a (successful) open() call. More... | |
Static Protected Member Functions inherited from ChimeraTK::DummyBackend | |
static std::string | convertPathRelativeToDmapToAbs (std::string const &mapfileName) |
Protected Attributes inherited from ChimeraTK::DummyBackend | |
std::string | _mapFile |
name of the map file More... | |
std::map< uint64_t, std::vector< int32_t > > | _barContents |
std::set< std::pair< uint64_t, uint64_t > > | _readOnlyAddresses |
std::multimap< AddressRange, boost::function< void(void)> > | _writeCallbackFunctions |
std::mutex | mutex |
Protected Attributes inherited from ChimeraTK::NumericAddressedBackend | |
std::unique_ptr< NumericAddressedRegisterCatalogue > | _registerMapPointer |
NumericAddressedRegisterCatalogue & | _registerMap |
MetadataCatalogue | _metadataCatalogue |
metadata catalogue More... | |
std::mutex | _unalignedAccess |
mutex for protecting unaligned access More... | |
friend | NumericAddressedLowLevelTransferElement |
friend | TriggeredPollDistributor |
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... | |
Definition at line 23 of file ExceptionDummyBackend.h.
|
explicit |
|
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 25 of file ExceptionDummyBackend.cc.
bool ChimeraTK::ExceptionDummy::asyncReadActivated | ( | ) |
Function to test whether async read transfers are activated.
Definition at line 85 of file ExceptionDummyBackend.cc.
|
overridevirtual |
This closes the device, clears all internal registers, read-only settings and callback functions.
As the device could be opened with another mapping file later, these will most probably be invalid in this case. This is why the read-only settings and callback functions have to be set again when reopening the file.
Reimplemented from ChimeraTK::DummyBackend.
Definition at line 121 of file ExceptionDummyBackend.cc.
|
static |
ChimeraTK::ExceptionDummy::DEFINE_VIRTUAL_FUNCTION_OVERRIDE_VTABLE | ( | DummyBackendBase | , |
getRegisterAccessor_impl | , | ||
boost::shared_ptr< NDRegisterAccessor< T >> | const RegisterPath &, size_t, size_t, AccessModeFlags | ||
) |
|
inline |
Query map for overwritten data validities.
Definition at line 85 of file ExceptionDummyBackend.h.
size_t ChimeraTK::ExceptionDummy::getWriteCount | ( | const RegisterPath & | path | ) |
Function to obtain the number of writes of a register since the creation of the backend.
Note: This currently only works if writes are always starting at the beginning of the register (i.e. without an offset relative to the register). Also does not work for DUMMY_WRITEABLE registers.
Definition at line 77 of file ExceptionDummyBackend.cc.
size_t ChimeraTK::ExceptionDummy::getWriteOrder | ( | const RegisterPath & | path | ) |
Function to obtain the write order number of a register.
Comparing the write order number for different registers allows to determine which register has been written last (later writs have bigger write order numbers). Note: This currently only works if writes are always starting at the beginning of the register (i.e. without an offset relative to the register). Also does not work for DUMMY_WRITEABLE registers.
Definition at line 69 of file ExceptionDummyBackend.cc.
|
overridevirtual |
Open the device.
Reimplemented from ChimeraTK::DummyBackend.
Definition at line 110 of file ExceptionDummyBackend.cc.
|
overridevirtual |
Read function to be implemented by backends.
TODO: Add documentation!
Reimplemented from ChimeraTK::DummyBackend.
Reimplemented in DummyForDoubleBuffering.
Definition at line 128 of file ExceptionDummyBackend.cc.
|
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 46 of file ExceptionDummyBackend.cc.
|
inline |
Use decorator to overwrite returned data validity of individual (poll-type) variables.
Works only in the direction valid->invalid.
Definition at line 79 of file ExceptionDummyBackend.h.
void ChimeraTK::ExceptionDummy::triggerPush | ( | RegisterPath | path, |
VersionNumber | v = {} |
||
) |
Function to trigger sending values for push-type variables.
Definition at line 10 of file ExceptionDummyBackend.cc.
|
overridevirtual |
Write function to be implemented by backends.
TODO: Add documentation!
Reimplemented from ChimeraTK::DummyBackend.
Definition at line 138 of file ExceptionDummyBackend.cc.
bool ChimeraTK::ExceptionDummy::_activateNewPushAccessors {false} |
Flag is toggled by activateAsyncRead (true), setException (false) and close (false).
Protected by _pushDecoratorMutex
Definition at line 71 of file ExceptionDummyBackend.h.
std::map<RegisterPath, std::list<boost::weak_ptr<ExceptionDummyPushDecoratorBase> > > ChimeraTK::ExceptionDummy::_pushDecorators |
Map of active ExceptionDummyPushDecorator. Protected by _pushDecoratorMutex.
Definition at line 66 of file ExceptionDummyBackend.h.
std::mutex ChimeraTK::ExceptionDummy::_pushDecoratorsMutex |
Mutex to protect data structures for push decorators.
Definition at line 64 of file ExceptionDummyBackend.h.
std::map<RegisterPath, VersionNumber> ChimeraTK::ExceptionDummy::_pushVersions |
Map of version numbers to use in push decorators. Protected by _pushDecoratorMutex.
Definition at line 68 of file ExceptionDummyBackend.h.
std::map<RegisterPath, DataValidity> ChimeraTK::ExceptionDummy::_registerValidities |
This map is used for setting individual (poll-type) variables to DataValidity=faulty.
Definition at line 76 of file ExceptionDummyBackend.h.
std::mutex ChimeraTK::ExceptionDummy::_registerValiditiesMutex |
mutex to protect map _registerValidities
Definition at line 74 of file ExceptionDummyBackend.h.
std::map<std::pair<uint64_t, uint64_t>, std::atomic<size_t> > ChimeraTK::ExceptionDummy::_writeCounterMap |
Map used allow determining number of writes of a specific register by tests. Map key is pair of bar and address.
Definition at line 99 of file ExceptionDummyBackend.h.
std::atomic<size_t> ChimeraTK::ExceptionDummy::_writeOrderCounter {0} |
Global counter for order numbers going into _writeOrderMap.
Definition at line 96 of file ExceptionDummyBackend.h.
std::map<std::pair<uint64_t, uint64_t>, std::atomic<size_t> > ChimeraTK::ExceptionDummy::_writeOrderMap |
Map used allow determining order of writes by tests. Map key is pair of bar and address.
Definition at line 93 of file ExceptionDummyBackend.h.