Commit 493a4c7a authored by Valentin Valls's avatar Valentin Valls
Browse files

Rename 'on_scan_started' into 'on_scan_created'

parent f67d8c57
......@@ -105,9 +105,9 @@ class ScansObserver:
"""
pass
def on_scan_started(self, scan_db_name: str, scan_info: Dict):
def on_scan_created(self, scan_db_name: str, scan_info: Dict):
"""
Called upon scan start.
Called upon scan created (devices are not yet prepared).
Arguments:
scan_db_name: Identifier of the scan
......@@ -336,13 +336,13 @@ class ScansWatcher:
# New scan was created
scan_info = node.info.get_all()
self._running_scans.add(db_name)
observer.on_scan_started(db_name, scan_info)
observer.on_scan_created(db_name, scan_info)
elif node_type == "scan_group":
if self._watch_scan_group:
# New scan was created
scan_info = node.info.get_all()
self._running_scans.add(db_name)
observer.on_scan_started(db_name, scan_info)
observer.on_scan_created(db_name, scan_info)
else:
scan_db_name = self._get_scan_db_name_from_child(db_name)
if scan_db_name is not None:
......@@ -470,7 +470,7 @@ class DefaultScansObserver(ScansObserver):
"""
self._current_event = event
def on_scan_started(self, scan_db_name: str, scan_info: Dict):
def on_scan_created(self, scan_db_name: str, scan_info: Dict):
# Pre-compute mapping from each channels to its master
top_master_per_channels = {}
for top_master, meta in scan_info["acquisition_chain"].items():
......
......@@ -216,9 +216,9 @@ class ScanManager(bliss_scan.ScansObserver):
managed)."""
return scan_db_name in self.__cache
def on_scan_started(self, scan_db_name: str, scan_info: Dict):
def on_scan_created(self, scan_db_name: str, scan_info: Dict):
_logger.info("Scan started: %s", scan_info.get("title", scan_db_name))
_logger.debug("on_scan_started %s", scan_db_name)
_logger.debug("on_scan_created %s", scan_db_name)
if scan_db_name in self.__cache:
# We should receive a single new_scan per scan, but let's check anyway
_logger.debug("new_scan from %s ignored", scan_db_name)
......
......@@ -803,7 +803,7 @@ class ScanPrinterFromRedis(scan_mdl.ScansObserver):
requested_channels = scan_renderer.displayable_channel_names.copy()
scan_renderer.set_displayed_channels(requested_channels)
def on_scan_started(self, scan_db_name: str, scan_info: typing.Dict):
def on_scan_created(self, scan_db_name: str, scan_info: typing.Dict):
self.scan_renderer = ScanRenderer(scan_info)
# Update the displayed channels before printing the scan header
if self.scan_renderer.scan_type != "ct":
......@@ -866,13 +866,13 @@ class ScanDataListener(scan_mdl.ScansObserver):
return None
return ScanPrinterFromRedis(self.scan_display)
def on_scan_started(self, scan_db_name: str, scan_info: typing.Dict):
def on_scan_created(self, scan_db_name: str, scan_info: typing.Dict):
"""Called from Redis callback on scan started"""
if self._scan_displayer is None:
self._scan_displayer = self._create_scan_displayer(scan_info)
if self._scan_displayer is not None:
self._scan_id = scan_db_name
self._scan_displayer.on_scan_started(scan_db_name, scan_info)
self._scan_displayer.on_scan_created(scan_db_name, scan_info)
else:
self._warning_messages.append(
f"\nWarning: a new scan '{scan_db_name}' has been started while scan '{self._scan_id}' is running.\nNew scan outputs will be ignored."
......
......@@ -345,7 +345,7 @@ class PrintScanProgress(scan_mdl.ScansObserver):
def __init__(self):
self._data = {}
def on_scan_started(self, scan_db_name: str, scan_info: typing.Dict):
def on_scan_created(self, scan_db_name: str, scan_info: typing.Dict):
self._data = {}
def on_ndim_data_received(
......
......@@ -35,8 +35,8 @@ SCAN_INFO_3 = {
class MockedScanManager(scan_manager.ScanManager):
def emit_scan_started(self, scan_info):
self.on_scan_started(scan_info["node_name"], scan_info)
def emit_scan_created(self, scan_info):
self.on_scan_created(scan_info["node_name"], scan_info)
def emit_scan_finished(self, scan_info):
self.on_scan_finished(scan_info["node_name"], scan_info)
......@@ -67,12 +67,12 @@ def test_interleaved_scans():
scans = manager.get_alive_scans()
assert len(scans) == 0
manager.emit_scan_started(scan_info_1)
manager.emit_scan_created(scan_info_1)
scans = manager.get_alive_scans()
assert len(scans) == 1
assert scans[0].scanInfo() == scan_info_1
manager.emit_scan_started(scan_info_2)
manager.emit_scan_created(scan_info_2)
manager.emit_scalar_updated(scan_info_1, "axis:roby", numpy.arange(2))
manager.emit_scalar_updated(scan_info_2, "axis:robz", numpy.arange(3))
manager.wait_data_processed()
......@@ -95,7 +95,7 @@ def test_sequencial_scans():
manager = MockedScanManager(flintModel=None)
manager.emit_scan_started(scan_info_1)
manager.emit_scan_created(scan_info_1)
manager.emit_scalar_updated(scan_info_1, "axis:roby", numpy.arange(2))
manager.wait_data_processed()
scans = manager.get_alive_scans()
......@@ -104,7 +104,7 @@ def test_sequencial_scans():
assert manager.get_alive_scans() == []
assert scans[0].scanInfo() == scan_info_1
manager.emit_scan_started(scan_info_2)
manager.emit_scan_created(scan_info_2)
manager.emit_scalar_updated(scan_info_2, "axis:robz", numpy.arange(3))
manager.wait_data_processed()
scans = manager.get_alive_scans()
......@@ -119,7 +119,7 @@ def test_bad_sequence__end_before_new():
manager = MockedScanManager(flintModel=None)
manager.emit_scan_finished(scan_info_1)
manager.emit_scan_started(scan_info_1)
manager.emit_scan_created(scan_info_1)
# FIXME What to do anyway then? The manager is locked
......@@ -170,7 +170,7 @@ def test_image__default():
manager = MockedScanManager(flintModel=None)
manager.emit_scan_started(scan_info_3)
manager.emit_scan_created(scan_info_3)
scan = manager.get_alive_scans()[0]
image = numpy.arange(1).reshape(1, 1)
......@@ -191,7 +191,7 @@ def test_image__disable_video():
manager = MockedScanManager(flintModel=None)
manager.emit_scan_started(scan_info_3)
manager.emit_scan_created(scan_info_3)
scan = manager.get_alive_scans()[0]
image = numpy.arange(1).reshape(1, 1)
......@@ -216,7 +216,7 @@ def test_image__decoding_error():
manager = MockedScanManager(flintModel=None)
manager.emit_scan_started(scan_info_3)
manager.emit_scan_created(scan_info_3)
scan = manager.get_alive_scans()[0]
image = numpy.arange(1).reshape(1, 1)
......@@ -241,7 +241,7 @@ def test_prefered_user_refresh():
manager = MockedScanManager(flintModel=None)
manager.emit_scan_started(scan_info_3)
manager.emit_scan_created(scan_info_3)
scan = manager.get_alive_scans()[0]
channel = scan.getChannelByName("lima:image")
channel.setPreferedRefreshRate("foo", 500)
......@@ -275,7 +275,7 @@ def test_scalar_data_lost():
manager = MockedScanManager(flintModel=None)
# Disabled async consumption
manager.emit_scan_started(scan_info_1)
manager.emit_scan_created(scan_info_1)
scans = manager.get_alive_scans()
assert len(scans) == 1
assert scans[0].scanInfo() == scan_info_1
......
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