Commit 8c6025e3 authored by Matias Guijarro's avatar Matias Guijarro
Browse files

Merge branch '2819-add-scan-property-to-sequence-object' into 'master'

Resolve "add scan property to sequence object"

Closes #2819

See merge request bliss/bliss!3794
parents 44df3c82 0df89ab5
Pipeline #49177 passed with stages
in 129 minutes and 30 seconds
......@@ -140,7 +140,7 @@ class Sequence:
def __init__(self, scan_info=None, title="sequence_of_scans"):
self.title = title
self.scan = None
self._scan = None
self._scan_info = ScanInfo.normalize(scan_info)
self._scan_info["is-scan-sequence"] = True
self.custom_channels = dict()
......@@ -161,7 +161,6 @@ class Sequence:
@contextmanager
def sequence_context(self):
self._build_scan()
group_scan = gevent.spawn(self.scan.run)
......@@ -228,8 +227,14 @@ class Sequence:
else:
self.group_custom_slave = None
self.scan = ScanGroup(chain, self.title, save=True, scan_info=self._scan_info)
self.scan.add_preset(StatePreset(self))
self._scan = ScanGroup(chain, self.title, save=True, scan_info=self._scan_info)
self._scan.add_preset(StatePreset(self))
@property
def scan(self):
if self._scan is None:
self._build_scan()
return self._scan
@property
def node(self):
......@@ -242,14 +247,14 @@ class Sequence:
Which is the initial one, or the one published by the scan which publish
this sequence.
"""
if self.scan is None:
if self._scan is None:
return self._scan_info
else:
self.scan.scan_info
@property
def state(self):
if self.scan is None:
if self._scan is None:
return ScanState.IDLE
else:
return self.scan.state
......
......@@ -19,6 +19,7 @@ from bliss.scanning.chain import AcquisitionChannel
from bliss.data.node import get_session_node
from bliss import current_session
from bliss.scanning.scan import ScanState
from bliss.scanning.acquisition.calc import CalcChannelAcquisitionSlave
def test_sequence_terminated_scans(session):
......@@ -443,3 +444,27 @@ def test_sequence_issue_2752(session, scan_meta):
with seq.sequence_context() as ctx:
pass
assert "Failed to prepare scan sequence" in str(excinfo)
def test_sequence_create_scan_before_running(session):
diode = session.config.get("diode")
seq = Sequence()
scan = seq.scan
calc = CalcChannelAcquisitionSlave("", [], None, [])
scan.acq_chain.add(seq.group_acq_master, calc)
nodes_before_running = scan.acq_chain.nodes_list
with seq.sequence_context() as seq_context:
s1 = scans.loopscan(20, .1, diode, run=False)
seq_context.add(s1)
g1 = gevent.spawn(s1.run)
gevent.joinall([g1], raise_error=True)
nodes_after_running = seq.scan.acq_chain.nodes_list
# check that scan sequence does not have been recreated with sequence context
assert nodes_before_running == nodes_after_running
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment