15 auto acc = acc_weak.lock();
16 if(!acc->_isActive)
continue;
31 for(
auto& acc_weak : pair.second) {
32 auto acc = acc_weak.lock();
33 if(acc->_isActive)
continue;
37 acc->_isActive =
true;
38 acc->_hasException =
false;
53 for(
auto& acc_weak : pair.second) {
54 auto acc = acc_weak.lock();
55 if(!acc->_isActive)
continue;
56 acc->_isActive =
false;
57 if(acc->_hasException)
continue;
58 acc->_hasException =
true;
71 auto adrPair = std::make_pair(info.bar, info.address);
79 auto adrPair = std::make_pair(info.bar, info.address);
93 :
DummyBackend(mapFileName, dataConsistencyKeyDescriptor) {
102 [[maybe_unused]] std::string address, std::map<std::string, std::string> parameters) {
103 if(parameters[
"map"].empty()) {
106 return boost::shared_ptr<DeviceBackend>(
new ExceptionDummy(parameters[
"map"]));
147 auto itWriteOrder =
_writeOrderMap.find(std::make_pair(bar, address));
151 auto& orderNumberInMap = itWriteOrder->second;
155 while((current = orderNumberInMap.load()) < generatedOrderNumber) {
156 orderNumberInMap.compare_exchange_weak(current, generatedOrderNumber);
162 itWriteCounter->second++;
168 template<
typename UserType>
169 boost::shared_ptr<NDRegisterAccessor<UserType>> ExceptionDummy::getRegisterAccessor_impl(
171 auto path = registerPathName;
173 auto pathComponents = path.getComponents();
174 bool pushRead =
false;
175 if(pathComponents[pathComponents.size() - 1] ==
"PUSH_READ") {
184 DummyBackendBase, getRegisterAccessor_impl, UserType, path, numberOfWords, wordOffsetInRegister, flags);
188 auto decorator = boost::make_shared<ExceptionDummyPushDecorator<UserType>>(
189 acc, boost::dynamic_pointer_cast<ExceptionDummy>(this->shared_from_this()));
194 decorator->_isActive =
true;
195 decorator->trigger();
200 else if(acc->isReadable()) {
202 auto decorator = boost::make_shared<ExceptionDummyPollDecorator<UserType>>(
203 acc, boost::dynamic_pointer_cast<ExceptionDummy>(this->shared_from_this()));
208 if(pathComponents[pathComponents.size() - 1] !=
"DUMMY_WRITEABLE" &&
209 (pathComponents[0].find(
"DUMMY_INTERRUPT_") != 0)) {
211 auto adrPair = std::make_pair(info.bar, info.address);
218 acc->setExceptionBackend(shared_from_this());
#define OVERRIDE_VIRTUAL_FUNCTION_TEMPLATE(BaseClass, functionName)
Save the old vtable to be accessible by CALL_BASE_FUNCTION_TEMPLATE and overwrite it with the new imp...
#define CALL_BASE_FUNCTION_TEMPLATE(BaseClass, functionName, templateArgument,...)
Execute the virtual function template call to the base implementation of the function.
Set of AccessMode flags with additional functionality for an easier handling.
void remove(AccessMode flag)
Remove the given flag from the set.
bool has(AccessMode flag) const
Check if a certain flag is in the set.
virtual void activateAsyncRead() noexcept
Activate asyncronous read for all transfer elements where AccessMode::wait_for_new_data is set.
virtual void setExceptionImpl() noexcept
Function to be (optionally) implemented by backends if additional actions are needed when switching t...
void setException(const std::string &message) noexcept final
Set the backend into an exception state.
Base class for DummyBackends, provides common functionality.
std::atomic< bool > throwExceptionWrite
std::atomic< bool > throwExceptionRead
std::atomic< size_t > throwExceptionCounter
std::atomic< bool > throwExceptionOpen
The dummy device opens a mapping file instead of a device, and implements all registers defined in th...
void write(uint64_t bar, uint64_t address, int32_t const *data, size_t sizeInBytes) override
Write function to be implemented by backends.
void read(uint64_t bar, uint64_t address, int32_t *data, size_t sizeInBytes) override
Read function to be implemented by backends.
void open() override
Open the device.
void closeImpl() override
This closes the device, clears all internal registers, read-only settings and callback functions.
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.
void read(uint64_t bar, uint64_t address, int32_t *data, size_t sizeInBytes) override
Read function to be implemented by backends.
static boost::shared_ptr< DeviceBackend > createInstance(std::string address, std::map< std::string, std::string > parameters)
void open() override
Open the device.
ExceptionDummy(std::string const &mapFileName, const std::string &dataConsistencyKeyDescriptor="")
size_t getWriteOrder(const RegisterPath &path)
Function to obtain the write order number of a register.
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 write(uint64_t bar, uint64_t address, int32_t const *data, size_t sizeInBytes) override
Write function to be implemented by backends.
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.
NumericAddressedRegisterInfo getRegisterInfo(const RegisterPath ®isterPathName)
getRegisterInfo returns a NumericAddressedRegisterInfo object for the given register.
Class to store a register path name.
void setAltSeparator(const std::string &altSeparator)
set alternative separator.
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.
@ wait_for_new_data
Make any read blocking until new data has arrived since the last read.