ChimeraTK-DeviceAccess
03.25.00
Loading...
Searching...
No Matches
TriggeredPollDistributor.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/TriggeredPollDistributor.h
"
5
6
#include "
async/DataConsistencyKey.h
"
7
#include "
async/SubDomain.h
"
8
#include "
BackendRegisterCatalogue.h
"
9
10
namespace
ChimeraTK::async
{
11
12
/********************************************************************************************************************/
13
14
TriggeredPollDistributor::TriggeredPollDistributor
(boost::shared_ptr<DeviceBackend> backend,
15
boost::shared_ptr<
SubDomain<std::nullptr_t>
> parent, boost::shared_ptr<Domain> asyncDomain)
16
:
SourceTypedAsyncAccessorManager
<
std
::nullptr_t>(
std
::move(backend),
std
::move(asyncDomain)),
17
_parent(
std
::move(parent)) {
18
FILL_VIRTUAL_FUNCTION_TEMPLATE_VTABLE
(
createAsyncVariable
);
19
20
// get DataConsistencyRealm from backend catalogue
21
_dataConsistencyRealm
=
_backend
->getRegisterCatalogue().getImpl().getDataConsistencyRealm(
_parent
->getId());
22
if
(
_dataConsistencyRealm
) {
23
// get accessor for the DataConsistencyKey from the backend and add it to our TransferGroup
24
auto
path =
_backend
->getRegisterCatalogue().getImpl().getDataConsistencyKeyRegisterPath(
_parent
->getId());
25
_dataConsistencyKeyAccessor
.
replace
(
_backend
->getRegisterAccessor<
DataConsistencyKey::BaseType
>(path, 0, 0, {}));
26
_transferGroup
.
addAccessor
(
_dataConsistencyKeyAccessor
);
27
}
28
}
29
30
/********************************************************************************************************************/
31
32
bool
TriggeredPollDistributor::prepareIntermediateBuffers
() {
33
try
{
34
_transferGroup
.
read
();
35
}
36
catch
(
ChimeraTK::runtime_error
&) {
37
// Nothing to do. Backend's set exception has already been called by the accessor in the transfer group that
38
// raised it.
39
return
false
;
40
}
41
42
// update version number
43
if
(
_dataConsistencyRealm
) {
44
auto
newVersion =
_dataConsistencyRealm
->getVersion(
DataConsistencyKey
(
_dataConsistencyKeyAccessor
));
45
if
(newVersion >=
_lastVersion
) {
46
_version
= newVersion;
47
_lastVersion
=
_version
;
48
_forceFaulty
=
false
;
49
}
50
else
{
51
_version
=
_lastVersion
;
52
_forceFaulty
=
true
;
53
}
54
}
55
56
return
true
;
57
}
58
59
/********************************************************************************************************************/
60
61
}
// namespace ChimeraTK::async
BackendRegisterCatalogue.h
DataConsistencyKey.h
SubDomain.h
TriggeredPollDistributor.h
FILL_VIRTUAL_FUNCTION_TEMPLATE_VTABLE
#define FILL_VIRTUAL_FUNCTION_TEMPLATE_VTABLE(functionName)
Fill the vtable of a virtual function template defined with DEFINE_VIRTUAL_FUNCTION_TEMPLATE.
Definition
VirtualFunctionTemplate.h:78
ChimeraTK::NDRegisterAccessorAbstractor::replace
void replace(const NDRegisterAccessorAbstractor< UserType > &newAccessor)
Assign a new accessor to this NDRegisterAccessorAbstractor.
Definition
NDRegisterAccessorAbstractor.h:69
ChimeraTK::TransferGroup::addAccessor
void addAccessor(TransferElementAbstractor &accessor)
Add a register accessor to the group.
Definition
TransferGroup.cc:301
ChimeraTK::TransferGroup::read
void read()
Trigger read transfer for all accessors in the group.
Definition
TransferGroup.cc:44
ChimeraTK::async::AsyncAccessorManager::_backend
boost::shared_ptr< DeviceBackend > _backend
Definition
AsyncAccessorManager.h:106
ChimeraTK::async::DataConsistencyKey
Definition
DataConsistencyKey.h:12
ChimeraTK::async::DataConsistencyKey::BaseType
uint64_t BaseType
Numeric data type for the key. Must be a valid UserType for the register accessors.
Definition
DataConsistencyKey.h:15
ChimeraTK::async::SourceTypedAsyncAccessorManager
Definition
AsyncAccessorManager.h:136
ChimeraTK::async::SourceTypedAsyncAccessorManager< std::nullptr_t >::_version
VersionNumber _version
Definition
AsyncAccessorManager.h:160
ChimeraTK::async::SubDomain
Send backend-specific asynchronous data to different distributors:
Definition
SubDomain.h:33
ChimeraTK::async::TriggeredPollDistributor::_dataConsistencyRealm
std::shared_ptr< DataConsistencyRealm > _dataConsistencyRealm
Definition
TriggeredPollDistributor.h:37
ChimeraTK::async::TriggeredPollDistributor::_forceFaulty
bool _forceFaulty
Definition
TriggeredPollDistributor.h:39
ChimeraTK::async::TriggeredPollDistributor::TriggeredPollDistributor
TriggeredPollDistributor(boost::shared_ptr< DeviceBackend > backend, boost::shared_ptr< SubDomain< std::nullptr_t > > parent, boost::shared_ptr< Domain > asyncDomain)
Definition
TriggeredPollDistributor.cc:14
ChimeraTK::async::TriggeredPollDistributor::_dataConsistencyKeyAccessor
ScalarRegisterAccessor< DataConsistencyKey::BaseType > _dataConsistencyKeyAccessor
Definition
TriggeredPollDistributor.h:38
ChimeraTK::async::TriggeredPollDistributor::_parent
boost::shared_ptr< SubDomain< std::nullptr_t > > _parent
Definition
TriggeredPollDistributor.h:36
ChimeraTK::async::TriggeredPollDistributor::prepareIntermediateBuffers
bool prepareIntermediateBuffers() override
Poll all sync variables.
Definition
TriggeredPollDistributor.cc:32
ChimeraTK::async::TriggeredPollDistributor::createAsyncVariable
std::unique_ptr< AsyncVariable > createAsyncVariable(AccessorInstanceDescriptor const &descriptor)
Definition
TriggeredPollDistributor.h:71
ChimeraTK::async::TriggeredPollDistributor::_transferGroup
TransferGroup _transferGroup
Definition
TriggeredPollDistributor.h:35
ChimeraTK::async::TriggeredPollDistributor::_lastVersion
VersionNumber _lastVersion
Definition
TriggeredPollDistributor.h:40
ChimeraTK::runtime_error
Exception thrown when a runtime error has occured.
Definition
Exception.h:18
ChimeraTK::async
Definition
design_AsyncNDRegisterAcessor_and_NumericAddressedBackend.dox:1
std
STL namespace.
sources
ChimeraTK-DeviceAccess
src
async
TriggeredPollDistributor.cc
Generated by
1.9.8