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

do not use deprecated DOOCS API and fix some warnings

parent 05ee1a5c
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,6 @@
#define D_TEXTUNIFIER_H
#include <d_fct.h>
#include <eq_sts_codes.h>
/** A compatibility class that adds the constructor which would create a history,
* and the set_and_archive function to the D_text interface. As this does not
......@@ -14,9 +13,8 @@ struct D_textUnifier : public D_text {
using D_text::D_text;
D_textUnifier(EqFct* eqFct, std::string doocsPropertyName);
/// \todo FIXE: eq_sts_codes will be deprecated, but currently is require to compile with the latest pubilshed doocs release
/// It will be changed to ArchiveStatus.
void set_and_archive(const std::string& str, eq_sts_codes status = sts_ok, u_int seconds = 0, u_int microseconds = 0);
void set_and_archive(
const std::string& str, ArchiveStatus status, doocs::Timestamp timestamp, doocs::EventId eventId);
D_hist* get_histPointer();
};
......
......@@ -66,9 +66,13 @@ namespace ChimeraTK {
// will be activated), but we have to if it is there. -> Abstraction,
// please!
if(this->get_histPointer()) {
// Set eventId
doocs::EventId eventId;
if(_macroPulseNumberSource) eventId = doocs::EventId(_macroPulseNumberSource->accessData(0));
/*FIXME: The archiver also has a status code. Set it correctly.*/
// The timestamp we give with set_and_archive is for the archiver only.
this->set_and_archive(data, sts_ok /*default*/, seconds, microseconds / 1000);
this->set_and_archive(data, ArchiveStatus::sts_ok, timestamp, eventId);
}
else {
this->set_value(data);
......
......@@ -3,8 +3,7 @@
// just call the constructor without history (the only one)
D_textUnifier::D_textUnifier(EqFct* eqFct, std::string doocsPropertyName) : D_text(doocsPropertyName, eqFct) {}
void D_textUnifier::set_and_archive(
const std::string& str, eq_sts_codes /*status*/, u_int /*seconds*/, u_int /*microseconds*/) {
void D_textUnifier::set_and_archive(const std::string& str, ArchiveStatus, doocs::Timestamp, doocs::EventId) {
set_value(str);
}
......
......@@ -81,24 +81,24 @@ BOOST_AUTO_TEST_CASE(toDeviceFloatTest) {
controlSystemFloat->accessData(0) = 0;
// just write to the doocs scalar, it is automatically sending
DoocsProcessScalar<float, D_float> doocsScalar(NULL, "TO_DEVICE_FLOAT", controlSystemFloat, updater);
DoocsProcessScalar<float, D_float> doocsScalar(nullptr, "TO_DEVICE_FLOAT", controlSystemFloat, updater);
BOOST_CHECK(set_doocs_value(doocsScalar, 12.125) == 0);
BOOST_CHECK(controlSystemFloat->accessData(0) == 12.125);
BOOST_CHECK_CLOSE(controlSystemFloat->accessData(0), 12.125, 0.00001);
// receive on the device side and check that the value has arrived
deviceFloat->readNonBlocking();
BOOST_CHECK(deviceFloat->accessData(0) == 12.125);
BOOST_CHECK_CLOSE(deviceFloat->accessData(0), 12.125, 0.00001);
// check that the value() overloading is working by calling the function of
// the base class (note: cast to a reference, otherwise inheritance/ virtual
// functions calls do not work)
BOOST_CHECK(set_doocs_value(static_cast<D_float&>(doocsScalar), -13.) == 0);
BOOST_CHECK(controlSystemFloat->accessData(0) == -13.);
BOOST_CHECK_CLOSE(controlSystemFloat->accessData(0), -13., 0.00001);
// receive on the device side and check that the value has arrived
deviceFloat->readNonBlocking();
BOOST_CHECK(deviceFloat->accessData(0) == -13.);
BOOST_CHECK_CLOSE(deviceFloat->accessData(0), -13., 0.00001);
}
BOOST_AUTO_TEST_CASE(toDeviceDoubleTest) {
......@@ -117,7 +117,7 @@ BOOST_AUTO_TEST_CASE(toDeviceDoubleTest) {
controlSystemDouble->accessData(0) = 0;
// just write to the doocs scalar, it is automatically sending
DoocsProcessScalar<double, D_double> doocsScalar(NULL, "TO_DEVICE_DOUBLE", controlSystemDouble, updater);
DoocsProcessScalar<double, D_double> doocsScalar(nullptr, "TO_DEVICE_DOUBLE", controlSystemDouble, updater);
BOOST_CHECK(set_doocs_value(doocsScalar, 12.125) == 0);
BOOST_CHECK(controlSystemDouble->accessData(0) == 12.125);
......@@ -130,11 +130,11 @@ BOOST_AUTO_TEST_CASE(toDeviceDoubleTest) {
// the base class (note: cast to a reference, otherwise inheritance/ virtual
// functions calls do not work)
BOOST_CHECK(set_doocs_value(static_cast<D_double&>(doocsScalar), -13.) == 0);
BOOST_CHECK(controlSystemDouble->accessData(0) == -13.);
BOOST_CHECK_CLOSE(controlSystemDouble->accessData(0), -13., 0.00001);
// receive on the device side and check that the value has arrived
deviceDouble->readNonBlocking();
BOOST_CHECK(deviceDouble->accessData(0) == -13.);
BOOST_CHECK_CLOSE(deviceDouble->accessData(0), -13., 0.00001);
}
BOOST_AUTO_TEST_CASE_TEMPLATE(fromDeviceIntegerTypeTest, T, integer_test_types) {
......@@ -262,12 +262,12 @@ BOOST_AUTO_TEST_CASE(fromDeviceFloatTest) {
deviceVariable->accessData(0) = 12.125;
deviceVariable->write();
BOOST_CHECK(controlSystemVariable->accessData(0) == 0.0);
BOOST_CHECK_CLOSE(controlSystemVariable->accessData(0), 0.0, 0.00001);
BOOST_CHECK_CLOSE(doocsScalar.value(), 0.0, 1e-6);
updater.update();
BOOST_CHECK(controlSystemVariable->accessData(0) == 12.125);
BOOST_CHECK(doocsScalar.value() == 12.125);
BOOST_CHECK_CLOSE(controlSystemVariable->accessData(0), 12.125, 0.00001);
BOOST_CHECK_CLOSE(doocsScalar.value(), 12.125, 0.00001);
}
BOOST_AUTO_TEST_CASE(fromDeviceDoubleTest) {
......@@ -291,12 +291,12 @@ BOOST_AUTO_TEST_CASE(fromDeviceDoubleTest) {
deviceVariable->accessData(0) = 12.125;
deviceVariable->write();
BOOST_CHECK(controlSystemVariable->accessData(0) == 0);
BOOST_CHECK(doocsScalar.value() == 0);
BOOST_CHECK_CLOSE(controlSystemVariable->accessData(0), 0, 0.00001);
BOOST_CHECK_CLOSE(doocsScalar.value(), 0, 0.00001);
updater.update();
BOOST_CHECK(controlSystemVariable->accessData(0) == 12.125);
BOOST_CHECK(doocsScalar.value() == 12.125);
BOOST_CHECK_CLOSE(controlSystemVariable->accessData(0), 12.125, 0.00001);
BOOST_CHECK_CLOSE(doocsScalar.value(), 12.125, 0.00001);
}
BOOST_AUTO_TEST_SUITE_END()
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