Skip to content
Snippets Groups Projects
Commit e2d464e4 authored by Jens Georg's avatar Jens Georg
Browse files

Throw logic_error when writing to write-only doocs variable

parent 88784458
No related branches found
No related tags found
No related merge requests found
...@@ -103,6 +103,9 @@ namespace ChimeraTK { ...@@ -103,6 +103,9 @@ namespace ChimeraTK {
_processScalar->accessData(0) = this->value(); _processScalar->accessData(0) = this->value();
_processScalar->write(); _processScalar->write();
} }
else {
throw ChimeraTK::logic_error("Trying to write to a non-writable variable");
}
} }
/** /**
......
...@@ -154,7 +154,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(fromDeviceIntegerTypeTest, T, integer_test_types) ...@@ -154,7 +154,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(fromDeviceIntegerTypeTest, T, integer_test_types)
// initialise the doocs scalar // initialise the doocs scalar
DoocsProcessScalar<T, D_int> doocsScalar(NULL, "FROM_DEVICE_VARIABLE", controlSystemVariable, updater); DoocsProcessScalar<T, D_int> doocsScalar(NULL, "FROM_DEVICE_VARIABLE", controlSystemVariable, updater);
BOOST_CHECK(set_doocs_value(doocsScalar, 0) == 0);
deviceVariable->accessData(0) = 42; deviceVariable->accessData(0) = 42;
deviceVariable->write(); deviceVariable->write();
...@@ -185,18 +184,17 @@ BOOST_AUTO_TEST_CASE(fromDeviceFloatTest) { ...@@ -185,18 +184,17 @@ BOOST_AUTO_TEST_CASE(fromDeviceFloatTest) {
devManager->createProcessArray<float>(deviceToControlSystem, "fromDeviceVariable", 1); devManager->createProcessArray<float>(deviceToControlSystem, "fromDeviceVariable", 1);
ProcessArray<float>::SharedPtr controlSystemVariable = csManager->getProcessArray<float>("fromDeviceVariable"); ProcessArray<float>::SharedPtr controlSystemVariable = csManager->getProcessArray<float>("fromDeviceVariable");
// set the variables to 0 // set the variables to 0
deviceVariable->accessData(0) = 0; deviceVariable->accessData(0) = 0.0;
controlSystemVariable->accessData(0) = 0; controlSystemVariable->accessData(0) = 0.0;
// initialise the doocs scalar // initialise the doocs scalar
DoocsProcessScalar<float, D_float> doocsScalar(NULL, "FROM_DEVICE_VARIABLE", controlSystemVariable, updater); DoocsProcessScalar<float, D_float> doocsScalar(nullptr, "FROM_DEVICE_VARIABLE", controlSystemVariable, updater);
BOOST_CHECK(set_doocs_value(doocsScalar, 0) == 0);
deviceVariable->accessData(0) = 12.125; deviceVariable->accessData(0) = 12.125;
deviceVariable->write(); deviceVariable->write();
BOOST_CHECK(controlSystemVariable->accessData(0) == 0); BOOST_CHECK(controlSystemVariable->accessData(0) == 0.0);
BOOST_CHECK(doocsScalar.value() == 0); BOOST_CHECK_CLOSE(doocsScalar.value(), 0.0, 1e-6);
updater.update(); updater.update();
BOOST_CHECK(controlSystemVariable->accessData(0) == 12.125); BOOST_CHECK(controlSystemVariable->accessData(0) == 12.125);
...@@ -219,8 +217,7 @@ BOOST_AUTO_TEST_CASE(fromDeviceDoubleTest) { ...@@ -219,8 +217,7 @@ BOOST_AUTO_TEST_CASE(fromDeviceDoubleTest) {
controlSystemVariable->accessData(0) = 0; controlSystemVariable->accessData(0) = 0;
// initialise the doocs scalar // initialise the doocs scalar
DoocsProcessScalar<double, D_double> doocsScalar(NULL, "FROM_DEVICE_VARIABLE", controlSystemVariable, updater); DoocsProcessScalar<double, D_double> doocsScalar(nullptr, "FROM_DEVICE_VARIABLE", controlSystemVariable, updater);
BOOST_CHECK(set_doocs_value(doocsScalar, 0) == 0);
deviceVariable->accessData(0) = 12.125; deviceVariable->accessData(0) = 12.125;
deviceVariable->write(); deviceVariable->write();
......
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