Commit 2a498ba0 authored by Perceval Guillou's avatar Perceval Guillou
Browse files

IntegAcqSlave finishes reading before stopping device

parent 7bc47bc5
Pipeline #50571 passed with stages
in 116 minutes and 15 seconds
......@@ -514,30 +514,31 @@ class IntegratingCounterAcquisitionSlave(BaseCounterAcquisitionSlave):
self.start_device()
def stop(self):
# --- call a hook that users can implement in order to stop the associated device
self.stop_device()
self._stop_flag = True
def trigger(self):
pass
def reading(self):
from_index = 0
while (
not self.npoints or self._nb_acq_points < self.npoints
) and not self._stop_flag:
try:
from_index = 0
while (
not self.npoints or self._nb_acq_points < self.npoints
) and not self._stop_flag:
counters = list(self._counters.keys())
data = [
counters[i].conversion_function(x)
for i, x in enumerate(self.device.get_values(from_index, *counters))
]
counters = list(self._counters.keys())
data = [
counters[i].conversion_function(x)
for i, x in enumerate(self.device.get_values(from_index, *counters))
]
if not all_equal([len(d) for d in data]):
raise RuntimeError("Read data can't have different sizes")
if len(data[0]) > 0:
from_index += len(data[0])
self._nb_acq_points += len(data[0])
self._emit_new_data(data)
gevent.sleep(0.02)
if not all_equal([len(d) for d in data]):
raise RuntimeError("Read data can't have different sizes")
if len(data[0]) > 0:
from_index += len(data[0])
self._nb_acq_points += len(data[0])
self._emit_new_data(data)
gevent.sleep(0.02)
finally: # killing the reading task raise an exception in the try above
self.stop_device()
......@@ -230,7 +230,11 @@ class CT2CounterAcquisitionSlave(IntegratingCounterAcquisitionSlave):
event.disconnect(
self.device._master_controller.server, DataSignal, self.rx_data
)
def stop(self):
self._stop_flag = True
self.__buffer_event.set()
self.stop_device()
def rx_data(self, data, signal):
self.__buffer.extend(data)
......
......@@ -12,7 +12,6 @@ import numpy
from bliss.scanning.chain import AcquisitionMaster, AcquisitionSlave
from bliss.scanning.channel import AcquisitionChannel
from bliss.scanning.acquisition.counter import IntegratingCounterAcquisitionSlave
class MusstDefaultAcquisitionMaster(AcquisitionMaster):
......
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