20 template<
typename UserType>
25 virtual void toRaw(UserType cooked, std::byte*
raw) = 0;
26 static std::shared_ptr<RawConverterCapsule<UserType>>
makeCapsule(
83 std::shared_ptr<RawConverterCapsule<T>>&
_rc;
107 auto* basePtr =
reinterpret_cast<std::byte*
>(
_buffer);
108 auto* startPtr = basePtr +
static_cast<size_t>(
_pitch) * sample;
118 std::shared_ptr<proxies::RawConverterCapsule<T>>&
_rc;
213 std::shared_ptr<proxies::RawConverterCapsule<T>>
_rc;
219 return reinterpret_cast<std::byte*
>(ptr);
249 :
_dev(dev),
_path(module +
"/" + name) {
258 assert(c.bitOffset % 8 == 0);
260 _nbytes.push_back((c.width - 1) / 8 + 1);
297 auto* seq =
reinterpret_cast<int32_t*
>(basePtr +
_offsets[sequence]);
320 std::vector<std::shared_ptr<proxies::RawConverterCapsule<T>>>
_rc;
353 boost::shared_ptr<DeviceBackend>
const& backend, std::string
const& module, std::string
const& name)
The dummy device opens a mapping file instead of a device, and implements all registers defined in th...
void setWriteCallbackFunction(AddressRange addressRange, boost::function< void(void)> const &writeCallbackFunction)
std::map< uint64_t, std::vector< int32_t > > _barContents
Register accessor for accessing multiplexed 2D array registers internally of a DummyBackend implement...
unsigned int _nElements
number of elements per sequence
DummyMultiplexedRegisterAccessor(DummyBackend *dev, std::string const &module, std::string const &name)
Constructor should normally be called in the constructor of the DummyBackend implementation.
std::vector< std::shared_ptr< proxies::RawConverterCapsule< T > > > _rc
pointer to fixed point converter
DummyBackend * _dev
pointer to VirtualDevice
DummyBackend & getBackend() const
Return the backend.
RegisterPath _path
path of the register
unsigned int getNumberOfSequences()
return number of sequences
const RegisterPath & getRegisterPath() const
Return the register path.
std::vector< uint32_t > _nbytes
number of bytes per word for sequences
const NumericAddressedRegisterInfo & getRegisterInfo()
DummyMultiplexedRegisterAccessor(const DummyMultiplexedRegisterAccessor &)=default
NumericAddressedRegisterInfo _registerInfo
register map information
int _pitch
pitch in bytes (distance between samples of the same sequence)
void operator=(const DummyMultiplexedRegisterAccessor &rightHandSide) const =delete
remove assignment operator since it will be confusing
unsigned int getNumberOfElements()
return number of elements per sequence
proxies::DummyRegisterSequence< T > operator[](unsigned int sequence)
Get or set register content by [] operators.
std::vector< uint32_t > _offsets
offsets in bytes for sequences
Register accessor for accessing single word or 1D array registers internally of a DummyBackend implem...
DummyBackend * _dev
pointer to VirtualDevice
DummyRegisterAccessor(const DummyRegisterAccessor &)=default
DummyBackend & getBackend() const
Return the backend.
void operator=(const DummyRegisterAccessor &rightHandSide) const =delete
remove assignment operator since it will be confusing */
std::byte * getElement(unsigned int index)
return element
const RegisterPath & getRegisterPath() const
Return the register path.
std::shared_ptr< proxies::RawConverterCapsule< T > > _rc
fixed point converter
unsigned int getNumberOfElements()
return number of elements
RegisterPath _path
path of the register
proxies::DummyRegisterElement< T > operator[](unsigned int index)
Get or set register content by [] operator.
proxies::DummyRegisterElement< T > getProxy(int index)
return a proxy object
DummyRegisterAccessor(DummyBackend *dev, std::string const &module, std::string const &name)
Constructor should normally be called in the constructor of the DummyBackend implementation.
const NumericAddressedRegisterInfo & getRegisterInfo()
void setWriteCallback(const std::function< void()> &writeCallback)
Set callback function which is called when the register is written to (through the normal Device inte...
NumericAddressedRegisterInfo _registerInfo
register map information
std::unique_lock< std::mutex > getBufferLock()
Get a lock to safely modify the buffer in a multi-treaded environment.
Accessor for raw 32 bit integer access to the underlying memory space.
void operator=(const DummyRegisterRawAccessor &rightHandSide) const =delete
remove assignment operator since it will be confusing
DummyRegisterRawAccessor(boost::shared_ptr< DeviceBackend > const &backend, std::string const &module, std::string const &name)
unsigned int getNumberOfElements() const
return number of elements
boost::shared_ptr< DummyBackend > _backend
pointer to dummy backend
int32_t & operator[](unsigned int index)
Get or set register content by [] operator.
DummyRegisterRawAccessor(const DummyRegisterRawAccessor &)=default
NumericAddressedRegisterInfo _registerInfo
register map information
std::unique_lock< std::mutex > getBufferLock()
Get a lock to safely modify the buffer.
int32_t * _buffer
raw buffer of this accessor
DummyRegisterRawAccessor & operator=(int32_t rhs)
NumericAddressedRegisterCatalogue & _registerMap
NumericAddressedRegisterInfo getBackendRegister(const RegisterPath ®isterPathName) const override
Note: Override this function if backend has "hidden" registers which are not added to the map and hen...
uint32_t nElements
Number of elements in register.
std::vector< ChannelInfo > channels
Define per-channel information (bit interpretation etc.), 1D/scalars have exactly one entry.
uint64_t bar
Upper part of the address (name originally from PCIe, meaning now generalised)
uint32_t elementPitchBits
Distance in bits (!) between two elements (of the same channel)
uint64_t address
Lower part of the address relative to BAR, in bytes.
Class to store a register path name.
Exception thrown when a logic error has occured.
Temporary proxy class for use in the DummyRegister and DummyMultiplexedRegister classes.
std::byte * _buffer
raw buffer of this element
DummyRegisterElement< T > & operator=(T rhs)
assignment operator
DummyRegisterElement< T > operator++()
pre-increment operator
T operator++(int)
post-increment operator
T operator--(int)
post-decrement operator
int _nbytes
number of bytes per word
DummyRegisterElement(std::shared_ptr< RawConverterCapsule< T > > &rc, int nbytes, std::byte *buffer)
std::shared_ptr< RawConverterCapsule< T > > & _rc
fixed point converter to be used for this element
DummyRegisterElement< T > operator--()
pre-decrement operator
Temporary proxy class for sequences, used in the DummyMultiplexedRegister class.
int _pitch
pitch in bytes (distance between samples of the same sequence)
int _nbytes
number of bytes per word
DummyRegisterElement< T > operator[](unsigned int sample)
Get or set register content by [] operator.
int32_t * _buffer
reference to the raw buffer (first word of the sequence)
DummyRegisterSequence(std::shared_ptr< proxies::RawConverterCapsule< T > > &rc, int nbytes, int pitch, int32_t *buffer)
std::shared_ptr< proxies::RawConverterCapsule< T > > & _rc
fixed point converter to be used for this sequence
void operator=(const DummyRegisterSequence &rightHandSide) const =delete
remove assignment operator since it will be confusing */
This abstract class encapsulates a RawConverter to erase the exact RawConverter type (with all its te...
virtual UserType toCooked(std::byte *raw)=0
virtual ~RawConverterCapsule()=default
virtual void toRaw(UserType cooked, std::byte *raw)=0
static std::shared_ptr< RawConverterCapsule< UserType > > makeCapsule(const ChimeraTK::NumericAddressedRegisterInfo &info, size_t channelIndex)
@ raw
Raw access: disable any possible conversion from the original hardware data type into the given UserT...