Skip to content
Snippets Groups Projects
Commit 9b8eb7f8 authored by David Hammer's avatar David Hammer
Browse files

Rudimentary overview scene starting for manager

parent 9e1c4a12
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
...@@ -23,7 +23,7 @@ from karabo.middlelayer import ( ...@@ -23,7 +23,7 @@ from karabo.middlelayer import (
KaraboError, Device, DeviceClientBase, Descriptor, Hash, Configurable, KaraboError, Device, DeviceClientBase, Descriptor, Hash, Configurable,
Slot, Node, Type, Slot, Node, Type,
AccessMode, AccessLevel, Assignment, DaqPolicy, State, Unit, AccessMode, AccessLevel, Assignment, DaqPolicy, State, Unit,
UInt16, UInt32, Bool, Double, String, VectorString, VectorHash, UInt16, UInt32, Bool, Double, Schema, String, VectorString, VectorHash,
background, call, callNoWait, setNoWait, sleep, instantiate, slot, coslot, background, call, callNoWait, setNoWait, sleep, instantiate, slot, coslot,
getDevice, getTopology, getConfiguration, getConfigurationFromPast, getDevice, getTopology, getConfiguration, getConfigurationFromPast,
get_property) get_property)
...@@ -31,6 +31,7 @@ from karabo.middlelayer_api.proxy import ProxyFactory ...@@ -31,6 +31,7 @@ from karabo.middlelayer_api.proxy import ProxyFactory
from karabo import version as karaboVersion from karabo import version as karaboVersion
from ._version import version as deviceVersion from ._version import version as deviceVersion
from . import scenes
''' '''
...@@ -302,6 +303,28 @@ class CalibrationManager(DeviceClientBase, Device): ...@@ -302,6 +303,28 @@ class CalibrationManager(DeviceClientBase, Device):
else []), else []),
accessMode=AccessMode.READONLY) accessMode=AccessMode.READONLY)
availableScenes = VectorString(
displayedName='Available scenes',
displayType='Scenes',
requiredAccessLevel=AccessLevel.OBSERVER,
accessMode=AccessMode.READONLY,
defaultValue=['overview'],
daqPolicy=DaqPolicy.OMIT)
@slot
def requestScene(self, params):
name = params.get('name', default='overview')
if name == 'overview':
# Assumes there are correction devices known to manager
scene_data = scenes.manager_device_overview_scene(
self.deviceId,
self._correction_device_schema,
self._correction_device_ids)
payload = Hash('success', True, 'name', name, 'data', scene_data)
return Hash('type', 'deviceScene',
'origin', self.deviceId,
'payload', payload)
detectorType = String( detectorType = String(
displayedName='Detector type', displayedName='Detector type',
description='Type of the detector to manage.', description='Type of the detector to manage.',
...@@ -591,6 +614,9 @@ class CalibrationManager(DeviceClientBase, Device): ...@@ -591,6 +614,9 @@ class CalibrationManager(DeviceClientBase, Device):
# Obtain the device schema from a correction device server. # Obtain the device schema from a correction device server.
managed_schema, _, _ = await call(corr_server, 'slotGetClassSchema', managed_schema, _, _ = await call(corr_server, 'slotGetClassSchema',
self._correction_class_id) self._correction_class_id)
# saving this for later
self._correction_device_schema = Schema()
self._correction_device_schema.copy(managed_schema)
if managed_schema.name != self._correction_class_id: if managed_schema.name != self._correction_class_id:
self._set_fatal( self._set_fatal(
......
...@@ -355,6 +355,9 @@ class CorrectionDeviceStatus: ...@@ -355,6 +355,9 @@ class CorrectionDeviceStatus:
class CompactCorrectionDeviceOverview: class CompactCorrectionDeviceOverview:
def __init__(self, device_id, schema_hash): def __init__(self, device_id, schema_hash):
self.name = LabelModel(
text=device_id.split("/")[-1], width=5 * BASE_INC, height=BASE_INC
)
self.status = DisplayStateColorModel( self.status = DisplayStateColorModel(
show_string=True, show_string=True,
keys=[f"{device_id}.state"], keys=[f"{device_id}.state"],
...@@ -375,6 +378,9 @@ class CompactCorrectionDeviceOverview: ...@@ -375,6 +378,9 @@ class CompactCorrectionDeviceOverview:
self.ampeln = ConstantLoadedAmpeln(device_id, schema_hash) self.ampeln = ConstantLoadedAmpeln(device_id, schema_hash)
def render(self, x, y): def render(self, x, y):
self.name.x = x
self.name.y = y
x += self.name.width
self.status.x = x self.status.x = x
self.status.y = y self.status.y = y
x += self.status.width x += self.status.width
...@@ -384,7 +390,13 @@ class CompactCorrectionDeviceOverview: ...@@ -384,7 +390,13 @@ class CompactCorrectionDeviceOverview:
self.tid.x = x self.tid.x = x
self.tid.y = y self.tid.y = y
x += self.tid.width x += self.tid.width
return [self.status, self.rate, self.tid] + self.ampeln.render(x, y) return [self.name, self.status, self.rate, self.tid] + self.ampeln.render(x, y)
def width(self):
return 19 * BASE_INC + self.ampeln.width()
def height(self):
return BASE_INC
def correction_device_overview_scene(device_id, schema): def correction_device_overview_scene(device_id, schema):
...@@ -416,3 +428,27 @@ def correction_device_overview_scene(device_id, schema): ...@@ -416,3 +428,27 @@ def correction_device_overview_scene(device_id, schema):
children=subscenes, children=subscenes,
) )
return write_scene(scene) return write_scene(scene)
def manager_device_overview_scene(
manager_device_id, correction_device_schema, correction_device_ids
):
if isinstance(correction_device_schema, karathon.Schema):
schema_hash = correction_device_schema.getParameterHash()
else:
schema_hash = correction_device_schema.hash
x = PADDING
y = PADDING
subscenes = []
for device_id in correction_device_ids:
ccdo = CompactCorrectionDeviceOverview(device_id, schema_hash)
subscenes.extend(ccdo.render(x, y))
y += ccdo.height()
scene = SceneModel(
height=y + 2 * PADDING,
width=ccdo.width() + 2 * PADDING,
children=subscenes,
)
return write_scene(scene)
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