Skip to content
Snippets Groups Projects

Resolve L2SDP-1037

Merged Pieter Donker requested to merge L2SDP-1037 into master
1 file
+ 16
10
Compare changes
  • Side-by-side
  • Inline
+ 16
10
@@ -58,7 +58,7 @@ using namespace std;
#define SECONDS_PER_TICK 1
// target offset is set to 100msec after pps to avoid problems with statistics output.
#define TARGET_PPS_MONITOR_OFFSET 0.1
#define TARGET_PPS_MONITOR_OFFSET 0.1
#define TARGET_PPS_MONITOR_OFFSET_MIN (TARGET_PPS_MONITOR_OFFSET - 0.001)
#define TARGET_PPS_MONITOR_OFFSET_MAX (TARGET_PPS_MONITOR_OFFSET + 0.001)
#define MONITOR_DELAY_CHANGE_NS 1000000
@@ -96,7 +96,7 @@ bool timespec_gt(struct timespec ts1, struct timespec ts2)
{
ts1 = timespec_normalise(ts1);
ts2 = timespec_normalise(ts2);
return (ts1.tv_sec > ts2.tv_sec || (ts1.tv_sec == ts2.tv_sec && ts1.tv_nsec > ts2.tv_nsec));
}
@@ -104,14 +104,14 @@ bool timespec_lt(struct timespec ts1, struct timespec ts2)
{
ts1 = timespec_normalise(ts1);
ts2 = timespec_normalise(ts2);
return (ts1.tv_sec < ts2.tv_sec || (ts1.tv_sec == ts2.tv_sec && ts1.tv_nsec < ts2.tv_nsec));
}
struct timespec timespec_diff(struct timespec ts1, struct timespec ts2)
{
struct timespec diff;
ts1 = timespec_normalise(ts1);
ts2 = timespec_normalise(ts2);
@@ -161,10 +161,10 @@ void monitor_timer()
this_thread::sleep_for(chrono::microseconds(1));
clock_gettime(CLOCK_REALTIME, &time_now);
}
// set time seconds for next monitor run
time_next_run.tv_sec = time_now.tv_sec + 1;
SD.uptime++;
LOG_F(DEBUG, "t0 = %11.9f sec", (time_now.tv_sec + (time_now.tv_nsec / 1e9)));
@@ -184,7 +184,7 @@ void monitor_timer()
monitor_start_times = SD.fpga_map->get_all_monitor_start_times();
monitor_start_time.tv_sec = time_now.tv_sec + 1;
monitor_start_time.tv_nsec = time_now.tv_nsec;
for (uint i = 0; i < monitor_start_times.size(); i++) {
if (timespec_lt((monitor_start_times[i]), monitor_start_time)) {
monitor_start_time = (monitor_start_times[i]);
@@ -209,20 +209,26 @@ void monitor_timer()
}
LOG_F(DEBUG, "monitor_pps_offset_time = %11.9f sec", monitor_pps_offset_time);
// measured system-time on hw-pps
struct timespec ts_pps_time;
ts_pps_time.tv_sec = monitor_start_time.tv_sec;
ts_pps_time.tv_nsec = monitor_start_time.tv_nsec - (int64_t)(monitor_pps_offset_time * 1e9);
ts_pps_time = timespec_normalise(ts_pps_time);
// system-time on second change
struct timespec ts_time_now_top;
ts_time_now_top.tv_sec = time_now.tv_sec;
ts_time_now_top.tv_nsec = 0L;
double tod_pps_delta = 0.0;
if (monitor_pps_offset_time != 2.0) {
if (monitor_pps_offset_time != 2.0) {
// save for TR_pps_monitor_delta_R
SD.pps_monitor_delta = monitor_pps_offset_time;
// calc tod_pps_delta, it can be a value from -1.3 .. 1.0
// < 0.0 sdpfw pps is before tod second change
// > 0.0 sdpfw pps is after tod second change
tod_pps_delta = timespec_to_double(timespec_diff(time_now, ts_pps_time)); // tod_pps_delta in seconds
tod_pps_delta = timespec_to_double(timespec_diff(ts_time_now_top, ts_pps_time)); // tod_pps_delta in seconds
}
/* Correct and save for TR_tod_pps_delta_R.
@@ -238,7 +244,7 @@ void monitor_timer()
}
LOG_F(DEBUG, "tod_pps_delta = %11.9f sec", SD.tod_pps_delta);
/* set time for next monitor run. */
// if first run or sdpfw pps missing, do nothing and wait for next pps.
Loading