tests/svghmi/py_ext_0@py_ext/pyfile.xml
author Edouard Tisserant <edouard.tisserant@gmail.com>
Mon, 03 Aug 2020 18:22:19 +0200
branchsvghmi
changeset 3002 30b0635fe92e
parent 2996 14635b09d329
child 3031 440d74319a74
permissions -rw-r--r--
SVGHMI: Add ForEach Widget is svghmi test
2983
43198edb6ac0 SVGHMI: Add use of Python PLC Globals it test
Edouard Tisserant
parents:
diff changeset
     1
<?xml version='1.0' encoding='utf-8'?>
43198edb6ac0 SVGHMI: Add use of Python PLC Globals it test
Edouard Tisserant
parents:
diff changeset
     2
<PyFile xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
43198edb6ac0 SVGHMI: Add use of Python PLC Globals it test
Edouard Tisserant
parents:
diff changeset
     3
  <variables>
43198edb6ac0 SVGHMI: Add use of Python PLC Globals it test
Edouard Tisserant
parents:
diff changeset
     4
    <variable name="SomePLCglobal" type="HMI_STRING" onchange="MyOnChangeFunc"/>
2996
14635b09d329 SVGHMI: JsonTable now generate working data access code for data/* elements.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2994
diff changeset
     5
    <variable name="AlarmCount" type="HMI_INT"/>
2983
43198edb6ac0 SVGHMI: Add use of Python PLC Globals it test
Edouard Tisserant
parents:
diff changeset
     6
  </variables>
43198edb6ac0 SVGHMI: Add use of Python PLC Globals it test
Edouard Tisserant
parents:
diff changeset
     7
  <globals>
43198edb6ac0 SVGHMI: Add use of Python PLC Globals it test
Edouard Tisserant
parents:
diff changeset
     8
    <xhtml:p><![CDATA[
2994
b6a9ef7f7e43 SVGHMI: minimal JSON Table Widget communication infra + corresponding python code as py_ext code in svghmi test. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2983
diff changeset
     9
from twisted.web.resource import Resource
2996
14635b09d329 SVGHMI: JsonTable now generate working data access code for data/* elements.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2994
diff changeset
    10
import json
2994
b6a9ef7f7e43 SVGHMI: minimal JSON Table Widget communication infra + corresponding python code as py_ext code in svghmi test. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2983
diff changeset
    11
b6a9ef7f7e43 SVGHMI: minimal JSON Table Widget communication infra + corresponding python code as py_ext code in svghmi test. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2983
diff changeset
    12
class AlarmJsonResource(Resource):
b6a9ef7f7e43 SVGHMI: minimal JSON Table Widget communication infra + corresponding python code as py_ext code in svghmi test. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2983
diff changeset
    13
    def render_GET(self, request):
b6a9ef7f7e43 SVGHMI: minimal JSON Table Widget communication infra + corresponding python code as py_ext code in svghmi test. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2983
diff changeset
    14
        return ''
b6a9ef7f7e43 SVGHMI: minimal JSON Table Widget communication infra + corresponding python code as py_ext code in svghmi test. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2983
diff changeset
    15
b6a9ef7f7e43 SVGHMI: minimal JSON Table Widget communication infra + corresponding python code as py_ext code in svghmi test. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2983
diff changeset
    16
    def render_POST(self, request):
b6a9ef7f7e43 SVGHMI: minimal JSON Table Widget communication infra + corresponding python code as py_ext code in svghmi test. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2983
diff changeset
    17
        print(request.__dict__)
b6a9ef7f7e43 SVGHMI: minimal JSON Table Widget communication infra + corresponding python code as py_ext code in svghmi test. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2983
diff changeset
    18
        newdata = request.content.getvalue()
b6a9ef7f7e43 SVGHMI: minimal JSON Table Widget communication infra + corresponding python code as py_ext code in svghmi test. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2983
diff changeset
    19
        print newdata
2996
14635b09d329 SVGHMI: JsonTable now generate working data access code for data/* elements.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2994
diff changeset
    20
        selected_alarms = [
14635b09d329 SVGHMI: JsonTable now generate working data access code for data/* elements.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2994
diff changeset
    21
            {"name":"three", "sides":3},
14635b09d329 SVGHMI: JsonTable now generate working data access code for data/* elements.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2994
diff changeset
    22
            {"name":"four", "sides":4},
14635b09d329 SVGHMI: JsonTable now generate working data access code for data/* elements.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2994
diff changeset
    23
            {"name":"five", "sides":5},
14635b09d329 SVGHMI: JsonTable now generate working data access code for data/* elements.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2994
diff changeset
    24
            {"name":"six", "sides":6},
14635b09d329 SVGHMI: JsonTable now generate working data access code for data/* elements.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2994
diff changeset
    25
        ]
14635b09d329 SVGHMI: JsonTable now generate working data access code for data/* elements.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2994
diff changeset
    26
        return json.dumps(selected_alarms)
2994
b6a9ef7f7e43 SVGHMI: minimal JSON Table Widget communication infra + corresponding python code as py_ext code in svghmi test. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2983
diff changeset
    27
2983
43198edb6ac0 SVGHMI: Add use of Python PLC Globals it test
Edouard Tisserant
parents:
diff changeset
    28
43198edb6ac0 SVGHMI: Add use of Python PLC Globals it test
Edouard Tisserant
parents:
diff changeset
    29
def MyOnChangeFunc(changed_var_name):
43198edb6ac0 SVGHMI: Add use of Python PLC Globals it test
Edouard Tisserant
parents:
diff changeset
    30
    print changed_var_name + ": " + getattr(PLCGlobals, changed_var_name)
43198edb6ac0 SVGHMI: Add use of Python PLC Globals it test
Edouard Tisserant
parents:
diff changeset
    31
43198edb6ac0 SVGHMI: Add use of Python PLC Globals it test
Edouard Tisserant
parents:
diff changeset
    32
]]></xhtml:p>
43198edb6ac0 SVGHMI: Add use of Python PLC Globals it test
Edouard Tisserant
parents:
diff changeset
    33
  </globals>
43198edb6ac0 SVGHMI: Add use of Python PLC Globals it test
Edouard Tisserant
parents:
diff changeset
    34
  <init>
43198edb6ac0 SVGHMI: Add use of Python PLC Globals it test
Edouard Tisserant
parents:
diff changeset
    35
    <xhtml:p><![CDATA[
43198edb6ac0 SVGHMI: Add use of Python PLC Globals it test
Edouard Tisserant
parents:
diff changeset
    36
]]></xhtml:p>
43198edb6ac0 SVGHMI: Add use of Python PLC Globals it test
Edouard Tisserant
parents:
diff changeset
    37
  </init>
43198edb6ac0 SVGHMI: Add use of Python PLC Globals it test
Edouard Tisserant
parents:
diff changeset
    38
  <cleanup>
43198edb6ac0 SVGHMI: Add use of Python PLC Globals it test
Edouard Tisserant
parents:
diff changeset
    39
    <xhtml:p><![CDATA[
43198edb6ac0 SVGHMI: Add use of Python PLC Globals it test
Edouard Tisserant
parents:
diff changeset
    40
]]></xhtml:p>
43198edb6ac0 SVGHMI: Add use of Python PLC Globals it test
Edouard Tisserant
parents:
diff changeset
    41
  </cleanup>
43198edb6ac0 SVGHMI: Add use of Python PLC Globals it test
Edouard Tisserant
parents:
diff changeset
    42
  <start>
43198edb6ac0 SVGHMI: Add use of Python PLC Globals it test
Edouard Tisserant
parents:
diff changeset
    43
    <xhtml:p><![CDATA[
2994
b6a9ef7f7e43 SVGHMI: minimal JSON Table Widget communication infra + corresponding python code as py_ext code in svghmi test. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2983
diff changeset
    44
b6a9ef7f7e43 SVGHMI: minimal JSON Table Widget communication infra + corresponding python code as py_ext code in svghmi test. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2983
diff changeset
    45
svghmi_root.putChild("alarms", AlarmJsonResource())
b6a9ef7f7e43 SVGHMI: minimal JSON Table Widget communication infra + corresponding python code as py_ext code in svghmi test. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2983
diff changeset
    46
b6a9ef7f7e43 SVGHMI: minimal JSON Table Widget communication infra + corresponding python code as py_ext code in svghmi test. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2983
diff changeset
    47
2983
43198edb6ac0 SVGHMI: Add use of Python PLC Globals it test
Edouard Tisserant
parents:
diff changeset
    48
]]></xhtml:p>
43198edb6ac0 SVGHMI: Add use of Python PLC Globals it test
Edouard Tisserant
parents:
diff changeset
    49
  </start>
43198edb6ac0 SVGHMI: Add use of Python PLC Globals it test
Edouard Tisserant
parents:
diff changeset
    50
  <stop>
43198edb6ac0 SVGHMI: Add use of Python PLC Globals it test
Edouard Tisserant
parents:
diff changeset
    51
    <xhtml:p><![CDATA[
43198edb6ac0 SVGHMI: Add use of Python PLC Globals it test
Edouard Tisserant
parents:
diff changeset
    52
]]></xhtml:p>
43198edb6ac0 SVGHMI: Add use of Python PLC Globals it test
Edouard Tisserant
parents:
diff changeset
    53
  </stop>
43198edb6ac0 SVGHMI: Add use of Python PLC Globals it test
Edouard Tisserant
parents:
diff changeset
    54
</PyFile>