372 <xsd:element name="SVGHMI"> |
372 <xsd:element name="SVGHMI"> |
373 <xsd:complexType> |
373 <xsd:complexType> |
374 <xsd:attribute name="OnStart" type="xsd:string" use="optional"/> |
374 <xsd:attribute name="OnStart" type="xsd:string" use="optional"/> |
375 <xsd:attribute name="OnStop" type="xsd:string" use="optional"/> |
375 <xsd:attribute name="OnStop" type="xsd:string" use="optional"/> |
376 <xsd:attribute name="OnWatchdog" type="xsd:string" use="optional"/> |
376 <xsd:attribute name="OnWatchdog" type="xsd:string" use="optional"/> |
|
377 <xsd:attribute name="WatchdogInitial" type="xsd:integer" use="optional"/> |
|
378 <xsd:attribute name="WatchdogInterval" type="xsd:integer" use="optional"/> |
377 </xsd:complexType> |
379 </xsd:complexType> |
378 </xsd:element> |
380 </xsd:element> |
379 </xsd:schema> |
381 </xsd:schema> |
380 """ |
382 """ |
381 |
383 |
509 ")") if given_command else "# no command given" |
511 ")") if given_command else "# no command given" |
510 |
512 |
511 runtimefile_path = os.path.join(buildpath, "runtime_svghmi1_%s.py" % location_str) |
513 runtimefile_path = os.path.join(buildpath, "runtime_svghmi1_%s.py" % location_str) |
512 runtimefile = open(runtimefile_path, 'w') |
514 runtimefile = open(runtimefile_path, 'w') |
513 runtimefile.write(""" |
515 runtimefile.write(""" |
514 # TODO : multi |
516 # TODO : multiple watchdog (one for each svghmi instance) |
515 def watchdog_trigger(): |
517 def svghmi_watchdog_trigger(): |
516 {svghmi_cmds[Watchdog]} |
518 {svghmi_cmds[Watchdog]} |
517 |
519 |
|
520 svghmi_watchdog = None |
|
521 |
518 def _runtime_svghmi1_{location}_start(): |
522 def _runtime_svghmi1_{location}_start(): |
519 svghmi_root.putChild('{view_name}', NoCacheFile('{xhtml}', defaultType='application/xhtml+xml')) |
523 global svghmi_watchdog |
|
524 svghmi_root.putChild( |
|
525 '{view_name}', |
|
526 NoCacheFile('{xhtml}', |
|
527 defaultType='application/xhtml+xml')) |
|
528 |
520 {svghmi_cmds[Start]} |
529 {svghmi_cmds[Start]} |
521 |
530 |
|
531 svghmi_watchdog = Watchdog( |
|
532 {watchdog_initial}, |
|
533 {watchdog_interval}, |
|
534 svghmi_watchdog_trigger) |
|
535 |
522 def _runtime_svghmi1_{location}_stop(): |
536 def _runtime_svghmi1_{location}_stop(): |
|
537 global svghmi_watchdog |
|
538 if svghmi_watchdog is not None: |
|
539 svghmi_watchdog.cancel() |
|
540 svghmi_watchdog = None |
|
541 |
523 svghmi_root.delEntity('{view_name}') |
542 svghmi_root.delEntity('{view_name}') |
524 {svghmi_cmds[Stop]} |
543 {svghmi_cmds[Stop]} |
525 |
544 |
526 """.format(location=location_str, |
545 """.format(location=location_str, |
527 xhtml=target_fname, |
546 xhtml=target_fname, |
528 view_name=view_name, |
547 view_name=view_name, |
529 svghmi_cmds=svghmi_cmds)) |
548 svghmi_cmds=svghmi_cmds, |
|
549 watchdog_initial = self.GetParamsAttributes("SVGHMI.WatchdogInitial")["value"], |
|
550 watchdog_interval = self.GetParamsAttributes("SVGHMI.WatchdogInterval")["value"], |
|
551 )) |
530 |
552 |
531 runtimefile.close() |
553 runtimefile.close() |
532 |
554 |
533 res += (("runtime_svghmi1_%s.py" % location_str, open(runtimefile_path, "rb")),) |
555 res += (("runtime_svghmi1_%s.py" % location_str, open(runtimefile_path, "rb")),) |
534 |
556 |