![]() |
ChimeraTK-DeviceAccess 03.20.00
|
Special accessor used to test the behaviour of the TransferElement base class and the TransferGroup. More...
#include <TransferElementTestAccessor.h>
Public Member Functions | |
TransferElementTestAccessor (AccessModeFlags flags) | |
~TransferElementTestAccessor () override | |
void | doPreRead (TransferType type) override |
Backend specific implementation of preRead(). | |
void | doPreWrite (TransferType type, VersionNumber versionNumber) override |
Backend specific implementation of preWrite(). | |
void | doReadTransferSynchronously () override |
Implementation version of readTransfer() for synchronous reads. | |
bool | doWriteTransfer (ChimeraTK::VersionNumber versionNumber) override |
Implementation version of writeTransfer(). | |
bool | doWriteTransferDestructively (ChimeraTK::VersionNumber versionNumber) override |
Implementation version of writeTransferDestructively(). | |
void | doPostRead (TransferType type, bool updateDataBuffer) override |
Backend specific implementation of postRead(). | |
void | doPostWrite (TransferType type, VersionNumber versionNumber) override |
Backend specific implementation of postWrite(). | |
bool | mayReplaceOther (const boost::shared_ptr< TransferElement const > &other) const override |
Check whether the TransferElement can be used in places where the TransferElement "other" is currently used, e.g. | |
std::vector< boost::shared_ptr< TransferElement > > | getHardwareAccessingElements () override |
Obtain the underlying TransferElements with actual hardware access. | |
std::list< boost::shared_ptr< TransferElement > > | getInternalElements () override |
Obtain the full list of TransferElements internally used by this TransferElement. | |
void | replaceTransferElement (boost::shared_ptr< TransferElement > newElement) override |
Search for all underlying TransferElements which are considered identical (see sameRegister()) with the given TransferElement. | |
bool | isReadOnly () const override |
Check if transfer element is read only, i.e. | |
bool | isReadable () const override |
Check if transfer element is readable. | |
bool | isWriteable () const override |
Check if transfer element is writeable. | |
void | interrupt () override |
Return from a blocking read immediately and throw boost::thread_interrupted. | |
void | resetCounters () |
void | putRuntimeErrorOnQueue () |
void | putDiscardValueOnQueue () |
bool | push () |
![]() | |
NDRegisterAccessor (std::string const &name, AccessModeFlags accessModeFlags, std::string const &unit=std::string(TransferElement::unitNotSet), std::string const &description=std::string()) | |
Creates an NDRegisterAccessor with the specified name (passed on to the transfer element). | |
UserType & | accessData (size_t sample) |
Get or set register accessor's buffer content (1D version). | |
const UserType & | accessData (size_t sample) const |
UserType & | accessData (unsigned int channel, unsigned int sample) |
Get or set register accessor's buffer content (2D version). | |
const UserType & | accessData (unsigned int channel, unsigned int sample) const |
std::vector< UserType > & | accessChannel (unsigned int channel) |
Get or set register accessor's channel vector. | |
const std::vector< UserType > & | accessChannel (unsigned int channel) const |
std::vector< std::vector< UserType > > & | accessChannels () |
Get or set register accessor's 2D channel vector. | |
const std::vector< std::vector< UserType > > & | accessChannels () const |
unsigned int | getNumberOfSamples () const |
Return number of elements per channel. | |
unsigned int | getNumberOfChannels () const |
Return number of channels. | |
const std::type_info & | getValueType () const override |
Returns the std::type_info for the value type of this transfer element. | |
template<typename COOKED_TYPE > | |
COOKED_TYPE | getAsCooked (unsigned int channel, unsigned int sample) const |
DEFINE_VIRTUAL_FUNCTION_TEMPLATE_VTABLE (getAsCooked_impl, T const(unsigned int, unsigned int)) | |
template<typename COOKED_TYPE > | |
COOKED_TYPE | getAsCooked_impl (unsigned int channel, unsigned int sample) const |
template<typename COOKED_TYPE > | |
void | setAsCooked (unsigned int channel, unsigned int sample, COOKED_TYPE value) |
DEFINE_VIRTUAL_FUNCTION_TEMPLATE_VTABLE (setAsCooked_impl, void(unsigned int, unsigned int, T)) | |
template<typename COOKED_TYPE > | |
void | setAsCooked_impl (unsigned int channel, unsigned int sample, COOKED_TYPE value) |
boost::shared_ptr< TransferElement > | makeCopyRegisterDecorator () override |
Create a CopyRegisterDecorator of the right type decorating this TransferElement. | |
virtual boost::shared_ptr< NDRegisterAccessor< UserType > > | decorateDeepInside (std::function< boost::shared_ptr< NDRegisterAccessor< UserType > >(const boost::shared_ptr< NDRegisterAccessor< UserType > > &)> factory) |
Decorate the innermost TransferElement of the stack of decorators or decorator-like accessors. | |
![]() | |
TransferElement (std::string name, AccessModeFlags accessModeFlags, std::string unit=std::string(unitNotSet), std::string description=std::string()) | |
Creates a transfer element with the specified name. | |
TransferElement (const TransferElement &other)=delete | |
Copying and moving is not allowed. | |
TransferElement (TransferElement &&other)=delete | |
TransferElement & | operator= (const TransferElement &other)=delete |
TransferElement & | operator= (TransferElement &&other)=delete |
virtual | ~TransferElement ()=default |
Abstract base classes need a virtual destructor. | |
const std::string & | getName () const |
Returns the name that identifies the process variable. | |
const std::string & | getUnit () const |
Returns the engineering unit. | |
const std::string & | getDescription () const |
Returns the description of this variable/register. | |
AccessModeFlags | getAccessModeFlags () const |
Return the AccessModeFlags for this TransferElement. | |
void | setDataValidity (DataValidity validity=DataValidity::ok) |
Set the current DataValidity for this TransferElement. | |
DataValidity | dataValidity () const |
Return current validity of the data. | |
void | read () |
Read the data from the device. | |
bool | readNonBlocking () |
Read the next value, if available in the input buffer. | |
bool | readLatest () |
Read the latest value, discarding any other update since the last read if present. | |
bool | write (ChimeraTK::VersionNumber versionNumber={}) |
Write the data to device. | |
bool | writeDestructively (ChimeraTK::VersionNumber versionNumber={}) |
Just like write(), but allows the implementation to destroy the content of the user buffer in the process. | |
ChimeraTK::VersionNumber | getVersionNumber () const |
Returns the version number that is associated with the last transfer (i.e. | |
void | setActiveException (std::exception_ptr &setThisException) |
Set an active exception. | |
virtual void | setExceptionBackend (boost::shared_ptr< DeviceBackend > exceptionBackend) |
Set the backend to which the exception has to be reported. | |
boost::shared_ptr< DeviceBackend > | getExceptionBackend () |
Return the exception backend. | |
cppext::future_queue< void > | getReadQueue () |
Function to get a copy of the read queue. | |
void | readTransfer () |
Read the data from the device but do not fill it into the user buffer of this TransferElement. | |
bool | readTransferNonBlocking () |
Read the data from the device but do not fill it into the user buffer of this TransferElement. | |
void | preRead (TransferType type) |
Perform any pre-read tasks if necessary. | |
void | postRead (TransferType type, bool updateDataBuffer) |
Transfer the data from the device receive buffer into the user buffer, while converting the data into the user data format if needed. | |
void | preWrite (TransferType type, ChimeraTK::VersionNumber versionNumber) |
Transfer the data from the user buffer into the device send buffer, while converting the data from then user data format if needed. | |
void | postWrite (TransferType type, VersionNumber versionNumber) |
Perform any post-write clean-ups if necessary. | |
bool | writeTransfer (ChimeraTK::VersionNumber versionNumber) |
Write the data to the device. | |
bool | writeTransferDestructively (ChimeraTK::VersionNumber versionNumber) |
Write the data to the device. | |
virtual boost::shared_ptr< TransferElement > | getHighLevelImplElement () |
Obtain the highest level implementation TransferElement. | |
virtual void | setPersistentDataStorage (boost::shared_ptr< ChimeraTK::PersistentDataStorage >) |
Associate a persistent data storage object to be updated on each write operation of this ProcessArray. | |
TransferElementID | getId () const |
Obtain unique ID for this TransferElement, see TransferElementID for details. | |
template<typename QUEUE_TYPE > | |
void | interrupt_impl (QUEUE_TYPE &dataTransportQueue) |
Implementation of interrupt() | |
bool | isReadTransactionInProgress () const |
Check whether a read transaction is in progress, i.e. | |
bool | isWriteTransactionInProgress () const |
Check whether a write transaction is in progress, i.e. | |
ReadAnyGroup * | getReadAnyGroup () const |
Obtain the ReadAnyGroup this TransferElement is part of, or nullptr if not in a ReadAnyGroup. | |
virtual void | setInReadAnyGroup (ReadAnyGroup *rag) |
Set the ReadAnyGroup of which this TransferElement is part of. | |
Static Public Attributes | |
static std::atomic< size_t > | _currentIndex |
![]() | |
static constexpr char | unitNotSet [] = "n./a." |
Constant string to be used as a unit when the unit is not provided or known. | |
Additional Inherited Members | |
![]() | |
using | SharedPtr = boost::shared_ptr< TransferElement > |
A typedef for more compact syntax. | |
![]() | |
DEFINE_VIRTUAL_FUNCTION_TEMPLATE_VTABLE_FILLER (NDRegisterAccessor< UserType >, getAsCooked_impl, 2) | |
DEFINE_VIRTUAL_FUNCTION_TEMPLATE_VTABLE_FILLER (NDRegisterAccessor< UserType >, setAsCooked_impl, 3) | |
![]() | |
void | makeUniqueId () |
Allow generating a unique ID from derived classes. | |
![]() | |
std::vector< std::vector< UserType > > | buffer_2D |
Buffer of converted data elements. | |
![]() | |
boost::shared_ptr< DeviceBackend > | _exceptionBackend |
The backend to which the runtime_errors are reported via DeviceBackend::setException(). | |
std::string | _name |
Identifier uniquely identifying the TransferElement. | |
std::string | _unit |
Engineering unit. | |
std::string | _description |
Description of this variable/register. | |
TransferElementID | _id |
The ID of this TransferElement. | |
bool | _isInTransferGroup {false} |
Flag whether this TransferElement has been added to a TransferGroup or not. | |
ReadAnyGroup * | _inReadAnyGroup {nullptr} |
ReadAnyGroup this TransferElement has been added to, nullptr if not in a ReadAnyGroup. | |
AccessModeFlags | _accessModeFlags |
The access mode flags for this transfer element. | |
cppext::future_queue< void > | _readQueue |
The queue for asynchronous read transfers. | |
VersionNumber | _versionNumber {nullptr} |
The version number of the last successful transfer. | |
DataValidity | _dataValidity {DataValidity::ok} |
The validity of the data in the application buffer. | |
std::exception_ptr | _activeException {nullptr} |
Exception to be rethrown in postXXX() in case hasSeenException == true Can be set via setActiveException(). | |
Special accessor used to test the behaviour of the TransferElement base class and the TransferGroup.
Definition at line 11 of file TransferElementTestAccessor.h.
|
inline |
Definition at line 13 of file TransferElementTestAccessor.h.
|
inlineoverride |
Definition at line 20 of file TransferElementTestAccessor.h.
|
inlineoverridevirtual |
Backend specific implementation of postRead().
postRead() will call this function, but it will make sure that it gets called only once per transfer.
No actual communication may be done. Hence, no runtime_error exception may be thrown by this function. Also it must be acceptable to call this function while the device is closed or not functional (see isFunctional()) and no exception is thrown.
Notes for backend implementations:
Reimplemented from ChimeraTK::TransferElement.
Definition at line 97 of file TransferElementTestAccessor.h.
|
inlineoverridevirtual |
Backend specific implementation of postWrite().
postWrite() will call this function, but it will make sure that it gets called only once per transfer.
No actual communication may be done. Hence, no runtime_error exception may be thrown by this function. Also it must be acceptable to call this function while the device is closed or not functional (see isFunctional()) and no exception is thrown.
Reimplemented from ChimeraTK::TransferElement.
Definition at line 123 of file TransferElementTestAccessor.h.
|
inlineoverridevirtual |
Backend specific implementation of preRead().
preRead() will call this function, but it will make sure that it gets called only once per transfer.
No actual communication may be done. Hence, no runtime_error exception may be thrown by this function. Also it must be acceptable to call this function while the device is closed or not functional (see isFunctional()) and no exception is thrown.
Reimplemented from ChimeraTK::TransferElement.
Definition at line 22 of file TransferElementTestAccessor.h.
|
inlineoverridevirtual |
Backend specific implementation of preWrite().
preWrite() will call this function, but it will make sure that it gets called only once per transfer.
No actual communication may be done. Hence, no runtime_error exception may be thrown by this function. Also it must be acceptable to call this function while the device is closed or not functional (see isFunctional()) and no exception is thrown.
Reimplemented from ChimeraTK::TransferElement.
Definition at line 37 of file TransferElementTestAccessor.h.
|
inlineoverridevirtual |
Implementation version of readTransfer() for synchronous reads.
This function must be implemented by the backend. For the functional description read the documentation of readTransfer().
Implementation notes:
Implements ChimeraTK::TransferElement.
Definition at line 54 of file TransferElementTestAccessor.h.
|
inlineoverridevirtual |
Implementation version of writeTransfer().
This function must be implemented by the backend. For the functional description read the documentation of writeTransfer().
Implementation notes:
Implements ChimeraTK::TransferElement.
Definition at line 67 of file TransferElementTestAccessor.h.
|
inlineoverridevirtual |
Implementation version of writeTransferDestructively().
This function must be implemented by the backend. For the functional description read the documentation of writeTransfer().
Implementation notes:
Reimplemented from ChimeraTK::TransferElement.
Definition at line 82 of file TransferElementTestAccessor.h.
|
inlineoverridevirtual |
Obtain the underlying TransferElements with actual hardware access.
If this transfer element is directly reading from / writing to the hardware, it will return a list just containing a shared pointer of itself.
Note: Avoid using this in application code, since it will break the abstraction!
Implements ChimeraTK::TransferElement.
Definition at line 135 of file TransferElementTestAccessor.h.
|
inlineoverridevirtual |
Obtain the full list of TransferElements internally used by this TransferElement.
The function is recursive, i.e. elements used by the elements returned by this function are also added to the list. It is guaranteed that the directly used elements are first in the list and the result from recursion is appended to the list.
Example: A decorator would return a list with its target TransferElement followed by the result of getInternalElements() called on its target TransferElement.
If this TransferElement is not using any other element, it should return an empty vector. Thus those elements which return a list just containing themselves in getHardwareAccessingElements() will return an empty list here in getInternalElements().
Note: Avoid using this in application code, since it will break the abstraction!
Implements ChimeraTK::TransferElement.
Definition at line 142 of file TransferElementTestAccessor.h.
|
inlineoverridevirtual |
Return from a blocking read immediately and throw boost::thread_interrupted.
This function can be used to shutdown a thread waiting on data to arrive, which might never happen because the sending part of the application is already shut down, or there is no new data at the moment.
Note that this function does not stop the sending thread. It just places a boost::thread_interrupted exception on the _TransferElement::_readQueue, so a waiting read() has something to receive and returns. If regular data is put into the queue just before the exception, this is received first. Hence it is not guaranteed that the read call that is supposed to be interrupted will actually throw an exception. But it is guaranteed that it returns immediately. Also it is guaranteed that eventually the boost::thread_interrupted exception will be received, unless more values are written to the queue and the exception is overwritten.
See Technical specification: TransferElement B.8.6
Implementation notice: This default implementation is always doing nothing. Each TransferElement implementation that supports AccessMode::wait_for_new_data (or may need to interrupt synchronous read calls) has to override it like this (unless the TransferElement has special requirements): void interrupt() override { this->interrupt_impl(this->_myDataTransportQueue); }
Reimplemented from ChimeraTK::TransferElement.
Definition at line 166 of file TransferElementTestAccessor.h.
|
inlineoverridevirtual |
Check if transfer element is readable.
It throws an exception if you try to read and isReadable() is not true.
Implements ChimeraTK::TransferElement.
Definition at line 156 of file TransferElementTestAccessor.h.
|
inlineoverridevirtual |
Check if transfer element is read only, i.e.
it is readable but not writeable.
Implements ChimeraTK::TransferElement.
Definition at line 151 of file TransferElementTestAccessor.h.
|
inlineoverridevirtual |
Check if transfer element is writeable.
It throws an exception if you try to write and isWriteable() is not true.
Implements ChimeraTK::TransferElement.
Definition at line 161 of file TransferElementTestAccessor.h.
|
inlineoverridevirtual |
Check whether the TransferElement can be used in places where the TransferElement "other" is currently used, e.g.
to merge the two transfers. This function must be used in replaceTransferElement() by implementations which use other TransferElements, to determine if a used TransferElement shall be replaced with the TransferElement "other".
The purpose of this function is not to determine if at any point in the hierarchy an replacement could be done. This function only works on a single level. It is not used by the TransferGroup to determine replaceTransferElement() whether shall be used (it is always called). Instead this function can be used by decorators etc. inside their implementation of replaceTransferElement() to determine if they might swap their implementation(s).
Note for decorators and similar implementations: This function must not be decorated. It should only return true if this should actually be replaced with other in the call to replaceTransferElement() one level up in the hierarchy. If the replacement should be done further down in the hierarchy, simply return false. It should only return if other is fully identical to this (i.e. behaves identical in all situations but might be another instance).
Reimplemented from ChimeraTK::TransferElement.
Definition at line 132 of file TransferElementTestAccessor.h.
|
inline |
Definition at line 262 of file TransferElementTestAccessor.h.
|
inline |
Definition at line 252 of file TransferElementTestAccessor.h.
|
inline |
Definition at line 243 of file TransferElementTestAccessor.h.
|
inlineoverridevirtual |
Search for all underlying TransferElements which are considered identical (see sameRegister()) with the given TransferElement.
These TransferElements are then replaced with the new element. If no underlying element matches the new element, this function has no effect.
Reimplemented from ChimeraTK::TransferElement.
Definition at line 147 of file TransferElementTestAccessor.h.
|
inline |
Definition at line 212 of file TransferElementTestAccessor.h.
AccessModeFlags ChimeraTK::TransferElement::_accessModeFlags |
The access mode flags for this transfer element.
Definition at line 838 of file TransferElement.h.
std::exception_ptr ChimeraTK::TransferElement::_activeException |
Exception to be rethrown in postXXX() in case hasSeenException == true Can be set via setActiveException().
Definition at line 871 of file TransferElement.h.
|
static |
Definition at line 182 of file TransferElementTestAccessor.h.
std::vector<boost::shared_ptr<TransferElement> > ChimeraTK::TransferElementTestAccessor< UserType >::_hardwareAccessingElements |
Definition at line 207 of file TransferElementTestAccessor.h.
std::vector<boost::shared_ptr<TransferElementTestAccessor<UserType> > > ChimeraTK::TransferElementTestAccessor< UserType >::_internalElements |
Definition at line 205 of file TransferElementTestAccessor.h.
std::set<TransferElementID> ChimeraTK::TransferElementTestAccessor< UserType >::_listMayReplaceElements |
Definition at line 209 of file TransferElementTestAccessor.h.
std::list<TransferElementID> ChimeraTK::TransferElementTestAccessor< UserType >::_listReplacementElements |
Definition at line 204 of file TransferElementTestAccessor.h.
size_t ChimeraTK::TransferElementTestAccessor< UserType >::_postIndex {999999} |
Definition at line 181 of file TransferElementTestAccessor.h.
size_t ChimeraTK::TransferElementTestAccessor< UserType >::_postRead_counter {0} |
Definition at line 177 of file TransferElementTestAccessor.h.
size_t ChimeraTK::TransferElementTestAccessor< UserType >::_postWrite_counter {0} |
Definition at line 178 of file TransferElementTestAccessor.h.
VersionNumber ChimeraTK::TransferElementTestAccessor< UserType >::_postWrite_version {nullptr} |
Definition at line 189 of file TransferElementTestAccessor.h.
size_t ChimeraTK::TransferElementTestAccessor< UserType >::_preIndex {999999} |
Definition at line 179 of file TransferElementTestAccessor.h.
size_t ChimeraTK::TransferElementTestAccessor< UserType >::_preRead_counter {0} |
Definition at line 172 of file TransferElementTestAccessor.h.
bool ChimeraTK::TransferElementTestAccessor< UserType >::_previousDataLost {false} |
Definition at line 194 of file TransferElementTestAccessor.h.
size_t ChimeraTK::TransferElementTestAccessor< UserType >::_preWrite_counter {0} |
Definition at line 173 of file TransferElementTestAccessor.h.
VersionNumber ChimeraTK::TransferElementTestAccessor< UserType >::_preWrite_version {nullptr} |
Definition at line 187 of file TransferElementTestAccessor.h.
bool ChimeraTK::TransferElementTestAccessor< UserType >::_readable {true} |
Definition at line 169 of file TransferElementTestAccessor.h.
cppext::future_queue<void> ChimeraTK::TransferElement::_readQueue |
The queue for asynchronous read transfers.
This is the void queue which is a continuation of the actual data transport queue, which is implementation dependent. With _readQueue the exception propagation and waiting for new data is implemented in TransferElement.
Definition at line 859 of file TransferElement.h.
size_t ChimeraTK::TransferElementTestAccessor< UserType >::_readTransfer_counter {0} |
Definition at line 174 of file TransferElementTestAccessor.h.
std::exception_ptr ChimeraTK::TransferElementTestAccessor< UserType >::_seenActiveException {nullptr} |
Definition at line 190 of file TransferElementTestAccessor.h.
UserType ChimeraTK::TransferElementTestAccessor< UserType >::_setPostReadData {UserType()} |
Definition at line 201 of file TransferElementTestAccessor.h.
VersionNumber ChimeraTK::TransferElementTestAccessor< UserType >::_setPostReadVersion {nullptr} |
Definition at line 200 of file TransferElementTestAccessor.h.
bool ChimeraTK::TransferElementTestAccessor< UserType >::_throwLogicErr {false} |
Definition at line 195 of file TransferElementTestAccessor.h.
std::exception_ptr ChimeraTK::TransferElementTestAccessor< UserType >::_thrownException {nullptr} |
Definition at line 191 of file TransferElementTestAccessor.h.
bool ChimeraTK::TransferElementTestAccessor< UserType >::_throwNumericCast {false} |
Definition at line 199 of file TransferElementTestAccessor.h.
bool ChimeraTK::TransferElementTestAccessor< UserType >::_throwRuntimeErrInPre {false} |
Definition at line 197 of file TransferElementTestAccessor.h.
bool ChimeraTK::TransferElementTestAccessor< UserType >::_throwRuntimeErrInPreconditions {false} |
Definition at line 198 of file TransferElementTestAccessor.h.
bool ChimeraTK::TransferElementTestAccessor< UserType >::_throwRuntimeErrInTransfer {false} |
Definition at line 196 of file TransferElementTestAccessor.h.
size_t ChimeraTK::TransferElementTestAccessor< UserType >::_transferIndex {999999} |
Definition at line 180 of file TransferElementTestAccessor.h.
TransferType ChimeraTK::TransferElementTestAccessor< UserType >::_transferType_post |
Definition at line 185 of file TransferElementTestAccessor.h.
TransferType ChimeraTK::TransferElementTestAccessor< UserType >::_transferType_pre |
Definition at line 185 of file TransferElementTestAccessor.h.
bool ChimeraTK::TransferElementTestAccessor< UserType >::_updateDataBuffer |
Definition at line 186 of file TransferElementTestAccessor.h.
bool ChimeraTK::TransferElementTestAccessor< UserType >::_writeable {true} |
Definition at line 168 of file TransferElementTestAccessor.h.
size_t ChimeraTK::TransferElementTestAccessor< UserType >::_writeTransfer_counter {0} |
Definition at line 175 of file TransferElementTestAccessor.h.
VersionNumber ChimeraTK::TransferElementTestAccessor< UserType >::_writeTransfer_version {nullptr} |
Definition at line 188 of file TransferElementTestAccessor.h.
size_t ChimeraTK::TransferElementTestAccessor< UserType >::_writeTransferDestructively_counter {0} |
Definition at line 176 of file TransferElementTestAccessor.h.