Public Access
working prototype: stopping with experiment, display data
This commit is contained in:
@@ -59,10 +59,10 @@ import matplotlib.figure
|
||||
from damaris.gui import ExperimentWriter, ExperimentHandling
|
||||
from damaris.gui import ResultReader, ResultHandling
|
||||
from damaris.gui import BackendDriver
|
||||
from damaris.gui.TemperatureMonitor import TemperatureMonitor
|
||||
#from damaris.gui.gtkcodebuffer import CodeBuffer, SyntaxLoader
|
||||
#from damaris.data import Drawable # this is a base class, it should be used...
|
||||
from damaris.data import DataPool, Accumulation, ADC_Result, MeasurementResult
|
||||
from damaris.data import DataPool, Accumulation, ADC_Result, MeasurementResult, TemperatureResult
|
||||
# TemperatureMonitor imported lazily to avoid circular import issues
|
||||
|
||||
# default, can be set to true from start script
|
||||
debug = False
|
||||
@@ -517,6 +517,8 @@ class DamarisGUI:
|
||||
self.data = self.si.data
|
||||
# run frontend and script engines
|
||||
self.monitor.observe_data_pool( self.data )
|
||||
# Start temperature monitoring if configured (before scripts start)
|
||||
self.start_temperature_monitoring(actual_config)
|
||||
self.si.runScripts( )
|
||||
except Exception as e:
|
||||
#print "ToDo evaluate exception",str(e), "at",traceback.extract_tb(sys.exc_info()[2])[-1][1:3]
|
||||
@@ -578,9 +580,6 @@ class DamarisGUI:
|
||||
if actual_config[ "data_pool_name" ] != "":
|
||||
self.dump_states( init=True )
|
||||
|
||||
# Start temperature monitoring if configured
|
||||
self.start_temperature_monitoring(actual_config)
|
||||
|
||||
gobject.timeout_add( 200, self.observe_running_experiment )
|
||||
|
||||
def observe_running_experiment( self ):
|
||||
@@ -693,6 +692,8 @@ class DamarisGUI:
|
||||
|
||||
still_running = [_f for _f in [ self.si.exp_handling, self.si.res_handling, self.si.back_driver, self.dump_thread ] if _f]
|
||||
if len( still_running ) == 0:
|
||||
# Stop temperature monitoring when experiment finishes
|
||||
self.stop_temperature_monitoring()
|
||||
if self.save_thread is None and self.dump_filename != "":
|
||||
print("all subprocesses ended, saving data pool")
|
||||
# thread to save data...
|
||||
@@ -1010,8 +1011,9 @@ class DamarisGUI:
|
||||
temp_interval = config.get("temperature_interval", 2.0)
|
||||
|
||||
try:
|
||||
# Import the factory
|
||||
# Import the factory and TemperatureMonitor (lazy import to avoid circular issues)
|
||||
from damaris.tools.temperature import create_controller
|
||||
from damaris.gui.TemperatureMonitor import TemperatureMonitor
|
||||
|
||||
# Create controller based on type
|
||||
if controller_type == "eurotherm":
|
||||
@@ -2331,18 +2333,20 @@ pygobject version %(pygobject)s
|
||||
"data_pool_comprate": self.config_data_pool_comprate.get_value_as_int( ),
|
||||
"script_font": self.config_script_font_button.get_font_name( ),
|
||||
"adc_bit_depth": self.config_adc_bit_depth_spinbutton.get_value_as_int(),
|
||||
# Temperature monitoring configuration
|
||||
"enable_temperature_monitoring": self.config_temp_monitoring_checkbutton.get_active(),
|
||||
"temperature_controller_type": self.config_temp_controller_type_combobox.get_active_text(),
|
||||
"temperature_device": self.config_temp_device_entry.get_text(),
|
||||
"temperature_baudrate": self._get_temp_baudrate(),
|
||||
"temperature_interval": self.config_temp_interval_spinbutton.get_value()
|
||||
# Temperature monitoring configuration (only if widgets exist)
|
||||
"enable_temperature_monitoring": self.config_temp_monitoring_checkbutton.get_active() if hasattr(self, 'config_temp_monitoring_checkbutton') else False,
|
||||
"temperature_controller_type": self.config_temp_controller_type_combobox.get_active_text() if hasattr(self, 'config_temp_controller_type_combobox') else "eurotherm",
|
||||
"temperature_device": self.config_temp_device_entry.get_text() if hasattr(self, 'config_temp_device_entry') else "",
|
||||
"temperature_baudrate": self._get_temp_baudrate() if hasattr(self, 'config_temp_baudrate_combobox') else 19200,
|
||||
"temperature_interval": self.config_temp_interval_spinbutton.get_value() if hasattr(self, 'config_temp_interval_spinbutton') else 2.0
|
||||
}
|
||||
ADC_Result.default_bit_depth = actual_config["adc_bit_depth"]
|
||||
return actual_config
|
||||
|
||||
def _get_temp_baudrate(self):
|
||||
"""Get selected baud rate from combobox."""
|
||||
if not hasattr(self, 'config_temp_baudrate_combobox'):
|
||||
return 19200
|
||||
active_text = self.config_temp_baudrate_combobox.get_active_text()
|
||||
if active_text:
|
||||
try:
|
||||
@@ -2382,24 +2386,36 @@ pygobject version %(pygobject)s
|
||||
except (ValueError, TypeError):
|
||||
pass
|
||||
|
||||
# Temperature monitoring configuration
|
||||
if "enable_temperature_monitoring" in config:
|
||||
self.config_temp_monitoring_checkbutton.set_active(config["enable_temperature_monitoring"])
|
||||
if "temperature_controller_type" in config:
|
||||
controller_type = config["temperature_controller_type"]
|
||||
if controller_type in ["eurotherm", "simulated"]:
|
||||
self.config_temp_controller_type_combobox.set_active_text(controller_type)
|
||||
# Update widget visibility based on type
|
||||
self._update_temp_widgets_visibility()
|
||||
if "temperature_device" in config:
|
||||
self.config_temp_device_entry.set_text(config["temperature_device"])
|
||||
if "temperature_baudrate" in config:
|
||||
baudrate = str(config["temperature_baudrate"])
|
||||
if baudrate in ["9600", "19200", "38400", "57600", "115200"]:
|
||||
self.config_temp_baudrate_combobox.set_active_text(baudrate)
|
||||
else:
|
||||
self.config_temp_baudrate_combobox.set_active(0) # Default to 19200
|
||||
if "temperature_interval" in config:
|
||||
# Temperature monitoring configuration (only if widgets exist)
|
||||
if hasattr(self, 'config_temp_monitoring_checkbutton') and "enable_temperature_monitoring" in config:
|
||||
try:
|
||||
self.config_temp_monitoring_checkbutton.set_active(bool(config["enable_temperature_monitoring"]))
|
||||
except (TypeError, ValueError):
|
||||
pass
|
||||
if hasattr(self, 'config_temp_controller_type_combobox') and "temperature_controller_type" in config:
|
||||
try:
|
||||
controller_type = config["temperature_controller_type"]
|
||||
if controller_type in ["eurotherm", "simulated"]:
|
||||
self.config_temp_controller_type_combobox.set_active_text(controller_type)
|
||||
# Update widget visibility based on type
|
||||
self._update_temp_widgets_visibility()
|
||||
except (TypeError, ValueError):
|
||||
pass
|
||||
if hasattr(self, 'config_temp_device_entry') and "temperature_device" in config:
|
||||
try:
|
||||
self.config_temp_device_entry.set_text(str(config["temperature_device"]))
|
||||
except (TypeError, ValueError):
|
||||
pass
|
||||
if hasattr(self, 'config_temp_baudrate_combobox') and "temperature_baudrate" in config:
|
||||
try:
|
||||
baudrate = str(config["temperature_baudrate"])
|
||||
if baudrate in ["9600", "19200", "38400", "57600", "115200"]:
|
||||
self.config_temp_baudrate_combobox.set_active_text(baudrate)
|
||||
else:
|
||||
self.config_temp_baudrate_combobox.set_active(0) # Default to 19200
|
||||
except (TypeError, ValueError):
|
||||
pass
|
||||
if hasattr(self, 'config_temp_interval_spinbutton') and "temperature_interval" in config:
|
||||
try:
|
||||
self.config_temp_interval_spinbutton.set_value(float(config["temperature_interval"]))
|
||||
except (ValueError, TypeError):
|
||||
@@ -2459,20 +2475,26 @@ pygobject version %(pygobject)s
|
||||
|
||||
def _update_temp_widgets_visibility(self):
|
||||
"""Show/hide widgets based on selected controller type."""
|
||||
active_type = self.config_temp_controller_type_combobox.get_active_text()
|
||||
# Defensive: check if combobox exists
|
||||
if not hasattr(self, 'config_temp_controller_type_combobox'):
|
||||
return
|
||||
|
||||
if active_type == "eurotherm":
|
||||
# Show device selection widgets
|
||||
self.config_temp_device_hbox.show()
|
||||
self.config_temp_baudrate_hbox.show()
|
||||
elif active_type == "simulated":
|
||||
# Hide device-specific widgets for simulated controller
|
||||
self.config_temp_device_hbox.hide()
|
||||
self.config_temp_baudrate_hbox.hide()
|
||||
else:
|
||||
# Show everything for unknown types
|
||||
self.config_temp_device_hbox.show()
|
||||
self.config_temp_baudrate_hbox.show()
|
||||
active_type = self.config_temp_controller_type_combobox.get_active_text()
|
||||
if active_type is None:
|
||||
active_type = "eurotherm"
|
||||
|
||||
# Defensive: check if widgets exist before showing/hiding
|
||||
show_device = active_type == "eurotherm"
|
||||
if hasattr(self, 'config_temp_device_hbox'):
|
||||
if show_device:
|
||||
self.config_temp_device_hbox.show()
|
||||
else:
|
||||
self.config_temp_device_hbox.hide()
|
||||
if hasattr(self, 'config_temp_baudrate_hbox'):
|
||||
if show_device:
|
||||
self.config_temp_baudrate_hbox.show()
|
||||
else:
|
||||
self.config_temp_baudrate_hbox.hide()
|
||||
|
||||
def load_config_handler( self, widget ):
|
||||
if self.system_default_filename:
|
||||
@@ -3373,7 +3395,7 @@ class MonitorWidgets:
|
||||
if in_result is None:
|
||||
self.clear_display( )
|
||||
return
|
||||
if isinstance( in_result, Accumulation ) or isinstance( in_result, ADC_Result ):
|
||||
if isinstance( in_result, Accumulation ) or isinstance( in_result, ADC_Result ) or isinstance( in_result, TemperatureResult ):
|
||||
|
||||
xmin = in_result.get_xmin( )
|
||||
xmax = in_result.get_xmax( )
|
||||
|
||||
Reference in New Issue
Block a user