def prepare_meas(self, params):
     """ Set the measurement group parameters
     """
     synchronization = params["synchronization"]
     codec = CodecFactory().getCodec('json')
     data = codec.encode(('', synchronization))
     self.meas.write_attribute('synchronization', data[1])
 def prepare_meas(self, params):
     """ Set the measurement group parameters
     """
     synchronization = params["synchronization"]
     codec = CodecFactory().getCodec('json')
     data = codec.encode(('', synchronization))
     self.meas.write_attribute('synchronization', data[1])
Beispiel #3
0
class TangoAttributeListener(AttributeListener):

    def __init__(self, data_key="value"):
        AttributeListener.__init__(self)
        codec_name = getattr(sardanacustomsettings, "VALUE_BUFFER_CODEC")
        self._codec = CodecFactory().getCodec(codec_name)
        self._data_key = data_key

    def push_event(self, *args, **kwargs):
        self.event_received(*args, **kwargs)

    def event_received(self, *args, **kwargs):
        try:
            event = args[0]
            if event.err:
                for err in event.errors:
                    if err.reason == 'UnsupportedFeature':
                        # when subscribing for events, Tango does one
                        # readout of the attribute. However the Data
                        # attribute is not fereseen for readout, it is
                        # just the event communication channel.
                        # Ignoring this exception..
                        return
                    else:
                        raise err
            _, _value = self._codec.decode(event.attr_value.value)
            value = _value.get("value") or _value.get("value_ref")
            idx = _value['index']
            dev = event.device
            obj_fullname = _get_full_name(dev)
            # filling the measurement records
            with self.data_lock:
                channel_data = self.data.get(obj_fullname, [])
                expected_idx = len(channel_data)
                pad = [None] * (idx[0] - expected_idx)
                channel_data.extend(pad + value)
                self.data[obj_fullname] = channel_data
        except Exception, e:
            print e
            raise Exception('"data" event callback failed')
Beispiel #4
0
 def __init__(self, data_key="value"):
     AttributeListener.__init__(self)
     codec_name = getattr(sardanacustomsettings, "VALUE_BUFFER_CODEC")
     self._codec = CodecFactory().getCodec(codec_name)
     self._data_key = data_key