本文整理汇总了Python中PyTango.Except.to_dev_failed方法的典型用法代码示例。如果您正苦于以下问题:Python Except.to_dev_failed方法的具体用法?Python Except.to_dev_failed怎么用?Python Except.to_dev_failed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyTango.Except
的用法示例。
在下文中一共展示了Except.to_dev_failed方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _on_pseudo_counter_changed
# 需要导入模块: from PyTango import Except [as 别名]
# 或者: from PyTango.Except import to_dev_failed [as 别名]
def _on_pseudo_counter_changed(self, event_source, event_type,
event_value):
# during server startup and shutdown avoid processing element
# creation events
if SardanaServer.server_state != State.Running:
return
timestamp = time.time()
name = event_type.name.lower()
attr_name = name
# TODO: remove this condition when Data attribute will be substituted
# by ValueBuffer
if name == "valuebuffer":
attr_name = "data"
try:
attr = self.get_attribute_by_name(attr_name)
except DevFailed:
return
quality = AttrQuality.ATTR_VALID
priority = event_type.priority
value, w_value, error = None, None, None
if name == "state":
value = self.calculate_tango_state(event_value)
elif name == "status":
value = self.calculate_tango_status(event_value)
elif name == "valuebuffer":
value = self._encode_value_chunk(event_value)
self._first_read_cache = True
elif name == "value":
if isinstance(event_value, SardanaAttribute):
# first obtain the value - during this process it may
# enter into the error state, either when updating the elements
# values or when calculating the pseudo value
value = event_value.value
if event_value.error:
error = Except.to_dev_failed(*event_value.exc_info)
timestamp = event_value.timestamp
else:
value = event_value
state = self.pseudo_counter.get_state(propagate=0)
if state == State.Moving:
quality = AttrQuality.ATTR_CHANGING
else:
if isinstance(event_value, SardanaAttribute):
if event_value.error:
error = Except.to_dev_failed(*event_value.exc_info)
else:
value = event_value.value
timestamp = event_value.timestamp
self.set_attribute(attr, value=value, w_value=w_value,
timestamp=timestamp, quality=quality,
priority=priority, error=error, synch=False)
示例2: on_controller_changed
# 需要导入模块: from PyTango import Except [as 别名]
# 或者: from PyTango.Except import to_dev_failed [as 别名]
def on_controller_changed(self, event_src, event_type, event_value):
# during server startup and shutdown avoid processing element
# creation events
if SardanaServer.server_state != State.Running:
return
timestamp = time.time()
name = event_type.name.lower()
multi_attr = self.get_device_attr()
try:
attr = multi_attr.get_attr_by_name(name)
except DevFailed:
return
quality = AttrQuality.ATTR_VALID
priority = event_type.priority
error = None
if name == "state":
event_value = self.calculate_tango_state(event_value)
elif name == "status":
event_value = self.calculate_tango_status(event_value)
else:
if isinstance(event_value, SardanaAttribute):
if event_value.error:
error = Except.to_dev_failed(*event_value.exc_info)
timestamp = event_value.timestamp
event_value = event_value.value
self.set_attribute(
attr, value=event_value, timestamp=timestamp, quality=quality, priority=priority, error=error, synch=False
)
示例3: _on_measurement_group_changed
# 需要导入模块: from PyTango import Except [as 别名]
# 或者: from PyTango.Except import to_dev_failed [as 别名]
def _on_measurement_group_changed(self, event_source, event_type, event_value):
# during server startup and shutdown avoid processing element
# creation events
if SardanaServer.server_state != State.Running:
return
timestamp = time.time()
name = event_type.name
name = name.replace('_', '')
multi_attr = self.get_device_attr()
attr = multi_attr.get_attr_by_name(name)
quality = AttrQuality.ATTR_VALID
priority = event_type.priority
error = None
if name == "state":
event_value = self.calculate_tango_state(event_value)
elif name == "status":
event_value = self.calculate_tango_status(event_value)
elif name == "acquisitionmode":
event_value = AcqMode.whatis(event_value)
elif name == "configuration":
cfg = self.measurement_group.get_user_configuration()
codec = CodecFactory().getCodec('json')
_, event_value = codec.encode(('', cfg))
else:
if isinstance(event_value, SardanaAttribute):
if event_value.error:
error = Except.to_dev_failed(*event_value.exc_info)
timestamp = event_value.timestamp
event_value = event_value.value
self.set_attribute(attr, value=event_value, timestamp=timestamp,
quality=quality, priority=priority, error=error,
synch=False)
示例4: on_zerod_changed
# 需要导入模块: from PyTango import Except [as 别名]
# 或者: from PyTango.Except import to_dev_failed [as 别名]
def on_zerod_changed(self, event_source, event_type, event_value):
# during server startup and shutdown avoid processing element
# creation events
if SardanaServer.server_state != State.Running:
return
timestamp = time.time()
name = event_type.name
quality = AttrQuality.ATTR_VALID
priority = event_type.priority
error = None
attr = self.get_device_attr().get_attr_by_name(name)
if name == "state":
event_value = self.calculate_tango_state(event_value)
elif name == "status":
event_value = self.calculate_tango_status(event_value)
else:
if isinstance(event_value, SardanaAttribute):
if event_value.error:
error = Except.to_dev_failed(*event_value.exc_info)
timestamp = event_value.timestamp
event_value = event_value.value
if name == "value":
state = self.zerod.get_state()
if state == State.Moving:
quality = AttrQuality.ATTR_CHANGING
self.set_attribute(attr, value=event_value, timestamp=timestamp,
quality=quality, priority=priority, error=error,
synch=False)
示例5: on_door_changed
# 需要导入模块: from PyTango import Except [as 别名]
# 或者: from PyTango.Except import to_dev_failed [as 别名]
def on_door_changed(self, event_source, event_type, event_value):
# during server startup and shutdown avoid processing element
# creation events
if SardanaServer.server_state != State.Running:
return
timestamp = time.time()
name = event_type.name.lower()
multi_attr = self.get_device_attr()
try:
attr = multi_attr.get_attr_by_name(name)
except DevFailed:
return
if name == "state":
event_value = self.calculate_tango_state(event_value)
elif name == "status":
event_value = self.calculate_tango_status(event_value)
elif name == "recorddata":
format, value = event_value
codec = CodecFactory().getCodec(format)
event_value = codec.encode(('', value))
else:
if isinstance(event_value, SardanaAttribute):
if event_value.error:
error = Except.to_dev_failed(*event_value.exc_info)
timestamp = event_value.timestamp
event_value = event_value.value
if attr.get_data_type() == ArgType.DevEncoded:
codec = CodecFactory().getCodec('json')
event_value = codec.encode(('', event_value))
self.set_attribute(attr, value=event_value, timestamp=timestamp)
示例6: _on_oned_changed
# 需要导入模块: from PyTango import Except [as 别名]
# 或者: from PyTango.Except import to_dev_failed [as 别名]
def _on_oned_changed(self, event_source, event_type, event_value):
# during server startup and shutdown avoid processing element
# creation events
if SardanaServer.server_state != State.Running:
return
timestamp = time.time()
name = event_type.name.lower()
name = name.replace('_', '') # for integration_time events
attr_name = name
# TODO: remove this condition when Data attribute will be substituted
# by ValueBuffer
if name == "valuebuffer":
attr_name = "data"
try:
attr = self.get_attribute_by_name(attr_name)
except DevFailed:
return
quality = AttrQuality.ATTR_VALID
priority = event_type.priority
value, w_value, error = None, None, None
if name == "state":
value = self.calculate_tango_state(event_value)
elif name == "status":
value = self.calculate_tango_status(event_value)
elif name == "valuebuffer":
value = self._encode_value_chunk(event_value)
self._first_read_cache = True
else:
if isinstance(event_value, SardanaAttribute):
if event_value.error:
error = Except.to_dev_failed(*event_value.exc_info)
else:
value = event_value.value
timestamp = event_value.timestamp
else:
value = event_value
if name == "timer" and value is None:
value = "None"
elif name == "value":
w_value = event_source.get_value_attribute().w_value
state = self.oned.get_state()
if state == State.Moving:
quality = AttrQuality.ATTR_CHANGING
self.set_attribute(attr, value=value, w_value=w_value,
timestamp=timestamp, quality=quality,
priority=priority, error=error, synch=False)
示例7: _on_motor_changed
# 需要导入模块: from PyTango import Except [as 别名]
# 或者: from PyTango.Except import to_dev_failed [as 别名]
def _on_motor_changed(self, event_source, event_type, event_value):
# during server startup and shutdown avoid processing element
# creation events
if SardanaServer.server_state != State.Running:
return
timestamp = time.time()
name = event_type.name.lower()
if name == "w_position" and not self.in_write_position:
self.debug("Storing dial set point: %s",
self.motor.dial_position.w_value)
self.set_write_dial_position_to_db()
return
try:
attr = self.get_attribute_by_name(name)
except DevFailed:
return
quality = AttrQuality.ATTR_VALID
priority = event_type.priority
value, w_value, error = None, None, None
if name == "state":
value = self.calculate_tango_state(event_value)
elif name == "status":
value = self.calculate_tango_status(event_value)
else:
if isinstance(event_value, SardanaAttribute):
if event_value.error:
error = Except.to_dev_failed(*event_value.exc_info)
else:
value = event_value.value
timestamp = event_value.timestamp
else:
value = event_value
state = self.motor.get_state(propagate=0)
if name == "position":
w_value = event_source.get_position_attribute().w_value
if state == State.Moving:
quality = AttrQuality.ATTR_CHANGING
elif name == "dialposition" and state == State.Moving:
quality = AttrQuality.ATTR_CHANGING
self.set_attribute(attr, value=value, w_value=w_value,
timestamp=timestamp, quality=quality,
priority=priority, error=error, synch=False)
示例8: _on_motor_group_changed
# 需要导入模块: from PyTango import Except [as 别名]
# 或者: from PyTango.Except import to_dev_failed [as 别名]
def _on_motor_group_changed(self, event_source, event_type, event_value):
# during server startup and shutdown avoid processing element
# creation events
if SardanaServer.server_state != State.Running:
return
timestamp = time.time()
name = event_type.name.lower()
attr = self.get_attribute_by_name(name)
quality = AttrQuality.ATTR_VALID
priority = event_type.priority
value, w_value, error = None, None, None
if name == "state":
value = self.calculate_tango_state(event_value)
elif name == "status":
value = self.calculate_tango_status(event_value)
else:
if isinstance(event_value, SardanaAttribute):
if event_value.error:
error = Except.to_dev_failed(*event_value.exc_info)
else:
value = event_value.value
timestamp = event_value.timestamp
else:
value = event_value
state = self.motor_group.get_state(propagate=0)
if name == "position":
w_value = event_value.w_value
if state == State.Moving:
quality = AttrQuality.ATTR_CHANGING
self.set_attribute(
attr,
value=value,
w_value=w_value,
timestamp=timestamp,
quality=quality,
priority=priority,
error=error,
synch=False,
)
示例9: on_zerod_changed
# 需要导入模块: from PyTango import Except [as 别名]
# 或者: from PyTango.Except import to_dev_failed [as 别名]
def on_zerod_changed(self, event_source, event_type, event_value):
# during server startup and shutdown avoid processing element
# creation events
if SardanaServer.server_state != State.Running:
return
timestamp = time.time()
quality = AttrQuality.ATTR_VALID
priority = event_type.priority
value = None
error = None
name = event_type.name.lower()
attr_name = name
# TODO: remove this condition when Data attribute will be substituted
# by ValueBuffer
if name == "valuebuffer":
attr_name = "data"
attr = self.get_device_attr().get_attr_by_name(attr_name)
if name == "state":
value = self.calculate_tango_state(event_value)
elif name == "status":
value = self.calculate_tango_status(event_value)
elif name == "valuebuffer":
value = self._encode_value_chunk(event_value)
elif name == "value":
if isinstance(event_value, SardanaAttribute):
if event_value.error:
error = Except.to_dev_failed(*event_value.exc_info)
else:
value = event_value.value
timestamp = event_value.timestamp
else:
value = event_value
if name == "value":
state = self.zerod.get_state()
if state == State.Moving:
quality = AttrQuality.ATTR_CHANGING
self.set_attribute(attr, value=value, timestamp=timestamp,
quality=quality, priority=priority, error=error,
synch=False)
示例10: _on_twod_changed
# 需要导入模块: from PyTango import Except [as 别名]
# 或者: from PyTango.Except import to_dev_failed [as 别名]
def _on_twod_changed(self, event_source, event_type, event_value):
# during server startup and shutdown avoid processing element
# creation events
if SardanaServer.server_state != State.Running:
return
timestamp = time.time()
name = event_type.name.lower()
name = name.replace('_', '') # for integration_time events
try:
attr = self.get_attribute_by_name(name)
except DevFailed:
return
quality = AttrQuality.ATTR_VALID
priority = event_type.priority
value, w_value, error = None, None, None
if name == "state":
value = self.calculate_tango_state(event_value)
elif name == "status":
value = self.calculate_tango_status(event_value)
else:
if isinstance(event_value, SardanaAttribute):
if event_value.error:
error = Except.to_dev_failed(*event_value.exc_info)
else:
value = event_value.value
timestamp = event_value.timestamp
else:
value = event_value
if name == "timer" and value is None:
value = "None"
elif name == "value":
state = self.twod.get_state()
if state == State.Moving:
quality = AttrQuality.ATTR_CHANGING
self.set_attribute(attr, value=value, w_value=w_value,
timestamp=timestamp, quality=quality,
priority=priority, error=error, synch=False)