# HG changeset patch # User Edouard Tisserant # Date 1621322924 -7200 # Node ID f037e901a17c98492039f875f8e64ae2cb485b22 # Parent fe945f1f48b7e59f8b5993c047641980ad23a8f0# Parent 5f756332ada18914b9408bd0a2f1668f13e4e6a9 Merged SVGHMI branches diff -r fe945f1f48b7 -r f037e901a17c bacnet/bacnet.py --- a/bacnet/bacnet.py Tue May 18 09:22:17 2021 +0200 +++ b/bacnet/bacnet.py Tue May 18 09:28:44 2021 +0200 @@ -38,9 +38,7 @@ from ConfigTreeNode import ConfigTreeNode import util.paths as paths -base_folder = os.path.split(os.path.dirname(os.path.realpath(__file__)))[0] -base_folder = os.path.join(base_folder, "..") -BacnetPath = os.path.join(base_folder, "BACnet") +BacnetPath = paths.ThirdPartyPath("BACnet") BacnetLibraryPath = os.path.join(BacnetPath, "lib") BacnetIncludePath = os.path.join(BacnetPath, "include") BacnetIncludePortPath = os.path.join(BacnetPath, "ports") diff -r fe945f1f48b7 -r f037e901a17c canfestival/canfestival.py --- a/canfestival/canfestival.py Tue May 18 09:22:17 2021 +0200 +++ b/canfestival/canfestival.py Tue May 18 09:28:44 2021 +0200 @@ -33,14 +33,14 @@ from gnosis.xml.pickle.util import setParanoia # pylint: disable=import-error import util.paths as paths + from util.TranslationCatalogs import AddCatalog from ConfigTreeNode import ConfigTreeNode from PLCControler import \ LOCATION_CONFNODE, \ LOCATION_VAR_MEMORY -base_folder = paths.AbsParentDir(__file__, 2) # noqa -CanFestivalPath = os.path.join(base_folder, "CanFestival-3") # noqa +CanFestivalPath = paths.ThirdPartyPath("CanFestival-3") # noqa sys.path.append(os.path.join(CanFestivalPath, "objdictgen")) # noqa # pylint: disable=wrong-import-position diff -r fe945f1f48b7 -r f037e901a17c modbus/modbus.py --- a/modbus/modbus.py Tue May 18 09:22:17 2021 +0200 +++ b/modbus/modbus.py Tue May 18 09:28:44 2021 +0200 @@ -32,9 +32,7 @@ from PLCControler import LOCATION_CONFNODE, LOCATION_VAR_MEMORY import util.paths as paths -base_folder = os.path.split(os.path.dirname(os.path.realpath(__file__)))[0] -base_folder = os.path.join(base_folder, "..") -ModbusPath = os.path.join(base_folder, "Modbus") +ModbusPath = paths.ThirdPartyPath("Modbus") # diff -r fe945f1f48b7 -r f037e901a17c svghmi/gen_index_xhtml.xslt --- a/svghmi/gen_index_xhtml.xslt Tue May 18 09:22:17 2021 +0200 +++ b/svghmi/gen_index_xhtml.xslt Tue May 18 09:28:44 2021 +0200 @@ -1,6 +1,6 @@ - - + + @@ -1743,7 +1743,7 @@ - + @@ -5463,21 +5463,21 @@ /* show active */ - this.active_elt.setAttribute("style", this.active_elt_style); + this.active_elt.style.display = ""; /* hide inactive */ - this.inactive_elt.setAttribute("style", "display:none"); + this.inactive_elt.style.display = "none"; } else { /* show inactive */ - this.inactive_elt.setAttribute("style", this.inactive_elt_style); + this.inactive_elt.style.display = ""; /* hide active */ - this.active_elt.setAttribute("style", "display:none"); + this.active_elt.style.display = "none"; } @@ -5485,6 +5485,36 @@ + update_disability() { + + if(this.disabled) { + + /* show disabled */ + + this.disabled_elt.style.display = ""; + + /* hide inactive */ + + this.inactive_elt.style.display = "none"; + + /* hide active */ + + this.active_elt.style.display = "none"; + + } else { + + /* hide disabled */ + + this.disabled_elt.style.display = "none"; + + this.update_activity(); + + } + + } + + + make_on_click() { let that = this; @@ -5493,13 +5523,21 @@ return function(evt){ - /* TODO: suport path pointing to local variable whom value - - would be an HMI_TREE index to jump to a relative page */ - - const index = that.indexes.length > 0 ? that.indexes[0] + that.offset : undefined; - - switch_page(name, index); + /* TODO: in order to allow jumps to page selected through for exemple a dropdown, + + support path pointing to local variable whom value + + would be an HMI_TREE index and then jump to a relative page not hard-coded in advance */ + + + + if(!that.disabled) { + + const index = that.indexes.length > 0 ? that.indexes[0] + that.offset : undefined; + + switch_page(name, index); + + } } @@ -5517,7 +5555,7 @@ this.active = ((ref_name == undefined || ref_name == page_name) && index == ref_index); - this.update_activity(); + this.update_state(); } @@ -5529,29 +5567,7 @@ this.disabled = !Number(value); - if(this.disabled) { - - /* show disabled */ - - this.disabled_elt.setAttribute("style", this.disabled_elt_style); - - /* hide inactive */ - - this.inactive_elt.setAttribute("style", "display:none"); - - /* hide active */ - - this.active_elt.setAttribute("style", "display:none"); - - } else { - - /* hide disabled */ - - this.disabled_elt.setAttribute("style", "display:none"); - - this.update_activity(); - - } + this.update_state(); } @@ -5587,23 +5603,27 @@ this.element.onclick = this.make_on_click(); - this.active_elt_style = this.active_elt.getAttribute("style"); - - this.inactive_elt_style = this.inactive_elt.getAttribute("style"); - this.activable = true; + + this.unsubscribable = true; + + + this.update_state = - this.disabled_elt_style = this.disabled_elt.getAttribute("style"); - + this.update_disability + + + this.update_activity - this.unsubscribable = true; - + null + ; + }, @@ -7426,9 +7446,9 @@ Made with SVGHMI. https://beremiz.org - + - diff -r fe945f1f48b7 -r f037e901a17c svghmi/widget_jump.ysl2 --- a/svghmi/widget_jump.ysl2 Tue May 18 09:22:17 2021 +0200 +++ b/svghmi/widget_jump.ysl2 Tue May 18 09:28:44 2021 +0200 @@ -33,14 +33,29 @@ update_activity() { if(this.active) { /* show active */ - this.active_elt.setAttribute("style", this.active_elt_style); + this.active_elt.style.display = ""; /* hide inactive */ - this.inactive_elt.setAttribute("style", "display:none"); + this.inactive_elt.style.display = "none"; } else { /* show inactive */ - this.inactive_elt.setAttribute("style", this.inactive_elt_style); + this.inactive_elt.style.display = ""; /* hide active */ - this.active_elt.setAttribute("style", "display:none"); + this.active_elt.style.display = "none"; + } + } + + update_disability() { + if(this.disabled) { + /* show disabled */ + this.disabled_elt.style.display = ""; + /* hide inactive */ + this.inactive_elt.style.display = "none"; + /* hide active */ + this.active_elt.style.display = "none"; + } else { + /* hide disabled */ + this.disabled_elt.style.display = "none"; + this.update_activity(); } } @@ -48,10 +63,14 @@ let that = this; const name = this.args[0]; return function(evt){ - /* TODO: suport path pointing to local variable whom value - would be an HMI_TREE index to jump to a relative page */ - const index = that.indexes.length > 0 ? that.indexes[0] + that.offset : undefined; - switch_page(name, index); + /* TODO: in order to allow jumps to page selected through for exemple a dropdown, + support path pointing to local variable whom value + would be an HMI_TREE index and then jump to a relative page not hard-coded in advance */ + + if(!that.disabled) { + const index = that.indexes.length > 0 ? that.indexes[0] + that.offset : undefined; + switch_page(name, index); + } } } @@ -60,24 +79,13 @@ const ref_index = this.indexes.length > 0 ? this.indexes[0] + this.offset : undefined; const ref_name = this.args[0]; this.active = ((ref_name == undefined || ref_name == page_name) && index == ref_index); - this.update_activity(); + this.update_state(); } } dispatch(value) { this.disabled = !Number(value); - if(this.disabled) { - /* show disabled */ - this.disabled_elt.setAttribute("style", this.disabled_elt_style); - /* hide inactive */ - this.inactive_elt.setAttribute("style", "display:none"); - /* hide active */ - this.active_elt.setAttribute("style", "display:none"); - } else { - /* hide disabled */ - this.disabled_elt.setAttribute("style", "display:none"); - this.update_activity(); - } + this.update_state(); } || } @@ -95,19 +103,24 @@ | init: function() { | this.element.onclick = this.make_on_click(); if "$have_activity" { - | this.active_elt_style = this.active_elt.getAttribute("style"); - | this.inactive_elt_style = this.inactive_elt.getAttribute("style"); | this.activable = true; } + if "not($have_disability)" { + | this.unsubscribable = true; + } + > this.update_state = choose { when "$have_disability" { - | this.disabled_elt_style = this.disabled_elt.getAttribute("style"); + > this.update_disability } - otherwise { - | this.unsubscribable = true; + when "$have_activity" { + > this.update_activity } + otherwise > null } + > ;\n | }, + } widget_page("Jump"){ diff -r fe945f1f48b7 -r f037e901a17c tests/svghmi/plc.xml --- a/tests/svghmi/plc.xml Tue May 18 09:22:17 2021 +0200 +++ b/tests/svghmi/plc.xml Tue May 18 09:28:44 2021 +0200 @@ -1,7 +1,7 @@ - + @@ -74,14 +74,21 @@ - + + + + + + - + - + + + @@ -97,12 +104,40 @@ TargetPressure - - - + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + @@ -115,15 +150,20 @@ - - - + + + + + + + + - + - - + + @@ -133,15 +173,20 @@ - - - + + + + + + + + - + - - + + @@ -151,15 +196,24 @@ - - - + + + + + + + + + + + + - + - - + + @@ -169,15 +223,20 @@ - - - + + + + + + + + - + - - + + @@ -187,15 +246,24 @@ - - - + + + + + + + + + + + + - + - - + + @@ -205,35 +273,36 @@ - - - - - - - - - - - - - - - - - - + + + + + + 0 + + + + + + + 0 + + + + + + + + + + + - - - - - diff -r fe945f1f48b7 -r f037e901a17c tests/svghmi/svghmi_0@svghmi/svghmi.svg --- a/tests/svghmi/svghmi_0@svghmi/svghmi.svg Tue May 18 09:22:17 2021 +0200 +++ b/tests/svghmi/svghmi_0@svghmi/svghmi.svg Tue May 18 09:28:44 2021 +0200 @@ -125,12 +125,12 @@ inkscape:pageopacity="0" inkscape:pageshadow="2" inkscape:document-units="px" - inkscape:current-layer="hmi0" + inkscape:current-layer="g1499-7" showgrid="false" units="px" - inkscape:zoom="1.1929688" - inkscape:cx="772.0138" - inkscape:cy="-68.272506" + inkscape:zoom="0.84355633" + inkscape:cx="1857.6296" + inkscape:cy="687.32797" inkscape:window-width="1600" inkscape:window-height="836" inkscape:window-x="0" @@ -3465,8 +3465,9 @@ inkscape:label="HMI:Jump:RelativePageTest@/PUMP0" id="g1458-8"> + inkscape:label="disabled" + id="g1450-4" + style="display:inline"> + + + + + + + inkscape:label="disabled"> + + + + + + + + + + + + + inkscape:label="disabled" + style="display:inline"> + + + + + +