# HG changeset patch # User Edouard Tisserant <edouard.tisserant@gmail.com> # Date 1627281746 -7200 # Node ID f0c97422b34a0434ff9fa6642e936de93a1aedb8 # Parent 3c893aed919855942a8ead539b6385829acd6cd6 SVGHMI: Fix detection of library without instance and instances without library. Added one more widget in the widget library. Renamed "view_name" in "name" in commands substitutions. diff -r 3c893aed9198 -r f0c97422b34a svghmi/svghmi.py --- a/svghmi/svghmi.py Fri Jul 23 13:16:15 2021 +0200 +++ b/svghmi/svghmi.py Mon Jul 26 08:42:26 2021 +0200 @@ -57,8 +57,10 @@ global hmi_tree_root, on_hmitree_update, maxConnectionsTotal already_found_watchdog = False + found_SVGHMI_instance = False for CTNChild in self.GetCTR().IterChildren(): if isinstance(CTNChild, SVGHMI): + found_SVGHMI_instance = True # collect maximum connection total for all svghmi nodes maxConnectionsTotal += CTNChild.GetParamsAttributes("SVGHMI.MaxConnections")["value"] @@ -68,6 +70,9 @@ self.FatalError("SVGHMI: Only one watchdog enabled HMI allowed") already_found_watchdog = True + if not found_SVGHMI_instance: + self.FatalError("SVGHMI : Library is selected but not used. Please either deselect it in project config or add a SVGHMI node to project.") + """ PLC Instance Tree: @@ -117,9 +122,6 @@ hmi_types_instances.pop(i) break - if hmi_tree_root is None: - self.FatalError("SVGHMI : Library is selected but not used. Please either deselect it in project config or add a SVGHMI node to project.") - # deduce HMI tree from PLC HMI_* instances for v in hmi_types_instances: path = v["IEC_path"].split(".") @@ -478,10 +480,10 @@ self.GetCTRoot().logger.write(" "*self.indent + "... finished in %.3fs\n"%(t - oldt)) def get_SVGHMI_options(self): - view_name = self.BaseParams.getName() + name = self.BaseParams.getName() port = self.GetParamsAttributes("SVGHMI.Port")["value"] interface = self.GetParamsAttributes("SVGHMI.Interface")["value"] - path = self.GetParamsAttributes("SVGHMI.Path")["value"].format(name=view_name) + path = self.GetParamsAttributes("SVGHMI.Path")["value"].format(name=name) if path and path[0]=='/': path = path[1:] enable_watchdog = self.GetParamsAttributes("SVGHMI.EnableWatchdog")["value"] @@ -490,7 +492,7 @@ ) + ("#watchdog" if enable_watchdog else "") return dict( - view_name=view_name, + name=name, port=port, interface=interface, path=path, @@ -498,6 +500,10 @@ url=url) def CTNGenerate_C(self, buildpath, locations): + global hmi_tree_root + + if hmi_tree_root is None: + self.FatalError("SVGHMI : Library is not selected. Please select it in project config.") location_str = "_".join(map(str, self.GetCurrentLocation())) svghmi_options = self.get_SVGHMI_options() @@ -562,7 +568,7 @@ result = transform.transform(svgdom) # , profile_run=True) self.ProgressEnd("xslt") except XSLTApplyError as e: - self.FatalError("SVGHMI " + svghmi_options["view_name"] + ": " + e.message) + self.FatalError("SVGHMI " + svghmi_options["name"] + ": " + e.message) finally: for entry in transform.get_error_log(): message = "SVGHMI: "+ entry.message + "\n" @@ -621,7 +627,7 @@ if srv is not None: svghmi_root, svghmi_listener, path_list = srv if '{path}' in path_list: - raise Exception("SVGHMI {view_name}: path {path} already used on {interface}:{port}") + raise Exception("SVGHMI {name}: path {path} already used on {interface}:{port}") else: svghmi_root = Resource() factory = HMIWebSocketServerFactory() @@ -649,7 +655,7 @@ {watchdog_interval}, svghmi_{location}_watchdog_trigger) else: - raise Exception("SVGHMI {view_name}: only one watchdog allowed") + raise Exception("SVGHMI {name}: only one watchdog allowed") def _runtime_{location}_svghmi_stop(): diff -r 3c893aed9198 -r f0c97422b34a svghmi/widgetlib/spinctrl.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/svghmi/widgetlib/spinctrl.svg Mon Jul 26 08:42:26 2021 +0200 @@ -0,0 +1,130 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="210mm" + height="297mm" + viewBox="0 0 210 297" + version="1.1" + id="svg2283" + inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)" + sodipodi:docname="spinctrl.svg"> + <defs + id="defs2277" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="5.6" + inkscape:cx="133.93728" + inkscape:cy="643.13396" + inkscape:document-units="mm" + inkscape:current-layer="svg2283" + showgrid="false" + inkscape:window-width="3840" + inkscape:window-height="2096" + inkscape:window-x="1600" + inkscape:window-y="27" + inkscape:window-maximized="1" /> + <metadata + id="metadata2280"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + transform="matrix(0.07564509,0,0,0.07564509,88.680233,101.90213)" + id="g446" + inkscape:label="HMI:Input@/SELECTION"> + <text + inkscape:label="value" + id="text432" + y="218.24219" + x="216.32812" + style="font-style:normal;font-weight:normal;font-size:160px;line-height:125%;font-family:sans-serif;text-align:end;letter-spacing:0px;word-spacing:0px;text-anchor:end;fill:#ff8c00;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;" + xml:space="preserve"><tspan + style="text-align:end;text-anchor:end;stroke-width:1px;fill:#ff8c00;" + y="218.24219" + x="216.32812" + id="tspan430" + sodipodi:role="line">8</tspan></text> + <path + inkscape:label="-1" + inkscape:transform-center-y="7.4781812" + d="m 302.6459,-210.03172 -51.81035,0 25.90517,-44.86908 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="1.5707963" + sodipodi:arg1="0.52359878" + sodipodi:r2="14.956361" + sodipodi:r1="29.912722" + sodipodi:cy="-224.98808" + sodipodi:cx="276.74072" + sodipodi:sides="3" + id="path436" + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#e6e6e6;fill-opacity:1;fill-rule:nonzero;stroke:#ff6600;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + sodipodi:type="star" + transform="scale(1,-1)" /> + <rect + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:0;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#ff00ff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + id="rect438" + width="230.94511" + height="128" + x="1.8178837" + y="95.40741" + onclick="" + inkscape:label="edit" /> + <path + sodipodi:type="star" + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#e6e6e6;fill-opacity:1;fill-rule:nonzero;stroke:#ff6600;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + id="path442" + sodipodi:sides="3" + sodipodi:cx="276.74072" + sodipodi:cy="96.444443" + sodipodi:r1="29.912722" + sodipodi:r2="14.956361" + sodipodi:arg1="0.52359878" + sodipodi:arg2="1.5707963" + inkscape:flatsided="true" + inkscape:rounded="0" + inkscape:randomized="0" + d="m 302.6459,111.4008 -51.81035,0 25.90517,-44.869079 z" + inkscape:transform-center-y="-7.4781804" + inkscape:label="+1" /> + <path + inkscape:transform-center-x="1.0089177e-06" + sodipodi:type="star" + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#e6e6e6;fill-opacity:1;fill-rule:nonzero;stroke:#ff6600;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + id="path444" + sodipodi:sides="4" + sodipodi:cx="276.74072" + sodipodi:cy="160.71626" + sodipodi:r1="41.281136" + sodipodi:r2="21.657967" + sodipodi:arg1="0.77793027" + sodipodi:arg2="1.5633284" + inkscape:flatsided="true" + inkscape:rounded="0" + inkscape:randomized="0" + d="m 306.14807,189.68763 -58.37872,0.43598 -0.43597,-58.37872 58.37871,-0.43597 z" + inkscape:transform-center-y="-10.828983" + inkscape:label="=0" /> + </g> +</svg>