12 template<
typename UserType>
13 struct ExceptionDummyPushDecorator;
15 struct ExceptionDummyPushDecoratorBase;
17 struct ExceptionDummyPollDecoratorBase;
18 template<
typename UserType>
19 struct ExceptionDummyPollDecorator;
25 explicit ExceptionDummy(std::string
const& mapFileName,
const std::string& dataConsistencyKeyDescriptor =
"");
31 std::string address, std::map<std::string, std::string> parameters);
37 void read(uint64_t bar, uint64_t address, int32_t* data,
size_t sizeInBytes)
override;
39 void write(uint64_t bar, uint64_t address, int32_t
const* data,
size_t sizeInBytes)
override;
103 template<
typename UserType>
104 boost::shared_ptr<NDRegisterAccessor<UserType>> getRegisterAccessor_impl(
119 template<
typename UserType>
122 boost::shared_ptr<ExceptionDummy> backend)
124 assert(_target->isReadable());
132 _path = _target->getName();
134 _path /=
"PUSH_READ";
138 std::unique_lock<std::mutex> lk(
_backend->_pushDecoratorsMutex);
141 for(
auto it = list.begin(); it != list.end(); ++it) {
142 if(it->lock().get() ==
nullptr) {
148 catch(std::exception& e) {
153 std::cout <<
"~ExceptionDummyPushDecorator(): Unexpected exception: " << e.what() << std::endl;
155 std::cout <<
"~ExceptionDummyPushDecorator(): Could not unlist instance!" << std::endl;
171 std::vector<std::vector<UserType>>
_data;
184 b.
_data = _target->accessChannels();
206 if(updateDataBuffer) {
232 template<
typename UserType>
235 boost::shared_ptr<ExceptionDummy> backend)
237 assert(_target->isReadable());
239 _path = _target->getName();
Set of AccessMode flags with additional functionality for an easier handling.
void add(AccessMode flag)
Add the given flag to the set.
Base class for DummyBackends, provides common functionality.
The dummy device opens a mapping file instead of a device, and implements all registers defined in th...
std::map< RegisterPath, DataValidity > _registerValidities
This map is used for setting individual (poll-type) variables to DataValidity=faulty.
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.
std::map< RegisterPath, VersionNumber > _pushVersions
Map of version numbers to use in push decorators. Protected by _pushDecoratorMutex.
bool _activateNewPushAccessors
Flag is toggled by activateAsyncRead (true), setException (false) and close (false).
std::map< RegisterPath, std::list< boost::weak_ptr< ExceptionDummyPushDecoratorBase > > > _pushDecorators
Map of active ExceptionDummyPushDecorator. Protected by _pushDecoratorMutex.
static boost::shared_ptr< DeviceBackend > createInstance(std::string address, std::map< std::string, std::string > parameters)
void open() override
Open the device.
DEFINE_VIRTUAL_FUNCTION_OVERRIDE_VTABLE(DummyBackendBase, getRegisterAccessor_impl, boost::shared_ptr< NDRegisterAccessor< T > >(const RegisterPath &, size_t, size_t, AccessModeFlags))
std::mutex _registerValiditiesMutex
mutex to protect map _registerValidities
size_t getWriteOrder(const RegisterPath &path)
Function to obtain the write order number of a register.
DataValidity getValidity(RegisterPath path)
Query map for overwritten data validities.
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 a...
void setValidity(RegisterPath path, DataValidity val)
Use decorator to overwrite returned data validity of individual (poll-type) variables.
void closeImpl() override
This closes the device, clears all internal registers, read-only settings and callback functions.
size_t getWriteCount(const RegisterPath &path)
Function to obtain the number of writes of a register since the creation of the backend.
std::mutex _pushDecoratorsMutex
Mutex to protect data structures for push decorators.
void setExceptionImpl() noexcept override
Function to be (optionally) implemented by backends if additional actions are needed when switching t...
void triggerPush(RegisterPath path, VersionNumber v={})
Function to trigger sending values for push-type variables.
std::atomic< size_t > _writeOrderCounter
Global counter for order numbers going into _writeOrderMap.
void activateAsyncRead() noexcept override
Activate asyncronous read for all transfer elements where AccessMode::wait_for_new_data is set.
bool asyncReadActivated()
Function to test whether async read transfers are activated.
Base class for decorators of the NDRegisterAccessor.
N-dimensional register accessor.
std::vector< std::vector< UserType > > buffer_2D
Buffer of converted data elements.
Class to store a register path name.
void setAltSeparator(const std::string &altSeparator)
set alternative separator.
virtual void setExceptionBackend(boost::shared_ptr< DeviceBackend > exceptionBackend)
Set the backend to which the exception has to be reported.
AccessModeFlags _accessModeFlags
The access mode flags for this transfer element.
DataValidity _dataValidity
The validity of the data in the application buffer.
void interrupt_impl(QUEUE_TYPE &dataTransportQueue)
Implementation of interrupt()
VersionNumber _versionNumber
The version number of the last successful transfer.
cppext::future_queue< void > _readQueue
The queue for asynchronous read transfers.
Class for generating and holding version numbers without exposing a numeric representation.
Exception thrown when a logic error has occured.
Exception thrown when a runtime error has occured.
DataValidity
The current state of the data.
@ faulty
The data is considered valid.
@ wait_for_new_data
Make any read blocking until new data has arrived since the last read.
TransferType
Used to indicate the applicable operation on a Transferelement.
virtual ~ExceptionDummyPollDecoratorBase()=default
A decorator that returns invalid data for polled variables.
ExceptionDummyPollDecorator(const boost::shared_ptr< ChimeraTK::NDRegisterAccessor< UserType > > &target, boost::shared_ptr< ExceptionDummy > backend)
DataValidity _dataValidity
The validity of the data in the application buffer.
boost::shared_ptr< ExceptionDummy > _backend
void doPostRead(TransferType type, bool updateDataBuffer) override
Backend specific implementation of postRead().
std::vector< std::vector< UserType > > _data
virtual ~ExceptionDummyPushDecoratorBase()=default
void setExceptionBackend(boost::shared_ptr< DeviceBackend > exceptionBackend) override
Set the backend to which the exception has to be reported.
DataValidity _dataValidity
The validity of the data in the application buffer.
VersionNumber _versionNumber
The version number of the last successful transfer.
cppext::future_queue< Buffer > _myReadQueue
cppext::future_queue< void > _readQueue
The queue for asynchronous read transfers.
~ExceptionDummyPushDecorator() override
ExceptionDummyPushDecorator(const boost::shared_ptr< ChimeraTK::NDRegisterAccessor< UserType > > &target, boost::shared_ptr< ExceptionDummy > backend)
void doPostRead(TransferType, bool updateDataBuffer) override
Backend specific implementation of postRead().
void interrupt() override
Return from a blocking read immediately and throw boost::thread_interrupted.
void doPreRead(TransferType) override
Backend specific implementation of preRead().
boost::shared_ptr< ExceptionDummy > _backend