373 class SVGHMI(object): |
374 class SVGHMI(object): |
374 XSD = """<?xml version="1.0" encoding="utf-8" ?> |
375 XSD = """<?xml version="1.0" encoding="utf-8" ?> |
375 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
376 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
376 <xsd:element name="SVGHMI"> |
377 <xsd:element name="SVGHMI"> |
377 <xsd:complexType> |
378 <xsd:complexType> |
378 <xsd:attribute name="enableHTTP" type="xsd:boolean" use="optional" default="false"/> |
379 <xsd:attribute name="OnStart" type="xsd:string" use="optional"/> |
379 <xsd:attribute name="bindAddress" type="xsd:string" use="optional" default="localhost"/> |
380 <xsd:attribute name="OnStop" type="xsd:string" use="optional"/> |
|
381 <xsd:attribute name="OnWatchdog" type="xsd:string" use="optional"/> |
380 <xsd:attribute name="port" type="xsd:string" use="optional" default="8080"/> |
382 <xsd:attribute name="port" type="xsd:string" use="optional" default="8080"/> |
381 </xsd:complexType> |
383 </xsd:complexType> |
382 </xsd:element> |
384 </xsd:element> |
383 </xsd:schema> |
385 </xsd:schema> |
384 """ |
386 """ |
501 """) |
503 """) |
502 |
504 |
503 target_file.close() |
505 target_file.close() |
504 |
506 |
505 res += ((target_fname, open(target_path, "rb")),) |
507 res += ((target_fname, open(target_path, "rb")),) |
|
508 |
|
509 svghmi_cmds = {} |
|
510 for thing in ["Start", "Stop", "Watchdog"]: |
|
511 given_command = self.GetParamsAttributes("SVGHMI.On"+thing)["value"] |
|
512 if given_command: |
|
513 svghmi_cmds[thing] = shlex.split(given_command) |
506 |
514 |
507 runtimefile_path = os.path.join(buildpath, "runtime_svghmi1_%s.py" % location_str) |
515 runtimefile_path = os.path.join(buildpath, "runtime_svghmi1_%s.py" % location_str) |
508 runtimefile = open(runtimefile_path, 'w') |
516 runtimefile = open(runtimefile_path, 'w') |
509 runtimefile.write(""" |
517 runtimefile.write(""" |
|
518 # TODO : multi |
|
519 svghmi_cmds = %(svghmi_cmds)s |
|
520 def svghmi_cmd(cmd): |
|
521 if cmd in svghmi_cmds: |
|
522 Popen(svghmi_cmds[cmd]) |
|
523 |
|
524 def watchdog_trigger(): |
|
525 svghmi_cmd("Watchdog") |
|
526 |
510 def _runtime_svghmi1_%(location)s_start(): |
527 def _runtime_svghmi1_%(location)s_start(): |
511 svghmi_root.putChild('%(view_name)s',File('%(xhtml)s', defaultType='application/xhtml+xml')) |
528 svghmi_root.putChild('%(view_name)s',File('%(xhtml)s', defaultType='application/xhtml+xml')) |
|
529 svghmi_cmd("Start") |
512 |
530 |
513 def _runtime_svghmi1_%(location)s_stop(): |
531 def _runtime_svghmi1_%(location)s_stop(): |
514 svghmi_root.delEntity('%(view_name)s') |
532 svghmi_root.delEntity('%(view_name)s') |
|
533 svghmi_cmd("Stop") |
515 |
534 |
516 """ % {"location": location_str, |
535 """ % {"location": location_str, |
517 "xhtml": target_fname, |
536 "xhtml": target_fname, |
518 "view_name": view_name}) |
537 "view_name": view_name, |
|
538 "svghmi_cmds": repr(svghmi_cmds)}) |
519 |
539 |
520 runtimefile.close() |
540 runtimefile.close() |
521 |
541 |
522 res += (("runtime_svghmi1_%s.py" % location_str, open(runtimefile_path, "rb")),) |
542 res += (("runtime_svghmi1_%s.py" % location_str, open(runtimefile_path, "rb")),) |
523 |
543 |