ChimeraTK-DeviceAccess 03.20.00
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ChimeraTK::DummyBackendBase Class Referenceabstract

Base class for DummyBackends, provides common functionality. More...

#include <DummyBackendBase.h>

+ Inheritance diagram for ChimeraTK::DummyBackendBase:
+ Collaboration diagram for ChimeraTK::DummyBackendBase:

Public Member Functions

 DummyBackendBase (std::string const &mapFileName, const std::string &dataConsistencyKeyDescriptor="")
 
 ~DummyBackendBase () override=default
 
size_t minimumTransferAlignment (uint64_t bar) const override
 Determines the supported minimum alignment for any read/write requests.
 
 DEFINE_VIRTUAL_FUNCTION_OVERRIDE_VTABLE (NumericAddressedBackend, getRegisterAccessor_impl, boost::shared_ptr< NDRegisterAccessor< T > >(const RegisterPath &, size_t, size_t, AccessModeFlags))
 
virtual VersionNumber triggerInterrupt (uint32_t interruptNumber)=0
 Simulate the arrival of an interrupt.
 
void read (uint8_t bar, uint32_t address, int32_t *data, size_t sizeInBytes) final
 You cannot override the read version with 32 bit address any more.
 
void write (uint8_t bar, uint32_t address, int32_t const *data, size_t sizeInBytes) final
 You cannot override the write version with 32 bit address any more.
 
bool barIndexValid (uint64_t bar) override
 All bars are valid in dummies.
 
std::map< uint64_t, size_t > getBarSizesInBytesFromRegisterMapping () const
 Determines the size of each bar because the DummyBackends allocate memory per bar.
 
template<typename UserType >
boost::shared_ptr< NDRegisterAccessor< UserType > > getRegisterAccessor_impl (const RegisterPath &registerPathName, size_t numberOfWords, size_t wordOffsetInRegister, AccessModeFlags flags)
 Specific override which allows to create "DUMMY_INTEERRUPT_X" accessors.
 
- Public Member Functions inherited from ChimeraTK::NumericAddressedBackend
 NumericAddressedBackend (const std::string &mapFileName="", std::unique_ptr< NumericAddressedRegisterCatalogue > registerMapPointer=std::make_unique< NumericAddressedRegisterCatalogue >(), const std::string &dataConsistencyKeyDescriptor="")
 
 ~NumericAddressedBackend () override=default
 
virtual void read (uint64_t bar, uint64_t address, int32_t *data, size_t sizeInBytes)
 Read function to be implemented by backends.
 
virtual void write (uint64_t bar, uint64_t address, int32_t const *data, size_t sizeInBytes)
 Write function to be implemented by backends.
 
virtual bool canMergeRequests () const
 Determines whether the backend supports merging of requests (read or write)
 
RegisterCatalogue getRegisterCatalogue () const override
 Return the register catalogue with detailed information on all registers.
 
MetadataCatalogue getMetadataCatalogue () const override
 Return the device metadata catalogue.
 
NumericAddressedRegisterInfo getRegisterInfo (const RegisterPath &registerPathName)
 getRegisterInfo returns a NumericAddressedRegisterInfo object for the given register.
 
void activateAsyncRead () noexcept override
 Activate asyncronous read for all transfer elements where AccessMode::wait_for_new_data is set.
 
void close () final
 Deactivates all asynchronous accessors and calls closeImpl().
 
virtual void closeImpl ()
 All backends derrived from NumericAddressedBackend must implement closeImpl() instead of close.
 
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).
 
void setExceptionImpl () noexcept override
 Turn off the internal variable which remembers that async is active.
 
template<typename BackendSpecificUserType >
std::pair< BackendSpecificUserType, VersionNumbergetAsyncDomainInitialValue (size_t asyncDomainId)
 Get the initial value for a certain async::Domain.
 
- 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
 
