From acbd201d166ffa4b1f2bdafdcecbca95d7203443 Mon Sep 17 00:00:00 2001
From: Michael Pawelzik <michael.pawelzik@desy.de>
Date: Fri, 28 Jul 2023 17:34:07 +0200
Subject: [PATCH] bug fixes in protype of measurement class bug fixes import
 teststand json file time unit configuration switched from
 ext_sensor_param.json to test_stand.json host names of meas_equipment devices
 replaced by IP adress -> reason: otherwise no connection possible batch file
 for program start included -> Path in batch must be corrected to location of
 program

------------------
after test with long term run version should be tagged
---
 Python_script/TestStandGUI.bat          |  6 ++++++
 Python_script/climate-lab-gui.py        |  4 ++--
 Python_script/ext_sensor_param.json     |  2 +-
 Python_script/prototype.py              | 26 ++++++++++++-------------
 Python_script/test_stand_parameter.json |  2 +-
 5 files changed, 23 insertions(+), 17 deletions(-)
 create mode 100644 Python_script/TestStandGUI.bat

diff --git a/Python_script/TestStandGUI.bat b/Python_script/TestStandGUI.bat
new file mode 100644
index 0000000..020561a
--- /dev/null
+++ b/Python_script/TestStandGUI.bat
@@ -0,0 +1,6 @@
+@echo off
+cd..
+cd..
+cd C:\climate-lab-test-stand-modified\Python_script & REM path has to be changed to folder with file "climate-lab-gui.py"
+python C:\climate-lab-test-stand-modified\Python_script\climate-lab-gui.py %* & REM Python_script & REM path has to be changed to folder with file "climate-lab-gui.py"
+pause
\ No newline at end of file
diff --git a/Python_script/climate-lab-gui.py b/Python_script/climate-lab-gui.py
index ac4cade..2ab868f 100755
--- a/Python_script/climate-lab-gui.py
+++ b/Python_script/climate-lab-gui.py
@@ -94,7 +94,7 @@ class TestStandMainWindow(QMainWindow):
                 
                 # add ext_sens_data to parameterlist of plot_output method, Michael
                 # ext_sens_data are the imported values from json file ext_sens_data.json , Michael
