--- a/svghmi/gen_index_xhtml.xslt Tue Aug 25 14:34:49 2020 +0200
+++ b/svghmi/gen_index_xhtml.xslt Wed Aug 26 11:26:45 2020 +0200
@@ -1496,61 +1496,85 @@
- <xsl:text> on_mouse_down(evt) {
- <xsl:text> if (this.active_style && this.inactive_style) {
- <xsl:text> this.active_elt.setAttribute("style", this.active_style);
- <xsl:text> this.inactive_elt.setAttribute("style", "display:none");
- <xsl:text> this.apply_hmi_value(0, 1);
- <xsl:text> on_mouse_up(evt) {
- <xsl:text> if (this.active_style && this.inactive_style) {
- <xsl:text> this.active_elt.setAttribute("style", "display:none");
- <xsl:text> this.inactive_elt.setAttribute("style", this.inactive_style);
- <xsl:text> this.apply_hmi_value(0, 0);
- <xsl:text> this.active_style = this.active_elt ? this.active_elt.style.cssText : undefined;
- <xsl:text> this.inactive_style = this.inactive_elt ? this.inactive_elt.style.cssText : undefined;
+ <xsl:text> // TODO decouple update of DOM from event (i.e use animate()) + <xsl:text> // TODO State of the button should distinguish UI feedbak from current PLC value + <xsl:text> on_mouse_down(evt) { <xsl:text> if (this.active_style && this.inactive_style) {
+ <xsl:text> console.log("pressedi...") + <xsl:text> this.active_elt.setAttribute("style", this.active_style); + <xsl:text> this.inactive_elt.setAttribute("style", "display:none"); + <xsl:text> this.apply_hmi_value(0, 1); + <xsl:text> console.log("pressed") + <xsl:text> // TODO inhibit all mouse/touch events except mouse up (in other word grab cursor) + <xsl:text> on_mouse_up(evt) { + <xsl:text> if (this.active_style && this.inactive_style) { + <xsl:text> console.log("unpressedi...") <xsl:text> this.active_elt.setAttribute("style", "display:none");
<xsl:text> this.inactive_elt.setAttribute("style", this.inactive_style);
- <xsl:text> this.element.setAttribute("onmousedown", "hmi_widgets["+this.element_id+"].on_mouse_down(evt)");
- <xsl:text> this.element.setAttribute("onmouseup", "hmi_widgets["+this.element_id+"].on_mouse_up(evt)");
+ <xsl:text> this.apply_hmi_value(0, 0); + <xsl:text> console.log("unpressed") + <xsl:text> // TODO release inhibited events + <xsl:text> // TODO : move to widget_defs so that we can have generated string literals directly + <xsl:text> this.active_style = this.active_elt ? this.active_elt.style.cssText : undefined; + <xsl:text> this.inactive_style = this.inactive_elt ? this.inactive_elt.style.cssText : undefined; + <xsl:text> if (this.active_style && this.inactive_style) { + <xsl:text> this.active_elt.setAttribute("style", "display:none"); + <xsl:text> this.inactive_elt.setAttribute("style", this.inactive_style); + <xsl:text> this.element.setAttribute("onmousedown", "hmi_widgets[\""+this.element_id+"\"].on_mouse_down(evt)"); + <xsl:text> this.element.setAttribute("onmouseup", "hmi_widgets[\""+this.element_id+"\"].on_mouse_up(evt)"); @@ -1986,8 +2010,6 @@
<xsl:text> this.fields[index] = value;
- <xsl:text> console.log(value, index);
<xsl:text> this.element.textContent = this.args.length == 1 ? vsprintf(this.args[0],this.fields) : this.fields.join(' ');
@@ -2825,8 +2847,6 @@
- <xsl:text> console.log(this.menu_offset);
<xsl:text> this.set_partial_text();
@@ -3359,7 +3379,9 @@
<xsl:text> args: this.args,
- <xsl:text> vars: this.cache
+ <xsl:text> vars: this.cache, + <xsl:text> visible: this.visible @@ -3389,8 +3411,6 @@
<xsl:text> dispatch(value, oldval, index) {
- <xsl:text> console.log("mhooo", index);
<xsl:text> this.cache[index] = value;
<xsl:text> this.do_http_request();
@@ -3586,11 +3606,69 @@
<xsl:template mode="json_table_render" match="svg:g">
<xsl:param name="expressions"/>
<xsl:param name="widget_elts"/>
+ <xsl:variable name="gid" select="@id"/> + <xsl:variable name="varprefix"> + <xsl:text>obj_</xsl:text> + <xsl:value-of select="$gid"/> + <xsl:for-each select="$expressions/expression"> + <xsl:text> let </xsl:text> + <xsl:value-of select="$varprefix"/> + <xsl:value-of select="position()"/> + <xsl:text> = </xsl:text> + <xsl:value-of select="@content"/> + <xsl:text> if(</xsl:text> + <xsl:value-of select="$varprefix"/> + <xsl:value-of select="position()"/> + <xsl:text> == undefined) { + <xsl:text> console.log("</xsl:text> + <xsl:value-of select="$varprefix"/> + <xsl:value-of select="position()"/> + <xsl:text> = </xsl:text> + <xsl:value-of select="@content"/> + <xsl:variable name="new_expressions"> + <xsl:for-each select="$expressions/expression"> + <xsl:copy-of select="@name"/> + <xsl:attribute name="content"> + <xsl:value-of select="$varprefix"/> + <xsl:value-of select="position()"/> + <xsl:text> id("</xsl:text> + <xsl:value-of select="@id"/> + <xsl:text>").setAttribute("style", "</xsl:text> + <xsl:value-of select="@style"/> <xsl:variable name="label" select="func:filter_non_widget_label(., $widget_elts)"/>
<xsl:apply-templates mode="json_table_render" select="*">
- <xsl:with-param name="expressions" select="func:json_expressions($expressions, $label)"/>
+ <xsl:with-param name="expressions" select="func:json_expressions(exsl:node-set($new_expressions), $label)"/> <xsl:with-param name="widget_elts" select="$widget_elts"/>
+ <xsl:text> } catch(err) { + <xsl:text> id("</xsl:text> + <xsl:value-of select="$gid"/> + <xsl:text>").setAttribute("style", "display:none"); <xsl:template mode="widget_defs" match="widget[@type='JsonTable']">
<xsl:param name="hmi_element"/>
@@ -3608,7 +3686,15 @@
<xsl:with-param name="mandatory" select="'no'"/>
<xsl:variable name="data_elt" select="$result_svg_ns//*[@id = $hmi_element/@id]/*[@inkscape:label = 'data']"/>
- <xsl:text> spread_json_data: function(jdata) {
+ <xsl:text> visible: </xsl:text> + <xsl:value-of select="count($data_elt/*[@inkscape:label])"/> + <xsl:text> spread_json_data: function(janswer) { + <xsl:text> let [range,position,jdata] = janswer; + <xsl:text> console.log(range,position,jdata); <xsl:apply-templates mode="json_table_render" select="$data_elt/*">
<xsl:with-param name="expressions" select="$initexpr_ns"/>
@@ -5453,8 +5539,6 @@
<xsl:text> if(index > last_remote_index){
- <xsl:text> console.log("updated local variable ",index,value);
<xsl:text> updates[index] = value;
<xsl:text> requestHMIAnimation();
@@ -5805,8 +5889,6 @@
<xsl:text> let [keypadid, xcoord, ycoord] = keypads[valuetype];
- <xsl:text> console.log('XXX TODO : Edit value', path, valuetype, callback, initial, keypadid);
<xsl:text> edit_callback = callback;
<xsl:text> let widget = hmi_widgets[keypadid];
@@ -5895,8 +5977,6 @@
<xsl:text> eltsub.active.setAttribute("style", eltsub.active_style);
- <xsl:text> console.log("active", eltsub);
<xsl:text>function widget_inactive_activable(eltsub) {
@@ -5911,8 +5991,6 @@
<xsl:text> eltsub.inactive.setAttribute("style", eltsub.inactive_style);
- <xsl:text> console.log("inactive", eltsub);
--- a/tests/svghmi/py_ext_0@py_ext/pyfile.xml Tue Aug 25 14:34:49 2020 +0200
+++ b/tests/svghmi/py_ext_0@py_ext/pyfile.xml Wed Aug 26 11:26:45 2020 +0200
@@ -15,9 +15,8 @@
def TriggerAlarm(changed_var_name):
- if(getattr(PLCGlobals, changed_var_name)):
- Alarms.append((time.time(), PLCGlobals.AlarmText, PLCGlobals.AlarmStatus))
- PLCGlobals.AlarmNotify = random.randint(0, 4294967296)
+ Alarms.append((time.time(), PLCGlobals.AlarmText, PLCGlobals.AlarmStatus)) + PLCGlobals.AlarmNotify = random.randint(0, 4294967296) class AlarmJsonResource(Resource):
def render_GET(self, request):
--- a/tests/svghmi/svghmi_0@svghmi/svghmi.svg Tue Aug 25 14:34:49 2020 +0200
+++ b/tests/svghmi/svghmi_0@svghmi/svghmi.svg Wed Aug 26 11:26:45 2020 +0200
@@ -182,12 +182,12 @@
inkscape:document-units="px"
- inkscape:current-layer="hmi0"
+ inkscape:current-layer="g1887" - inkscape:zoom="0.61756226"
- inkscape:cy="527.07406"
+ inkscape:zoom="2.1826319" + inkscape:cx="845.38352" + inkscape:cy="510.70061" inkscape:window-width="1800"
inkscape:window-height="836"
@@ -5775,84 +5775,190 @@
style="stroke-width:1.04184687"
- inkscape:label="HMI:Button@/SENDALARM"
+ inkscape:label="HMI:Input@/SENDALARM" transform="matrix(0.51020953,0,0,0.5903916,155.46943,-173.35252)">
- style="stroke-width:1.04184687"
- inkscape:label="button"
- style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#e6e6e6;fill-opacity:1;fill-rule:nonzero;stroke:#ff6600;stroke-width:5.20923424;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
- style="stroke-width:1.04184687"
- style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:sans-serif;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;display:inline;fill:#ff6600;fill-opacity:1;stroke:none;stroke-width:1.04184675px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
- inkscape:label="setting_jmp"><tspan
+ style="stroke-width:1.04184687"> + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#e6e6e6;fill-opacity:1;fill-rule:nonzero;stroke:#ff6600;stroke-width:5.20923424;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + inkscape:label="button" + style="stroke-width:1.04184687"> + inkscape:label="setting_jmp"
- style="text-align:center;text-anchor:middle;fill:#ff6600;stroke-width:1.04184675px">send</tspan></text>
+ style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:sans-serif;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;display:inline;fill:#ff6600;fill-opacity:1;stroke:none;stroke-width:1.04184675px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + xml:space="preserve"><tspan + style="text-align:center;text-anchor:middle;fill:#ff6600;stroke-width:1.04184675px" + sodipodi:role="line">send</tspan></text> - transform="matrix(0.28590269,0,0,0.28590269,568.76957,-66.870442)"
- inkscape:label="HMI:DropDown:active:warning:normal:ack@/ALARMSTATUS"
- style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#53676c;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
+ inkscape:label="HMI:Input@/ALARMSTATUS" + transform="matrix(0.28590269,0,0,0.28590269,780.70444,146.1427)">
- style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:80px;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#d42aff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ style="font-style:normal;font-weight:normal;font-size:160px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + inkscape:label="value"><tspan
- style="text-align:start;text-anchor:start;fill:#d42aff;stroke-width:1px">sel_0</tspan></text>
- inkscape:label="button"
- inkscape:transform-center-y="10.92088"
- d="m 1200.5,1018.6835 -18.9155,-32.76262 -18.9155,-32.76264 37.831,0 37.831,0 -18.9155,32.76264 z"
- inkscape:randomized="0"
- inkscape:flatsided="false"
- sodipodi:arg2="2.6179939"
- sodipodi:arg1="1.5707963"
- sodipodi:r2="21.841761"
- sodipodi:r1="43.683521"
- style="opacity:1;vector-effect:none;fill:#a7a5a6;fill-opacity:1;stroke:none;stroke-width:0.35277769;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
- sodipodi:type="star" />
+ style="stroke-width:2px">8888</tspan></text> + inkscape:label="="ack"" + transform="translate(-346.56635,170.47452)"> + inkscape:connector-curvature="0" + d="m 797.19546,145.18619 -80.62929,0.60214 -0.60215,-80.629288 80.6293,-0.60214 z" + inkscape:transform-center-y="-14.956361" + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#e6e6e6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" /> + style="font-style:normal;font-weight:normal;font-size:20px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + xml:space="preserve"><tspan + style="stroke-width:1px" + sodipodi:role="line">ack</tspan></text> + inkscape:label="="disabled"" + transform="translate(-416.52022,170.47452)"> + inkscape:transform-center-x="21.900597" + inkscape:transform-center-y="-3.6154501e-05" + d="m 622.6459,-170.03172 -51.81035,0 25.90517,-44.86908 z" + inkscape:randomized="0" + inkscape:flatsided="true" + sodipodi:arg2="1.5707963" + sodipodi:arg1="0.52359878" + sodipodi:r2="14.956361" + sodipodi:r1="29.912722" + sodipodi:cy="-184.98808" + sodipodi:cx="596.74072" + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#e6e6e6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:8.26390171;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + transform="matrix(0,-2.0000001,2.9285972,0,1233.7513,1298.6541)" /> + style="font-style:normal;font-weight:normal;font-size:20px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + style="stroke-width:1px">disabled</tspan></text> + inkscape:label="="active"" + transform="translate(-416.52022,170.47452)"> + inkscape:transform-center-x="14.956364" + transform="rotate(-90,746.45698,-44.543641)" + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#e6e6e6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + sodipodi:cx="596.74072" + sodipodi:cy="-216.2599" + sodipodi:r1="59.825443" + sodipodi:r2="29.912722" + sodipodi:arg1="0.52359878" + sodipodi:arg2="1.5707963" + inkscape:flatsided="true" + inkscape:randomized="0" + d="m 648.55108,-186.34718 -103.62071,0 51.81035,-89.73817 z" + inkscape:transform-center-y="-5.9989963e-06" /> + style="font-style:normal;font-weight:normal;font-size:20px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + xml:space="preserve"><tspan + style="stroke-width:1px" + sodipodi:role="line">active</tspan></text> + inkscape:label="="alarm"" + transform="translate(-416.52022,170.47452)"> + inkscape:transform-center-x="-14.956365" + transform="matrix(0,-1,-1,0,1043.9134,701.91334)" + inkscape:transform-center-y="-5.5023185e-06" + d="m 648.55108,135.08534 -103.62071,0 51.81035,-89.738161 z" + inkscape:randomized="0" + inkscape:flatsided="true" + sodipodi:arg2="1.5707963" + sodipodi:arg1="0.52359878" + sodipodi:r2="29.912722" + sodipodi:r1="59.825443" + sodipodi:cy="105.17262" + sodipodi:cx="596.74072" + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#e6e6e6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + sodipodi:type="star" /> + style="font-style:normal;font-weight:normal;font-size:20px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + xml:space="preserve"><tspan + style="stroke-width:1px" + sodipodi:role="line">alarm</tspan></text>