Commit dffa2df3 authored by Vincent Michel's avatar Vincent Michel

Fix PEPU scans after hardware tests

parent c3302228
......@@ -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)
......
......@@ -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)
......
......@@ -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
......@@ -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]
......
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