13#include <boost/algorithm/string.hpp>
14#include <boost/shared_ptr.hpp>
68 explicit Device(
const std::string& aliasName);
73 void open(std::string
const& aliasName);
100 template<
typename UserType>
127 template<
typename UserType>
129 size_t numberOfWords = 0,
size_t wordOffsetInRegister = 0,
130 const AccessModeFlags& flags = AccessModeFlags({}))
const;
145 template<
typename UserType>
147 size_t numberOfElements = 0,
size_t elementsOffset = 0,
148 const AccessModeFlags& flags = AccessModeFlags({}))
const;
168 [[nodiscard]]
bool isOpened()
const;
201 [[nodiscard]] boost::shared_ptr<DeviceBackend>
getBackend();
214 template<typename UserType>
215 [[nodiscard]] UserType
read(
216 const RegisterPath& registerPathName, const AccessModeFlags& flags = AccessModeFlags({}))
const;
229 template<
typename UserType>
230 [[nodiscard]] std::vector<UserType>
read(
const RegisterPath& registerPathName,
size_t numberOfWords,
231 size_t wordOffsetInRegister = 0,
const AccessModeFlags& flags = AccessModeFlags({}))
const;
241 template<
typename UserType>
243 const RegisterPath& registerPathName, UserType value,
const AccessModeFlags& flags = AccessModeFlags({}));
253 template<
typename UserType>
254 void write(
const RegisterPath& registerPathName,
const std::vector<UserType>& vector,
255 size_t wordOffsetInRegister = 0,
const AccessModeFlags& flags = AccessModeFlags({}));
265 template<
typename UserType>
270 _deviceBackendPointer->getRegisterAccessor<UserType>(registerPathName, 1, wordOffsetInRegister, flags));
275 template<
typename UserType>
277 size_t numberOfWords,
size_t wordOffsetInRegister,
const AccessModeFlags& flags)
const {
280 registerPathName, numberOfWords, wordOffsetInRegister, flags));
285 template<
typename UserType>
287 size_t numberOfElements,
size_t elementsOffset,
const AccessModeFlags& flags)
const {
290 registerPathName, numberOfElements, elementsOffset, flags));
295 template<
typename UserType>
297 auto acc = getScalarRegisterAccessor<UserType>(registerPathName, 0, flags);
304 template<
typename UserType>
307 auto acc = getOneDRegisterAccessor<UserType>(registerPathName, numberOfWords, wordOffsetInRegister, flags);
309 std::vector<UserType> vector(acc.getNElements());
316 template<
typename UserType>
318 auto acc = getScalarRegisterAccessor<UserType>(registerPathName, 0, flags);
325 template<
typename UserType>
328 auto acc = getOneDRegisterAccessor<UserType>(registerPathName, vector.size(), wordOffsetInRegister, flags);
332 auto& mutable_vector =
const_cast<std::vector<UserType>&
>(vector);
333 acc.swap(mutable_vector);
335 acc.swap(mutable_vector);
Set of AccessMode flags with additional functionality for an easier handling.
Class allows to read/write registers from device.
TwoDRegisterAccessor< UserType > getTwoDRegisterAccessor(const RegisterPath ®isterPathName, size_t numberOfElements=0, size_t elementsOffset=0, const AccessModeFlags &flags=AccessModeFlags({})) const
Get a TwoDRegisterAccessor object for the given register.
bool isOpened() const
Check if the device is currently opened.
std::set< DeviceBackend::BackendID > getInvolvedBackendIDs()
Recursively obtain the set of all backend IDs that are used withing the device.
void open()
Re-open the device after previously closeing it by calling close(), or when it was constructed with a...
MetadataCatalogue getMetadataCatalogue() const
Return the register catalogue with detailed information on all registers.
boost::shared_ptr< DeviceBackend > _deviceBackendPointer
void close()
Close the device.
void setException(const std::string &message)
Set the device into an exception state.
boost::shared_ptr< DeviceBackend > getBackend()
Obtain the backend.
VoidRegisterAccessor getVoidRegisterAccessor(const RegisterPath ®isterPathName, const AccessModeFlags &flags=AccessModeFlags({})) const
Get a VoidRegisterAccessor object for the given register.
ScalarRegisterAccessor< UserType > getScalarRegisterAccessor(const RegisterPath ®isterPathName, size_t wordOffsetInRegister=0, const AccessModeFlags &flags=AccessModeFlags({})) const
Get a ScalarRegisterObject object for the given register.
void checkPointersAreNotNull() const
RegisterCatalogue getRegisterCatalogue() const
Return the register catalogue with detailed information on all registers.
std::string readDeviceInfo() const
Return a device information string.
OneDRegisterAccessor< UserType > getOneDRegisterAccessor(const RegisterPath ®isterPathName, size_t numberOfWords=0, size_t wordOffsetInRegister=0, const AccessModeFlags &flags=AccessModeFlags({})) const
Get a OneDRegisterAccessor object for the given register.
bool isFunctional() const
Return wether a device is working as intended, usually this means it is opened and does not have any ...
UserType read(const RegisterPath ®isterPathName, const AccessModeFlags &flags=AccessModeFlags({})) const
Inefficient convenience function to read a single-word register without obtaining an accessor.
void activateAsyncRead() noexcept
Activate asyncronous read for all transfer elements where AccessMode::wait_for_new_data is set.
Device()=default
Create device instance without associating a backend yet.
void write(const RegisterPath ®isterPathName, UserType value, const AccessModeFlags &flags=AccessModeFlags({}))
Inefficient convenience function to write a single-word register without obtaining an accessor.
Accessor class to read and write registers transparently by using the accessor object like a vector o...
Class to store a register path name.
Accessor class to read and write scalar registers transparently by using the accessor object like a v...
Accessor class to read and write 2D registers.
Accessor class to read and write void-typed registers.