4#define BOOST_TEST_DYN_LINK
5#define BOOST_TEST_MODULE DeviceTest
6#include <boost/test/unit_test.hpp>
7using namespace boost::unit_test_framework;
26BOOST_AUTO_TEST_SUITE(DeviceTestSuite)
32 boost::shared_ptr<ChimeraTK::DummyBackend> backend = boost::dynamic_pointer_cast<ChimeraTK::DummyBackend>(
39 std::vector<int32_t> dataVector;
41 wordStatus = 0x444d4d59;
42 data =
device.
read<int32_t>(
"APP0.WORD_STATUS");
43 BOOST_CHECK(data == 0x444d4d59);
46 data =
device.
read<int32_t>(
"APP0.WORD_STATUS");
47 BOOST_CHECK(data == -42);
50 module0[1] = 0xDEADBEEF;
53 BOOST_CHECK(data == 120);
55 dataVector =
device.
read<int32_t>(
"APP0/MODULE0", 2, 0);
56 BOOST_CHECK(dataVector.size() == 2);
57 BOOST_CHECK(dataVector[0] == 120);
58 BOOST_CHECK(dataVector[1] ==
static_cast<signed>(0xDEADBEEF));
63 dataVector =
device.
read<int32_t>(
"APP0/MODULE0", 1, 0);
64 BOOST_CHECK(dataVector.size() == 1);
65 BOOST_CHECK(dataVector[0] == 66);
67 dataVector =
device.
read<int32_t>(
"APP0/MODULE0", 1, 1);
68 BOOST_CHECK(dataVector.size() == 1);
69 BOOST_CHECK(dataVector[0] == -33333);
81 BOOST_CHECK(device1.
isOpened() ==
false);
82 device1.
open(
"DUMMYD0");
83 BOOST_CHECK(device1.
isOpened() ==
true);
84 BOOST_CHECK_NO_THROW(device1.
open(
"DUMMYD0"));
88 device1a.
open(
"DUMMYD0");
89 BOOST_CHECK(device1a.
isOpened() ==
true);
92 BOOST_CHECK(device1.
isOpened() ==
true);
96 device1b.
open(
"DUMMYD0");
98 device1b.
open(
"DUMMYD0");
100 BOOST_CHECK(device1.
isOpened() ==
true);
103 BOOST_CHECK(device2.
isOpened() ==
false);
104 device2.
open(
"DUMMYD1");
105 BOOST_CHECK(device2.
isOpened() ==
true);
106 BOOST_CHECK_NO_THROW(device2.
open(
"DUMMYD1"));
107 BOOST_CHECK(device2.
isOpened() ==
true);
110 BOOST_CHECK(device3.
isOpened() ==
false);
111 BOOST_CHECK_NO_THROW(device3.
open(
"DUMMYD0"));
112 BOOST_CHECK(device3.
isOpened() ==
true);
114 BOOST_CHECK(device4.
isOpened() ==
false);
115 BOOST_CHECK_NO_THROW(device4.
open(
"DUMMYD1"));
116 BOOST_CHECK(device4.
isOpened() ==
true);
120 BOOST_CHECK(device5.
isOpened() ==
false);
122 BOOST_CHECK(device5.
isOpened() ==
false);
124 BOOST_CHECK(device5.
isOpened() ==
false);
127 BOOST_CHECK_NO_THROW(device5.
open(
"DUMMYD0"));
128 BOOST_CHECK(device5.
isOpened() ==
true);
130 BOOST_CHECK_NO_THROW(device5.
open(
"DUMMYD1"));
131 BOOST_CHECK(backend5->isOpen());
132 BOOST_CHECK(device5.
isOpened() ==
true);
136 BOOST_CHECK(backend5->isOpen());
137 BOOST_CHECK(device5.
isOpened() ==
true);
139 BOOST_CHECK(device5.
isOpened() ==
false);
140 BOOST_CHECK(!backend5->isOpen());
142 BOOST_CHECK(device5.
isOpened() ==
true);
143 BOOST_CHECK(backend5->isOpen());
155 std::cout << deviceInfo << std::endl;
156 BOOST_CHECK(deviceInfo.substr(0, 31) ==
"DummyBackend with mapping file ");
172BOOST_AUTO_TEST_SUITE_END()
static BackendFactory & getInstance()
Static function to get an instance of factory.
void setDMapFilePath(std::string dMapFilePath)
This function sets the _DMapFilePath.
std::string getDMapFilePath()
Returns the _DMapFilePath.
Class allows to read/write registers from device.
bool isOpened() const
Check if the device is currently opened.
boost::shared_ptr< DeviceBackend > _deviceBackendPointer
void close()
Close the device.
std::string readDeviceInfo() const
Return a device information string.
bool isFunctional() const
Return wether a device is working as intended, usually this means it is opened and does not have any ...
UserType read(const RegisterPath ®isterPathName, const AccessModeFlags &flags=AccessModeFlags({})) const
Inefficient convenience function to read a single-word register without obtaining an accessor.
void open(std::string const &aliasName)
Open a device by the given alias name from the DMAP file.
Register accessor for accessing single word or 1D array registers internally of a DummyBackend implem...
Exception thrown when a logic error has occured.
boost::shared_ptr< ChimeraTK::DeviceBackend > getBackend()
void setDMapFilePath(std::string dmapFilePath)
Set the location of the dmap file.
BOOST_AUTO_TEST_CASE(testConvenienceReadWrite)