diff --git a/Python_script/prototype.py b/Python_script/prototype.py index 0ab7c2eb837ea2591e083128b58c3fe2243ff5a0..25d6fa1516666fbad882ea1c4ae9f13c2c51bb4b 100755 --- a/Python_script/prototype.py +++ b/Python_script/prototype.py @@ -92,6 +92,9 @@ class Measurements: number_of_soaking_reads = next_soaking / self.sleep_time + 1 do_another_measurement = True + #next_read_time is the starttime of the second read (i.e. read after this one). The time of + #this read (i.e. the first read in the measurement) is now(). + next_read_time = self.clock.time() + self.sleep_time while do_another_measurement: # wait until set point is reached (+soaking time) magnitudes_queue = [] @@ -148,7 +151,8 @@ class Measurements: print('SOAKING FINISHED!') break else: - self.clock.sleep(self.sleep_time) + self.sleep_until(next_read_time) + next_read_time += self.sleep_time # perform the configured number of measurements and check that they are really stable # It started running after everything become stable @@ -171,7 +175,8 @@ class Measurements: if (self.temperature_stable and self.humidity_stable and self.magnitude_stable and self.phase_stable): print('Stable measurement ' + str(i+1) + '/' + str(next_reads)) - self.clock.sleep(self.sleep_time) + self.sleep_until(next_read_time) + next_read_time += self.sleep_time else: all_measurements_stable = False print('Measurement not stable. Retrying.') @@ -193,6 +198,11 @@ class Measurements: standby_response = self.chamber.set_mode('STANDBY') print(standby_response) + def sleep_until(self, wakeup_time): + remaining_sleep_time = wakeup_time - self.clock.time() + if remaining_sleep_time > 0: + self.clock.sleep(remaining_sleep_time) + def read_data(self): [temp, hum, mode, alarms] = self.chamber.read_monitor().split(',') power = self.vna.get_current_power() diff --git a/Python_script/test_stand_parameter.json b/Python_script/test_stand_parameter.json index 5c76f21a1b457ea9cab98cf57b8c32536117c579..00eaddac728001b3b50e700e59cc11e63a02e157 100644 --- a/Python_script/test_stand_parameter.json +++ b/Python_script/test_stand_parameter.json @@ -1 +1 @@ -{"delta_temp": 0.1, "delta_hum": 1, "delta_mag": 0.1 , "delta_phase": 0.02, "sleep_time": 1.0, "frequency": 1300000000, "vna_config_file": "climate-lab.znxml"} +{"delta_temp": 0.1, "delta_hum": 1, "delta_mag": 0.1 , "delta_phase": 0.02, "sleep_time": 10.0, "frequency": 1300000000, "vna_config_file": "climate-lab.znxml"}