SVGHMI: Parameters common to all widget constructors now passed as ordered parameters.
--- 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)";
const "eltid","@id";
- | "«@id»": new «$widget/@type»Widget ({
- | args: [
- foreach "$widget/arg"
- | "«@value»"`if "position()!=last()" > ,`
- | ],
- | offset: 0,
- | indexes: [
- foreach "$widget/path" {
+ const "args" foreach "$widget/arg" > "«@value»"`if "position()!=last()" > ,`
+ const "indexes" foreach "$widget/path" {
choose {
when "not(@index)" {
warning > Widget «$widget/@type» id="«$eltid»" : No match for path "«@value»" in HMI tree
}
otherwise {
- | «@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" {
||
class Widget {
- constructor(members){
+ constructor(elt_id,args,indexes,members){
+ this.element = id(elt_id);
+ this.args = args;
+ this.indexes = indexes;
+ this.offset = 0;
Object.keys(members).forEach(prop => this[prop]=members[prop]);
}
}