rework EnumType to use better Enum's

unfortunately IntEnum can't be bent like we would need it (extensible).
So we had to write our own....

The members of the Enum still behave like ints, but also have
.name and .value attributes, should they be needed.

needed adoptions to correctly use (and test) the EnumType are included.

Change-Id: Ie019d2f449a244c4fab00554b6c6daaac8948b59
Reviewed-on: https://forge.frm2.tum.de/review/17843
Tested-by: JenkinsCodeReview <bjoern_pedersen@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
This commit is contained in:
Enrico Faulhaber
2018-04-26 16:29:09 +02:00
parent 927ca854a2
commit 574a66c65b
15 changed files with 644 additions and 298 deletions

View File

@ -24,7 +24,6 @@ from __future__ import absolute_import
from secop.datatypes import EnumType, FloatRange, StringType
from secop.modules import Readable, Drivable, Param
from secop.protocol import status
try:
from pvaccess import Channel # import EPIVSv4 functionallity, PV access
@ -112,9 +111,9 @@ class EpicsReadable(Readable):
# XXX: Hardware may have it's own idea about the status: how to obtain?
if self.status_pv != 'unset':
# XXX: how to map an unknown type+value to an valid status ???
return status.UNKNOWN, self._read_pv(self.status_pv)
return Drivable.Status.UNKNOWN, self._read_pv(self.status_pv)
# status_pv is unset
return (status.OK, 'no pv set')
return (Drivable.Status.IDLE, 'no pv set')
class EpicsDrivable(Drivable):
@ -179,13 +178,11 @@ class EpicsDrivable(Drivable):
# XXX: Hardware may have it's own idea about the status: how to obtain?
if self.status_pv != 'unset':
# XXX: how to map an unknown type+value to an valid status ???
return status.UNKNOWN, self._read_pv(self.status_pv)
return Drivable.Status.UNKNOWN, self._read_pv(self.status_pv)
# status_pv is unset, derive status from equality of value + target
return (
status.OK,
'') if self.read_value() == self.read_target() else (
status.BUSY,
'Moving')
if self.read_value() == self.read_target():
return (Drivable.Status.OK, '')
return (Drivable.Status.BUSY, 'Moving')
# """Temperature control loop"""
@ -223,11 +220,9 @@ class EpicsTempCtrl(EpicsDrivable):
# XXX: comparison may need to collect a history to detect oscillations
at_target = abs(self.read_value(maxage) - self.read_target(maxage)) \
<= self.tolerance
return (
status.OK,
'at Target') if at_target else (
status.BUSY,
'Moving')
if at_target:
return (Drivable.Status.OK, 'at Target')
return (Drivable.Status.BUSY, 'Moving')
# TODO: add support for strings over epics pv
# def read_heaterrange(self, maxage=0):