ChimeraTK-DeviceAccess  03.18.00
testRegisterAccess.cpp
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 #define BOOST_TEST_DYN_LINK
5 #define BOOST_TEST_MODULE RegisterAccessSpecifierTest
6 #include <boost/test/unit_test.hpp>
7 using namespace boost::unit_test_framework;
8 
9 #include "Device.h"
10 
11 using namespace ChimeraTK;
12 
13 BOOST_AUTO_TEST_SUITE(RegisterAccessSpecifierTestSuite)
14 
15 BOOST_AUTO_TEST_CASE(testRegisterAccess) {
16  Device dev;
17  dev.open("(pci:pcieunidummys6?map=registerAccess.map)");
18  BOOST_CHECK(dev.isOpened());
19 
20  // Check RO
21  {
22  auto accessor = dev.getScalarRegisterAccessor<int>("BOARD.WORD_FIRMWARE");
23  BOOST_CHECK(accessor.isReadOnly());
24  BOOST_CHECK(!accessor.isWriteable());
25  BOOST_CHECK(accessor.isReadable());
26  }
27 
28  // Check RW
29  {
30  auto accessor = dev.getScalarRegisterAccessor<int>("ADC.WORD_CLK_DUMMY");
31  BOOST_CHECK(!accessor.isReadOnly());
32  BOOST_CHECK(accessor.isWriteable());
33  BOOST_CHECK(accessor.isReadable());
34  }
35 
36  // Check WO
37  {
38  auto accessor = dev.getScalarRegisterAccessor<int>("ADC.WORD_ADC_ENA");
39  BOOST_CHECK(!accessor.isReadOnly());
40  BOOST_CHECK(accessor.isWriteable());
41  BOOST_CHECK(!accessor.isReadable());
42  }
43 
44  // Check default: Access should be RW
45  {
46  auto accessor = dev.getScalarRegisterAccessor<int>("ADC.WORD_CLK_RST");
47  BOOST_CHECK(!accessor.isReadOnly());
48  BOOST_CHECK(accessor.isWriteable());
49  BOOST_CHECK(accessor.isReadable());
50  }
51 }
52 
53 BOOST_AUTO_TEST_SUITE_END()
Device.h
ChimeraTK::Device
Class allows to read/write registers from device.
Definition: Device.h:39
ChimeraTK::Device::open
void open(std::string const &aliasName)
Open a device by the given alias name from the DMAP file.
Definition: Device.cc:58
ChimeraTK::Device::getScalarRegisterAccessor
ScalarRegisterAccessor< UserType > getScalarRegisterAccessor(const RegisterPath &registerPathName, size_t wordOffsetInRegister=0, const AccessModeFlags &flags=AccessModeFlags({})) const
Get a ScalarRegisterObject object for the given register.
Definition: Device.h:263
ChimeraTK::Device::isOpened
bool isOpened() const
Check if the device is currently opened.
Definition: Device.cc:73
ChimeraTK
Definition: DummyBackend.h:16
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(testRegisterAccess)
Definition: testRegisterAccess.cpp:15