Skip to content
Snippets Groups Projects
Commit 449d7190 authored by Philipp Schmidt's avatar Philipp Schmidt
Browse files

manager: Add fatal device state and minor text fixes

parent c8f59f47
No related branches found
No related tags found
2 merge requests!12Snapshot: field test deployed version as of end of run 202201,!3Base correction device, CalCat interaction, DSSC and AGIPD devices
......@@ -26,12 +26,14 @@ from karabo.middlelayer import (
from karabo import version as karaboVersion
from ._version import version as deviceVersion
'''
Device states:
- INIT: When the device is starting up
- ACTIVE: When the device is ready to manage a calibration pipeline
- CHANGING: When the device is actively changing the pipeline configuration
- ERROR: Recoverable error, only allows server restart
- UNKNOWN: Unrecoverable error
'''
......@@ -335,6 +337,7 @@ class CalibrationManager(DeviceClientBase, Device):
detectorType = String(
displayedName='Detector type',
description='Type of the detector to manage.',
options=['AGIPD', 'LPD', 'DSSC', 'Jungfrau', 'ePix100', 'pnCCD',
'FastCCD'],
accessMode=AccessMode.INITONLY,
......@@ -561,8 +564,7 @@ class CalibrationManager(DeviceClientBase, Device):
else:
break
else:
self.state = State.UNKNOWN
self._set_status(f'Topology not available after {i+1} tries')
self._set_fatal(f'Topology not available after {i+1} tries')
return
self.logger.debug(f'Topology arrived after {i+1} tries')
......@@ -586,6 +588,12 @@ class CalibrationManager(DeviceClientBase, Device):
self.state = State.ERROR
self._set_status(text, level=logging.ERROR)
def _set_fatal(self, text):
"""Set the device into unknown state and log an error message."""
self.state = State.UNKNOWN
self._set_status(text, level=logging.CRITICAL)
def _set_exception(self, text, e):
"""Set the device into error upon an exception."""
......@@ -662,11 +670,11 @@ class CalibrationManager(DeviceClientBase, Device):
body=json.dumps({'server': {'command': command}})))
except (ConnectionError, HTTPError) as e:
raise RuntimeError(
f'Failed sending \'{command}\' to {name} on '
f'Failed sending `{command}` to {name} on '
f'{urlparse(self._server_hosts[name]).hostname}: {e}')
if not json.loads(reply.body)['success']:
raise RuntimeError('Command \'{command}\' for {name} failed')
raise RuntimeError('Command `{command}` for {name} failed')
while True:
await sleep(self.webserverApi.statePollInterval.value)
......@@ -729,7 +737,7 @@ class CalibrationManager(DeviceClientBase, Device):
if 'error' in s['status']}
if servers_in_error:
err.append(f'- Device server on {hostname} are in error state'
err.append(f'- Device servers on {hostname} are in error state'
+ ', '.join(servers_in_error))
continue
......@@ -737,7 +745,7 @@ class CalibrationManager(DeviceClientBase, Device):
if not s['control_allowed']}
if servers_disabled:
err.append(f'- Device servers on {hostname} not controllable '
err.append(f'- Device servers on {hostname} not controllable '
f'via webserver: ' + ', '.join(servers_disabled))
continue
......@@ -1097,14 +1105,14 @@ class CalibrationManager(DeviceClientBase, Device):
for device_id in device_ids:
callNoWait(device_id, slot, *args)
self.logger.debug(f'Called {device_id}.{slot}({args})')
self.logger.debug(f'Called {device_id}.{slot}{args}')
async def _call_on_corrections(self, slot, *args):
"""Call a slot on all correction devices."""
if self._correction_device_ids:
self._call(self._correction_device_ids, slot, *args)
self.logger.info(f'Called <CORR>.{slot}({args})')
self.logger.info(f'Called <CORR>.{slot}{args}')
def _set(self, device_ids, key, value):
"""Set the same property on a list of devices."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment