From c8c1d5dca64b2201920a208e3c31d2ecc05c76b7 Mon Sep 17 00:00:00 2001 From: Martin Killenberg <martin.killenberg@desy.de> Date: Thu, 12 Jan 2023 16:00:00 +0100 Subject: [PATCH] introduce communication delays for more realisitc simulation --- Python_script/VNA_dummy.py | 3 +++ Python_script/climate_chamber_dummy.py | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/Python_script/VNA_dummy.py b/Python_script/VNA_dummy.py index ab85c3c..11a259f 100644 --- a/Python_script/VNA_dummy.py +++ b/Python_script/VNA_dummy.py @@ -35,6 +35,7 @@ class VnaDummy: self.reference_temp = 25 self.magnitude_slope = 0.2 self.phase_slope = 0.1 + self.communication_delay = 0.2 def run_simulation(self): self.simulate_magnitude() @@ -104,6 +105,8 @@ class VnaDummy: measurment_string = ' ' for i in range(50): measurment_string += str(real_val) + ',' + str(imaginary_val) + ',' + # doing the measurement and reading out some time + self.simulated_state.simulated_time += self.communication_delay # removed last comma by adding slicing([:-1]) return measurment_string[:-1] diff --git a/Python_script/climate_chamber_dummy.py b/Python_script/climate_chamber_dummy.py index 457a304..b6741d5 100644 --- a/Python_script/climate_chamber_dummy.py +++ b/Python_script/climate_chamber_dummy.py @@ -28,6 +28,7 @@ class ClimateChamberDummy: self.target_humidity = 35 self.temperature_slope = 0.1 # 0.1 degrees/second self.humidity_slope = 0.5 # degrees/second + self.communication_delay = 0.3 def run_simulation(self): self.simulate_temp() @@ -72,11 +73,13 @@ class ClimateChamberDummy: def read_temperature(self): + self.simulated_state.simulated_time += self.communication_delay # data format: [current temp, set temp, upper limit, lower limit] return [self.simulated_state.simulated_temperature, self.target_temperature, 0., 100.] def read_humidity(self): + self.simulated_state.simulated_time += self.communication_delay # data format: [current temp, set temp, upper limit, lower limit] return [self.simulated_state.simulated_humidity, self.target_humidity, 0., 100.] @@ -86,6 +89,7 @@ class ClimateChamberDummy: self.target_temperature = temperature print('ChamberDummy: target temperature now is ' + str(self.target_temperature)) response = 'OK: TEMP, S30\r\n' + self.simulated_state.simulated_time += self.communication_delay return response def set_humidity(self, humidity): @@ -95,6 +99,7 @@ class ClimateChamberDummy: self.target_humidity = humidity print('ChamberDummy: target humidity now is ' + str(self.target_humidity)) response = 'OK: HUMI, S30\r\n' + self.simulated_state.simulated_time += self.communication_delay return response def close(self): @@ -105,6 +110,7 @@ class ClimateChamberDummy: def set_mode(self, mode): self.simulated_mode = mode response = 'FIXME!!!' + self.simulated_state.simulated_time += self.communication_delay return response def get_const(self): @@ -133,6 +139,7 @@ class ClimateChamberDummy: self.set_humidity(setPoint[1]) def read_mode(self): + self.simulated_state.simulated_time += self.communication_delay return self.simulated_mode # deprecated. Use read_humidity etc. instead -- GitLab