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