1 <?xml version='1.0' encoding='utf-8'?> |
1 <?xml version='1.0' encoding='utf-8'?> |
2 <PyFile xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
2 <PyFile xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
3 <variables> |
3 <variables> |
4 <variable name="SomePLCglobal" type="HMI_STRING" onchange="MyOnChangeFunc"/> |
4 <variable name="SomePLCglobal" type="HMI_STRING" onchange="MyOnChangeFunc"/> |
|
5 <variable name="AlarmCount" type="HMI_INT"/> |
5 </variables> |
6 </variables> |
6 <globals> |
7 <globals> |
7 <xhtml:p><![CDATA[ |
8 <xhtml:p><![CDATA[ |
8 from twisted.web.resource import Resource |
9 from twisted.web.resource import Resource |
|
10 import json |
9 |
11 |
10 class AlarmJsonResource(Resource): |
12 class AlarmJsonResource(Resource): |
11 def render_GET(self, request): |
13 def render_GET(self, request): |
12 return '' |
14 return '' |
13 |
15 |
14 def render_POST(self, request): |
16 def render_POST(self, request): |
15 print(request.__dict__) |
17 print(request.__dict__) |
16 newdata = request.content.getvalue() |
18 newdata = request.content.getvalue() |
17 print newdata |
19 print newdata |
18 return '' |
20 selected_alarms = [ |
|
21 {"name":"three", "sides":3}, |
|
22 {"name":"four", "sides":4}, |
|
23 {"name":"five", "sides":5}, |
|
24 {"name":"six", "sides":6}, |
|
25 ] |
|
26 return json.dumps(selected_alarms) |
19 |
27 |
20 |
28 |
21 def MyOnChangeFunc(changed_var_name): |
29 def MyOnChangeFunc(changed_var_name): |
22 print changed_var_name + ": " + getattr(PLCGlobals, changed_var_name) |
30 print changed_var_name + ": " + getattr(PLCGlobals, changed_var_name) |
23 |
31 |