# HG changeset patch # User Edouard Tisserant # Date 1578924901 -3600 # Node ID 074f43e6e11492eb4b5d1ec7a5477c257504ef87 # Parent d631f8671c75def5e9e369fde4d8df88e68e8969 SVGHMI : Added python fomating {port} and {name} to commands so that command can build target URL diff -r d631f8671c75 -r 074f43e6e114 svghmi/svghmi.py --- a/svghmi/svghmi.py Fri Jan 10 17:00:01 2020 +0100 +++ b/svghmi/svghmi.py Mon Jan 13 15:15:01 2020 +0100 @@ -379,7 +379,6 @@ - @@ -509,33 +508,30 @@ svghmi_cmds = {} for thing in ["Start", "Stop", "Watchdog"]: given_command = self.GetParamsAttributes("SVGHMI.On"+thing)["value"] - if given_command: - svghmi_cmds[thing] = shlex.split(given_command) + svghmi_cmds[thing] = ( + "Popen(" + + repr(shlex.split(given_command.format(port="8008", name=view_name))) + + ")") if given_command else "# no command given" runtimefile_path = os.path.join(buildpath, "runtime_svghmi1_%s.py" % location_str) runtimefile = open(runtimefile_path, 'w') runtimefile.write(""" # TODO : multi -svghmi_cmds = %(svghmi_cmds)s -def svghmi_cmd(cmd): - if cmd in svghmi_cmds: - Popen(svghmi_cmds[cmd]) - def watchdog_trigger(): - svghmi_cmd("Watchdog") - -def _runtime_svghmi1_%(location)s_start(): - svghmi_root.putChild('%(view_name)s',File('%(xhtml)s', defaultType='application/xhtml+xml')) - svghmi_cmd("Start") - -def _runtime_svghmi1_%(location)s_stop(): - svghmi_root.delEntity('%(view_name)s') - svghmi_cmd("Stop") - - """ % {"location": location_str, - "xhtml": target_fname, - "view_name": view_name, - "svghmi_cmds": repr(svghmi_cmds)}) + {svghmi_cmds.Watchdog} + +def _runtime_svghmi1_{location}_start(): + svghmi_root.putChild('{view_name}',File('{xhtml}', defaultType='application/xhtml+xml')) + {svghmi_cmds.Start} + +def _runtime_svghmi1_{location}_stop(): + svghmi_root.delEntity('{view_name}') + {svghmi_cmds.Stop} + + """.format(location=location_str, + xhtml=target_fname, + view_name=view_name, + svghmi_cmds=type("dicobj",(object,),svghmi_cmds))) runtimefile.close() diff -r d631f8671c75 -r 074f43e6e114 tests/svghmi/plc.xml --- a/tests/svghmi/plc.xml Fri Jan 10 17:00:01 2020 +0100 +++ b/tests/svghmi/plc.xml Mon Jan 13 15:15:01 2020 +0100 @@ -1,7 +1,7 @@ - + diff -r d631f8671c75 -r 074f43e6e114 tests/svghmi/svghmi_0@svghmi/confnode.xml --- a/tests/svghmi/svghmi_0@svghmi/confnode.xml Fri Jan 10 17:00:01 2020 +0100 +++ b/tests/svghmi/svghmi_0@svghmi/confnode.xml Mon Jan 13 15:15:01 2020 +0100 @@ -1,2 +1,2 @@ - +