diff --git a/bliss/controllers/pepu.py b/bliss/controllers/pepu.py index c86bb719067688f3aeaa1169d71139ac9c179341..ee5e6c41e9116f20378855cbb2f99f3a74308d54 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 449b40fc2e7c8b6eab4deb935071535280757492..03c3c60124c761704febf7007a1eb3961babeb99 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 248b952d14f93c34580d432004fd93b31f79d52e..d7973ed8e82632f5536b82c8acbe594c8122e2d9 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 7696b9756939d31974e12d18183564cf7b8c462a..bc0a19913d666670394e99ce771cc8cd36b5aab4 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]