Commit f1dc9363 authored by Vincent Michel's avatar Vincent Michel

Use BaseCounter instead of IntegratingCounter

parent 4cebcdd1
Pipeline #6960 failed with stages
in 17 minutes and 7 seconds
......@@ -4,7 +4,8 @@ import numpy
from .mythenlib import MythenInterface
from bliss.common.measurement import IntegratingCounter, counter_namespace
from bliss.common.measurement import BaseCounter, counter_namespace
from bliss.scanning.chain import AcquisitionDevice, AcquisitionChannel
def interface_property(name, mode=False):
......@@ -186,10 +187,21 @@ class Mythen(object):
# Mythen counter
class MythenCounter(IntegratingCounter):
class MythenCounter(BaseCounter):
# Initialization
def __init__(self, controller):
self.acquisition_device = None
super(MythenCounter, self).__init__("spectrum", controller)
self._name = "spectrum"
self._controller = controller
@property
def name(self):
return self._name
@property
def controller(self):
return self._controller
# Data properties
......@@ -204,23 +216,49 @@ class MythenCounter(IntegratingCounter):
# Get acquisition device
def create_acquisition_device(self, scan_pars, **settings):
self.acquisition_device = super(MythenCounter, self).create_acquisition_device(
scan_pars, **settings
scan_pars.update(settings)
count_time = scan_pars.pop("count_time")
return MythenAcquistionDevice(self, count_time, **scan_pars)
class MythenAcquistionDevice(AcquisitionDevice):
# Initialization
def __init__(self, counter, count_time, **kwargs):
self.kwargs = kwargs
self.counter = counter
self.count_time = count_time
valid_names = ("npoints", "trigger_type", "prepare_once", "start_once")
valid_kwargs = {
key: value for key, value in kwargs.items() if key in valid_names
}
super(MythenAcquistionDevice, self).__init__(
counter.controller, counter.controller.name, **valid_kwargs
)
return self.acquisition_device
self.channels.append(
AcquisitionChannel(counter.name, counter.dtype, counter.shape)
)
def add_counter(self, counter):
assert self.counter == counter
# Flow control
def prepare(self):
self.nframes = self.acquisition_device.npoints
self.exposure_time = self.acquisition_device.count_time
self.device.nframes = self.npoints
self.device.exposure_time = self.count_time
def start(self):
self.controller.start()
self.device.start()
def trigger(self):
# Software trigger is not supported by the mythen
pass
def get_value(self, from_index):
return self.controller.readout()
def reading(self):
spectrum = self.device.readout()
self.channels.update({self.counter.name: spectrum})
def stop(self):
self.controller.stop()
self.acquisition_device = None
self.device.stop()
......@@ -145,7 +145,7 @@ def test_mythen_ct_scan(run_command, beacon):
assert list(data[0]) == list(range(1280))
def test_mca_default_chain_with_counter_namespace(run_command, beacon):
def test_mythen_default_chain_with_counter_namespace(run_command, beacon):
m0 = beacon.get("m0")
mythen = beacon.get("mythen1")
scan = scans.ascan(m0, 0, 10, 3, 0.1, mythen, return_scan=True, save=False)
......
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