# HG changeset patch # User Edouard Tisserant # Date 1613984997 -3600 # Node ID cecfd6bb45930e849511507a778c2b5713f16481 # Parent 76c0c0a524c9e0c3eb7ed261f29a687eb3fdc30c# Parent 1d7c3d13a4dfec88146ea39c0fb3bf6a1a8d5917 Merge diff -r 1d7c3d13a4df -r cecfd6bb4593 svghmi/gen_index_xhtml.xslt --- a/svghmi/gen_index_xhtml.xslt Fri Feb 19 14:56:14 2021 +0100 +++ b/svghmi/gen_index_xhtml.xslt Mon Feb 22 10:09:57 2021 +0100 @@ -19,6 +19,7 @@ + /* @@ -61,6 +62,7 @@ + @@ -278,6 +280,7 @@ + /* @@ -302,10 +305,12 @@ + + /* @@ -332,6 +337,7 @@ + @@ -407,6 +413,7 @@ + /* @@ -423,6 +430,7 @@ + @@ -482,6 +490,7 @@ + /* @@ -512,6 +521,7 @@ + @@ -627,6 +637,7 @@ + /* @@ -644,10 +655,12 @@ + + /* @@ -676,6 +689,7 @@ + @@ -895,6 +909,7 @@ + /* @@ -911,9 +926,11 @@ + + /* @@ -940,6 +957,7 @@ + @@ -965,6 +983,7 @@ + /* @@ -1027,6 +1046,7 @@ + @@ -1129,6 +1149,7 @@ + /* @@ -1272,9 +1293,11 @@ + + /* @@ -1669,11 +1692,13 @@ + + /* @@ -1686,6 +1711,7 @@ + class @@ -1703,6 +1729,7 @@ + /* @@ -1718,6 +1745,7 @@ + @@ -2967,6 +2995,7 @@ + /* @@ -3443,6 +3472,7 @@ + function numb_event(e) { @@ -4452,16 +4482,12 @@ dispatch: function(value) { - - this.last_val = value; - - - + this.last_display = vsprintf(" - ", value); + ", [value]); @@ -4469,6 +4495,8 @@ + + this.request_animate(); @@ -4489,7 +4517,7 @@ ", " - ", this, this.last_val); + ", this, this.last_display); this.value_elt.style.pointerEvents = "none"; @@ -5155,6 +5183,7 @@ + /* @@ -5181,9 +5210,11 @@ + + /* @@ -5216,6 +5247,7 @@ + class KeypadWidget extends Widget{ diff -r 1d7c3d13a4df -r cecfd6bb4593 svghmi/gen_index_xhtml.ysl2 --- a/svghmi/gen_index_xhtml.ysl2 Fri Feb 19 14:56:14 2021 +0100 +++ b/svghmi/gen_index_xhtml.ysl2 Mon Feb 22 10:09:57 2021 +0100 @@ -7,11 +7,13 @@ decl emit(*name) alias - { *name; template *name { + const "_unused", "ns:ProgressStart(name())"; | | /* «local-name()» */ | content; | + const "__unused", "ns:ProgressEnd(name())"; } }; diff -r 1d7c3d13a4df -r cecfd6bb4593 svghmi/svghmi.py --- a/svghmi/svghmi.py Fri Feb 19 14:56:14 2021 +0100 +++ b/svghmi/svghmi.py Mon Feb 22 10:09:57 2021 +0100 @@ -14,6 +14,7 @@ import hashlib import weakref import shlex +import time import wx import wx.dataview as dv @@ -544,6 +545,18 @@ return TranslationToEtree(langs,translated_messages) + times = {} + def ProgressStart(self, _context, message): + t = time.time() + s = str(message) + self.times[s] = t + + def ProgressEnd(self, _context, message): + t = time.time() + s = str(message) + self.GetCTRoot().logger.write(" %s: %.3f\n"%(message, t - self.times[s])) + self.times[s] = t + def CTNGenerate_C(self, buildpath, locations): location_str = "_".join(map(str, self.GetCurrentLocation())) @@ -558,18 +571,26 @@ target_path = os.path.join(self._getBuildPath(), target_fname) target_file = open(target_path, 'wb') + self.GetCTRoot().logger.write("SVGHMI:\n") + if os.path.exists(svgfile): # TODO : move to __init__ transform = XSLTransform(os.path.join(ScriptDirectory, "gen_index_xhtml.xslt"), [("GetSVGGeometry", lambda *_ignored:self.GetSVGGeometry()), ("GetHMITree", lambda *_ignored:self.GetHMITree()), - ("GetTranslations", self.GetTranslations)]) - + ("GetTranslations", self.GetTranslations), + ("ProgressStart", self.ProgressStart), + ("ProgressEnd", self.ProgressEnd)]) + + + t = time.time() # load svg as a DOM with Etree svgdom = etree.parse(svgfile) + self.GetCTRoot().logger.write(" Source SVG parsing: %.3f\n"%(time.time()-t)) + # call xslt transform on Inkscape's SVG to generate XHTML try: result = transform.transform(svgdom) diff -r 1d7c3d13a4df -r cecfd6bb4593 svghmi/widget_input.ysl2 --- a/svghmi/widget_input.ysl2 Fri Feb 19 14:56:14 2021 +0100 +++ b/svghmi/widget_input.ysl2 Mon Feb 22 10:09:57 2021 +0100 @@ -41,18 +41,18 @@ | dispatch: function(value) { - if "$have_edit" - | this.last_val = value; - if "$have_value" { + if "$have_value or $have_edit" { choose{ when "count(arg) = 1" { - | this.last_display = vsprintf("«arg[1]/@value»", value); + | this.last_display = vsprintf("«arg[1]/@value»", [value]); } otherwise { | this.last_display = value; } } + } + if "$have_value" { | this.request_animate(); } | }, @@ -66,7 +66,7 @@ | init: function() { if "$have_edit" { - | this.edit_elt.onclick = () => edit_value("«path/@value»", "«path/@type»", this, this.last_val); + | this.edit_elt.onclick = () => edit_value("«path/@value»", "«path/@type»", this, this.last_display); if "$have_value" { | this.value_elt.style.pointerEvents = "none"; }