Skip to content

Commit

Permalink
#28 Better start/stop acq button, +temp metadata (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
TeraMika committed Sep 10, 2024
1 parent ebb0016 commit cf60ee3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
15 changes: 14 additions & 1 deletion control/src/livex/acquisition/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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),
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)

Expand All @@ -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)
Expand Down
21 changes: 5 additions & 16 deletions control/test/static/livex-react/src/components/setup/Trigger.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,25 +224,14 @@ function Trigger(props) {
</StatusBox>
</Col>
</Row>

<Row>
<EndPointButton
endpoint={liveXEndPoint}
fullpath={"acquisition/start"}
value={timeFrameValue==='free' ? true : false}
event_type="click">
start acquisition
</EndPointButton>
</Row>
<Row>
<EndPointButton
<EndPointButton style={{}}
endpoint={liveXEndPoint}
fullpath={"acquisition/stop"}
value={true}
fullpath={"acquisition/acquiring"}
value={liveXEndPoint.data.acquisition?.acquiring ? false : true}
event_type="click"
variant="danger"
>
stop acquisition
variant={liveXEndPoint.data.acquisition?.acquiring ? "danger" : "success" }>
{liveXEndPoint.data.acquisition?.acquiring ? "Stop acquisition" : "Start acquisition"}
</EndPointButton>
</Row>
</Container>
Expand Down

0 comments on commit cf60ee3

Please sign in to comment.