Commit b528a2ed authored by Matias Guijarro's avatar Matias Guijarro
Browse files

Merge branch '2811-stop-reading-before-stopping-device-lite' into 'master'

Resolve "stop reading before stopping device"

Closes #2811

See merge request bliss/bliss!3874
parents 7bc47bc5 2a498ba0
Pipeline #50584 failed with stages
in 102 minutes and 51 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