5#define BOOST_TEST_MODULE testControlSystemAccessors
11#include <ChimeraTK/BackendFactory.h>
12#include <ChimeraTK/ControlSystemAdapter/ControlSystemPVManager.h>
13#include <ChimeraTK/ControlSystemAdapter/DevicePVManager.h>
14#include <ChimeraTK/ControlSystemAdapter/PVManager.h>
16#include <boost/mpl/list.hpp>
17#include <boost/test/included/unit_test.hpp>
18#include <boost/thread/barrier.hpp>
20using namespace boost::unit_test_framework;
26 using test_types = boost::mpl::list<int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, float, double>;
28#define CHECK_TIMEOUT(condition, maxMilliseconds) \
30 std::chrono::steady_clock::time_point t0 = std::chrono::steady_clock::now(); \
31 while(!(condition)) { \
32 bool timeout_reached = (std::chrono::steady_clock::now() - t0) > std::chrono::milliseconds(maxMilliseconds); \
33 BOOST_CHECK(!timeout_reached); \
34 if(timeout_reached) break; \
45 const std::unordered_set<std::string>& tags = {})
67 ChimeraTK::BackendFactory::getInstance().setDMapFilePath(
"test.dmap");
82 auto pvManagers = ctk::createPVManager();
83 app.setPVManager(pvManagers.second);
88 auto myFeeder = pvManagers.first->getProcessArray<T>(
"/TestModule/feeder");
89 auto consumer = pvManagers.first->getProcessArray<T>(
"/TestModule/consumer");
95 BOOST_TEST(myFeeder->getName() ==
"/TestModule/feeder");
96 BOOST_TEST(myFeeder->getUnit() ==
"MV/m");
97 BOOST_TEST(myFeeder->getDescription() ==
"The test module - Some fancy explanation about this variable");
100 BOOST_CHECK_EQUAL(myFeeder->readNonBlocking(),
false);
102 BOOST_CHECK_EQUAL(myFeeder->readNonBlocking(),
true);
103 BOOST_CHECK_EQUAL(myFeeder->readNonBlocking(),
false);
104 BOOST_CHECK(myFeeder->accessData(0) == 42);
107 BOOST_CHECK_EQUAL(myFeeder->readNonBlocking(),
false);
109 BOOST_CHECK_EQUAL(myFeeder->readNonBlocking(),
true);
110 BOOST_CHECK_EQUAL(myFeeder->readNonBlocking(),
false);
111 BOOST_CHECK(myFeeder->accessData(0) == 120);
120 auto pvManagers = ctk::createPVManager();
121 app.setPVManager(pvManagers.second);
126 auto myConsumer = pvManagers.first->getProcessArray<T>(
"/TestModule/consumer");
127 BOOST_TEST(myConsumer->getName() ==
"/TestModule/consumer");
128 BOOST_TEST(myConsumer->getUnit() ==
"");
129 BOOST_TEST(myConsumer->getDescription() ==
"The test module - No comment.");
131 myConsumer->accessData(0) = 123;
139 myConsumer->accessData(0) = 42;
144 myConsumer->accessData(0) = 120;
void run() override
Execute the module.
void initialise() override
void debugMakeConnections()
Enable debug output for the ConnectionMaker.
void shutdown() override
This will remove the global pointer to the instance and allows creating another instance afterwards.
ApplicationModule()=default
Default constructor: Allows late initialisation of modules (e.g.
InvalidityTracer application module.
boost::mpl::list< int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, float, double > test_types
BOOST_AUTO_TEST_CASE_TEMPLATE(testFeedToCS, T, test_types)
Convenience class for output scalar accessors (always UpdateMode::push)
TestModule< T > testModule
~TestApplication() override
ctk::ScalarOutput< T > feeder
ctk::ScalarPushInput< T > consumer
TestModule(ctk::ModuleGroup *owner, const std::string &name, const std::string &description, const std::unordered_set< std::string > &tags={})
boost::barrier mainLoopStarted
void mainLoop() override
To be implemented by the user: function called in a separate thread executing the main loop of the mo...