author | dporopat <denis.poropat@smarteh.si> |
Fri, 20 Apr 2018 11:21:20 +0200 | |
branch | #2476 |
changeset 2001 | bcbd41efd846 |
parent 1941 | cde74a39df51 |
child 2005 | 0d32b17f15b9 |
permissions | -rw-r--r-- |
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
1 |
#!/usr/bin/env python |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1443
diff
changeset
|
3 |
|
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1443
diff
changeset
|
4 |
# This file is part of Beremiz, a Integrated Development Environment for |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1443
diff
changeset
|
5 |
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
6 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1443
diff
changeset
|
7 |
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
8 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1443
diff
changeset
|
9 |
# See COPYING file for copyrights details. |
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
10 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1443
diff
changeset
|
11 |
# This program is free software; you can redistribute it and/or |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1443
diff
changeset
|
12 |
# modify it under the terms of the GNU General Public License |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1443
diff
changeset
|
13 |
# as published by the Free Software Foundation; either version 2 |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1443
diff
changeset
|
14 |
# of the License, or (at your option) any later version. |
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
15 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1443
diff
changeset
|
16 |
# This program is distributed in the hope that it will be useful, |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1443
diff
changeset
|
17 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1443
diff
changeset
|
18 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1443
diff
changeset
|
19 |
# GNU General Public License for more details. |
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
20 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1443
diff
changeset
|
21 |
# You should have received a copy of the GNU General Public License |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1443
diff
changeset
|
22 |
# along with this program; if not, write to the Free Software |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1443
diff
changeset
|
23 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
24 |
|
1826
91796f408540
fix usage of python2-only print statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
25 |
|
1881
091005ec69c4
fix pylint py3k conversion warning: "(no-absolute-import) import missing `from __future__ import absolute_import`"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1872
diff
changeset
|
26 |
from __future__ import absolute_import |
1826
91796f408540
fix usage of python2-only print statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
27 |
from __future__ import print_function |
2001
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
28 |
import wx |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
29 |
from controls.UriLocationEditor import IConnectorPanel |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
30 |
from zope.interface import implementer |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
31 |
|
1732
94ffe74e6895
clean-up: fix PEP8 E401 multiple imports on one line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1595
diff
changeset
|
32 |
import traceback |
1832
0f1081928d65
fix wrong-import-order. first standard modules are imported, then others
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1826
diff
changeset
|
33 |
from threading import Thread, Event |
0f1081928d65
fix wrong-import-order. first standard modules are imported, then others
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1826
diff
changeset
|
34 |
|
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
35 |
from twisted.internet import reactor, threads |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
36 |
from autobahn.twisted import wamp |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
37 |
from autobahn.twisted.websocket import WampWebSocketClientFactory, connectWS |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
38 |
from autobahn.wamp import types |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
39 |
from autobahn.wamp.exception import TransportLost |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
40 |
from autobahn.wamp.serializer import MsgPackSerializer |
1832
0f1081928d65
fix wrong-import-order. first standard modules are imported, then others
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1826
diff
changeset
|
41 |
|
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
42 |
|
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
43 |
_WampSession = None |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1440
diff
changeset
|
44 |
_WampConnection = None |
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
45 |
_WampSessionEvent = Event() |
2001
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
46 |
URITypes = ["WAMP", "WAMPS"] |
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
47 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
48 |
|
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
49 |
class WampSession(wamp.ApplicationSession): |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
50 |
def onJoin(self, details): |
1841
9fd29e8b1393
fix pylint warning '(global-variable-not-assigned) Using global for 'X' but no assignment is done'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1832
diff
changeset
|
51 |
global _WampSession |
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
52 |
_WampSession = self |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
53 |
_WampSessionEvent.set() |
1826
91796f408540
fix usage of python2-only print statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
54 |
print('WAMP session joined for :', self.config.extra["ID"]) |
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
55 |
|
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
56 |
def onLeave(self, details): |
1841
9fd29e8b1393
fix pylint warning '(global-variable-not-assigned) Using global for 'X' but no assignment is done'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1832
diff
changeset
|
57 |
global _WampSession |
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
58 |
_WampSessionEvent.clear() |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
59 |
_WampSession = None |
1826
91796f408540
fix usage of python2-only print statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
60 |
print('WAMP session left') |
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
61 |
|
1749
d73b64672238
clean-up: fix PEP8 E305 expected 2 blank lines after class or function definition
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1748
diff
changeset
|
62 |
|
1747
6046ffa2280f
clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
63 |
PLCObjDefaults = { |
6046ffa2280f
clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
64 |
"StartPLC": False, |
6046ffa2280f
clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
65 |
"GetTraceVariables": ("Broken", None), |
6046ffa2280f
clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
66 |
"GetPLCstatus": ("Broken", None), |
6046ffa2280f
clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
67 |
"RemoteExec": (-1, "RemoteExec script failed!") |
6046ffa2280f
clean-up: fix PEP8 E201 whitespace after '{'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
68 |
} |
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
69 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
70 |
|
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
71 |
def WAMP_connector_factory(uri, confnodesroot): |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
72 |
""" |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
73 |
WAMP://127.0.0.1:12345/path#realm#ID |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
74 |
WAMPS://127.0.0.1:12345/path#realm#ID |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
75 |
""" |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
76 |
servicetype, location = uri.split("://") |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
77 |
urlpath, realm, ID = location.split('#') |
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
78 |
urlprefix = {"WAMP": "ws", |
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
79 |
"WAMPS": "wss"}[servicetype] |
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
80 |
url = urlprefix+"://"+urlpath |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
81 |
|
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
82 |
def RegisterWampClient(): |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
83 |
|
1753
19f19c66b67e
clean-up: fix most PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1750
diff
changeset
|
84 |
# start logging to console |
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
85 |
# log.startLogging(sys.stdout) |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
86 |
|
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
87 |
# create a WAMP application session factory |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
88 |
component_config = types.ComponentConfig( |
1894
f224383cc883
Fixed changes from dporopat and agregorcic about WAMP CRA and config.
Edouard Tisserant
parents:
1881
diff
changeset
|
89 |
realm=unicode(realm), |
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1740
diff
changeset
|
90 |
extra={"ID": ID}) |
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
91 |
session_factory = wamp.ApplicationSessionFactory( |
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1740
diff
changeset
|
92 |
config=component_config) |
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
93 |
session_factory.session = WampSession |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
94 |
|
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
95 |
# create a WAMP-over-WebSocket transport client factory |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
96 |
transport_factory = WampWebSocketClientFactory( |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
97 |
session_factory, |
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1740
diff
changeset
|
98 |
url=url, |
1894
f224383cc883
Fixed changes from dporopat and agregorcic about WAMP CRA and config.
Edouard Tisserant
parents:
1881
diff
changeset
|
99 |
serializers=[MsgPackSerializer()]) |
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
100 |
|
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
101 |
# start the client from a Twisted endpoint |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
102 |
conn = connectWS(transport_factory) |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1732
diff
changeset
|
103 |
confnodesroot.logger.write(_("WAMP connecting to URL : %s\n") % url) |
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
104 |
return conn |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
105 |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1440
diff
changeset
|
106 |
AddToDoBeforeQuit = confnodesroot.AppFrame.AddToDoBeforeQuit |
1750
acf02488f37f
clean-up: fix PEP8 E306 expected 1 blank line before a nested definition, found X
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1749
diff
changeset
|
107 |
|
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1440
diff
changeset
|
108 |
def ThreadProc(): |
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1440
diff
changeset
|
109 |
global _WampConnection |
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1440
diff
changeset
|
110 |
_WampConnection = RegisterWampClient() |
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1440
diff
changeset
|
111 |
AddToDoBeforeQuit(reactor.stop) |
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1440
diff
changeset
|
112 |
reactor.run(installSignalHandlers=False) |
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1440
diff
changeset
|
113 |
|
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
114 |
def WampSessionProcMapper(funcname): |
1894
f224383cc883
Fixed changes from dporopat and agregorcic about WAMP CRA and config.
Edouard Tisserant
parents:
1881
diff
changeset
|
115 |
wampfuncname = unicode('.'.join((ID, funcname))) |
1750
acf02488f37f
clean-up: fix PEP8 E306 expected 1 blank line before a nested definition, found X
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1749
diff
changeset
|
116 |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
117 |
def catcher_func(*args, **kwargs): |
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
118 |
if _WampSession is not None: |
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
119 |
try: |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
120 |
return threads.blockingCallFromThread( |
1443
ff8a22d45c44
WAMP : prefix callee names with given ID so that multiple PLC and IDE can join the same realm
Edouard Tisserant
parents:
1441
diff
changeset
|
121 |
reactor, _WampSession.call, wampfuncname, |
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
122 |
*args, **kwargs) |
1846
14b40afccd69
remove unused variables found by pylint
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1841
diff
changeset
|
123 |
except TransportLost: |
1595
b3cc68dd037d
add internatialization support for Beremiz_service.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
124 |
confnodesroot.logger.write_error(_("Connection lost!\n")) |
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
125 |
confnodesroot._SetConnector(None) |
1846
14b40afccd69
remove unused variables found by pylint
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1841
diff
changeset
|
126 |
except Exception: |
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
127 |
errmess = traceback.format_exc() |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
128 |
confnodesroot.logger.write_error(errmess+"\n") |
1826
91796f408540
fix usage of python2-only print statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
129 |
print(errmess) |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
130 |
# confnodesroot._SetConnector(None) |
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
131 |
return PLCObjDefaults.get(funcname) |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
132 |
return catcher_func |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
133 |
|
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
134 |
class WampPLCObjectProxy(object): |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
135 |
def __init__(self): |
1841
9fd29e8b1393
fix pylint warning '(global-variable-not-assigned) Using global for 'X' but no assignment is done'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1832
diff
changeset
|
136 |
global _WampConnection |
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
137 |
if not reactor.running: |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
138 |
Thread(target=ThreadProc).start() |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
139 |
else: |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1440
diff
changeset
|
140 |
_WampConnection = threads.blockingCallFromThread( |
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
141 |
reactor, RegisterWampClient) |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
142 |
if not _WampSessionEvent.wait(5): |
1872
866fb3ab8778
fix pylint error "(undefined-variable) Undefined variable 'X'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1846
diff
changeset
|
143 |
_WampConnection.stopConnecting() |
1765
ccf59c1f0b45
clean-up: fix PEP8 W602 deprecated form of raising exception
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1753
diff
changeset
|
144 |
raise Exception(_("WAMP connection timeout")) |
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
145 |
|
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
146 |
def __del__(self): |
1441
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1440
diff
changeset
|
147 |
_WampConnection.disconnect() |
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1440
diff
changeset
|
148 |
# |
826730e60407
Added auto-reconnect for runtime. Fixed Beremiz closing problem caused by remaining twisted reactor thread in IDE.
Edouard Tisserant
parents:
1440
diff
changeset
|
149 |
# reactor.stop() |
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
150 |
|
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
151 |
def __getattr__(self, attrName): |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
152 |
member = self.__dict__.get(attrName, None) |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
153 |
if member is None: |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
154 |
member = WampSessionProcMapper(attrName) |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
155 |
self.__dict__[attrName] = member |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
156 |
return member |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
157 |
|
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
158 |
# Try to get the proxy object |
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
159 |
try: |
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
160 |
return WampPLCObjectProxy() |
1846
14b40afccd69
remove unused variables found by pylint
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1841
diff
changeset
|
161 |
except Exception: |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1732
diff
changeset
|
162 |
confnodesroot.logger.write_error(_("WAMP connection to '%s' failed.\n") % location) |
1440
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
163 |
confnodesroot.logger.write_error(traceback.format_exc()) |
e8daabf2c438
Runtime : Added PLCobject methods registring. IDE : Added WAMP connector. Still need some fixes
Edouard Tisserant
parents:
diff
changeset
|
164 |
return None |
2001
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
165 |
|
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
166 |
|
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
167 |
def WAMP_connector_dialog(confnodesroot): |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
168 |
[ID_IPTEXT, ID_PORTTEXT, ID_REALMTEXT, ID_WAMPIDTEXT, ID_SECURECHECKBOX] = [wx.NewId() for _init_ctrls in range(5)] |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
169 |
|
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
170 |
|
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
171 |
@implementer(IConnectorPanel) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
172 |
class WAMPConnectorPanel(wx.Panel): |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
173 |
def __init__(self, typeConnector, parrent, *args, **kwargs): |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
174 |
self.type = typeConnector |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
175 |
self.parrent = parrent |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
176 |
wx.Panel.__init__(self, parrent, *args, **kwargs) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
177 |
self._init_ctrls() |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
178 |
self._init_sizers() |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
179 |
self.uri = None |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
180 |
|
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
181 |
def _init_ctrls(self): |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
182 |
self.IpText = wx.TextCtrl(parent=self, id=ID_IPTEXT, size = wx.Size(200, -1)) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
183 |
self.PortText = wx.TextCtrl(parent=self, id=ID_PORTTEXT, size = wx.Size(200, -1)) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
184 |
self.RealmText = wx.TextCtrl(parent=self, id=ID_REALMTEXT, size = wx.Size(200, -1)) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
185 |
self.WAMPIDText = wx.TextCtrl(parent=self, id=ID_WAMPIDTEXT, size = wx.Size(200, -1)) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
186 |
self.SecureCheckbox = wx.CheckBox(self, ID_SECURECHECKBOX, _("Is connection secure?")) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
187 |
|
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
188 |
def _init_sizers(self): |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
189 |
self.mainSizer = wx.BoxSizer(wx.VERTICAL) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
190 |
self.uriSizer = wx.BoxSizer(wx.HORIZONTAL) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
191 |
self.portSizer = wx.BoxSizer(wx.HORIZONTAL) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
192 |
self.realmSizer = wx.BoxSizer(wx.HORIZONTAL) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
193 |
self.wampIDSizer = wx.BoxSizer(wx.HORIZONTAL) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
194 |
|
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
195 |
self.uriSizer.Add(wx.StaticText(self, wx.ID_ANY, _("URI host:"), size = wx.Size(70, -1)), proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
196 |
self.uriSizer.AddSpacer((0,0)) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
197 |
self.uriSizer.Add(self.IpText, proportion=1, flag=wx.ALIGN_RIGHT) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
198 |
self.mainSizer.Add(self.uriSizer, border=2, flag=wx.ALL) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
199 |
|
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
200 |
self.portSizer.Add(wx.StaticText(self, wx.ID_ANY, _("URI port:"), size = wx.Size(70, -1)), proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
201 |
self.portSizer.AddSpacer((0,0)) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
202 |
self.portSizer.Add(self.PortText, proportion=1, flag=wx.ALIGN_RIGHT) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
203 |
self.mainSizer.Add(self.portSizer, border=2, flag=wx.ALL) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
204 |
|
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
205 |
self.realmSizer.Add(wx.StaticText(self, wx.ID_ANY, _("Realm:"), size = wx.Size(70, -1)), proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
206 |
self.realmSizer.AddSpacer((0, 0)) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
207 |
self.realmSizer.Add(self.RealmText, proportion=1, flag=wx.ALIGN_RIGHT) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
208 |
self.mainSizer.Add(self.realmSizer, border=2, flag=wx.ALL) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
209 |
|
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
210 |
self.wampIDSizer.Add(wx.StaticText(self, wx.ID_ANY, _("WAMP ID:"), size = wx.Size(70, -1)), proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
211 |
self.wampIDSizer.AddSpacer((0, 0)) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
212 |
self.wampIDSizer.Add(self.WAMPIDText, proportion=1, flag=wx.ALIGN_RIGHT) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
213 |
self.mainSizer.Add(self.wampIDSizer, border=2, flag=wx.ALL) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
214 |
|
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
215 |
self.mainSizer.Add(self.SecureCheckbox, proportion=1, flag=wx.ALIGN_LEFT) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
216 |
|
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
217 |
self.SetSizer(self.mainSizer) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
218 |
|
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
219 |
def SetURI(self, uri): |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
220 |
self.uri = uri |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
221 |
uri_list = uri.strip().split(":") |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
222 |
length = len(uri_list) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
223 |
|
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
224 |
if length > 0: |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
225 |
if uri_list[0] == URITypes[1]: |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
226 |
self.SecureCheckbox.SetValue(True) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
227 |
|
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
228 |
if length > 2: |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
229 |
self.IpText.SetValue(uri_list[1].strip("/")) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
230 |
wampSett = uri_list[2].split("#") |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
231 |
length2 = len(wampSett) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
232 |
if length2 > 0: |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
233 |
self.PortText.SetValue(wampSett[0]) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
234 |
if length2 > 1: |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
235 |
self.RealmText.SetValue(wampSett[1]) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
236 |
if length2 > 2: |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
237 |
self.WAMPIDText.SetValue(wampSett[2]) |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
238 |
|
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
239 |
def GetURI(self): |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
240 |
if self.IpText.Validate(): |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
241 |
typeForURI = self.type + "S" if self.SecureCheckbox.GetValue() else self.type |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
242 |
self.uri = typeForURI + "://" + self.IpText.GetValue() + ":" + self.PortText.GetValue() + "#" + self.RealmText.GetValue() + "#" + self.WAMPIDText.GetValue() |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
243 |
return self.uri |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
244 |
else: |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
245 |
return "" |
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
246 |
|
bcbd41efd846
#2476 Added uri location editor, getting connectors from list in Beremiz.
dporopat <denis.poropat@smarteh.si>
parents:
1941
diff
changeset
|
247 |
return WAMPConnectorPanel("WAMP", confnodesroot) |