From 5cdc0a0f7748530b9a1ad209121b897718977adb Mon Sep 17 00:00:00 2001 From: Tomasz Kozak <tomasz.kozak@desy.de> Date: Mon, 21 Sep 2020 13:36:04 +0200 Subject: [PATCH] Store in history only first invalid data. Rest of data is not stored. --- include/DoocsProcessScalar.h | 15 ++++++++++++--- src/DoocsIfff.cc | 14 +++++++++++--- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/include/DoocsProcessScalar.h b/include/DoocsProcessScalar.h index e071c52..9b4d23b 100644 --- a/include/DoocsProcessScalar.h +++ b/include/DoocsProcessScalar.h @@ -47,7 +47,14 @@ namespace ChimeraTK { // DoocsUpdater auto data = _processScalar->accessData(0); + bool storeInHistory = true; + auto archiverStatus = ArchiveStatus::sts_ok; if(_processScalar->dataValidity() != ChimeraTK::DataValidity::ok) { + if(this->d_error()) // data are alredy invalid, do not store in history + storeInHistory = false; + + archiverStatus = ArchiveStatus::sts_err; + //set data invalid in DOOCS for current data this->d_error(stale_data); } else { @@ -70,14 +77,16 @@ namespace ChimeraTK { // we must not call set_and_archive if there is no history (otherwise it // will be activated), but we have to if it is there. -> Abstraction, // please! - if(this->get_histPointer()) { + // + // We should also checked if data should be stored (flag storeInHistory). Invalid data should NOT be stored except first invalid data point. + // (https://github.com/ChimeraTK/ControlSystemAdapter-DoocsAdapter/issues/40) + if(this->get_histPointer() && storeInHistory) { // 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, ArchiveStatus::sts_ok, timestamp, eventId); + this->set_and_archive(data, archiverStatus, timestamp, eventId); } else { this->set_value(data); diff --git a/src/DoocsIfff.cc b/src/DoocsIfff.cc index 41f6b68..b3ee22a 100644 --- a/src/DoocsIfff.cc +++ b/src/DoocsIfff.cc @@ -62,10 +62,16 @@ namespace ChimeraTK { return; } + bool storeInHistory = true; + auto archiverStatus = ArchiveStatus::sts_ok; if(_i1Value->dataValidity() != ChimeraTK::DataValidity::ok || _f1Value->dataValidity() != ChimeraTK::DataValidity::ok || _f2Value->dataValidity() != ChimeraTK::DataValidity::ok || _f3Value->dataValidity() != ChimeraTK::DataValidity::ok) { + if(this->d_error()) // data are alredy invalid, do not store in history + storeInHistory = false; + + archiverStatus = ArchiveStatus::sts_err; this->d_error(stale_data); } else { @@ -85,15 +91,17 @@ namespace ChimeraTK { set_global_timestamp(timestamp); } - if(this->get_histPointer()) { + // We should also checked if data should be stored (flag storeInHistory). Invalid data should NOT be stored except first invalid data point. + // (https://github.com/ChimeraTK/ControlSystemAdapter-DoocsAdapter/issues/40) + if(this->get_histPointer() && storeInHistory) { /* doocs::EventId eventId = (_macroPulseNumberSource) ? doocs::EventId(_macroPulseNumberSource->accessData(0)) : doocs::EventId(0); */ - /*FIXME: The archiver also has a status code. Set it correctly.*/ + /*FIXME: This set_and_archive does not support the timestamp yet (only sec and msec, and I guess m is milli?)*/ /*FIXME: This set_and_archive does not support eventIDs yet */ - this->set_and_archive(&ifff, ArchiveStatus::sts_ok, 0, 0 /*msec*/); + this->set_and_archive(&ifff, archiverStatus, 0, 0 /*msec*/); } else { this->set_value(&ifff); -- GitLab