ChimeraTK-DeviceAccess 03.25.00
Loading...
Searching...
No Matches
DummyMuxedInterruptDistributor.cc
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
5
6#include "async/SubDomain.h"
7
8#include <nlohmann/json.hpp>
9
10namespace ChimeraTK::async {
11
13 boost::shared_ptr<SubDomain<std::nullptr_t>> parent, ChimeraTK::RegisterPath const& module)
14 : MuxedInterruptDistributor(std::move(parent)), _module(module) {
15 _activeInterrupts = _backend->getRegisterAccessor<uint32_t>(_module / "active_ints", 1, 0, {});
16 if(!_activeInterrupts->isReadable()) {
18 "DummyMuxedInterruptDistributor: Handshake register not readable: " + _activeInterrupts->getName());
19 }
20 }
21
22 /********************************************************************************************************************/
23
25 try {
26 _activeInterrupts->read();
27 for(uint32_t i = 0; i < 32; ++i) {
28 if(_activeInterrupts->accessData(0) & 0x1U << i) {
29 try {
30 auto subDomain = _subDomains.at(i).lock();
31 if(subDomain) {
32 subDomain->distribute(nullptr, version);
33 }
34 }
35 catch(std::out_of_range&) {
36 _backend->setException(
37 "ERROR: DummyMuxedInterruptDistributor reports unknown active interrupt " + std::to_string(i));
38 }
39 }
40 }
41 }
43 // Nothing to do. The transferElement part of _activeInterrupts has already called the backend's setException
44 }
45 }
46
47 /********************************************************************************************************************/
48
49 std::unique_ptr<DummyMuxedInterruptDistributor> DummyMuxedInterruptDistributor::create(
50 std::string const& desrciption, boost::shared_ptr<SubDomain<std::nullptr_t>> parent) {
51 auto jdescription = nlohmann::json::parse(desrciption);
52 auto module = jdescription["module"].get<std::string>();
53 return std::make_unique<DummyMuxedInterruptDistributor>(std::move(parent), module);
54 }
55
56} // namespace ChimeraTK::async
Class to store a register path name.
Class for generating and holding version numbers without exposing a numeric representation.
void handle(VersionNumber version) override
The interrupt handling functions implements the handshake with the interrupt controller.
boost::shared_ptr< NDRegisterAccessor< uint32_t > > _activeInterrupts
DummyMuxedInterruptDistributor(boost::shared_ptr< SubDomain< std::nullptr_t > > parent, RegisterPath const &module)
static std::unique_ptr< DummyMuxedInterruptDistributor > create(std::string const &desrciption, boost::shared_ptr< SubDomain< std::nullptr_t > > parent)
Interface base class for interrupt controller handlers.
std::map< size_t, boost::weak_ptr< SubDomain< std::nullptr_t > > > _subDomains
Send backend-specific asynchronous data to different distributors:
Definition SubDomain.h:33
Exception thrown when a runtime error has occured.
Definition Exception.h:18
STL namespace.
std::string to_string(const std::string &v)