Commit 017a0923 authored by Matias Guijarro's avatar Matias Guijarro Committed by Vincent Michel
Browse files

bliss/scanning/chain.py: new AcquisitionChannelList class

Container for AcquisitionChannel objects. Works like a list.
Offers an '.update' method to update channel values, and to
emit the 'new_data' event.
parent 444f2e67
......@@ -13,6 +13,27 @@ import weakref
import numpy as np
class AcquisitionChannelList(list):
def __init__(self, parent, *args, **kwargs):
list.__init__(self, *args, **kwargs)
self.__parent = parent
def update(self, values_dict=None):
"""Update all channels and emit the new_data event
Input:
values_dict - { channel_name: value, ... }
"""
if values_dict:
for channel in self:
channel.value = values_dict[channel.name]
dispatcher.send("new_data", self.__parent, {
"channel_data": dict([(c.name, c.value) for c in self])})
class AcquisitionChannel(object):
def __init__(self, name, dtype, shape):
self.__name = name
......@@ -99,7 +120,7 @@ class AcquisitionMaster(object):
self.__parent = None
self.__slaves = list()
self.__triggers = list()
self.__channels = list()
self.__channels = AcquisitionChannelList(self)
self.__npoints = npoints
#self.__trigger_mode = trigger_mode
self.__trigger_type = trigger_type
......@@ -146,12 +167,6 @@ class AcquisitionMaster(object):
def channels(self):
return self.__channels
@channels.setter
def channels(self, channels_list):
if not isinstance(channels_list, list):
raise TypeError("%s: A channels list is expected." % self.name)
self.__channels = channels_list
@property
def npoints(self):
return self.__npoints
......@@ -222,7 +237,7 @@ class AcquisitionDevice(object):
self.__type = data_type
self._reading_task = None
self.__trigger_type = trigger_type
self.__channels = list()
self.__channels = AcquisitionChannelList(self)
self.__npoints = npoints
self.__prepare_once = prepare_once
self.__start_once = start_once
......@@ -263,12 +278,6 @@ class AcquisitionDevice(object):
def channels(self):
return self.__channels
@channels.setter
def channels(self, channels_list):
if not isinstance(channels_list, list):
raise TypeError("%s: A channels list is expected." % self.name)
self.__channels = channels_list
@property
def npoints(self):
return self.__npoints
......
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