-                prototype.plot_output(output_basename, temp_extensions, True, config_ext_sens_data, output_basename +
+                prototype.plot_output(output_basename, temp_extensions, True, config_data, config_ext_sens_data, output_basename +
                                       ': Temperature sweep ' + str(temperatures[0]) + '--' +
                                       str(temperatures[-1]) + ' degC @ ' + str(self.fixedParameter.value()) + ' % r.h.')
 
@@ -111,7 +111,7 @@ class TestStandMainWindow(QMainWindow):
                                 
                 # add ext_sens_data to parameterlist of plot_output method, Michael
                 # ext_sens_data are the imported values from json file ext_sens_data.json, Michael 
-                prototype.plot_output(output_basename, hum_extensions, True, config_ext_sens_data, output_basename +
+                prototype.plot_output(output_basename, hum_extensions, True, config_data, config_ext_sens_data, output_basename +
                                       ': Humidity sweep ' + str(humidities[0]) + '--' +
                                       str(humidities[-1]) + ' % r.h. @ ' + str(self.fixedParameter.value()) + ' degC')
 
diff --git a/Python_script/ext_sensor_param.json b/Python_script/ext_sensor_param.json
index a0e69b7..77f69fe 100644
--- a/Python_script/ext_sensor_param.json
+++ b/Python_script/ext_sensor_param.json
@@ -1 +1 @@
-{"ch_temp_dut": "0.0", "ch_hum_dut": "0.1", "ch_temp_room": "1.0" , "ch_hum_room": "1.1", "ch_air_press_room":  "1.3", "ch_temp_meas_inst": "2.0", "ch_hum_meas_inst": "2.1", time_unit": "min"}
+{"ch_temp_dut": "0.0", "ch_hum_dut": "0.1", "ch_temp_room": "1.0" , "ch_hum_room": "1.1", "ch_air_press_room":  "1.3", "ch_temp_meas_inst": "2.0", "ch_hum_meas_inst": "2.1"}
diff --git a/Python_script/prototype.py b/Python_script/prototype.py
index 698189e..a0fd08c 100755
--- a/Python_script/prototype.py
+++ b/Python_script/prototype.py
@@ -52,7 +52,7 @@ class MeasurementData:
         # new variable for measurement instruments temp, Michael
         self.temp_dut = temp_dut
         self.temp_room = temp_room
-        self.temp_meas_equip = temp_meas_instr
+        self.temp_meas_instr = temp_meas_instr
         # new variables for DUT humidity, room humidity, air pressure room, Michael
         self.hum_dut = hum_dut
         self.hum_room = hum_room
@@ -68,7 +68,7 @@ class Measurements:
         self.max_delta_hum = config_data['delta_hum']
         self.max_delta_mag = config_data['delta_mag']
         self.max_delta_phase = config_data['delta_phase']
-        self.ext_sens_data =config_ext_sens_data
+        self.ext_sens_data = config_ext_sens_data
         self.sleep_time = config_data["sleep_time"]
         self.frequency = config_data["frequency"]
         self.vna_config_file = config_data["vna_config_file"]
@@ -76,7 +76,7 @@ class Measurements:
         self.chamber = climate_chamber.create_chamber(chamber_address, target_accuracy)
         self.vna = VNA.create_vna(vna_address, target_accuracy)
         # new object for external sensors, decice 'ALMEMO710', fixed IP in code for device, Michael
-        self.ext_sensors = almemo710.almemo710(ip = logger_adress, wait_time = 1)
+        self.ext_sensors = almemo710.almemo710(ip = logger_adress, timeout = 1)
         self.standby = standby
         self.output_basename = output_basename
         self.clock = virtual_time.get_clock(chamber_address, target_accuracy)
@@ -178,7 +178,7 @@ class Measurements:
                           'READBACK_HUMIDITY', 'RF_POWER', 'RF_FREQUENCY', 'DUT_IDENTIFIER', 'RUN_ID',
                           'EQUILIBRIUM_INDICATOR', 'TEMP_HEATER', 'HUM_HEATER',
                           'TEMP_DUT', 'TEMP_ROOM', 'TEMP_MEAS_INSTR',
-                          'HUM_DUT','HUM_ROOM', 'HUM_MEAS_INSTR', 'AIR_PRESSURE_ROOM',
+                          'HUM_DUT','HUM_ROOM', 'HUM_MEAS_INSTR', 'AIR_PRESS_ROOM',
                           'S11_MAGNITUDE', 'S11_PHASE', 'S12_MAGNITUDE',
                           'S12_PHASE', 'S21_MAGNITUDE', 'S21_PHASE', 'S22_MAGNITUDE', 'S22_PHASE']
             # csv.dict writer add adda row wise
@@ -374,7 +374,7 @@ class Measurements:
             # Humidity for room of external hum sensors added, Michael         
             'HUM_ROOM': data.hum_room,
             # Humidity for measurement instruments of external hum sensors added, Michael         
-            'HUM_MEAS_INSTR': data.hum_instr,            
+            'HUM_MEAS_INSTR': data.hum_meas_instr,            
             # Air pressure for room of external sensors added, Michael
             'AIR_PRESS_ROOM': data.air_press_room,
             'S11_PHASE': self.calculate_mean_phase(data.s11),
@@ -401,6 +401,10 @@ class Measurements:
         
         # request temperatures, humidities and and air pressure from external sensors, Michael
         self.ext_sensors.request_meas_vals_all_channels()
+            
+        # get DUT temperature, room temperature and measurement instruments temperature , Michael 
+        temp_dut = self.ext_sensors.fetch_channel_param_from_meas_buffer(pattern = \
+                                                    self.ext_sens_data['ch_temp_dut'])[0].meas_val
         # get DUT temperature, room temperature and measurement instruments temperature , Michael 
         temp_dut = self.ext_sensors.fetch_channel_param_from_meas_buffer(pattern = \
                                                     self.ext_sens_data['ch_temp_dut'])[0].meas_val
@@ -418,9 +422,7 @@ class Measurements:
         # get air pressure room, Michael 
         air_press_room = self.ext_sensors.fetch_channel_param_from_meas_buffer(pattern = \
                                                     self.ext_sens_data['ch_air_press_room'])[0].meas_val
-        
-        # return temp_dut, temp_room, temp_meas_inst, hum_dut, hum_room, hum_meas_inst,
-        # air_press_room    
+                 
         return temp_dut, temp_room, temp_meas_inst, hum_dut, hum_room, hum_meas_inst, \
             air_press_room
     
@@ -476,13 +478,11 @@ class Measurements:
         return (target_hum-self.max_delta_hum <= float(readback_hum)) and \
                (float(readback_hum) <= target_hum+self.max_delta_hum)
 
-def plot_output(output_basename, measurements_appendices, show_blocking_plot, ext_sens_data, title = ''):
+def plot_output(output_basename, measurements_appendices, show_blocking_plot, config_data, ext_sens_data, title = ''):
     
-    # declaration empty tuple for regression state, plot regression, plot correlation coefficient, Michael  
-
     # set time unit for PostPlot of measurement results to imported value from json file
-    # ext_sens_data.json, Michael
-    time_unit = str(ext_sens_data['time_unit'])                
+    # test_stand_parameter.json, Michael
+    time_unit = str(config_data['time_unit'])                
 
     list_of_frames = []
     # storepath is set to working directory with subfolder Plots, Michael
diff --git a/Python_script/test_stand_parameter.json b/Python_script/test_stand_parameter.json
index 1227c25..377cd13 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.01 , "delta_phase": 1.5, "sleep_time": 10.0, "frequency": 1300000000, "vna_config_file": "CalSetup310M.znxml","chamber_ip":"mskclimate3", "vna_ip":"mskzna43", "data_folder":"measurements", "logger_ip": '192.168.115.94'}
+{"delta_temp": 0.1, "delta_hum": 1, "delta_mag": 0.01 , "delta_phase": 1.5, "sleep_time": 10.0, "frequency": 1300000000, "vna_config_file": "CalSetup2.znxml","chamber_ip":"192.168.115.186", "vna_ip":"192.168.115.39", "data_folder":"measurements", "logger_ip": "192.168.115.94", "time_unit": "min"}
-- 
GitLab