# HG changeset patch # User Edouard Tisserant # Date 1603902072 -7200 # Node ID a9b03c2634c56c0d9fa73ac72a1457ecb2101108 # Parent 81758c94f3dfda6a2255d76df92a395b0c36083d Arbitrary variables added to JsonTable subscription are now passed as 'extra' field in json query. As an example added JsonTable filtering in tests/svghmi diff -r 81758c94f3df -r a9b03c2634c5 svghmi/gen_index_xhtml.xslt --- a/svghmi/gen_index_xhtml.xslt Thu Oct 22 22:44:29 2020 +0200 +++ b/svghmi/gen_index_xhtml.xslt Wed Oct 28 18:21:12 2020 +0200 @@ -3826,7 +3826,9 @@ class JsonTableWidget extends Widget{ - cache = [100,50]; + // arbitrary defaults to avoid missing entries in query + + cache = [0,100,50]; do_http_request(...opt) { @@ -3840,6 +3842,8 @@ visible: this.visible, + extra: this.cache.slice(4), + options: opt }; @@ -4177,8 +4181,6 @@ this.apply_hmi_value(3, this.visible); - console.log(range,position,jdata); - diff -r 81758c94f3df -r a9b03c2634c5 svghmi/widget_jsontable.ysl2 --- a/svghmi/widget_jsontable.ysl2 Thu Oct 22 22:44:29 2020 +0200 +++ b/svghmi/widget_jsontable.ysl2 Wed Oct 28 18:21:12 2020 +0200 @@ -3,13 +3,15 @@ template "widget[@type='JsonTable']", mode="widget_class" || class JsonTableWidget extends Widget{ - cache = [100,50]; + // arbitrary defaults to avoid missing entries in query + cache = [0,100,50]; do_http_request(...opt) { const query = { args: this.args, range: this.cache[1], position: this.cache[2], visible: this.visible, + extra: this.cache.slice(4), options: opt }; @@ -220,7 +222,6 @@ | this.apply_hmi_value(1, range); | this.apply_hmi_value(2, position); | this.apply_hmi_value(3, this.visible); - | console.log(range,position,jdata); apply "$data_elt", mode="json_table_render_except_comments" { with "expressions","$initexpr_ns"; with "widget_elts","$hmi_element/*[@inkscape:label = 'data']/descendant::svg:*"; diff -r 81758c94f3df -r a9b03c2634c5 tests/svghmi/plc.xml --- a/tests/svghmi/plc.xml Thu Oct 22 22:44:29 2020 +0200 +++ b/tests/svghmi/plc.xml Wed Oct 28 18:21:12 2020 +0200 @@ -1,7 +1,7 @@ - + diff -r 81758c94f3df -r a9b03c2634c5 tests/svghmi/py_ext_0@py_ext/pyfile.xml --- a/tests/svghmi/py_ext_0@py_ext/pyfile.xml Thu Oct 22 22:44:29 2020 +0200 +++ b/tests/svghmi/py_ext_0@py_ext/pyfile.xml Wed Oct 28 18:21:12 2020 +0200 @@ -34,6 +34,7 @@ range_feedback = newdata[u'range'] slider_position = newdata[u'position'] visible = newdata[u'visible'] + extra = newdata[u'extra'] options = newdata[u'options'] if len(options) == 2 : @@ -41,18 +42,22 @@ if action == "onClick[acknowledge]": AlarmIndex[int(alarmid)][2] = "ack" - answer = self.renderTable(range_feedback, slider_position, visible) + answer = self.renderTable(range_feedback, slider_position, visible, extra) janswer = json.dumps(answer) return janswer - def renderTable(self, old_range, old_position, visible): - new_range = len(Alarms) + def renderTable(self, old_range, old_position, visible, extra): + if len(extra) > 0 and extra[0] != "": + fAlarms = [alrm for alrm in Alarms if alrm[1].find(extra[0])!=-1] + else: + fAlarms = Alarms + new_range = len(fAlarms) delta = new_range - visible new_position = 0 if delta <= 0 else delta if old_position > delta else old_position new_visible = new_range if delta <= 0 else visible visible_alarms = [] - for ts, text, status, alarmid in Alarms[new_position:new_position + new_visible]: + for ts, text, status, alarmid in fAlarms[new_position:new_position + new_visible]: visible_alarms.append({ "time": time.ctime(ts), "text": text, # TODO translate text diff -r 81758c94f3df -r a9b03c2634c5 tests/svghmi/svghmi_0@svghmi/svghmi.svg --- a/tests/svghmi/svghmi_0@svghmi/svghmi.svg Thu Oct 22 22:44:29 2020 +0200 +++ b/tests/svghmi/svghmi_0@svghmi/svghmi.svg Wed Oct 28 18:21:12 2020 +0200 @@ -200,12 +200,12 @@ inkscape:current-layer="hmi0" showgrid="false" units="px" - inkscape:zoom="0.38583842" - inkscape:cx="-56.535477" - inkscape:cy="77.476632" - inkscape:window-width="1920" - inkscape:window-height="1043" - inkscape:window-x="0" + inkscape:zoom="1.5433537" + inkscape:cx="-705.74041" + inkscape:cy="175.04058" + inkscape:window-width="3840" + inkscape:window-height="2123" + inkscape:window-x="1600" inkscape:window-y="0" inkscape:window-maximized="1" showguides="true" @@ -5248,7 +5248,7 @@ style="fill:#ffffff;stroke-width:1px">Alarm Page @@ -5695,7 +5695,7 @@ inkscape:label="disabled" /> @@ -5757,7 +5757,7 @@ sodipodi:type="star" /> @@ -5821,34 +5821,34 @@ range position notify 8888 + + 8888 + + + filter +