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