From dffa2df3a663d165cffd61d21ede68b7c637a865 Mon Sep 17 00:00:00 2001 From: Vincent Michel Date: Wed, 7 Feb 2018 19:33:34 +0100 Subject: [PATCH] Fix PEPU scans after hardware tests --- bliss/controllers/pepu.py | 7 ++++++- bliss/scanning/acquisition/pepu.py | 2 +- tests/controllers_hw/pepu.py | 15 +++++++++++++-- tests/scans/test_pepu_scans.py | 3 ++- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/bliss/controllers/pepu.py b/bliss/controllers/pepu.py index c86bb7190..ee5e6c41e 100644 --- a/bliss/controllers/pepu.py +++ b/bliss/controllers/pepu.py @@ -537,7 +537,9 @@ class Stream(object): array.dtype = [(source, array.dtype) for source in self.info.sources] return array - def idata(self, n): + def idata(self, n=None): + if n is None: + n = self.nb_points while n > 0: data = self.read() n -= data.shape[0] @@ -657,6 +659,9 @@ class PEPU(object): self.remove_stream(name) elif name in self.streams: raise ValueError('Stream {0!r} already exists'.format(name)) + # Hack: the PEPU does NOT preserve the source order + if sources: + sources = sorted(sources) info = StreamInfo(name, active, scope, trigger, frequency, nb_points, sources) return self._create_stream(info) diff --git a/bliss/scanning/acquisition/pepu.py b/bliss/scanning/acquisition/pepu.py index 449b40fc2..03c3c6012 100644 --- a/bliss/scanning/acquisition/pepu.py +++ b/bliss/scanning/acquisition/pepu.py @@ -116,7 +116,7 @@ class PepuAcquisitionDevice(AcquisitionDevice): def reading(self): """Spawn by the chain.""" - for data in self.stream.idata(): + for data in self.stream.idata(self.npoints): if data: self.publish(data) diff --git a/tests/controllers_hw/pepu.py b/tests/controllers_hw/pepu.py index 248b952d1..d7973ed8e 100644 --- a/tests/controllers_hw/pepu.py +++ b/tests/controllers_hw/pepu.py @@ -8,6 +8,8 @@ Run with: """ import pytest + +from bliss.common import scans from bliss.controllers.pepu import PEPU, Signal, Trigger pytestmark = pytest.mark.pepu @@ -89,5 +91,14 @@ def test_streams_acquisition(pepu, acquisitions, blocks, block_size): # Read block assert stream.nb_points_ready == block_size data = stream.read(n=block_size) - expected = [[1.5, -1.5]] * block_size - assert data.tolist() == expected + assert data['CALC1'].tolist() == [1.5] * block_size + assert data['CALC2'].tolist() == [-1.5] * block_size + + +def test_timescan(pepu): + scan = scans.timescan( + 0.1, pepu.counters.CALC1, pepu.counters.CALC2, + npoints=3, return_scan=True, save=False) + data = scans.get_data(scan) + assert data['CALC1'].tolist() == [1.5] * 3 + assert data['CALC2'].tolist() == [-1.5] * 3 diff --git a/tests/scans/test_pepu_scans.py b/tests/scans/test_pepu_scans.py index 7696b9756..bc0a19913 100644 --- a/tests/scans/test_pepu_scans.py +++ b/tests/scans/test_pepu_scans.py @@ -24,7 +24,8 @@ def pepu(): trigger = gevent.queue.Queue() - def idata(): + def idata(n): + assert n == len(pepu.mock_points) for point in pepu.mock_points: data = np.array(point) data.dtype = [(counter.name, float) for counter in pepu.counters] -- GitLab