# HG changeset patch
# User Edouard Tisserant
# Date 1598434005 -7200
# Node ID 92101729f7b76328490f19b568be2ee56a9980a0
# Parent da51baea69cb2bd4aa7e7c87157aeef864bc32d3
SVGHMI: Alarm test not using Button widget anymore, too many problems. Use Input widget instead to increment value on each click and execute python code on change.
diff -r da51baea69cb -r 92101729f7b7 svghmi/gen_index_xhtml.xslt
--- 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 @@
- on_mouse_down(evt) {
-
- if (this.active_style && this.inactive_style) {
-
- this.active_elt.setAttribute("style", this.active_style);
-
- this.inactive_elt.setAttribute("style", "display:none");
-
- }
-
- this.apply_hmi_value(0, 1);
-
- }
-
-
-
- on_mouse_up(evt) {
-
- if (this.active_style && this.inactive_style) {
-
- this.active_elt.setAttribute("style", "display:none");
-
- this.inactive_elt.setAttribute("style", this.inactive_style);
-
- }
-
- this.apply_hmi_value(0, 0);
-
- }
-
-
-
- init() {
-
- this.active_style = this.active_elt ? this.active_elt.style.cssText : undefined;
-
- this.inactive_style = this.inactive_elt ? this.inactive_elt.style.cssText : undefined;
-
-
+ // TODO decouple update of DOM from event (i.e use animate())
+
+
+
+
+
+ // TODO State of the button should distinguish UI feedbak from current PLC value
+
+
+
+ on_mouse_down(evt) {
if (this.active_style && this.inactive_style) {
+ console.log("pressedi...")
+
+ this.active_elt.setAttribute("style", this.active_style);
+
+ this.inactive_elt.setAttribute("style", "display:none");
+
+ }
+
+ this.apply_hmi_value(0, 1);
+
+ console.log("pressed")
+
+ // TODO inhibit all mouse/touch events except mouse up (in other word grab cursor)
+
+ }
+
+
+
+ on_mouse_up(evt) {
+
+ if (this.active_style && this.inactive_style) {
+
+ console.log("unpressedi...")
+
this.active_elt.setAttribute("style", "display:none");
this.inactive_elt.setAttribute("style", this.inactive_style);
}
-
-
- this.element.setAttribute("onmousedown", "hmi_widgets["+this.element_id+"].on_mouse_down(evt)");
-
- this.element.setAttribute("onmouseup", "hmi_widgets["+this.element_id+"].on_mouse_up(evt)");
-
- }
+ this.apply_hmi_value(0, 0);
+
+ console.log("unpressed")
+
+ // TODO release inhibited events
+
+ }
+
+
+
+ init() {
+
+ // TODO : move to widget_defs so that we can have generated string literals directly
+
+ this.active_style = this.active_elt ? this.active_elt.style.cssText : undefined;
+
+ this.inactive_style = this.inactive_elt ? this.inactive_elt.style.cssText : undefined;
+
+
+
+ if (this.active_style && this.inactive_style) {
+
+ this.active_elt.setAttribute("style", "display:none");
+
+ this.inactive_elt.setAttribute("style", this.inactive_style);
+
+ }
+
+
+
+ this.element.setAttribute("onmousedown", "hmi_widgets[\""+this.element_id+"\"].on_mouse_down(evt)");
+
+ this.element.setAttribute("onmouseup", "hmi_widgets[\""+this.element_id+"\"].on_mouse_up(evt)");
+
+ }
}
@@ -1986,8 +2010,6 @@
this.fields[index] = value;
- console.log(value, index);
-
this.element.textContent = this.args.length == 1 ? vsprintf(this.args[0],this.fields) : this.fields.join(' ');
}
@@ -2825,8 +2847,6 @@
}
- console.log(this.menu_offset);
-
this.set_partial_text();
},
@@ -3359,7 +3379,9 @@
args: this.args,
- vars: this.cache
+ vars: this.cache,
+
+ visible: this.visible
};
@@ -3389,8 +3411,6 @@
dispatch(value, oldval, index) {
- console.log("mhooo", index);
-
this.cache[index] = value;
this.do_http_request();
@@ -3586,11 +3606,69 @@
+
+
+ obj_
+
+ _
+
+ try {
+
+
+ let
+
+
+ =
+
+ ;
+
+ if(
+
+
+ == undefined) {
+
+ console.log("
+
+
+ =
+
+ ");
+
+ throw null;
+
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+ id("
+
+ ").setAttribute("style", "
+
+ ");
+
-
+
+ } catch(err) {
+
+ id("
+
+ ").setAttribute("style", "display:none");
+
+ }
+
@@ -3608,7 +3686,15 @@
- spread_json_data: function(jdata) {
+ visible:
+
+ ,
+
+ spread_json_data: function(janswer) {
+
+ let [range,position,jdata] = janswer;
+
+ console.log(range,position,jdata);
@@ -5453,8 +5539,6 @@
if(index > last_remote_index){
- console.log("updated local variable ",index,value);
-
updates[index] = value;
requestHMIAnimation();
@@ -5805,8 +5889,6 @@
let [keypadid, xcoord, ycoord] = keypads[valuetype];
- console.log('XXX TODO : Edit value', path, valuetype, callback, initial, keypadid);
-
edit_callback = callback;
let widget = hmi_widgets[keypadid];
@@ -5895,8 +5977,6 @@
eltsub.active.setAttribute("style", eltsub.active_style);
- console.log("active", eltsub);
-
};
function widget_inactive_activable(eltsub) {
@@ -5911,8 +5991,6 @@
eltsub.inactive.setAttribute("style", eltsub.inactive_style);
- console.log("inactive", eltsub);
-
};
diff -r da51baea69cb -r 92101729f7b7 tests/svghmi/py_ext_0@py_ext/pyfile.xml
--- 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):
global Alarms
- 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):
diff -r da51baea69cb -r 92101729f7b7 tests/svghmi/svghmi_0@svghmi/svghmi.svg
--- 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:pageopacity="0"
inkscape:pageshadow="2"
inkscape:document-units="px"
- inkscape:current-layer="hmi0"
+ inkscape:current-layer="g1887"
showgrid="false"
units="px"
- inkscape:zoom="0.61756226"
- inkscape:cx="494.4152"
- inkscape:cy="527.07406"
+ inkscape:zoom="2.1826319"
+ inkscape:cx="845.38352"
+ inkscape:cy="510.70061"
inkscape:window-width="1800"
inkscape:window-height="836"
inkscape:window-x="0"
@@ -5775,84 +5775,190 @@
-
-
-
-
+
+
+
+
+ send
+ 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">send
+
-
+ style="stroke-width:2"
+ inkscape:label="HMI:Input@/ALARMSTATUS"
+ id="g1887"
+ transform="matrix(0.28590269,0,0,0.28590269,780.70444,146.1427)">
sel_0
-
+ id="tspan1841"
+ x="136.32812"
+ y="218.24219"
+ style="stroke-width:2px">8888
+
+
+ ack
+
+
+
+ disabled
+
+
+
+ active
+
+
+
+ alarm
+