author | Edouard Tisserant |
Thu, 19 Sep 2019 15:32:36 +0200 | |
branch | svghmi |
changeset 2782 | 723e420dfe72 |
parent 2779 | 75c6a31caca6 |
child 2788 | 2ed9ff826d03 |
permissions | -rw-r--r-- |
2771
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
1 |
#!/usr/bin/env python |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
3 |
|
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
4 |
# This file is part of Beremiz |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
5 |
# Copyright (C) 2019: Edouard TISSERANT |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
6 |
# See COPYING file for copyrights details. |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
7 |
|
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
8 |
from __future__ import absolute_import |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
9 |
|
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
10 |
from twisted.web.server import Site |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
11 |
from twisted.web.resource import Resource |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
12 |
from twisted.internet import reactor |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
13 |
from twisted.web.static import File |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
14 |
|
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
15 |
from autobahn.twisted.websocket import WebSocketServerFactory, WebSocketServerProtocol |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
16 |
from autobahn.twisted.resource import WebSocketResource |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
17 |
|
2773 | 18 |
# TODO multiclient : |
19 |
# session list lock |
|
20 |
# svghmi_sessions = [] |
|
21 |
||
22 |
svghmi_session = None |
|
2771
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
23 |
|
2774
9857b4b0d979
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2773
diff
changeset
|
24 |
svghmi_send_collect = PLCBinary.svghmi_send_collect |
9857b4b0d979
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2773
diff
changeset
|
25 |
svghmi_send_collect.restype = ctypes.c_int # error or 0 |
9857b4b0d979
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2773
diff
changeset
|
26 |
svghmi_send_collect.argtypes = [ |
9857b4b0d979
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2773
diff
changeset
|
27 |
ctypes.POINTER(ctypes.c_uint32), # size |
2779
75c6a31caca6
SVGHMI: Work In Progress : fixed pointer types in ctypes interface, cleaned up server startup and cleanup code, changed document type to XHTML, cleaner JS script : encapsulated in a function and in CDATA.
Edouard Tisserant
parents:
2777
diff
changeset
|
28 |
ctypes.POINTER(ctypes.c_char_p)] # data ptr |
2774
9857b4b0d979
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2773
diff
changeset
|
29 |
# TODO multiclient : switch to arrays |
9857b4b0d979
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2773
diff
changeset
|
30 |
|
9857b4b0d979
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2773
diff
changeset
|
31 |
svghmi_recv_dispatch = PLCBinary.svghmi_recv_dispatch |
9857b4b0d979
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2773
diff
changeset
|
32 |
svghmi_recv_dispatch.restype = ctypes.c_int # error or 0 |
9857b4b0d979
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2773
diff
changeset
|
33 |
svghmi_recv_dispatch.argtypes = [ |
2779
75c6a31caca6
SVGHMI: Work In Progress : fixed pointer types in ctypes interface, cleaned up server startup and cleanup code, changed document type to XHTML, cleaner JS script : encapsulated in a function and in CDATA.
Edouard Tisserant
parents:
2777
diff
changeset
|
34 |
ctypes.c_uint32, # size |
75c6a31caca6
SVGHMI: Work In Progress : fixed pointer types in ctypes interface, cleaned up server startup and cleanup code, changed document type to XHTML, cleaner JS script : encapsulated in a function and in CDATA.
Edouard Tisserant
parents:
2777
diff
changeset
|
35 |
ctypes.c_char_p] # data ptr |
2774
9857b4b0d979
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2773
diff
changeset
|
36 |
# TODO multiclient : switch to arrays |
9857b4b0d979
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2773
diff
changeset
|
37 |
|
2771
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
38 |
class HMISession(object): |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
39 |
def __init__(self, protocol_instance): |
2773 | 40 |
global svghmi_session |
2775
3b93409ba22c
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2774
diff
changeset
|
41 |
|
2773 | 42 |
# TODO: kill existing session for robustness |
43 |
assert(svghmi_session is None) |
|
44 |
||
45 |
svghmi_session = self |
|
46 |
self.protocol_instance = protocol_instance |
|
2771
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
47 |
|
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
48 |
# TODO multiclient : |
2773 | 49 |
# svghmi_sessions.append(self) |
2771
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
50 |
# get a unique bit index amont other svghmi_sessions, |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
51 |
# so that we can match flags passed by C->python callback |
2775
3b93409ba22c
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2774
diff
changeset
|
52 |
|
2771
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
53 |
def __del__(self): |
2773 | 54 |
global svghmi_session |
55 |
assert(svghmi_session) |
|
56 |
svghmi_session = None |
|
57 |
||
58 |
# TODO multiclient : |
|
59 |
# svghmi_sessions.remove(self) |
|
2771
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
60 |
|
2772 | 61 |
def onMessage(self, msg): |
2779
75c6a31caca6
SVGHMI: Work In Progress : fixed pointer types in ctypes interface, cleaned up server startup and cleanup code, changed document type to XHTML, cleaner JS script : encapsulated in a function and in CDATA.
Edouard Tisserant
parents:
2777
diff
changeset
|
62 |
# pass message to the C side recieve_message() |
75c6a31caca6
SVGHMI: Work In Progress : fixed pointer types in ctypes interface, cleaned up server startup and cleanup code, changed document type to XHTML, cleaner JS script : encapsulated in a function and in CDATA.
Edouard Tisserant
parents:
2777
diff
changeset
|
63 |
c_string = ctypes.c_char_p(msg) |
75c6a31caca6
SVGHMI: Work In Progress : fixed pointer types in ctypes interface, cleaned up server startup and cleanup code, changed document type to XHTML, cleaner JS script : encapsulated in a function and in CDATA.
Edouard Tisserant
parents:
2777
diff
changeset
|
64 |
c_string_pointer = ctypes.c_void_p(ctypes.addressof(c_string)) |
75c6a31caca6
SVGHMI: Work In Progress : fixed pointer types in ctypes interface, cleaned up server startup and cleanup code, changed document type to XHTML, cleaner JS script : encapsulated in a function and in CDATA.
Edouard Tisserant
parents:
2777
diff
changeset
|
65 |
svghmi_recv_dispatch(len(msg), msg) |
2771
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
66 |
|
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
67 |
# TODO multiclient : pass client index as well |
2777
cdf6584953a0
SVGHMI: WIP for python<->C data exchange : message from browser hit the C side.
Edouard Tisserant
parents:
2776
diff
changeset
|
68 |
|
2775
3b93409ba22c
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2774
diff
changeset
|
69 |
|
2774
9857b4b0d979
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2773
diff
changeset
|
70 |
def sendMessage(self, msg): |
9857b4b0d979
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2773
diff
changeset
|
71 |
self.sendMessage(msg, True) |
2771
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
72 |
|
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
73 |
class HMIProtocol(WebSocketServerProtocol): |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
74 |
|
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
75 |
def __init__(self, *args, **kwargs): |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
76 |
self._hmi_session = None |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
77 |
WebSocketServerProtocol.__init__(self, *args, **kwargs) |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
78 |
|
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
79 |
def onOpen(self): |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
80 |
self._hmi_session = HMISession(self) |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
81 |
print "open" |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
82 |
|
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
83 |
def onClose(self, wasClean, code, reason): |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
84 |
del self._hmi_session |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
85 |
self._hmi_session = None |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
86 |
print "close" |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
87 |
|
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
88 |
def onMessage(self, msg, isBinary): |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
89 |
self._hmi_session.onMessage(msg) |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
90 |
print msg |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
91 |
#self.sendMessage(msg, binary) |
2775
3b93409ba22c
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2774
diff
changeset
|
92 |
|
2779
75c6a31caca6
SVGHMI: Work In Progress : fixed pointer types in ctypes interface, cleaned up server startup and cleanup code, changed document type to XHTML, cleaner JS script : encapsulated in a function and in CDATA.
Edouard Tisserant
parents:
2777
diff
changeset
|
93 |
class HMIWebSocketServerFactory(WebSocketServerFactory): |
75c6a31caca6
SVGHMI: Work In Progress : fixed pointer types in ctypes interface, cleaned up server startup and cleanup code, changed document type to XHTML, cleaner JS script : encapsulated in a function and in CDATA.
Edouard Tisserant
parents:
2777
diff
changeset
|
94 |
protocol = HMIProtocol |
75c6a31caca6
SVGHMI: Work In Progress : fixed pointer types in ctypes interface, cleaned up server startup and cleanup code, changed document type to XHTML, cleaner JS script : encapsulated in a function and in CDATA.
Edouard Tisserant
parents:
2777
diff
changeset
|
95 |
|
2771
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
96 |
svghmi_root = None |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
97 |
svghmi_listener = None |
2775
3b93409ba22c
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2774
diff
changeset
|
98 |
svghmi_send_thread = None |
3b93409ba22c
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2774
diff
changeset
|
99 |
|
2776
246ae685ab65
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2775
diff
changeset
|
100 |
def SendThreadProc(): |
246ae685ab65
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2775
diff
changeset
|
101 |
global svghmi_session |
246ae685ab65
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2775
diff
changeset
|
102 |
size = ctypes.c_uint32() |
2779
75c6a31caca6
SVGHMI: Work In Progress : fixed pointer types in ctypes interface, cleaned up server startup and cleanup code, changed document type to XHTML, cleaner JS script : encapsulated in a function and in CDATA.
Edouard Tisserant
parents:
2777
diff
changeset
|
103 |
ptr = ctypes.c_char_p() |
2776
246ae685ab65
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2775
diff
changeset
|
104 |
res = 0 |
246ae685ab65
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2775
diff
changeset
|
105 |
while svghmi_send_collect(ctypes.byref(size), ctypes.byref(ptr)) == 0 and \ |
246ae685ab65
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2775
diff
changeset
|
106 |
svghmi_session is not None and \ |
246ae685ab65
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2775
diff
changeset
|
107 |
svghmi_session.sendMessage(ctypes.string_at(ptr,size)) == 0: |
246ae685ab65
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2775
diff
changeset
|
108 |
pass |
246ae685ab65
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2775
diff
changeset
|
109 |
|
246ae685ab65
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2775
diff
changeset
|
110 |
# TODO multiclient : dispatch to sessions |
246ae685ab65
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2775
diff
changeset
|
111 |
|
2771
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
112 |
|
2779
75c6a31caca6
SVGHMI: Work In Progress : fixed pointer types in ctypes interface, cleaned up server startup and cleanup code, changed document type to XHTML, cleaner JS script : encapsulated in a function and in CDATA.
Edouard Tisserant
parents:
2777
diff
changeset
|
113 |
|
2771
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
114 |
# Called by PLCObject at start |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
115 |
def _runtime_svghmi0_start(): |
2775
3b93409ba22c
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2774
diff
changeset
|
116 |
global svghmi_listener, svghmi_root, svghmi_send_thread |
2771
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
117 |
|
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
118 |
svghmi_root = Resource() |
2779
75c6a31caca6
SVGHMI: Work In Progress : fixed pointer types in ctypes interface, cleaned up server startup and cleanup code, changed document type to XHTML, cleaner JS script : encapsulated in a function and in CDATA.
Edouard Tisserant
parents:
2777
diff
changeset
|
119 |
svghmi_root.putChild("ws", WebSocketResource(HMIWebSocketServerFactory())) |
2771
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
120 |
|
2779
75c6a31caca6
SVGHMI: Work In Progress : fixed pointer types in ctypes interface, cleaned up server startup and cleanup code, changed document type to XHTML, cleaner JS script : encapsulated in a function and in CDATA.
Edouard Tisserant
parents:
2777
diff
changeset
|
121 |
svghmi_listener = reactor.listenTCP(8008, Site(svghmi_root)) |
2771
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
122 |
|
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
123 |
# start a thread that call the C part of SVGHMI |
2775
3b93409ba22c
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2774
diff
changeset
|
124 |
svghmi_send_thread = Thread(target=SendThreadProc, name="SVGHMI Send") |
3b93409ba22c
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2774
diff
changeset
|
125 |
svghmi_send_thread.start() |
2771
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
126 |
|
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
127 |
|
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
128 |
# Called by PLCObject at stop |
361366b891ca
WIP on svghmi, now builds and runs. HTTP serving + WS transport ready, missing actual data to transmit and thread to collect it.
Edouard Tisserant
parents:
diff
changeset
|
129 |
def _runtime_svghmi0_stop(): |
2775
3b93409ba22c
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2774
diff
changeset
|
130 |
global svghmi_listener, svghmi_root, svghmi_send_thread |
3b93409ba22c
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2774
diff
changeset
|
131 |
svghmi_root.delEntity("ws") |
3b93409ba22c
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2774
diff
changeset
|
132 |
svghmi_root = None |
2772 | 133 |
svghmi_listener.stopListening() |
2775
3b93409ba22c
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2774
diff
changeset
|
134 |
svghmi_listener = None |
3b93409ba22c
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2774
diff
changeset
|
135 |
# plc cleanup calls svghmi_(locstring)_cleanup and unlocks send thread |
3b93409ba22c
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2774
diff
changeset
|
136 |
svghmi_send_thread.join() |
3b93409ba22c
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2774
diff
changeset
|
137 |
svghmi_send_thread = None |
3b93409ba22c
SVGHMI: WIP for python<->C data exchange
Edouard Tisserant
parents:
2774
diff
changeset
|
138 |