std::set< DeviceBackend::BackendIDgetInvolvedBackendIDs () override
 Get the backend IDs of all involved backends.
 
- Public Member Functions inherited from ChimeraTK::DeviceBackend
virtual ~DeviceBackend ()=default
 Every virtual class needs a virtual desctructor.
 
virtual void open ()=0
 Open the device.
 
template<typename UserType >
boost::shared_ptr< NDRegisterAccessor< UserType > > getRegisterAccessor (const RegisterPath &registerPathName, 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))
 
virtual std::string readDeviceInfo ()=0
 Return a device information string containing hardware details like the firmware version number or the slot number used by the board.
 
BackendID getBackendID ()
 Get a unique ID for this backend instance.
 

Static Public Member Functions

static void checkSizeIsMultipleOfWordSize (size_t sizeInBytes)
 
template<typename T , typename... Args>
static boost::shared_ptr< DeviceBackendreturnInstance (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.
 

Public Attributes

std::atomic< bool > throwExceptionOpen {false}
 
std::atomic< bool > throwExceptionRead {false}
 
std::atomic< bool > throwExceptionWrite {false}
 
std::atomic< size_t > throwExceptionCounter {0}
 

Additional Inherited Members

- Public Types inherited from ChimeraTK::DeviceBackend
using BackendID = std::uintptr_t
 
- 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 inherited from ChimeraTK::NumericAddressedBackend
std::unique_ptr< NumericAddressedRegisterCatalogue_registerMapPointer
 
NumericAddressedRegisterCatalogue_registerMap
 
MetadataCatalogue _metadataCatalogue
 metadata catalogue
 
std::mutex _unalignedAccess
 mutex for protecting unaligned access
 
friend NumericAddressedLowLevelTransferElement
 
friend TriggeredPollDistributor
 
- 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.
 

Detailed Description

Base class for DummyBackends, provides common functionality.

Definition at line 31 of file DummyBackendBase.h.

Constructor & Destructor Documentation

◆ DummyBackendBase()

ChimeraTK::DummyBackendBase::DummyBackendBase ( std::string const &  mapFileName,
const std::string &  dataConsistencyKeyDescriptor = "" 
)
explicit

Definition at line 8 of file DummyBackendBase.cc.

◆ ~DummyBackendBase()

ChimeraTK::DummyBackendBase::~DummyBackendBase ( )
overridedefault

Member Function Documentation

◆ barIndexValid()

bool ChimeraTK::DummyBackendBase::barIndexValid ( uint64_t  bar)
overridevirtual

All bars are valid in dummies.

Reimplemented from ChimeraTK::NumericAddressedBackend.

Definition at line 20 of file DummyBackendBase.cc.

◆ checkSizeIsMultipleOfWordSize()

void ChimeraTK::DummyBackendBase::checkSizeIsMultipleOfWordSize ( size_t  sizeInBytes)
static

Definition at line 36 of file DummyBackendBase.cc.

◆ DEFINE_VIRTUAL_FUNCTION_OVERRIDE_VTABLE()

ChimeraTK::DummyBackendBase::DEFINE_VIRTUAL_FUNCTION_OVERRIDE_VTABLE ( NumericAddressedBackend  ,
getRegisterAccessor_impl  ,
boost::shared_ptr< NDRegisterAccessor< T > >  const RegisterPath &, size_t, size_t, AccessModeFlags 
)

◆ getBarSizesInBytesFromRegisterMapping()

std::map< uint64_t, size_t > ChimeraTK::DummyBackendBase::getBarSizesInBytesFromRegisterMapping ( ) const

Determines the size of each bar because the DummyBackends allocate memory per bar.

Definition at line 24 of file DummyBackendBase.cc.

◆ getRegisterAccessor_impl()

template<typename UserType >
boost::shared_ptr< NDRegisterAccessor< UserType > > ChimeraTK::DummyBackendBase::getRegisterAccessor_impl ( const RegisterPath registerPathName,
size_t  numberOfWords,
size_t  wordOffsetInRegister,
AccessModeFlags  flags 
)

Specific override which allows to create "DUMMY_INTEERRUPT_X" accessors.

Definition at line 43 of file DummyBackendBase.cc.

◆ minimumTransferAlignment()

size_t ChimeraTK::DummyBackendBase::minimumTransferAlignment ( uint64_t  bar) const
overridevirtual

Determines the supported minimum alignment for any read/write requests.

If the backend expects a particular alignment for read()/write() calls it should return a value bigger than 1. The address and sizeInBytes arguments of the read()/write() calls will be always an integer multiple of this number. Any unaligned transfers will be changed to meet these criteria (additional padding data will be thrown away).

The default implementation returns 1, which means no special alignment is required.

Returns
Minimum alignment in bytes

Reimplemented from ChimeraTK::NumericAddressedBackend.

Definition at line 15 of file DummyBackendBase.cc.

◆ read()

void ChimeraTK::DummyBackendBase::read ( uint8_t  bar,
uint32_t  address,
int32_t *  data,
size_t  sizeInBytes 
)
inlinefinalvirtual

You cannot override the read version with 32 bit address any more.

Please change your implementation to the 64 bit signature.

Reimplemented from ChimeraTK::NumericAddressedBackend.

Reimplemented in ChimeraTK::SharedDummyBackend.

Definition at line 55 of file DummyBackendBase.h.

◆ returnInstance()

template<typename T , typename... Args>
static boost::shared_ptr< DeviceBackend > ChimeraTK::DummyBackendBase::returnInstance ( const std::string &  instanceId,
Args &&...  arguments 
)
inlinestatic

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.

This functionality is now in the BackendFactory and has been removed here. The function is still in here because existing backend implementations use it in their createInstance() functions.

Parameters
instanceIdUsed as key for the object instance look up. "" as instanceId will return a new T instance that is not cached.
argumentsThis is a template argument list. The constructor of the created class T, gets called with the contents of the argument list as parameters.

Definition at line 102 of file DummyBackendBase.h.

◆ triggerInterrupt()

virtual VersionNumber ChimeraTK::DummyBackendBase::triggerInterrupt ( uint32_t  interruptNumber)
pure virtual

Simulate the arrival of an interrupt.

For all push-type accessors which have been created for that particular interrupt number, the data will be read out through a synchronous accessor and pushed into the data transport queues of the asynchronous accessors, so they can be received by the application.

Returns
The version number that was send with all data in this interrupt.

Implemented in ChimeraTK::DummyBackend, and ChimeraTK::SharedDummyBackend.

◆ write()

void ChimeraTK::DummyBackendBase::write ( uint8_t  bar,
uint32_t  address,
int32_t const *  data,
size_t  sizeInBytes 
)
inlinefinalvirtual

You cannot override the write version with 32 bit address any more.

Please change your implementation to the 64 bit signature.

Reimplemented from ChimeraTK::NumericAddressedBackend.

Reimplemented in ChimeraTK::SharedDummyBackend.

Definition at line 63 of file DummyBackendBase.h.

Member Data Documentation

◆ throwExceptionCounter

std::atomic<size_t> ChimeraTK::DummyBackendBase::throwExceptionCounter {0}

Definition at line 79 of file DummyBackendBase.h.

◆ throwExceptionOpen

std::atomic<bool> ChimeraTK::DummyBackendBase::throwExceptionOpen {false}

Definition at line 76 of file DummyBackendBase.h.

◆ throwExceptionRead

std::atomic<bool> ChimeraTK::DummyBackendBase::throwExceptionRead {false}

Definition at line 77 of file DummyBackendBase.h.

◆ throwExceptionWrite

std::atomic<bool> ChimeraTK::DummyBackendBase::throwExceptionWrite {false}

Definition at line 78 of file DummyBackendBase.h.


The documentation for this class was generated from the following files: