ppms driver now uses command handlers

this is a simplicifcation for the ppms driver

- the derivation of a changecmd from a querycmd is moved to
  CmdHandler.__init__
- the special treatment of handlers when writing configured
  parameters has moved to CmdHandler.write
- introduced Drivable.isDriving, changed Module.isBusy

Change-Id: I8862ecda9c8cc998bb018bd960f31c9488146707
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/22033
Tested-by: JenkinsCodeReview <bjoern_pedersen@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
2019-12-13 16:28:22 +01:00
parent cb4874331b
commit fcad78a682
6 changed files with 275 additions and 476 deletions

View File

@ -255,7 +255,7 @@ class Module(HasProperties, metaclass=ModuleMeta):
pobj = self.parameters[pname]
self.DISPATCHER.announce_update_error(self, pname, pobj, exception)
def isBusy(self):
def isBusy(self, status=None):
'''helper function for treating substates of BUSY correctly'''
# defined even for non drivable (used for dynamic polling)
return False
@ -295,21 +295,11 @@ class Module(HasProperties, metaclass=ModuleMeta):
with proper error handling
"""
try:
pobj = self.parameters[pname]
if pobj.handler:
pnames = pobj.handler.parameters
valuedict = {n: self.writeDict.pop(n) for n in pnames if n in self.writeDict}
if valuedict:
self.log.debug('write parameters %r', valuedict)
pobj.handler.write(self, valuedict, force_read=True)
return
pobj.handler.read(self)
if pname in self.writeDict:
self.log.debug('write parameter %s', pname)
getattr(self, 'write_'+ pname)(self.writeDict.pop(pname))
else:
if pname in self.writeDict:
self.log.debug('write parameter %s', pname)
getattr(self, 'write_'+ pname)(self.writeDict.pop(pname))
else:
getattr(self, 'read_'+ pname)()
getattr(self, 'read_'+ pname)()
except SilentError as e:
pass
except SECoPError as e:
@ -428,9 +418,13 @@ class Drivable(Writable):
'status' : Override(datatype=TupleOf(EnumType(Status), StringType())),
}
def isBusy(self):
def isBusy(self, status=None):
'''helper function for treating substates of BUSY correctly'''
return 300 <= self.status[0] < 400
return 300 <= (status or self.status)[0] < 400
def isDriving(self, status=None):
'''helper function (finalize is busy, not driving)'''
return 300 <= (status or self.status)[0] < 380
# improved polling: may poll faster if module is BUSY
def pollParams(self, nr=0):