--- a/XSLTransform.py Thu Jan 30 14:33:06 2020 +0100
+++ b/XSLTransform.py Tue Feb 11 13:56:48 2020 +0100
@@ -22,4 +22,7 @@
# print(self.xslt.error_log)
+ def get_error_log(self): + return self.xslt.error_log --- a/svghmi/gen_index_xhtml.xslt Thu Jan 30 14:33:06 2020 +0100
+++ b/svghmi/gen_index_xhtml.xslt Tue Feb 11 13:56:48 2020 +0100
@@ -230,20 +230,24 @@
<xsl:for-each select="$widget/path">
<xsl:variable name="hmipath" select="@value"/>
<xsl:variable name="hmitree_match" select="$indexed_hmitree/*[@hmipath = $hmipath]"/>
- <xsl:if test="count($hmitree_match) = 0">
- <xsl:message terminate="yes">
- <xsl:text>No match for path "</xsl:text>
- <xsl:value-of select="$hmipath"/>
- <xsl:text>" in HMI tree</xsl:text>
- <xsl:value-of select="$hmitree_match/@index"/>
- <xsl:if test="position()!=last()">
+ <xsl:when test="count($hmitree_match) = 0"> + <xsl:message terminate="no"> + <xsl:text>No match for path "</xsl:text> + <xsl:value-of select="$hmipath"/> + <xsl:text>" in HMI tree</xsl:text> + <xsl:value-of select="$hmitree_match/@index"/> + <xsl:if test="position()!=last()"> @@ -360,32 +364,30 @@
<xsl:text>function dispatch_value_to_widget(widget, index, value, oldval) {
- <xsl:text> let idxidx = widget.indexes.indexOf(index);
+ <xsl:text> let idxidx = widget.indexes.indexOf(index); + <xsl:text> let d = widget.dispatch; + <xsl:text> if(typeof(d) == "function" && idxidx == 0){ + <xsl:text> d.call(widget, value, oldval); - <xsl:text> if(idxidx == -1){
+ <xsl:text> }else if(typeof(d) == "object" && d.length >= idxidx){ + <xsl:text> d[idxidx].call(widget, value, oldval); + <xsl:text> }/* else dispatch_0, ..., dispatch_n ? */ - <xsl:text> throw new Error("Dispatching to widget not interested, should not happen.");
+ <xsl:text> throw new Error("Dunno how to dispatch to widget at index = " + index); - <xsl:text> let d = widget.dispatch;
- <xsl:text> if(typeof(d) == "function" && idxidx == 0){
- <xsl:text> return d.call(widget, value, oldval);
- <xsl:text> }else if(typeof(d) == "object" && d.length >= idxidx){
- <xsl:text> return d[idxidx].call(widget, value, oldval);
- <xsl:text> }/* else dispatch_0, ..., dispatch_n ? */
- <xsl:text> throw new Error("Dunno how to dispatch to widget at index = " + index);
@@ -426,7 +428,17 @@
<xsl:text> if(typeof(init) == "function"){
- <xsl:text> return init.call(widget);
+ <xsl:text> init.call(widget); + <xsl:text> } catch(err) { + <xsl:text> console.log("Widget initialization error : "+err.message); @@ -913,12 +925,14 @@
<xsl:param name="labels" select="''"/>
<xsl:param name="mandatory" select="'yes'"/>
<xsl:param name="hmi_element"/>
+ <xsl:variable name="widget_type" select="@type"/> <xsl:for-each select="str:split($labels)">
<xsl:variable name="name" select="."/>
<xsl:variable name="elt_id" select="$hmi_element//*[@inkscape:label=$name][1]/@id"/>
<xsl:if test="$mandatory='yes' and not($elt_id)">
- <xsl:message terminate="yes">
- <xsl:text>Meter widget must have a </xsl:text>
+ <xsl:message terminate="no"> + <xsl:value-of select="$widget_type"/> + <xsl:text> widget must have a </xsl:text> <xsl:value-of select="$name"/>
<xsl:text> element</xsl:text>
@@ -942,7 +956,7 @@
- <xsl:message terminate="yes">
+ <xsl:message terminate="no"> <xsl:text>Display widget as a group not implemented</xsl:text>
--- a/svghmi/gen_index_xhtml.ysl2 Thu Jan 30 14:33:06 2020 +0100
+++ b/svghmi/gen_index_xhtml.ysl2 Tue Feb 11 13:56:48 2020 +0100
@@ -227,9 +227,14 @@
const "hmipath","@value";
const "hmitree_match","$indexed_hmitree/*[@hmipath = $hmipath]";
- if "count($hmitree_match) = 0"
- error > No match for path "«$hmipath»" in HMI tree
+ when "count($hmitree_match) = 0" { + warning > No match for path "«$hmipath»" in HMI tree | «$hmitree_match/@index»`if "position()!=last()" > ,`
| element: document.getElementById("«@id»"),
@@ -328,10 +333,12 @@
param "mandatory","'yes'";
+ const "widget_type","@type"; foreach "str:split($labels)" {
const "elt_id","$hmi_element//*[@inkscape:label=$name][1]/@id";
- if "$mandatory='yes' and not($elt_id)" error > Meter widget must have a «$name» element
+ if "$mandatory='yes' and not($elt_id)" + warning > «$widget_type» widget must have a «$name» element | «$name»_elt: document.getElementById("«$elt_id»"),
@@ -347,7 +354,7 @@
| this.element.textContent = String(value);
- error > Display widget as a group not implemented
+ warning > Display widget as a group not implemented --- a/svghmi/svghmi.js Thu Jan 30 14:33:06 2020 +0100
+++ b/svghmi/svghmi.js Tue Feb 11 13:56:48 2020 +0100
@@ -3,19 +3,18 @@
var cache = hmitree_types.map(_ignored => undefined);
function dispatch_value_to_widget(widget, index, value, oldval) {
- let idxidx = widget.indexes.indexOf(index);
- throw new Error("Dispatching to widget not interested, should not happen.");
+ let idxidx = widget.indexes.indexOf(index); + let d = widget.dispatch; + if(typeof(d) == "function" && idxidx == 0){ + d.call(widget, value, oldval); + }else if(typeof(d) == "object" && d.length >= idxidx){ + d[idxidx].call(widget, value, oldval); + }/* else dispatch_0, ..., dispatch_n ? */ + throw new Error("Dunno how to dispatch to widget at index = " + index); - let d = widget.dispatch;
- if(typeof(d) == "function" && idxidx == 0){
- return d.call(widget, value, oldval);
- }else if(typeof(d) == "object" && d.length >= idxidx){
- return d[idxidx].call(widget, value, oldval);
- }/* else dispatch_0, ..., dispatch_n ? */
- throw new Error("Dunno how to dispatch to widget at index = " + index);
function dispatch_value(index, value) {
@@ -36,7 +35,12 @@
let widget = hmi_widgets[id];
if(typeof(init) == "function"){
- return init.call(widget);
+ console.log("Widget initialization error : "+err.message); --- a/svghmi/svghmi.py Thu Jan 30 14:33:06 2020 +0100
+++ b/svghmi/svghmi.py Tue Feb 11 13:56:48 2020 +0100
@@ -475,10 +475,14 @@
svgdom = etree.parse(svgfile)
# call xslt transform on Inkscape's SVG to generate XHTML
result = transform.transform(svgdom)
except XSLTApplyError as e:
self.FatalError("SVGHMI " + view_name + ": " + e.message)
+ for entry in transform.get_error_log(): + message = "SVGHMI: "+ entry.message + "\n" + self.GetCTRoot().logger.write_warning(message) result.write(target_file, encoding="utf-8")
@@ -508,7 +512,7 @@
repr(shlex.split(given_command.format(port="8008", name=view_name))) +
- ")") if given_command else "# no command given"
+ ")") if given_command else "pass # no command given" runtimefile_path = os.path.join(buildpath, "runtime_svghmi1_%s.py" % location_str)
runtimefile = open(runtimefile_path, 'w')