4#define BOOST_TEST_DYN_LINK
5#define BOOST_TEST_MODULE testGroupedDemultiplexing
6#include <boost/test/unit_test.hpp>
7using namespace boost::unit_test_framework;
29 device.
open(
"(ExceptionDummy:1?map=groupedDemux.jmap)");
36 for(
int c = 0; c < 16; ++c) {
37 for(
size_t e = 0; e <
nSamples; ++e) {
38 full[c][e] =
static_cast<int16_t
>(base + c * 10 + e);
46 writeTwoD(
device,
"/TEST/NODMA", base);
52 writeTwoD(
device,
"/TEST/NODMA2", base);
57BOOST_AUTO_TEST_SUITE(GroupedDemultiplexingTestSuite)
66 auto device = openDevice();
72 const std::array<std::array<int16_t, nSamples>, 4> vals = {
73 {{100, 101, 102, 103}, {200, 201, 202, 203}, {30, 31, 32, 33}, {400, 401, 402, 403}}};
74 for(
int c = 0; c < 4; ++c) {
75 for(
size_t s = 0; s <
nSamples; ++s) {
77 std::memcpy(&word, &vals[c][s], 2);
78 area[64 + c + s * 8] = word;
88 const std::vector<int> channels = {3, 1, 0, 2};
89 std::vector<ChimeraTK::OneDRegisterAccessor<int16_t>> accessors;
91 for(
int c : channels) {
93 accessors.push_back(a);
98 for(
size_t i = 0; i < channels.size(); ++i) {
99 const int c = channels[i];
100 for(
size_t e = 0; e <
nSamples; ++e) {
101 BOOST_TEST(accessors[i][e] == vals[c][e]);
106 for(
const auto& accessor : accessors) {
107 BOOST_TEST(accessor.getVersionNumber() == accessors.front().getVersionNumber());
117 auto device = openDevice();
125 BOOST_TEST(!r0.isWriteable());
133 for(
size_t e = 0; e <
nSamples; ++e) {
134 BOOST_TEST(r0[e] ==
static_cast<int16_t
>(9000 + 0 * 10 + e));
135 BOOST_TEST(r5[e] ==
static_cast<int16_t
>(9000 + 5 * 10 + e));
136 BOOST_TEST(r12[e] ==
static_cast<int16_t
>(9000 + 12 * 10 + e));
147 auto device = openDevice();
149 writeNodma2(
device, 4000);
159 group.addAccessor(chA);
160 group.addAccessor(ch4);
161 group.addAccessor(chB);
162 group.addAccessor(ch0);
166 for(
size_t e = 0; e <
nSamples; ++e) {
167 BOOST_TEST(ch0[e] ==
static_cast<int16_t
>(2000 + 10 + e));
168 BOOST_TEST(ch4[e] ==
static_cast<int16_t
>(2000 + 60 + e));
169 BOOST_TEST(chA[e] ==
static_cast<int16_t
>(4000 + e));
170 BOOST_TEST(chB[e] ==
static_cast<int16_t
>(4000 + 90 + e));
171 BOOST_TEST(chC[e] ==
static_cast<int16_t
>(2000 + 150 + e));
175 auto sharedElement = ch0.getHardwareAccessingElements().front();
176 for(
auto* accessor : {&ch4, &chA, &chB, &chC}) {
177 BOOST_TEST(accessor->getHardwareAccessingElements().front().get() == sharedElement.get());
187 auto device = openDevice();
190 const auto versionBefore = scalar.getVersionNumber();
195 BOOST_TEST(scalar ==
static_cast<int16_t
>(1234));
196 BOOST_TEST(scalar.getVersionNumber() > versionBefore);
205 auto device = openDevice();
208 BOOST_REQUIRE_EQUAL(array.getNElements(), 4U);
209 for(
size_t e = 0; e < array.getNElements(); ++e) {
210 array[e] =
static_cast<int16_t
>(700 + e);
215 for(
size_t e = 0; e < array.getNElements(); ++e) {
216 BOOST_TEST(array[e] ==
static_cast<int16_t
>(700 + e));
226 auto device = openDevice();
232 for(
size_t e = 0; e < array.getNElements(); ++e) {
233 array[e] =
static_cast<int16_t
>(800 + e);
242 BOOST_TEST(scalar ==
static_cast<int16_t
>(4321));
243 for(
size_t e = 0; e < array.getNElements(); ++e) {
244 BOOST_TEST(array[e] ==
static_cast<int16_t
>(800 + e));
248 auto sharedElement = scalar.getHardwareAccessingElements().front();
249 BOOST_TEST(array.getHardwareAccessingElements().front().get() == sharedElement.get());
257 auto device = openDevice();
260 for(
size_t e = 0; e < array.getNElements(); ++e) {
261 array[e] =
static_cast<int16_t
>(600 + e);
266 for(
size_t e = 0; e < array.getNElements(); ++e) {
267 BOOST_TEST(array[e] ==
static_cast<int16_t
>(600 + e));
272BOOST_AUTO_TEST_SUITE_END()
Class allows to read/write registers from device.
TwoDRegisterAccessor< UserType > getTwoDRegisterAccessor(const RegisterPath ®isterPathName, size_t numberOfElements=0, size_t elementsOffset=0, const AccessModeFlags &flags=AccessModeFlags({})) const
Get a TwoDRegisterAccessor object for the given register.
void close()
Close the device.
ScalarRegisterAccessor< UserType > getScalarRegisterAccessor(const RegisterPath ®isterPathName, size_t wordOffsetInRegister=0, const AccessModeFlags &flags=AccessModeFlags({})) const
Get a ScalarRegisterObject object for the given register.
OneDRegisterAccessor< UserType > getOneDRegisterAccessor(const RegisterPath ®isterPathName, size_t numberOfWords=0, size_t wordOffsetInRegister=0, const AccessModeFlags &flags=AccessModeFlags({})) const
Get a OneDRegisterAccessor object for the given register.
void open(std::string const &aliasName)
Open a device by the given alias name from the DMAP file.
Group multiple data accessors to efficiently trigger data transfers on the whole group.
void addAccessor(TransferElementAbstractor &accessor)
Add a register accessor to the group.
void read()
Trigger read transfer for all accessors in the group.
This header collects some conversion routines which should be useful both for ApplicationCore Python ...
std::string to_string(const std::string &v)
constexpr size_t nSamples
BOOST_AUTO_TEST_CASE(TestGroupedReadAllChannels)