Skip to content
Snippets Groups Projects
Commit 41a16fbd authored by Martin Christoph Hierholzer's avatar Martin Christoph Hierholzer
Browse files

necessary update for latest change in the ControlSystemAdapter interface...

necessary update for latest change in the ControlSystemAdapter interface (removal of deprecated functions)
parent f1bde410
No related branches found
No related tags found
No related merge requests found
......@@ -33,11 +33,9 @@ struct BusinessLogic{
ProcessArray<int>::SharedPtr fromDeviceInt;
BusinessLogic(boost::shared_ptr<ChimeraTK::DevicePVManager> const & pvManager)
: toDeviceInt(pvManager->createProcessArray<int>(
controlSystemToDevice, "TO_DEVICE_INT",1) ),
fromDeviceInt(pvManager->createProcessArray<int>(
deviceToControlSystem, "FROM_DEVICE_INT",1) ){
}
: toDeviceInt(pvManager->createProcessArray<int>(controlSystemToDevice, "TO_DEVICE_INT",1)),
fromDeviceInt(pvManager->createProcessArray<int>(deviceToControlSystem, "FROM_DEVICE_INT",1))
{}
};
BOOST_AUTO_TEST_SUITE( CSAdapterEqFctTestSuite )
......@@ -51,7 +49,7 @@ BOOST_AUTO_TEST_CASE( testCSAdapterEqFct ) {
// Test that the right number of properties is created.
// Currently the vector is still empty.
BOOST_CHECK( eqFct.fct_code() == 42);
BOOST_CHECK( eqFct.fct_code() == 42 );
BOOST_REQUIRE( eqFct.getDoocsProperties().size() == 2 );
// extract the two properties and test the send/receive functionality
......@@ -62,8 +60,7 @@ BOOST_AUTO_TEST_CASE( testCSAdapterEqFct ) {
std::map< std::string, D_int *> doocsProperties;
for (size_t i = 0; i < eqFct.getDoocsProperties().size(); ++i){
D_int * doocsInt =
dynamic_cast< D_int * >(eqFct.getDoocsProperties()[i].get() );
D_int *doocsInt = dynamic_cast<D_int*>(eqFct.getDoocsProperties()[i].get());
BOOST_REQUIRE(doocsInt);
doocsProperties[doocsInt->property_name()] = doocsInt;
}
......@@ -75,22 +72,22 @@ BOOST_AUTO_TEST_CASE( testCSAdapterEqFct ) {
// write once and check
set_doocs_value(*(doocsProperties["TO_DEVICE_INT "]),13);
businessLogic.toDeviceInt->readNonBlocking();
BOOST_CHECK( businessLogic.toDeviceInt->accessData(0) == 13 );
BOOST_CHECK_EQUAL( businessLogic.toDeviceInt->accessData(0), 13 );
// change and observe the change in the device
set_doocs_value(*(doocsProperties["TO_DEVICE_INT "]),14);
businessLogic.toDeviceInt->readNonBlocking();
BOOST_CHECK( businessLogic.toDeviceInt->accessData(0) == 14 );
BOOST_CHECK_EQUAL( businessLogic.toDeviceInt->accessData(0), 14 );
// and the other direction
businessLogic.fromDeviceInt->accessData(0) = 12;
businessLogic.fromDeviceInt->write();
eqFct.update();
BOOST_CHECK( doocsProperties["FROM_DEVICE_INT "]->value() == 12);
BOOST_CHECK_EQUAL( doocsProperties["FROM_DEVICE_INT "]->value(), 12);
businessLogic.fromDeviceInt->accessData(0) = 15;
businessLogic.fromDeviceInt->write();
eqFct.update();
BOOST_CHECK( doocsProperties["FROM_DEVICE_INT "]->value() == 15);
BOOST_CHECK_EQUAL( doocsProperties["FROM_DEVICE_INT "]->value(), 15);
}
BOOST_AUTO_TEST_SUITE_END()
......@@ -72,7 +72,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( toDeviceTest, T, simple_test_types ){
// receive on the device side and check that the value has arrived
deviceVariable->readNonBlocking();
std::vector<T> & deviceVector = deviceVariable->get();
std::vector<T> & deviceVector = deviceVariable->accessChannel(0);
for (size_t i =0; i < arraySize; ++i){
std::stringstream errorMessage;
errorMessage << "i = " <<i<< ", deviceVector[i] = "
......@@ -109,14 +109,14 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( fromDeviceTest, T, simple_test_types ){
T sign = (std::numeric_limits<T>::is_signed ? -1 : 1 );
T offset = (std::numeric_limits<T>::is_integer ? sizeof(T) : 1./sizeof(T) );
std::vector<T> & deviceVector = deviceVariable->get();
std::vector<T> & deviceVector = deviceVariable->accessChannel(0);
for (size_t i =0; i < arraySize; ++i){
deviceVector[i] = (sign*static_cast<T>(i*i) + offset) ;
}
deviceVariable->write();
// everything should still be 0 on the CS side
std::vector<T> & csVector = controlSystemVariable->get();
std::vector<T> & csVector = controlSystemVariable->accessChannel(0);
for (size_t i =0; i < arraySize; ++i){
BOOST_CHECK( csVector[i] == 0 );
BOOST_CHECK( doocsArray.read_spectrum(i) == 0 );
......@@ -124,7 +124,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( fromDeviceTest, T, simple_test_types ){
syncUtil.receiveAll();
// The actual vector buffer has changed. We have to get the new reference.
csVector = controlSystemVariable->get();
csVector = controlSystemVariable->accessChannel(0);
for (size_t i =0; i < arraySize; ++i){
BOOST_CHECK( csVector[i] == sign*static_cast<T>(i*i) + offset );
BOOST_CHECK( doocsArray.read_spectrum(i) == sign*static_cast<T>(i*i) + offset );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment