ChimeraTK-DeviceAccess  03.18.00
ChimeraTK::DeviceBackend Class Referenceabstract

The base class for backends providing IO functionality for the Device class. More...

#include <DeviceBackend.h>

+ Inheritance diagram for ChimeraTK::DeviceBackend:
+ Collaboration diagram for ChimeraTK::DeviceBackend:

Public Member Functions

virtual ~DeviceBackend ()=default
 Every virtual class needs a virtual desctructor. More...
 
virtual void open ()=0
 Open the device. More...
 
virtual void close ()=0
 Close the device. More...
 
virtual bool isOpen ()=0
 Return whether a device has been opened or not. More...
 
virtual bool isConnected ()=0
 Deprecated since 2022-03-03. More...
 
virtual bool isFunctional () const noexcept=0
 Return whether a device is working as intended, usually this means it is opened and does not have any errors. More...
 
virtual RegisterCatalogue getRegisterCatalogue () const =0
 Return the register catalogue with detailed information on all registers. More...
 
virtual MetadataCatalogue getMetadataCatalogue () const =0
 Return the device metadata catalogue. More...
 
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. More...
 
 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. More...
 
virtual void setException (const std::string &message) noexcept=0
 Set the backend into an exception state. More...
 
virtual void activateAsyncRead () noexcept
 Activate asyncronous read for all transfer elements where AccessMode::wait_for_new_data is set. More...
 
virtual void checkActiveException ()=0
 Function to be called by backends when needing to check for an active exception. More...
 

Detailed Description

The base class for backends providing IO functionality for the Device class.

Note that most backends should actually be based on the DeviceBackendImpl class (unless it is a decorator backend). The actual IO is always performed through register accessors, which is obtained through the getBufferingRegisterAccessor() member function.

Definition at line 28 of file DeviceBackend.h.

Constructor & Destructor Documentation

◆ ~DeviceBackend()

virtual ChimeraTK::DeviceBackend::~DeviceBackend ( )
virtualdefault

Every virtual class needs a virtual desctructor.

Member Function Documentation

◆ activateAsyncRead()

virtual void ChimeraTK::DeviceBackend::activateAsyncRead ( )
inlinevirtualnoexcept

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 in ChimeraTK::SubdeviceBackend, ChimeraTK::NumericAddressedBackend, ChimeraTK::ExceptionDummy, and ChimeraTK::LogicalNameMappingBackend.

Definition at line 97 of file DeviceBackend.h.

◆ checkActiveException()

virtual void ChimeraTK::DeviceBackend::checkActiveException ( )
pure virtual

Function to be called by backends when needing to check for an active exception.

If an active exception is found, the appropriate ChimeraTK::runtime_error is thrown by this function.

Implemented in ChimeraTK::DeviceBackendImpl.

◆ close()

◆ DEFINE_VIRTUAL_FUNCTION_TEMPLATE_VTABLE()

ChimeraTK::DeviceBackend::DEFINE_VIRTUAL_FUNCTION_TEMPLATE_VTABLE ( getRegisterAccessor_impl  ,
boost::shared_ptr< NDRegisterAccessor< T >>  const RegisterPath &, size_t, size_t, AccessModeFlags 
)

◆ getMetadataCatalogue()

virtual MetadataCatalogue ChimeraTK::DeviceBackend::getMetadataCatalogue ( ) const
pure virtual

Return the device metadata catalogue.

Implemented in ChimeraTK::NumericAddressedBackend, ChimeraTK::SubdeviceBackend, and ChimeraTK::DeviceBackendImpl.

+ Here is the caller graph for this function:

◆ getRegisterAccessor()

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

Get a NDRegisterAccessor object from the register name.

Definition at line 109 of file DeviceBackend.h.

+ Here is the caller graph for this function:

◆ getRegisterCatalogue()

virtual RegisterCatalogue ChimeraTK::DeviceBackend::getRegisterCatalogue ( ) const
pure virtual

◆ isConnected()

virtual bool ChimeraTK::DeviceBackend::isConnected ( )
pure virtual

Deprecated since 2022-03-03.

Do not use.

Implemented in ChimeraTK::DeviceBackendImpl.

◆ isFunctional()

virtual bool ChimeraTK::DeviceBackend::isFunctional ( ) const
pure virtualnoexcept

Return whether a device is working as intended, usually this means it is opened and does not have any errors.

The default implementation in DeviceBackendImpl reports (_opened && !_hasErrors). Backends can overload it to implement a more sophisticated error reporting. The implementation might involve a communication attempt with the device.

Notice: isFunctional() shall only return false if there are known errors (or the device is closed). If the working state is unknown, the response should be true. Client code will then try to read/write and might get an exception, while isFunctional()==false means you surely will get an exception.

Implemented in ChimeraTK::DeviceBackendImpl.

◆ isOpen()

virtual bool ChimeraTK::DeviceBackend::isOpen ( )
pure virtual

Return whether a device has been opened or not.

Implemented in ChimeraTK::XdmaBackend, and ChimeraTK::DeviceBackendImpl.

◆ open()

◆ readDeviceInfo()

virtual std::string ChimeraTK::DeviceBackend::readDeviceInfo ( )
pure virtual

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.

Implemented in ChimeraTK::UnifiedBackendTest< VECTOR_OF_REGISTERS_T >::ExceptionReportingBackend, ChimeraTK::PcieBackend, ChimeraTK::RebotBackend, ChimeraTK::DummyBackend, ChimeraTK::SubdeviceBackend, ChimeraTK::SharedDummyBackend, ChimeraTK::XdmaBackend, ChimeraTK::UioBackend, AsyncTestDummy, and ChimeraTK::LogicalNameMappingBackend.

◆ setException()

virtual void ChimeraTK::DeviceBackend::setException ( const std::string &  message)
pure virtualnoexcept

Set the backend into an exception state.

All backends must remember this, turn off asyncronous reads and all accessors will throw a ChimeraTK::runtime_error on read and write operations with the provided message string, until open() has been called successfully.

Implemented in ChimeraTK::DeviceBackendImpl.

+ Here is the caller graph for this function:

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