Commit c72638f6 authored by Matias Guijarro's avatar Matias Guijarro Committed by Wout De Nolf
Browse files

scanning, metadata: remove passing of scan meta object in .fill_* methods

parent bbc6d25e
......@@ -122,11 +122,11 @@ class _Base:
def wait_ready(self):
return self.device.wait_ready()
def fill_meta_at_scan_start(self, scan_meta):
return self.device.fill_meta_at_scan_start(scan_meta)
def fill_meta_at_scan_start(self):
return self.device.fill_meta_at_scan_start()
def fill_meta_at_scan_end(self, scan_meta):
return self.device.fill_meta_at_scan_end(scan_meta)
def fill_meta_at_scan_end(self):
return self.device.fill_meta_at_scan_end()
def _all_point_rx(self):
"""
......
......@@ -398,8 +398,8 @@ class FakeAcquisitionSlave(AcquisitionSlave):
# self.channels.update_from_array(data)
# self.channels.update({self.chname: self.positions})
def fill_meta_at_scan_start(self, scan_meta):
tmp_dict = super().fill_meta_at_scan_start(scan_meta)
def fill_meta_at_scan_start(self):
tmp_dict = super().fill_meta_at_scan_start()
for cnt in self._counters:
if isinstance(cnt, HasMetadataForScan):
mdata = cnt.scan_metadata()
......
......@@ -68,8 +68,8 @@ class BaseCounterAcquisitionSlave(AcquisitionSlave):
def _emit_new_data(self, data):
self.channels.update_from_iterable(data)
def fill_meta_at_scan_start(self, scan_meta):
tmp_dict = super().fill_meta_at_scan_start(scan_meta)
def fill_meta_at_scan_start(self):
tmp_dict = super().fill_meta_at_scan_start()
for cnt in self._counters:
if isinstance(cnt, HasMetadataForScan):
mdata = cnt.scan_metadata()
......
......@@ -459,8 +459,8 @@ class LimaAcquisitionMaster(AcquisitionMaster):
return True
return self._reading_task.get()
def fill_meta_at_scan_end(self, scan_meta):
tmp_dict = super().fill_meta_at_scan_end(scan_meta)
def fill_meta_at_scan_end(self):
tmp_dict = super().fill_meta_at_scan_end()
if tmp_dict is None:
tmp_dict = dict()
tmp_dict["acq_parameters"] = self.acq_params
......
......@@ -459,35 +459,26 @@ class AcquisitionObject:
if isinstance(self.device, CounterController):
self.device.apply_parameters(self._ctrl_params)
def fill_meta_at_scan_start(self, scan_meta):
def fill_meta_at_scan_start(self):
"""
In this method, acquisition device should collect any meta data
related to this device and prepare it for publishing. it is called
during the scan initialization.
This can be used in two ways:
1) attaching meta data to the scan_meta object and publishing it in scan_info
i.e: scan_meta.instrument.set(self,{"timing mode":"fast"})
2) the return value of this function is used to fill the meta data of the
node attached to this AcqObj
related to this device. It is called during the scan initialization.
The return value of this function is used to fill the meta data of the
node attached to this AcqObj
"""
device = self.device
if isinstance(device, HasMetadataForScan):
return device.scan_metadata()
return None
def fill_meta_at_scan_end(self, scan_meta):
def fill_meta_at_scan_end(self):
"""
In this method, acquisition device should collect and meta data
related to this device and prepare it for publishing. it is called
at the end of the scan.
This can be used in two ways:
related to this device. It is called at the end of the scan.
1) attaching meta data to the scan_meta object and publishing it in scan_info
i.e: :code:`scan_meta.instrument.set(self,{"timing mode":"fast"})`
2) the return value of this function is used to fill the meta data of the
node attached to this AcqObj
The return value of this function is used to fill the meta data of the
node attached to this AcqObj
"""
return None
......
......@@ -1465,7 +1465,7 @@ class Scan:
for acq_obj in self.acq_chain.nodes_list:
with KillMask(masked_kill_nb=1):
fill_meta = getattr(acq_obj, method_name)
metadata = fill_meta(self.user_scan_meta)
metadata = fill_meta()
# There is a difference between None and an empty dict.
# An empty dict shows up as a group in the Nexus file
# while None does not.
......
......@@ -489,7 +489,7 @@ def test_sequence(test_session_with_flint, lima_simulator):
def create_1d_controller(device_name, fixed_xarray=False, fixed_xchannel=False):
class OneDimAcquisitionSlave(SamplingCounterAcquisitionSlave):
def fill_meta_at_scan_start(self, scan_meta):
def fill_meta_at_scan_start(self):
def get_channel_by_counter_name(name):
for counter, channels in self._counters.items():
if counter.name == name:
......
......@@ -544,9 +544,7 @@ def test_children_timing(beacon, session):
g.kill()
def test_scan_end_timing(
session, scan_meta, dummy_acq_master, dummy_acq_device
): # , clean_gevent):
def test_scan_end_timing(session, scan_meta, dummy_acq_master, dummy_acq_device):
scan_meta.clear()
# Get controllers
......@@ -554,15 +552,12 @@ def test_scan_end_timing(
master = dummy_acq_master.get(None, name="master", npoints=1)
device = dummy_acq_device.get(None, name="device", npoints=1)
def a_slow_func():
def fill_meta_at_scan_end():
# this sleep is the point of the test...
# delay the filling of scan_info
gevent.sleep(.2)
return {"DummyDevice": "slow"}
def fill_meta_at_scan_end(scan_meta):
scan_meta.instrument.set("bla", a_slow_func())
device.fill_meta_at_scan_end = fill_meta_at_scan_end
chain.add(master, device)
......@@ -589,7 +584,7 @@ def test_scan_end_timing(
assert node.info.get("instrument")["some"] == "text"
return
# force existance of scan node before starting the scan
# force existence of scan node before starting the scan
scan._prepare_node()
gg = gevent.spawn(g, scan.node.db_name)
......
......@@ -86,8 +86,8 @@ def test_scan_meta_master_and_device(session, scan_meta):
def __init__(self):
super().__init__(name="my_master")
def fill_meta_at_scan_start(self, scan_meta):
scan_meta.instrument.set(self, master_dict)
def fill_meta_at_scan_start(self):
return master_dict
def prepare(self):
pass
......@@ -114,8 +114,8 @@ def test_scan_meta_master_and_device(session, scan_meta):
def __init__(self):
super().__init__(name=device_name)
def fill_meta_at_scan_start(self, scan_meta):
scan_meta.instrument.set(self, device_dict)
def fill_meta_at_scan_start(self):
return device_dict
def prepare(self):
pass
......
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