ChimeraTK-DeviceAccess  03.18.00
SubdeviceRegisterAccessor.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 
5 #include "NDRegisterAccessor.h"
6 #include "SubdeviceBackend.h"
7 
8 #include <algorithm>
9 
10 namespace ChimeraTK {
11 
12  /********************************************************************************************************************/
13 
15  public:
16  SubdeviceRegisterAccessor(boost::shared_ptr<SubdeviceBackend> backend, const std::string& registerPathName,
17  boost::shared_ptr<NDRegisterAccessor<int32_t>> accAddress,
18  boost::shared_ptr<NDRegisterAccessor<int32_t>> accDataArea,
19  boost::shared_ptr<NDRegisterAccessor<int32_t>> accStatus, size_t byteOffset, size_t numberOfWords);
20 
21  void doReadTransferSynchronously() override;
22 
23  bool doWriteTransfer(ChimeraTK::VersionNumber versionNumber) override;
24 
25  void doPreRead(TransferType type) override;
26 
27  void doPostRead(TransferType type, bool hasNewData) override;
28 
29  void doPreWrite(TransferType type, VersionNumber) override;
30 
31  void doPostWrite(TransferType type, VersionNumber) override;
32 
33  bool mayReplaceOther(const boost::shared_ptr<TransferElement const>&) const override;
34 
35  bool isReadOnly() const override;
36 
37  bool isReadable() const override;
38 
39  bool isWriteable() const override;
40 
41  protected:
43  boost::shared_ptr<SubdeviceBackend> _backend;
44 
46  boost::shared_ptr<NDRegisterAccessor<int32_t>> _accAddress; // address register, if present
47  boost::shared_ptr<NDRegisterAccessor<int32_t>> _accDataArea; // data or area register
48  boost::shared_ptr<NDRegisterAccessor<int32_t>> _accStatus; // status register, if present
49 
52 
54  std::vector<int32_t> _buffer;
55 
56  std::vector<boost::shared_ptr<TransferElement>> getHardwareAccessingElements() override;
57 
58  std::list<boost::shared_ptr<TransferElement>> getInternalElements() override;
59 
60  void replaceTransferElement(boost::shared_ptr<TransferElement> newElement) override;
61  };
62 
63 } // namespace ChimeraTK
ChimeraTK::SubdeviceRegisterAccessor::_accAddress
boost::shared_ptr< NDRegisterAccessor< int32_t > > _accAddress
Pointers to the three accessors.
Definition: SubdeviceRegisterAccessor.h:46
ChimeraTK::SubdeviceRegisterAccessor::isReadOnly
bool isReadOnly() const override
Definition: SubdeviceRegisterAccessor.cc:154
ChimeraTK::SubdeviceRegisterAccessor::_numberOfWords
size_t _numberOfWords
Definition: SubdeviceRegisterAccessor.h:51
ChimeraTK::SubdeviceRegisterAccessor::doWriteTransfer
bool doWriteTransfer(ChimeraTK::VersionNumber versionNumber) override
Definition: SubdeviceRegisterAccessor.cc:32
ChimeraTK::SubdeviceRegisterAccessor::_buffer
std::vector< int32_t > _buffer
internal buffer
Definition: SubdeviceRegisterAccessor.h:54
ChimeraTK::SubdeviceRegisterAccessor::isReadable
bool isReadable() const override
Definition: SubdeviceRegisterAccessor.cc:160
ChimeraTK::SubdeviceRegisterAccessor::getInternalElements
std::list< boost::shared_ptr< TransferElement > > getInternalElements() override
Definition: SubdeviceRegisterAccessor.cc:178
NDRegisterAccessor.h
ChimeraTK::SubdeviceRegisterAccessor::doPreWrite
void doPreWrite(TransferType type, VersionNumber) override
Definition: SubdeviceRegisterAccessor.cc:115
ChimeraTK::SubdeviceRegisterAccessor::getHardwareAccessingElements
std::vector< boost::shared_ptr< TransferElement > > getHardwareAccessingElements() override
Definition: SubdeviceRegisterAccessor.cc:172
ChimeraTK::SubdeviceRegisterAccessor::doPreRead
void doPreRead(TransferType type) override
Definition: SubdeviceRegisterAccessor.cc:103
ChimeraTK::SubdeviceRegisterAccessor::_accDataArea
boost::shared_ptr< NDRegisterAccessor< int32_t > > _accDataArea
Definition: SubdeviceRegisterAccessor.h:47
ChimeraTK::SubdeviceRegisterAccessor::_backend
boost::shared_ptr< SubdeviceBackend > _backend
Pointer to the backend.
Definition: SubdeviceRegisterAccessor.h:43
ChimeraTK::SubdeviceRegisterAccessor::_startAddress
size_t _startAddress
start address and length
Definition: SubdeviceRegisterAccessor.h:51
ChimeraTK::TransferType
TransferType
Used to indicate the applicable operation on a Transferelement.
Definition: TransferElement.h:51
ChimeraTK::SubdeviceRegisterAccessor::doReadTransferSynchronously
void doReadTransferSynchronously() override
Definition: SubdeviceRegisterAccessor.cc:26
ChimeraTK::SubdeviceRegisterAccessor::_accStatus
boost::shared_ptr< NDRegisterAccessor< int32_t > > _accStatus
Definition: SubdeviceRegisterAccessor.h:48
ChimeraTK::SubdeviceRegisterAccessor::doPostWrite
void doPostWrite(TransferType type, VersionNumber) override
Definition: SubdeviceRegisterAccessor.cc:142
ChimeraTK::SubdeviceRegisterAccessor::SubdeviceRegisterAccessor
SubdeviceRegisterAccessor(boost::shared_ptr< SubdeviceBackend > backend, const std::string &registerPathName, boost::shared_ptr< NDRegisterAccessor< int32_t >> accAddress, boost::shared_ptr< NDRegisterAccessor< int32_t >> accDataArea, boost::shared_ptr< NDRegisterAccessor< int32_t >> accStatus, size_t byteOffset, size_t numberOfWords)
Definition: SubdeviceRegisterAccessor.cc:12
ChimeraTK::SubdeviceRegisterAccessor::replaceTransferElement
void replaceTransferElement(boost::shared_ptr< TransferElement > newElement) override
Definition: SubdeviceRegisterAccessor.cc:184
ChimeraTK::VersionNumber
Class for generating and holding version numbers without exposing a numeric representation.
Definition: VersionNumber.h:23
ChimeraTK::SubdeviceRegisterAccessor::mayReplaceOther
bool mayReplaceOther(const boost::shared_ptr< TransferElement const > &) const override
Definition: SubdeviceRegisterAccessor.cc:148
SubdeviceBackend.h
ChimeraTK
Definition: DummyBackend.h:16
ChimeraTK::SubdeviceRegisterAccessor::doPostRead
void doPostRead(TransferType type, bool hasNewData) override
Definition: SubdeviceRegisterAccessor.cc:109
ChimeraTK::NDRegisterAccessor
N-dimensional register accessor.
Definition: ForwardDeclarations.h:17
ChimeraTK::SubdeviceRegisterAccessor::isWriteable
bool isWriteable() const override
Definition: SubdeviceRegisterAccessor.cc:166
ChimeraTK::SubdeviceRegisterAccessor
Definition: SubdeviceRegisterAccessor.h:14