tests/svghmi/py_ext_0@py_ext/pyfile.xml
author Edouard Tisserant
Fri, 21 Aug 2020 14:29:03 +0200
branchsvghmi
changeset 3034 793ce2117258
parent 3031 440d74319a74
child 3036 4930455428df
permissions -rw-r--r--
SVGHMI: JsonTable now makes meaningfull JSON request : all arguments and variables are passed in.
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"/>
3034
793ce2117258 SVGHMI: JsonTable now makes meaningfull JSON request : all arguments and variables are passed in.
Edouard Tisserant
parents: 3031
diff changeset
     5
    <variable name="AlarmNotify" 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
        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
    18
        print newdata
3034
793ce2117258 SVGHMI: JsonTable now makes meaningfull JSON request : all arguments and variables are passed in.
Edouard Tisserant
parents: 3031
diff changeset
    19
        print json.loads(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 = [
3031
440d74319a74 SVGHMI: Refactor the way JsonTable generate javascript code to access json data. Now support multiple assignments, used in the case of text to change both content and style on the same element.
Edouard Tisserant
parents: 2996
diff changeset
    21
            {"name":"three", "sides":3, "textstyle":"alarm"},
440d74319a74 SVGHMI: Refactor the way JsonTable generate javascript code to access json data. Now support multiple assignments, used in the case of text to change both content and style on the same element.
Edouard Tisserant
parents: 2996
diff changeset
    22
            {"name":"four", "sides":4, "textstyle":"ack"},
440d74319a74 SVGHMI: Refactor the way JsonTable generate javascript code to access json data. Now support multiple assignments, used in the case of text to change both content and style on the same element.
Edouard Tisserant
parents: 2996
diff changeset
    23
            {"name":"five", "sides":5, "textstyle":"active"},
440d74319a74 SVGHMI: Refactor the way JsonTable generate javascript code to access json data. Now support multiple assignments, used in the case of text to change both content and style on the same element.
Edouard Tisserant
parents: 2996
diff changeset
    24
            {"name":"six", "sides":6, "textstyle":"disabled"},
2996
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>