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

DeviceBackendImpl implements some basic functionality which should be available for all backends. More...

#include <DeviceBackendImpl.h>

+ Inheritance diagram for ChimeraTK::DeviceBackendImpl:
+ Collaboration diagram for ChimeraTK::DeviceBackendImpl:

Public Member Functions

bool isOpen () override
 Return whether a device has been opened or not.
 
bool isConnected () final
 Deprecated since 2022-03-03.
 
MetadataCatalogue getMetadataCatalogue () const override
 Return the device metadata catalogue.
 
virtual void setExceptionImpl () noexcept
 Function to be (optionally) implemented by backends if additional actions are needed when switching to the exception state.
 
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.
 
virtual void close ()=0
 Close the device.
 
virtual RegisterCatalogue getRegisterCatalogue () const =0
 Return the register catalogue with detailed information on all registers.
 
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.
 
virtual void activateAsyncRead () noexcept
 Activate asyncronous read for all transfer elements where AccessMode::wait_for_new_data is set.
 
BackendID getBackendID ()
 Get a unique ID for this backend instance.
 

Protected Member Functions

void setOpenedAndClearException () noexcept
 Backends should call this function at the end of a (successful) open() call.
 

Protected Attributes

std::atomic< bool > _opened {false}
 flag if backend is opened
 
async::DomainsContainer _asyncDomainsContainer
 Container for async::Domains to support wait_for_new_data.
 

Additional Inherited Members

- Public Types inherited from ChimeraTK::DeviceBackend
using BackendID = std::uintptr_t
 

Detailed Description

DeviceBackendImpl implements some basic functionality which should be available for all backends.

This is required to allow proper decorator patterns which should not have this functionality in the decorator itself.

Definition at line 25 of file DeviceBackendImpl.h.

Member Function Documentation

◆ checkActiveException()

void ChimeraTK::DeviceBackendImpl::checkActiveException ( )
inlinefinalvirtual

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.

Implements ChimeraTK::DeviceBackend.

Definition at line 95 of file DeviceBackendImpl.h.

◆ getActiveExceptionMessage()

std::string ChimeraTK::DeviceBackendImpl::getActiveExceptionMessage ( )
noexcept

Definition at line 50 of file DeviceBackendImpl.cc.

◆ getInvolvedBackendIDs()

std::set< DeviceBackend::BackendID > ChimeraTK::DeviceBackendImpl::getInvolvedBackendIDs ( )
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.

Implements ChimeraTK::DeviceBackend.

Reimplemented in ChimeraTK::LogicalNameMappingBackend, and ChimeraTK::SubdeviceBackend.

Definition at line 57 of file DeviceBackendImpl.cc.

◆ getMetadataCatalogue()

MetadataCatalogue ChimeraTK::DeviceBackendImpl::getMetadataCatalogue ( ) const
inlineoverridevirtual

Return the device metadata catalogue.

Implements ChimeraTK::DeviceBackend.

Reimplemented in ChimeraTK::SubdeviceBackend, and ChimeraTK::NumericAddressedBackend.

Definition at line 35 of file DeviceBackendImpl.h.

◆ isConnected()

bool ChimeraTK::DeviceBackendImpl::isConnected ( )
inlinefinalvirtual

Deprecated since 2022-03-03.

Do not use.

Implements ChimeraTK::DeviceBackend.

Definition at line 29 of file DeviceBackendImpl.h.

◆ isFunctional()

bool ChimeraTK::DeviceBackendImpl::isFunctional ( ) const
inlinefinalvirtualnoexcept

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.

Implements ChimeraTK::DeviceBackend.

Definition at line 86 of file DeviceBackendImpl.h.

◆ isOpen()

bool ChimeraTK::DeviceBackendImpl::isOpen ( )
inlineoverridevirtual

Return whether a device has been opened or not.

Implements ChimeraTK::DeviceBackend.

Reimplemented in ChimeraTK::XdmaBackend.

Definition at line 27 of file DeviceBackendImpl.h.

◆ setException()

void ChimeraTK::DeviceBackendImpl::setException ( const std::string &  message)
finalvirtualnoexcept

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.

Implements ChimeraTK::DeviceBackend.

Definition at line 26 of file DeviceBackendImpl.cc.

◆ setExceptionImpl()

virtual void ChimeraTK::DeviceBackendImpl::setExceptionImpl ( )
inlinevirtualnoexcept

Function to be (optionally) implemented by backends if additional actions are needed when switching to the exception state.

Reimplemented in ChimeraTK::ExceptionDummy, ChimeraTK::LogicalNameMappingBackend, ChimeraTK::SubdeviceBackend, ChimeraTK::NumericAddressedBackend, ChimeraTK::UnifiedBackendTest< VECTOR_OF_REGISTERS_T >::ExceptionReportingBackend, and AsyncTestDummy.

Definition at line 41 of file DeviceBackendImpl.h.

◆ setOpenedAndClearException()

void ChimeraTK::DeviceBackendImpl::setOpenedAndClearException ( )
protectednoexcept

Backends should call this function at the end of a (successful) open() call.

Definition at line 12 of file DeviceBackendImpl.cc.

Member Data Documentation

◆ _asyncDomainsContainer

async::DomainsContainer ChimeraTK::DeviceBackendImpl::_asyncDomainsContainer
protected

Container for async::Domains to support wait_for_new_data.

Used here to handle exception distribution.

Definition at line 67 of file DeviceBackendImpl.h.

◆ _opened

std::atomic<bool> ChimeraTK::DeviceBackendImpl::_opened {false}
protected

flag if backend is opened

Definition at line 61 of file DeviceBackendImpl.h.


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