--- a/svghmi/widgets_common.ysl2 Fri May 08 16:51:43 2020 +0200
+++ b/svghmi/widgets_common.ysl2 Sun May 10 16:32:19 2020 +0200
@@ -24,25 +24,19 @@
template "svg:*", mode="hmi_elements" {
const "widget", "func:widget(@id)";
- | "«@id»": new «$widget/@type»Widget ({
- | "«@value»"`if "position()!=last()" > ,`
- foreach "$widget/path" {
+ const "args" foreach "$widget/arg" > "«@value»"`if "position()!=last()" > ,` + const "indexes" foreach "$widget/path" { warning > Widget «$widget/@type» id="«$eltid»" : No match for path "«@value»" in HMI tree
- | «@index» /* «@value» */ `if "position()!=last()" > ,`
+ > «@index»`if "position()!=last()" > ,`
- | element: id("«@id»"),
+ | "«@id»": new «$widget/@type»Widget ("«@id»",[«$args»],[«$indexes»],{ apply "$widget", mode="widget_defs" with "hmi_element",".";
apply "$widget", mode="widget_subscribe" with "hmi_element",".";
| })`if "position()!=last()" > ,`
@@ -72,7 +66,11 @@
emit "preamble:widget-base-class" {
+ constructor(elt_id,args,indexes,members){ + this.element = id(elt_id); + this.indexes = indexes; Object.keys(members).forEach(prop => this[prop]=members[prop]);