10#include <boost/make_shared.hpp>
21 const LNMBackendRegisterInfo& info,
size_t pluginIndex,
const std::map<std::string, std::string>& parameters)
24 const auto& shift = parameters.at(
"shift");
28 auto [suffix, ec]{std::from_chars(shift.data(), shift.data() + shift.size(),
_shift)};
29 if(ec != std::errc()) {
31 R
"(: Unparseable parameter "shift".)");
34 catch(std::out_of_range&) {
36 R
"(: Missing parameter "shift".)");
40 const auto& numberOfBits = parameters.at(
"numberOfBits");
43 auto [suffix, ec]{std::from_chars(numberOfBits.data(), numberOfBits.data() + numberOfBits.size(),
_numberOfBits)};
44 if(ec != std::errc()) {
46 R
"(: Unparseable parameter "numberOfBits".)");
49 catch(std::out_of_range&) {
51 R
"(: Missing parameter "numberOfBits".)");
54 if(
const auto it = parameters.find(
"fractionalBits"); it != parameters.end()) {
59 if(ec != std::errc()) {
61 R
"(: Unparseable parameter "fractionalBits".)");
65 if(
const auto it = parameters.find(
"signed"); it != parameters.end()) {
66 std::stringstream ss(it->second);
85 template<
typename UserType,
typename TargetType>
89 if constexpr(std::is_same_v<TargetType, uint64_t>) {
92 std::format(
"BitRangePlugin (on {}) Unsupported flags in {}", params.
_name, params.
_flags.
serialize()));
97 boost::shared_ptr<DeviceBackend> targetDevice;
98 if(devName !=
"this") {
99 targetDevice = backend->_devices[devName];
102 targetDevice = backend;
117 return boost::make_shared<detail::BitRangeAccessorDecorator<UserType, false>>(
118 targetDevice, targetPath, target, regInfo, 1, 0);
void remove(AccessMode flag)
Remove the given flag from the set.
std::string serialize() const
Get a comma seperated list of all flag strings contained in the class.
bool has(AccessMode flag) const
Check if a certain flag is in the set.
Wrapper Class to avoid vector<bool> problems.
void setRawDataType(const DataType &d)
Set the raw data type.
@ none
The data type/concept does not exist, e.g. there is no raw transfer (do not confuse with Void)
LNMBackendRegisterInfo _info
RegisterInfo describing the the target register for which this plugin instance should work.
Base class for plugins that modify the behaviour of accessors in the logical name mapping backend.
BitRangeAccessPlugin(const LNMBackendRegisterInfo &info, size_t pluginIndex, const std::map< std::string, std::string > ¶meters)
bool dataInterpretationIsSigned
int32_t dataInterpretationFractionalBits
boost::shared_ptr< NDRegisterAccessor< UserType > > decorateAccessor(boost::shared_ptr< LogicalNameMappingBackend > &backend, boost::shared_ptr< NDRegisterAccessor< TargetType > > &target, const UndecoratedParams &accessorParams)
void doRegisterInfoUpdate() override
Implementation of the plugin specific register information update.
RegisterInfo structure for the LogicalNameMappingBackend.
RegisterPath getRegisterName() const override
Return full path name of the register (including modules)
DataDescriptor _dataDescriptor
AccessModeFlags supportedFlags
Supported AccessMode flags.
std::string deviceName
The target device alias.
bool isWriteable() const override
Return whether the register is writeable.
RegisterPath name
Name of the register.
N-dimensional register accessor.
std::vector< ChannelInfo > channels
Define per-channel information (bit interpretation etc.), 1D/scalars have exactly one entry.
Class to store a register path name.
Exception thrown when a logic error has occured.
@ wait_for_new_data
Make any read blocking until new data has arrived since the last read.
@ raw
Raw access: disable any possible conversion from the original hardware data type into the given UserT...
Helper struct to hold extra parameters needed by some plugins, used in decorateAccessor()
size_t _wordOffsetInRegister