From cf60ee36f9c73ca174aeee0f9f48a9c646bea13b Mon Sep 17 00:00:00 2001 From: TeraMika Date: Tue, 10 Sep 2024 09:17:23 +0100 Subject: [PATCH] #28 Better start/stop acq button, +temp metadata (#11) --- control/src/livex/acquisition/controller.py | 15 ++++++++++++- .../src/components/setup/Trigger.jsx | 21 +++++-------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/control/src/livex/acquisition/controller.py b/control/src/livex/acquisition/controller.py index 9e1ef15..4fc5875 100644 --- a/control/src/livex/acquisition/controller.py +++ b/control/src/livex/acquisition/controller.py @@ -28,6 +28,8 @@ def __init__(self, options): self.acq_frame_target = 1000 self.acq_time = 1 # Time in seconds + self.acquiring = False + # Requires trigger adapter, so is to be built later self.frequency_subtree = {} self.frequencies = {} @@ -115,6 +117,7 @@ def _build_tree(self): """Construct the parameter tree once adapters have been initialised.""" self.param_tree = ParameterTree({ 'acquisition': { + 'acquiring': (lambda: self.acquiring, None), 'start': (lambda: None, self.start_acquisition), 'stop': (lambda: None, self.stop_acquisition), 'time': (lambda: self.acq_time, self.set_acq_time), @@ -125,6 +128,8 @@ def _build_tree(self): def start_acquisition(self, freerun=False): """Start an acquisition. Disable timers, configure all values, then start timers simultaneously.""" + self.acquiring = True + # experiment id is the campaign name plus an incrementing suffix (the acquisition_number) campaign_name = self.iac_get(self.metadata, 'fields/campaign_name/value', param='value') # Spaces in filenames do not play nice with Linux @@ -136,13 +141,14 @@ def start_acquisition(self, freerun=False): furnace_file = experiment_id + "_furnace.hdf5" markdown_file = experiment_id + "_furnace.md" + markdown_filepath = self.filepath + "/logs/acquisitions" self.iac_set(self.metadata, 'fields/acquisition_num', 'value', acquisition_number) self.iac_set(self.metadata, 'fields/experiment_id', 'value', experiment_id) self.iac_set(self.metadata, 'hdf', 'file', furnace_file) self.iac_set(self.metadata, 'hdf', 'path', self.filepath) self.iac_set(self.metadata, 'markdown', 'file', markdown_file) - self.iac_set(self.metadata, 'markdown', 'path', self.filepath) + self.iac_set(self.metadata, 'markdown', 'path', markdown_filepath) # Set file name and path for furnace self.iac_set(self.furnace, 'filewriter', 'filepath', self.filepath) @@ -196,6 +202,8 @@ def start_acquisition(self, freerun=False): def stop_acquisition(self, value): """Stop the acquisition.""" + self.acquiring = False + # All timers can be explicitly disabled (even though they should turn themselves off). self.trigger.set_all_timers(False) @@ -222,6 +230,11 @@ def stop_acquisition(self, value): # Turn off acquisition coil self.iac_set(self.furnace, 'tcp', 'acquire', False) + # Set temperature profile metadata + self.iac_set(self.metadata, 'fields/thermal_gradient_kmm', 'value', self.furnace.controller.gradient.wanted) + self.iac_set(self.metadata, 'fields/thermal_gradient_distance', 'value', self.furnace.controller.gradient.distance), + self.iac_set(self.metadata, 'fields/cooling_rate', 'value', self.furnace.controller.aspc.rate) + # Write out metadata self.iac_set(self.metadata, 'hdf', 'write', True) self.iac_set(self.metadata, 'markdown', 'write', True) diff --git a/control/test/static/livex-react/src/components/setup/Trigger.jsx b/control/test/static/livex-react/src/components/setup/Trigger.jsx index 2581fd5..4901c04 100644 --- a/control/test/static/livex-react/src/components/setup/Trigger.jsx +++ b/control/test/static/livex-react/src/components/setup/Trigger.jsx @@ -224,25 +224,14 @@ function Trigger(props) { - - - - start acquisition - - - - stop acquisition + variant={liveXEndPoint.data.acquisition?.acquiring ? "danger" : "success" }> + {liveXEndPoint.data.acquisition?.acquiring ? "Stop acquisition" : "Start acquisition"}