Commit 25ffbdb7 authored by Sebastien Petitdemange's avatar Sebastien Petitdemange
Browse files

measument: added callback methods (prepare,start,stop) in Counter.

parent 2ea1f3aa
...@@ -222,7 +222,7 @@ class GroupedReadMixin(object): ...@@ -222,7 +222,7 @@ class GroupedReadMixin(object):
def start(self, *counters): def start(self, *counters):
pass pass
def end(self, *counters): def stop(self, *counters):
pass pass
class Counter(object): class Counter(object):
...@@ -237,6 +237,15 @@ class Counter(object): ...@@ -237,6 +237,15 @@ class Counter(object):
@property @property
def name(self): def name(self):
return self.__name return self.__name
def prepare(self):
pass
def start(self):
pass
def stop(self):
pass
class SamplingCounter(Counter): class SamplingCounter(Counter):
class GroupedReadHandler(GroupedReadMixin): class GroupedReadHandler(GroupedReadMixin):
...@@ -263,7 +272,7 @@ class SamplingCounter(Counter): ...@@ -263,7 +272,7 @@ class SamplingCounter(Counter):
try: try:
return grouped_read_handler.read(self)[0] return grouped_read_handler.read(self)[0]
finally: finally:
grouped_read_handler.end(self) grouped_read_handler.stop(self)
def DefaultSamplingCounterGroupedReadHandler(controller, handlers=weakref.WeakValueDictionary()): def DefaultSamplingCounterGroupedReadHandler(controller, handlers=weakref.WeakValueDictionary()):
class DefaultSamplingCounterGroupedReadHandler(SamplingCounter.GroupedReadHandler): class DefaultSamplingCounterGroupedReadHandler(SamplingCounter.GroupedReadHandler):
......
...@@ -95,15 +95,19 @@ class SamplingCounterAcquisitionDevice(BaseCounterAcquisitionDevice): ...@@ -95,15 +95,19 @@ class SamplingCounterAcquisitionDevice(BaseCounterAcquisitionDevice):
self.__mode = value self.__mode = value
def prepare(self): def prepare(self):
self.device.prepare(*self.grouped_read_counters)
self._nb_acq_points = 0 self._nb_acq_points = 0
self._stop_flag = False self._stop_flag = False
self._ready_flag = True self._ready_flag = True
self._event.clear() self._event.clear()
def start(self): def start(self):
pass self.device.start(*self.grouped_read_counters)
def stop(self): def stop(self):
self.device.stop(*self.grouped_read_counters)
self._stop_flag = True self._stop_flag = True
self._trig_time = None self._trig_time = None
self._event.set() self._event.set()
...@@ -173,13 +177,15 @@ class IntegratingCounterAcquisitionDevice(BaseCounterAcquisitionDevice): ...@@ -173,13 +177,15 @@ class IntegratingCounterAcquisitionDevice(BaseCounterAcquisitionDevice):
BaseCounterAcquisitionDevice.__init__(self, counter, count_time, auto_add_channel, **keys) BaseCounterAcquisitionDevice.__init__(self, counter, count_time, auto_add_channel, **keys)
def prepare(self): def prepare(self):
self.device.prepare(*self.grouped_read_counters)
self._nb_acq_points = 0 self._nb_acq_points = 0
self._stop_flag = False self._stop_flag = False
def start(self): def start(self):
pass self.device.start(*self.grouped_read_counters)
def stop(self): def stop(self):
self.device.stop(*self.grouped_read_counters)
self._stop_flag = True self._stop_flag = True
def trigger(self): def trigger(self):
......
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