svghmi/widget_display.ysl2
branchsvghmi
changeset 2998 e8f707d99dc3
parent 2883 8e3d130399b0
child 3008 dabad70db1bf
--- a/svghmi/widget_display.ysl2	Wed Jul 22 13:56:43 2020 +0200
+++ b/svghmi/widget_display.ysl2	Mon Aug 03 12:08:25 2020 +0200
@@ -1,19 +1,18 @@
 // widget_display.ysl2
 
 
+template "widget[@type='Display']", mode="widget_class"
+    ||
+    class DisplayWidget extends Widget{
+        frequency = 5;
+        dispatch(value) {
+            this.element.textContent = String(value);
+        }
+    }
+    ||
+
 template "widget[@type='Display']", mode="widget_defs" {
     param "hmi_element";
-    |     frequency: 5,
-    |     dispatch: function(value) {
-    choose {
-        when "$hmi_element[self::svg:text]"{
-        // TODO : care about <tspan> ?
-    |       this.element.textContent = String(value);
-        }
-        otherwise {
-            warning > Display widget as a group not implemented
-        }
-    }
-    |     },
-
+    if "$hmi_element[not(self::svg:text)]"
+        error > Display Widget id="«$hmi_element/@id»" is not a svg::text element
 }