Skip to content
Snippets Groups Projects
Commit 7ce7a2da authored by Martin Killenberg's avatar Martin Killenberg
Browse files

Fixed timestamp for archiver in DoocsProcessScalar.

By default, the timestamp that is attached to a variable is the global time stamp, which is only set updated by update() in the adapter, which is not used otherwise.
The adapter already was setting it for the time stamp that is attached to the variable itself, but not for the time stamp that used for archiving. This has been fixed. Now the time stamps in the Doocs histories are set correctly.

To test it run example2 of ApplicationCore, togehter with the oven_sim simulation and watch Oven.heatingCurrent.HIST
parent 19cdd51b
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@
#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
......@@ -9,13 +10,14 @@
* This class was introduces to avoid template specialisations in DoocsProcessScalar.
* (Local specialisations of functions don't work because one would have to
*/
struct D_textUnifier: public D_text {
struct D_textUnifier : public D_text {
using D_text::D_text;
D_textUnifier(EqFct* eqFct, std::string doocsPropertyName);
using D_text::D_text;
D_textUnifier(EqFct* eqFct, std::string doocsPropertyName);
void set_and_archive(const std::string &str);
D_hist * get_histPointer ();
/// \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);
D_hist* get_histPointer();
};
#endif // D_TEXTUNIFIER_H
......@@ -49,24 +49,29 @@ namespace ChimeraTK {
this->d_error(no_error);
}
// Convert time stamp from version number in Unix time (seconds and microseconds).
// Note that epoch of std::chrono::system_time might be different from Unix time, and Unix time omits leap seconds
// and hence is not the duration since the epoch! We have to convert to time_t and then find out the microseconds.
auto timestamp = _processScalar->getVersionNumber().getTime();
auto seconds = std::chrono::system_clock::to_time_t(timestamp);
auto microseconds = std::chrono::duration_cast<std::chrono::microseconds>(
timestamp - std::chrono::system_clock::from_time_t(seconds))
.count();
// 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()) {
this->set_and_archive(data);
/*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);
}
else {
this->set_value(data);
}
// Convert time stamp from version number in Unix time (seconds and microseconds).
// Note that epoch of std::chrono::system_time might be different from Unix time, and Unix time omits leap seconds
// and hence is not the duration since the epoch! We have to convert to time_t and then find out the microseconds.
auto timestamp = _processScalar->getVersionNumber().getTime();
auto seconds = std::chrono::system_clock::to_time_t(timestamp);
auto microseconds = std::chrono::duration_cast<std::chrono::microseconds>(
timestamp - std::chrono::system_clock::from_time_t(seconds))
.count();
// We must set the timestamp again so it is correctly attached to the variable. set_and_archive does not to it.
// This must happen after set_and_archive, otherwise the global time stamp is taken.
this->set_tmstmp(seconds, microseconds);
if(_macroPulseNumberSource) this->set_mpnum(_macroPulseNumberSource->accessData(0));
......
#include "D_textUnifier.h"
// just call the constructor without history (the only one)
D_textUnifier::D_textUnifier(EqFct* eqFct, std::string doocsPropertyName)
: D_text(doocsPropertyName, eqFct){
}
D_textUnifier::D_textUnifier(EqFct* eqFct, std::string doocsPropertyName) : D_text(doocsPropertyName, eqFct) {}
void D_textUnifier::set_and_archive(const std::string &str){
set_value(str);
void D_textUnifier::set_and_archive(
const std::string& str, eq_sts_codes /*status*/, u_int /*seconds*/, u_int /*microseconds*/) {
set_value(str);
}
D_hist * D_textUnifier::get_histPointer(){
return nullptr;
D_hist* D_textUnifier::get_histPointer() {
return nullptr;
}
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