20 const std::string& mapFileName, std::unique_ptr<NumericAddressedRegisterCatalogue> registerMapPointer)
21 : _registerMapPointer(std::move(registerMapPointer)), _registerMap(*_registerMapPointer) {
23 if(!mapFileName.empty()) {
38 if(components.size() != 3) {
41 auto bar = std::stoi(components[1]);
42 size_t pos = components[2].find_first_of(
'*');
43 auto address = std::stoi(components[2].substr(0, pos));
45 if(pos != std::string::npos) {
46 nBytes = std::stoi(components[2].substr(pos + 1));
49 nBytes =
sizeof(int32_t);
51 auto nElements = nBytes /
sizeof(int32_t);
52 if(nBytes == 0 || nBytes %
sizeof(int32_t) != 0) {
62 [[maybe_unused]] int32_t* data, [[maybe_unused]]
size_t sizeInBytes) {
63 throw ChimeraTK::logic_error(
"NumericAddressedBackend: internal error: interface read() called w/ 32bit address");
69 [[maybe_unused]] int32_t
const* data, [[maybe_unused]]
size_t sizeInBytes) {
70 throw ChimeraTK::logic_error(
"NumericAddressedBackend: internal error: interface write() called w/ 32bit address");
77 #pragma GCC diagnostic push
78 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
79 read(
static_cast<uint8_t
>(bar),
static_cast<uint32_t
>(address), data, sizeInBytes);
80 #pragma GCC diagnostic pop
86 #pragma GCC diagnostic push
87 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
88 write(
static_cast<uint8_t
>(bar),
static_cast<uint32_t
>(address), data, sizeInBytes);
89 #pragma GCC diagnostic pop
96 return bar <= 5 || bar == 13;
101 template<
typename UserType>
102 boost::shared_ptr<NDRegisterAccessor<UserType>> NumericAddressedBackend::getRegisterAccessor_impl(
109 "Register " + registerPathName +
" does not support AccessMode::wait_for_new_data.");
113 boost::static_pointer_cast<NumericAddressedBackend>(shared_from_this()),
114 registerInfo.getQualifiedAsyncId().front(), _asyncIsActive, registerPathName, numberOfWords,
115 wordOffsetInRegister, flags);
117 return getSyncRegisterAccessor<UserType>(registerPathName, numberOfWords, wordOffsetInRegister, flags);
122 template<
typename UserType>
123 boost::shared_ptr<NDRegisterAccessor<UserType>> NumericAddressedBackend::getSyncRegisterAccessor(
124 const RegisterPath& registerPathName,
size_t numberOfWords,
size_t wordOffsetInRegister, AccessModeFlags flags) {
125 boost::shared_ptr<NDRegisterAccessor<UserType>> accessor;
130 if(registerInfo.getNumberOfDimensions() <= 1) {
134 accessor = boost::shared_ptr<NDRegisterAccessor<UserType>>(
135 new NumericAddressedBackendRegisterAccessor<UserType, FixedPointConverter, true>(
136 shared_from_this(), registerPathName, numberOfWords, wordOffsetInRegister, flags));
139 accessor = boost::shared_ptr<NDRegisterAccessor<UserType>>(
140 new NumericAddressedBackendRegisterAccessor<UserType, FixedPointConverter, false>(
141 shared_from_this(), registerPathName, numberOfWords, wordOffsetInRegister, flags));
146 accessor = boost::shared_ptr<NDRegisterAccessor<UserType>>(
147 new NumericAddressedBackendRegisterAccessor<UserType, IEEE754_SingleConverter, true>(
148 shared_from_this(), registerPathName, numberOfWords, wordOffsetInRegister, flags));
151 accessor = boost::shared_ptr<NDRegisterAccessor<UserType>>(
152 new NumericAddressedBackendRegisterAccessor<UserType, IEEE754_SingleConverter, false>(
153 shared_from_this(), registerPathName, numberOfWords, wordOffsetInRegister, flags));
157 if constexpr(!std::is_same<UserType, std::string>::value) {
158 throw ChimeraTK::logic_error(
"NumericAddressedBackend: ASCII data must be read with std::string UserType.");
161 accessor = boost::shared_ptr<NDRegisterAccessor<UserType>>(
new NumericAddressedBackendASCIIAccessor(
162 shared_from_this(), registerPathName, numberOfWords, wordOffsetInRegister, flags));
166 throw ChimeraTK::logic_error(
"NumericAddressedBackend: trying to get accessor for unsupported data type");
171 flags.checkForUnknownFlags({});
173 accessor = boost::shared_ptr<NDRegisterAccessor<UserType>>(
174 new NumericAddressedBackendMuxedRegisterAccessor<UserType, IEEE754_SingleConverter>(
175 registerPathName, numberOfWords, wordOffsetInRegister, shared_from_this()));
178 accessor = boost::shared_ptr<NDRegisterAccessor<UserType>>(
179 new NumericAddressedBackendMuxedRegisterAccessor<UserType, FixedPointConverter>(
180 registerPathName, numberOfWords, wordOffsetInRegister, shared_from_this()));
184 accessor->setExceptionBackend(shared_from_this());
191 _asyncIsActive =
true;
194 auto activateDomain = [
this](
size_t key, boost::shared_ptr<async::Domain>& domain) {
195 auto domainImpl = boost::dynamic_pointer_cast<async::DomainImpl<std::nullptr_t>>(domain);
201 subscriptionDone.wait();
202 domainImpl->activate(
nullptr);
213 std::promise<void> subscriptionDonePromise;
214 subscriptionDonePromise.set_value();
215 return subscriptionDonePromise.get_future();
221 _asyncIsActive =
false;
243 _asyncIsActive =
false;