Bläddra i källkod

timed start measurment time. to syncronize the steady-time with the wall-time the wall-clock call has been surrounded by calls to steady-clock and the half of the difference added as uncertainty parameter, to the config file.

master
Matthias Janke 5 år sedan
förälder
incheckning
efd8184bf0
1 ändrade filer med 3 tillägg och 0 borttagningar
  1. 3
    0
      radangeld/main.cpp

+ 3
- 0
radangeld/main.cpp Visa fil

@@ -79,6 +79,7 @@ struct measurement_properties
79 79
 	std::chrono::time_point<std::chrono::system_clock> starttime;
80 80
 	std::chrono::time_point<std::chrono::system_clock> endtime;
81 81
 
82
+    std::chrono::time_point<std::chrono::steady_clock> starterrortime;
82 83
 	std::chrono::time_point<std::chrono::steady_clock> startmeastime;
83 84
 };
84 85
 
@@ -106,6 +107,7 @@ int writeprotocol (const std::string &filename, measurement_properties &mp)
106 107
 	libconfig::Setting &measurement = root.add ("Measurement", libconfig::Setting::TypeGroup);
107 108
 
108 109
 	measurement.add ("StartTime", libconfig::Setting::TypeString) = date::format ("%F %T ", date::make_zoned (date::current_zone(), mp.starttime) ) + date::current_zone()->name();
110
+	measurement.add ("StartTimeError_ns", libconfig::Setting::TypeInt64) = std::chrono::duration_cast<std::chrono::nanoseconds>(mp.startmeastime-mp.starterrortime).count()/2;
109 111
 	measurement.add ("EndTime", libconfig::Setting::TypeString) = date::format ("%F %T ", date::make_zoned (date::current_zone(), mp.endtime) ) + date::current_zone()->name();
110 112
 	measurement.add ("RunAsDaemon", libconfig::Setting::TypeBoolean) = mp.demonize;
111 113
 	measurement.add ("MaxIntegrationTime_s", libconfig::Setting::TypeInt) = static_cast<int> (mp.maxduration.count() );
@@ -185,6 +187,7 @@ void read_hid_reports (measurement_properties &mp, zmqpp::context &zmqc)
185 187
 	if (mp.demonize)
186 188
 		sd_notifyf(0, "READY=1\nSTATUS=Processing events…\nMAINPID=%lu", (unsigned long) getpid());
187 189
                  
190
+    mp.starterrortime = std::chrono::steady_clock::now();
188 191
 	mp.starttime = std::chrono::system_clock::now();
189 192
 	mp.startmeastime = std::chrono::steady_clock::now();
190 193
 

Laddar…
Avbryt
Spara