From a65e6c04f0f0e7e876fca75ecafadb83f32f4bf3 Mon Sep 17 00:00:00 2001
From: David Hammer <dhammer@mailbox.org>
Date: Wed, 13 Apr 2022 15:35:43 +0200
Subject: [PATCH] Add DAQs to manager overview scene, minor scene improvements

---
 src/calng/CalibrationManager.py | 11 +++++----
 src/calng/base_geometry.py      |  1 -
 src/calng/scenes.py             | 42 +++++++++++++++++++++++++++++++--
 3 files changed, 46 insertions(+), 8 deletions(-)

diff --git a/src/calng/CalibrationManager.py b/src/calng/CalibrationManager.py
index 83ee3070..c90e64ab 100644
--- a/src/calng/CalibrationManager.py
+++ b/src/calng/CalibrationManager.py
@@ -263,11 +263,12 @@ class CalibrationManager(DeviceClientBase, Device):
         if name == 'overview':
             # Assumes there are correction devices known to manager
             scene_data = scenes.manager_device_overview(
-                self.deviceId,
-                self.getDeviceSchema(),
-                self._correction_device_schema,
-                self._correction_device_ids,
-                self._domain_device_ids,
+                manager_device_id=self.deviceId,
+                manager_device_schema=self.getDeviceSchema(),
+                correction_device_ids=self._correction_device_ids,
+                correction_device_schema=self._correction_device_schema,
+                daq_device_ids=self._daq_device_ids,
+                domain_device_ids=self._domain_device_ids,
             )
             payload = Hash('success', True, 'name', name, 'data', scene_data)
         elif name == "correction_performance_overview":
diff --git a/src/calng/base_geometry.py b/src/calng/base_geometry.py
index c2fdb139..198d018c 100644
--- a/src/calng/base_geometry.py
+++ b/src/calng/base_geometry.py
@@ -346,7 +346,6 @@ class ManualQuadrantsGeometryBase(ManualGeometryBase):
     def requestScene(self, params):
         name = params.get("name", default="overview")
         if name == "overview":
-            # Assumes there are correction devices known to manager
             scene_data = scenes.quadrant_geometry_overview(
                 self.deviceId,
             )
diff --git a/src/calng/scenes.py b/src/calng/scenes.py
index 68bfa38a..0b2931bb 100644
--- a/src/calng/scenes.py
+++ b/src/calng/scenes.py
@@ -149,7 +149,7 @@ class Hline:
             LineModel(
                 stroke="#000000",
                 x1=x,
-                x2=x+self.width,
+                x2=x + self.width,
                 y1=y,
                 y2=y,
             )
@@ -526,6 +526,26 @@ class CompactCorrectionDeviceOverview(HorizontalLayout):
         )
 
 
+class CompactDaqOverview(HorizontalLayout):
+    def __init__(self, device_id):
+        super().__init__(padding=0)
+        self.children.extend(
+            [
+                DisplayLabelModel(
+                    keys=[f"{device_id}.deviceId"],
+                    width=8 * BASE_INC,
+                    height=BASE_INC,
+                    font_size=9,
+                ),
+                DisplayLabelModel(
+                    keys=[f"{device_id}.DataDispatcher.trainStride"],
+                    width=4 * BASE_INC,
+                    height=BASE_INC,
+                ),
+            ]
+        )
+
+
 @boxed
 class CompactDeviceLinkList(VerticalLayout):
     def __init__(self, device_ids):
@@ -990,8 +1010,9 @@ def correction_device_constant_overrides(device_id, schema, prefix="foundConstan
 def manager_device_overview(
     manager_device_id,
     manager_device_schema,
-    correction_device_schema,
     correction_device_ids,
+    correction_device_schema,
+    daq_device_ids,
     domain_device_ids,
 ):
     mds_hash = schema_to_hash(manager_device_schema)
@@ -1026,6 +1047,14 @@ def manager_device_overview(
             ),
         ),
         HorizontalLayout(
+            titled("DAQs", width=8 * NARROW_INC)(boxed(VerticalLayout))(
+                children=[Space(width=BASE_INC, height=BASE_INC)] * 2
+                + [
+                    CompactDaqOverview(device_id)
+                    for device_id in sorted(daq_device_ids)
+                ],
+                padding=0,
+            ),
             titled("Correction devices", width=8 * NARROW_INC)(boxed(VerticalLayout))(
                 children=[
                     DeviceSceneLinkModel(
@@ -1075,6 +1104,9 @@ def correction_device_performance_dashboard(correction_device_ids):
                 ],
                 width=30 * BASE_INC,
                 height=15 * BASE_INC,
+                x_label="timestamp",
+                y_label="rate",
+                y_units="Hz",
             ),
             TrendGraphModel(
                 keys=[
@@ -1083,6 +1115,9 @@ def correction_device_performance_dashboard(correction_device_ids):
                 ],
                 width=30 * BASE_INC,
                 height=15 * BASE_INC,
+                x_label="timestamp",
+                y_label="processing per train",
+                y_units="ms",
             ),
             TrendGraphModel(
                 keys=[
@@ -1091,6 +1126,9 @@ def correction_device_performance_dashboard(correction_device_ids):
                 ],
                 width=30 * BASE_INC,
                 height=15 * BASE_INC,
+                x_label="timestamp",
+                y_label="ratio of trains received",
+                y_units="%",
             ),
         ),
     )
-- 
GitLab