Commit 0dd97487 authored by Sebastien Petitdemange's avatar Sebastien Petitdemange

Merge branch 'issue-749' into 'master'

Issue 749: fix missing .fullname in Lima data node object

Closes #749

See merge request bliss/bliss!1296
parents 7a036756 dde4e49c
......@@ -54,9 +54,9 @@ class ChannelDataNode(DataNode):
self.info["shape"] = shape
if dtype is not None:
self.info["dtype"] = dtype
self.info["alias"] = alias or "None"
self.info["has_alias"] = alias is not None
self.info["fullname"] = fullname or "None"
self.info["alias"] = alias or "None"
self.info["fullname"] = fullname
self.info["unit"] = unit
self._queue = None
......@@ -78,7 +78,9 @@ class ChannelDataNode(DataNode):
self._create_queue()
data = event_dict.get("data")
self.info.update(event_dict["description"])
shape = event_dict["description"]["shape"]
if len(shape) == data.ndim:
self._queue.append(data)
else:
......
......@@ -277,20 +277,42 @@ class LimaImageChannelDataNode(DataNode):
def __init__(self, name, **keys):
shape = keys.pop("shape", None)
dtype = keys.pop("dtype", None)
fullname = keys.pop("fullname", None)
DataNode.__init__(self, "lima", name, **keys)
if keys.get("create", False):
self.info["shape"] = shape
self.info["dtype"] = dtype
self.info["fullname"] = fullname
cnx = self.db_connection
self.data = QueueObjSetting("%s_data" % self.db_name, connection=cnx)
self.data = QueueObjSetting(
"%s_data" % self.db_name, connection=self.db_connection
)
self._new_image_status_event = gevent.event.Event()
self._new_image_status = dict()
self._storage_task = None
self.from_stream = False
@property
def shape(self):
return self.info.get("shape")
@property
def dtype(self):
return self.info.get("dtype")
@property
def fullname(self):
return self.info.get("fullname")
@property
def db_name(self):
fullname = self.fullname or self.name
d = {x: None for x in self.parent.db_name.split(":")}
d.update({x: None for x in fullname.split(":")})
return ":".join(d.keys())
def __close__(self):
if self._storage_task is None:
return
......@@ -329,6 +351,8 @@ class LimaImageChannelDataNode(DataNode):
self.data.append(ref_status)
self.add_reference_data(desc)
else:
self.info.update(desc)
self._new_image_status.update(data)
self._new_image_status_event.set()
......
......@@ -51,7 +51,7 @@ def test_scan_node(session, redis_data_conn, scan_tmpdir):
scan_saving.base_path = str(scan_tmpdir)
parent = scan_saving.get_parent_node()
m = getattr(setup_globals, "roby")
m.velocity = 10
m.velocity = 5
diode = getattr(setup_globals, "diode")
chain = AcquisitionChain()
......@@ -187,6 +187,20 @@ def test_data_iterator_event(beacon, redis_data_conn, scan_tmpdir, session):
assert isinstance(n, ChannelDataNode)
def test_lima_data_channel_node(redis_data_conn, lima_session):
lima_sim = getattr(setup_globals, "lima_simulator")
timescan = scans.timescan(0.1, lima_sim, npoints=1)
session_node = get_node(lima_session.name)
image_node_db_name = "%s:timer:lima_simulator:image" % timescan.node.db_name
image_node = _get_or_create_node(image_node_db_name)
assert image_node.db_name == image_node_db_name
assert image_node.fullname == "lima_simulator:image"
assert image_node.shape == (1024, 1024)
assert image_node.dtype == numpy.uint32
@pytest.mark.parametrize("with_roi", [False, True], ids=["without ROI", "with ROI"])
def test_reference_with_lima(redis_data_conn, lima_session, with_roi):
lima_sim = getattr(setup_globals, "lima_simulator")
......@@ -196,7 +210,7 @@ def test_reference_with_lima(redis_data_conn, lima_session, with_roi):
if with_roi:
lima_sim.roi_counters["myroi"] = [0, 0, 1, 1]
timescan = scans.timescan(0.1, lima_sim, npoints=3, return_scan=True)
timescan = scans.timescan(0.1, lima_sim, npoints=3)
session_node = get_node(lima_session.name)
db_names = set([n.db_name for n in DataNodeIterator(session_node).walk(wait=False)])
......
Markdown is supported
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