central point for status codes
Put status code definitions into frappy.datatypes.StatusType. frappy.datatypes is anyway imported in servers and clients, so this is a better place than frappy.modules. Change-Id: I81dfc8a066f598fbd20854ed1a13b937b7facc8c Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/30703 Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de> Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
parent
349c510555
commit
9bf187758b
@ -45,7 +45,7 @@ import re
|
|||||||
from queue import Queue
|
from queue import Queue
|
||||||
from frappy.client import SecopClient
|
from frappy.client import SecopClient
|
||||||
from frappy.errors import SECoPError
|
from frappy.errors import SECoPError
|
||||||
from frappy.datatypes import get_datatype
|
from frappy.datatypes import get_datatype, StatusType
|
||||||
|
|
||||||
main = sys.modules['__main__']
|
main = sys.modules['__main__']
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ class Module:
|
|||||||
return '%s.%s = %s' % (self._name, pname, r)
|
return '%s.%s = %s' % (self._name, pname, r)
|
||||||
|
|
||||||
def _isBusy(self):
|
def _isBusy(self):
|
||||||
return 300 <= self.status[0] < 400
|
return self.status[0] // 100 == StatusType.BUSY // 100
|
||||||
|
|
||||||
def _status_value_update(self, m, p, status, t, e):
|
def _status_value_update(self, m, p, status, t, e):
|
||||||
if self._running:
|
if self._running:
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
# pylint: disable=unused-import
|
# pylint: disable=unused-import
|
||||||
from frappy.datatypes import ArrayOf, BLOBType, BoolType, EnumType, \
|
from frappy.datatypes import ArrayOf, BLOBType, BoolType, EnumType, \
|
||||||
FloatRange, IntRange, ScaledInteger, StringType, StructOf, TupleOf
|
FloatRange, IntRange, ScaledInteger, StringType, StructOf, TupleOf, StatusType
|
||||||
from frappy.lib.enum import Enum
|
from frappy.lib.enum import Enum
|
||||||
from frappy.modules import Attached, Communicator, \
|
from frappy.modules import Attached, Communicator, \
|
||||||
Done, Drivable, Feature, Module, Readable, Writable, HasAccessibles
|
Done, Drivable, Feature, Module, Readable, Writable, HasAccessibles
|
||||||
@ -39,7 +39,22 @@ from frappy.persistent import PersistentMixin, PersistentParam
|
|||||||
from frappy.rwhandler import ReadHandler, WriteHandler, CommonReadHandler, \
|
from frappy.rwhandler import ReadHandler, WriteHandler, CommonReadHandler, \
|
||||||
CommonWriteHandler, nopoll
|
CommonWriteHandler, nopoll
|
||||||
|
|
||||||
ERROR = Drivable.Status.ERROR
|
DISABLED = StatusType.DISABLED
|
||||||
WARN = Drivable.Status.WARN
|
IDLE = StatusType.IDLE
|
||||||
BUSY = Drivable.Status.BUSY
|
STANDBY = StatusType.STANDBY
|
||||||
IDLE = Drivable.Status.IDLE
|
PREPARED = StatusType.PREPARED
|
||||||
|
WARN = StatusType.WARN
|
||||||
|
WARN_STANDBY = StatusType.WARN_STANDBY
|
||||||
|
WARN_PREPARED = StatusType.WARN_PREPARED
|
||||||
|
UNSTABLE = StatusType.UNSTABLE # no SECoP standard (yet)
|
||||||
|
BUSY = StatusType.BUSY
|
||||||
|
DISABLING = StatusType.DISABLING
|
||||||
|
INITIALIZING = StatusType.INITIALIZING
|
||||||
|
PREPARING = StatusType.PREPARING
|
||||||
|
STARTING = StatusType.STARTING
|
||||||
|
RAMPING = StatusType.RAMPING
|
||||||
|
STABILIZING = StatusType.STABILIZING
|
||||||
|
FINALIZING = StatusType.FINALIZING
|
||||||
|
ERROR = StatusType.ERROR
|
||||||
|
ERROR_STANDBY = StatusType.ERROR_STANDBY
|
||||||
|
ERROR_PREPARED = StatusType.ERROR_PREPARED
|
||||||
|
@ -1243,6 +1243,26 @@ class LimitsType(TupleOf):
|
|||||||
|
|
||||||
class StatusType(TupleOf):
|
class StatusType(TupleOf):
|
||||||
# shorten initialisation and allow access to status enumMembers from status values
|
# shorten initialisation and allow access to status enumMembers from status values
|
||||||
|
DISABLED = 0
|
||||||
|
IDLE = 100
|
||||||
|
STANDBY = 130
|
||||||
|
PREPARED = 150
|
||||||
|
WARN = 200
|
||||||
|
WARN_STANDBY = 230
|
||||||
|
WARN_PREPARED = 250
|
||||||
|
UNSTABLE = 270 # no SECoP standard (yet)
|
||||||
|
BUSY = 300
|
||||||
|
DISABLING = 310
|
||||||
|
INITIALIZING = 320
|
||||||
|
PREPARING = 340
|
||||||
|
STARTING = 360
|
||||||
|
RAMPING = 370
|
||||||
|
STABILIZING = 380
|
||||||
|
FINALIZING = 390
|
||||||
|
ERROR = 400
|
||||||
|
ERROR_STANDBY = 430
|
||||||
|
ERROR_PREPARED = 450
|
||||||
|
|
||||||
def __init__(self, enum):
|
def __init__(self, enum):
|
||||||
super().__init__(EnumType(enum), StringType())
|
super().__init__(EnumType(enum), StringType())
|
||||||
self._enum = enum
|
self._enum = enum
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from frappy.datatypes import StatusType
|
||||||
from frappy.gui.qt import QIcon, Qt, QTreeWidget, QTreeWidgetItem, pyqtSignal
|
from frappy.gui.qt import QIcon, Qt, QTreeWidget, QTreeWidgetItem, pyqtSignal
|
||||||
|
|
||||||
|
|
||||||
@ -70,7 +71,7 @@ class ModuleItem(QTreeWidgetItem):
|
|||||||
return
|
return
|
||||||
if parameter == 'status':
|
if parameter == 'status':
|
||||||
if value.readerror:
|
if value.readerror:
|
||||||
self.setIcon(self.display[parameter], ModuleItem.statusIcon(400)) # 400=ERROR
|
self.setIcon(self.display[parameter], ModuleItem.statusIcon(StatusType.ERROR))
|
||||||
self.setText(self.display['status/text'], str(value.readerror))
|
self.setText(self.display['status/text'], str(value.readerror))
|
||||||
else:
|
else:
|
||||||
self.setIcon(self.display[parameter], ModuleItem.statusIcon(value.value[0].value))
|
self.setIcon(self.display[parameter], ModuleItem.statusIcon(value.value[0].value))
|
||||||
|
@ -764,16 +764,16 @@ class Readable(Module):
|
|||||||
"""basic readable module"""
|
"""basic readable module"""
|
||||||
# pylint: disable=invalid-name
|
# pylint: disable=invalid-name
|
||||||
Status = Enum('Status',
|
Status = Enum('Status',
|
||||||
IDLE=100,
|
IDLE=StatusType.IDLE,
|
||||||
WARN=200,
|
WARN=StatusType.WARN,
|
||||||
UNSTABLE=270,
|
UNSTABLE=270, # not SECoP standard. TODO: remove and adapt entangle
|
||||||
ERROR=400,
|
ERROR=StatusType.ERROR,
|
||||||
DISABLED=0,
|
DISABLED=StatusType.DISABLED,
|
||||||
UNKNOWN=401,
|
UNKNOWN=401, # not SECoP standard. TODO: remove and adapt entangle and epics
|
||||||
) #: status codes
|
) #: status codes
|
||||||
|
|
||||||
value = Parameter('current value of the module', FloatRange())
|
value = Parameter('current value of the module', FloatRange())
|
||||||
status = Parameter('current status of the module', TupleOf(EnumType(Status), StringType()),
|
status = Parameter('current status of the module', StatusType(Status),
|
||||||
default=(Status.IDLE, ''))
|
default=(Status.IDLE, ''))
|
||||||
pollinterval = Parameter('default poll interval', FloatRange(0.1, 120),
|
pollinterval = Parameter('default poll interval', FloatRange(0.1, 120),
|
||||||
default=5, readonly=False, export=True)
|
default=5, readonly=False, export=True)
|
||||||
@ -805,7 +805,7 @@ class Writable(Readable):
|
|||||||
class Drivable(Writable):
|
class Drivable(Writable):
|
||||||
"""basic drivable module"""
|
"""basic drivable module"""
|
||||||
|
|
||||||
Status = Enum(Readable.Status, BUSY=300) #: status codes
|
Status = Enum(Readable.Status, BUSY=StatusType.BUSY) #: status codes
|
||||||
|
|
||||||
status = Parameter(datatype=StatusType(Status)) # override Readable.status
|
status = Parameter(datatype=StatusType(Status)) # override Readable.status
|
||||||
|
|
||||||
@ -814,14 +814,14 @@ class Drivable(Writable):
|
|||||||
|
|
||||||
returns True when busy (also when finalizing)
|
returns True when busy (also when finalizing)
|
||||||
"""
|
"""
|
||||||
return 300 <= (status or self.status)[0] < 400
|
return StatusType.BUSY <= (status or self.status)[0] < StatusType.ERROR
|
||||||
|
|
||||||
def isDriving(self, status=None):
|
def isDriving(self, status=None):
|
||||||
"""check for driving, treating status substates correctly
|
"""check for driving, treating status substates correctly
|
||||||
|
|
||||||
returns True when busy, but not finalizing
|
returns True when busy, but not finalizing
|
||||||
"""
|
"""
|
||||||
return 300 <= (status or self.status)[0] < 390
|
return StatusType.BUSY <= (status or self.status)[0] < StatusType.FINALIZING
|
||||||
|
|
||||||
@Command(None, result=None)
|
@Command(None, result=None)
|
||||||
def stop(self):
|
def stop(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user