tests/logging/py_ext_0@py_ext/pyfile.xml
author Edouard Tisserant
Wed, 01 Jul 2020 10:36:20 +0200
changeset 2686 703ebf57508a
parent 1639 1953c268a194
permissions -rw-r--r--
Modbus and Bacnet websettings : Rename variables and functions to avoid name collisions.

Websettings for modbus and bacnet are now passed to runtime as python files loaded (execfile) at init of PLCObject with the same globals.
Because if this, same names used in previously different modules now colide.
<?xml version='1.0' encoding='utf-8'?>
<PyFile xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <variables/>
  <globals>
    <xhtml:p><![CDATA[import threading, time

MyT = None
Stop = False

def StartLog():
    global MyT
    MyT=threading.Thread(target = DoLog)
    MyT.start()

def DoLog():
    global Stop
    while not Stop:
        PLCObject.LogMessage("Python side Logging (PLC is %s)"%PLCObject.PLCStatus)
        time.sleep(0.3)

def StopLog():
    global MyT,Stop
    Stop=True

_runtime_init.append(StartLog)
_runtime_cleanup.append(StopLog)
]]></xhtml:p>
  </globals>
  <init>
    <xhtml:p><![CDATA[]]></xhtml:p>
  </init>
  <cleanup>
    <xhtml:p><![CDATA[]]></xhtml:p>
  </cleanup>
  <start>
    <xhtml:p><![CDATA[]]></xhtml:p>
  </start>
  <stop>
    <xhtml:p><![CDATA[]]></xhtml:p>
  </stop>
</PyFile>