ChimeraTK-DeviceAccess  03.18.00
UioBackend.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
2 // SPDX-License-Identifier: LGPL-3.0-or-later
3 #pragma once
4 
6 #include "UioAccess.h"
7 
8 #include <thread>
9 
10 namespace ChimeraTK {
11 
13  private:
14  std::shared_ptr<UioAccess> _uioAccess;
15 
16  std::thread _interruptWaitingThread;
17  std::atomic<bool> _stopInterruptLoop{false}; // Used to shut down thread
18 
19  void waitForInterruptLoop(std::promise<void> subscriptionDonePromise);
20 
21  /* data */
22  public:
23  UioBackend(std::string deviceName, std::string mapFileName);
24  ~UioBackend() override;
25 
26  static boost::shared_ptr<DeviceBackend> createInstance(
27  std::string address, std::map<std::string, std::string> parameters);
28 
29  void open() override;
30  void closeImpl() override;
31 
32  size_t minimumTransferAlignment([[maybe_unused]] uint64_t bar) const override { return 4; }
33 
34  bool barIndexValid(uint64_t bar) override;
35 
36  void read(uint64_t bar, uint64_t address, int32_t* data, size_t sizeInBytes) override;
37  void write(uint64_t bar, uint64_t address, int32_t const* data, size_t sizeInBytes) override;
38  std::future<void> activateSubscription(
39  uint32_t interruptNumber, boost::shared_ptr<async::DomainImpl<std::nullptr_t>> asyncDomain) override;
40 
41  std::string readDeviceInfo() override;
42 
43  boost::shared_ptr<async::DomainImpl<std::nullptr_t>> _asyncDomain;
44  };
45 
46 } // namespace ChimeraTK
ChimeraTK::UioBackend::readDeviceInfo
std::string readDeviceInfo() override
Return a device information string containing hardware details like the firmware version number or th...
Definition: UioBackend.cc:88
ChimeraTK::UioBackend::UioBackend
UioBackend(std::string deviceName, std::string mapFileName)
Definition: UioBackend.cc:8
ChimeraTK::UioBackend::~UioBackend
~UioBackend() override
Definition: UioBackend.cc:12
ChimeraTK::UioBackend
Definition: UioBackend.h:12
ChimeraTK::UioBackend::read
void read(uint64_t bar, uint64_t address, int32_t *data, size_t sizeInBytes) override
Read function to be implemented by backends.
Definition: UioBackend.cc:53
ChimeraTK::UioBackend::barIndexValid
bool barIndexValid(uint64_t bar) override
Function to be implemented by the backends.
Definition: UioBackend.cc:49
ChimeraTK::UioBackend::activateSubscription
std::future< void > activateSubscription(uint32_t interruptNumber, boost::shared_ptr< async::DomainImpl< std::nullptr_t >> asyncDomain) override
Activate/create the subscription for a given interrupt (for instance by starting the according interr...
Definition: UioBackend.cc:67
ChimeraTK::UioBackend::open
void open() override
Open the device.
Definition: UioBackend.cc:24
NumericAddressedBackend.h
ChimeraTK::NumericAddressedBackend
Base class for address-based device backends (e.g.
Definition: NumericAddressedBackend.h:20
ChimeraTK::UioBackend::createInstance
static boost::shared_ptr< DeviceBackend > createInstance(std::string address, std::map< std::string, std::string > parameters)
Definition: UioBackend.cc:16
ChimeraTK::async::DomainImpl
Definition: DomainImpl.h:15
UioAccess.h
ChimeraTK::UioBackend::write
void write(uint64_t bar, uint64_t address, int32_t const *data, size_t sizeInBytes) override
Write function to be implemented by backends.
Definition: UioBackend.cc:60
ChimeraTK::UioBackend::minimumTransferAlignment
size_t minimumTransferAlignment([[maybe_unused]] uint64_t bar) const override
Determines the supported minimum alignment for any read/write requests.
Definition: UioBackend.h:32
ChimeraTK::UioBackend::_asyncDomain
boost::shared_ptr< async::DomainImpl< std::nullptr_t > > _asyncDomain
Definition: UioBackend.h:43
ChimeraTK
Definition: DummyBackend.h:16
ChimeraTK::UioBackend::closeImpl
void closeImpl() override
All backends derrived from NumericAddressedBackend must implement closeImpl() instead of close.
Definition: UioBackend.cc:36