Commit 4b41c3f6 authored by Sebastien Petitdemange's avatar Sebastien Petitdemange
Browse files

integrating counter: new interface to create counters.

parent eadf1a3d
...@@ -274,3 +274,41 @@ class DefaultSamplingCounterGroupedReadHandler(SamplingCounter.GroupedReadHandle ...@@ -274,3 +274,41 @@ class DefaultSamplingCounterGroupedReadHandler(SamplingCounter.GroupedReadHandle
return self.controller.read_all(*counters) return self.controller.read_all(*counters)
class IntegratingCounter(Counter):
class GroupedReadHandler(GroupedReadMixin):
def get_values(self, from_index, *counters):
this method should return a list of reads values in the same order
as the counter_name
raise NotImplementedError
Base class for integrated counters.
def __init__(self, name, controller, acquisition_controller):
Counter.__init__(self, name, controller, DefaultIntegratingCounterGroupedReadHandler)
self.__acquisition_controller_ref = weakref.ref(acquisition_controller)
def get_values(self, from_index=0):
Overwrite in your class to provide a useful integrated counter class
this method is called after the prepare and start on the master handler.
this method can block until the data is ready or not and return empty data.
When data is ready should return the data from the acquisition
point **from_point_index**
raise NotImplementedError
def acquisition_controller(self):
return self.__acquisition_controller_ref()
class DefaultIntegratingCounterGroupedReadHandler(IntegratingCounter.GroupedReadHandler):
Default read all handler for controller which have read_all method
def get_values(self, from_index, *counters):
return self.controller.get_values(from_index, *counters)
...@@ -142,3 +142,47 @@ class CounterAcqDevice(AcquisitionDevice): ...@@ -142,3 +142,47 @@ class CounterAcqDevice(AcquisitionDevice):
self._ready_flag = True self._ready_flag = True
self._ready_event.set() self._ready_event.set()
class IntegratingAcqDevice(AcquisitionDevice):
def __init__(self,integrating_device,
prepare_once = keys.pop('prepare_once',npoints > 1 and True or False)
start_once = keys.pop('start_once',npoints > 1 and True or False)
npoints = max(1,npoints)
AcquisitionDevice.__init__(self, counter,, "zerod",
self._count_time = count_time
self.channels.append(AcquisitionChannel(,numpy.double, (1,)))
self._nb_acq_points = 0
def prepare(self):
self._nb_acq_points = 0
self._stop_flag = False
def start(self):
def stop(self):
self._stop_flag = True
def trigger(self):
def reading(self):
from_point_index = 0
while self._nb_acq_points < self.npoints and not self._stop_flag:
data = self.device.get_value(from_point_index)
if data:
from_point_index += len(data)
self._nb_acq_points += len(data)
channel_data = {}
{"channel_data": channel_data})
...@@ -10,6 +10,7 @@ from bliss.common.event import dispatcher ...@@ -10,6 +10,7 @@ from bliss.common.event import dispatcher
import time import time
import gevent import gevent
import numpy import numpy
import weakref
class SoftwareTimerMaster(AcquisitionMaster): class SoftwareTimerMaster(AcquisitionMaster):
def __init__(self,count_time,sleep_time=None, **keys): def __init__(self,count_time,sleep_time=None, **keys):
...@@ -55,3 +56,30 @@ class SoftwareTimerMaster(AcquisitionMaster): ...@@ -55,3 +56,30 @@ class SoftwareTimerMaster(AcquisitionMaster):
def stop(self): def stop(self):
pass pass
class IntegratingTimerMaster(object):
def __init__(self):
self.__count_time = 1.
def count_time(self):
return self.__count_time
def count_time(self,value):
self.__count_time = value
def prepare(self):
integrated_devices = [x.device for x in self.slaves]
def start(self):
def trigger(self):
def _prepare(self,integrated_devices):
""" Overwrite in your class if you need it """
def _start(self):
""" Overwrite in your class if you need it """
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