author | lbessard |
Fri, 09 Jan 2009 17:08:31 +0100 | |
changeset 289 | d17bd2f00a87 |
parent 271 | ea7928fd07da |
child 290 | 3bd617ae7a05 |
permissions | -rw-r--r-- |
262 | 1 |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
|
3 |
||
4 |
#This file is part of Beremiz, a Integrated Development Environment for |
|
5 |
#programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
|
6 |
# |
|
7 |
#Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
|
8 |
# |
|
9 |
#See COPYING file for copyrights details. |
|
10 |
# |
|
11 |
#This library is free software; you can redistribute it and/or |
|
12 |
#modify it under the terms of the GNU General Public |
|
13 |
#License as published by the Free Software Foundation; either |
|
14 |
#version 2.1 of the License, or (at your option) any later version. |
|
15 |
# |
|
16 |
#This library is distributed in the hope that it will be useful, |
|
17 |
#but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
19 |
#General Public License for more details. |
|
20 |
# |
|
21 |
#You should have received a copy of the GNU General Public |
|
22 |
#License along with this library; if not, write to the Free Software |
|
23 |
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
24 |
||
25 |
import os, sys, getopt |
|
26 |
||
27 |
def usage(): |
|
28 |
print """ |
|
29 |
Usage of Beremiz PLC execution service :\n |
|
271
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
30 |
%s {[-n name] [-i ip] [-p port] [-x enabletaskbar]|-h|--help} working_dir |
262 | 31 |
-n - zeroconf service name |
32 |
-i - ip of interface to bind to (x.x.x.x) |
|
33 |
-p - port number |
|
34 |
-h - print this help text and quit |
|
271
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
35 |
-x - enable/disable wxTaskbarIcon (0:disable 1:enable) |
262 | 36 |
|
37 |
working_dir - directory where are stored PLC files |
|
38 |
"""%sys.argv[0] |
|
39 |
||
40 |
try: |
|
271
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
41 |
opts, args = getopt.getopt(sys.argv[1:], "i:p:n:x:h") |
262 | 42 |
except getopt.GetoptError, err: |
43 |
# print help information and exit: |
|
44 |
print str(err) # will print something like "option -a not recognized" |
|
45 |
usage() |
|
46 |
sys.exit(2) |
|
47 |
||
48 |
# default values |
|
49 |
ip = "" |
|
50 |
port = 3000 |
|
51 |
name = os.environ[{ |
|
52 |
"linux2":"USER", |
|
53 |
"win32":"USERNAME", |
|
54 |
}.get(sys.platform, "USER")] |
|
271
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
55 |
enablewx = True |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
56 |
havewx = False |
262 | 57 |
|
58 |
for o, a in opts: |
|
59 |
if o == "-h": |
|
60 |
usage() |
|
61 |
sys.exit() |
|
62 |
elif o == "-i": |
|
63 |
if len(a.split(".")) == 4 or a == "localhost": |
|
64 |
ip = a |
|
65 |
elif o == "-p": |
|
66 |
# port: port that the service runs on |
|
67 |
port = int(a) |
|
68 |
elif o == "-n": |
|
69 |
name = a |
|
271
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
70 |
elif o == "-x": |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
71 |
enablewx = int(a) |
262 | 72 |
else: |
73 |
usage() |
|
74 |
sys.exit() |
|
75 |
||
76 |
if len(args) > 1: |
|
77 |
usage() |
|
78 |
sys.exit() |
|
79 |
elif len(args) == 1: |
|
80 |
WorkingDir = args[0] |
|
81 |
elif len(args) == 0: |
|
82 |
WorkingDir = os.getcwd() |
|
83 |
args=[WorkingDir] |
|
84 |
||
271
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
85 |
if enablewx: |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
86 |
try: |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
87 |
import wx, re |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
88 |
from wx.lib.embeddedimage import PyEmbeddedImage |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
89 |
from threading import Thread |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
90 |
from types import * |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
91 |
havewx = True |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
92 |
except: |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
93 |
havewx = False |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
94 |
|
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
95 |
if havewx: |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
96 |
defaulticon = PyEmbeddedImage( |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
97 |
"iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAABc5J" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
98 |
"REFUSIl9lW1MW9cZx3/n2vf6BQO2MZiXGBISILCVUEUlitYpjaKpXZJ1XZZ2kzJVY9r6IeLD" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
99 |
"pGTaNG3KtGmNNGlbpW3VFhRp0l6aZCllpVUqtVNJtBFKE5QXLxCjpCYEY7DBr9hcm3vPPgQY" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
100 |
"IQmPdKR7/vd5/v/n5dxzhZSSNeYBOoGDQGcoFPINDAyUDQ0NOUdGRmyGYSiBQGCpoaGhuGnT" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
101 |
"psShQ4f6WltbewEBVAK3gCBgrjJKKZFSKlLKeillt5Ty40gkMnnw4MFFQG60ysrKZHd3dyoe" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
102 |
"j//bNM0Le/fuPd/e3r5lmRMpJWK5ghrgFeBIT09P4/Hjx73pdFo47HaaNlfRutnJru0OKsoE" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
103 |
"E3GVqaSNa6EUw1dvIKWkoqKCrVu3FoeHh9WamppfRiKRn6wUYAUcwE7g2e7u7vrTp09XGIZB" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
104 |
"W1Mdv3qtmoBPrG0hHVsMhKLj6nqOqOWn/Pjnv2dgYIC5uTl1uSM71/pbgUbg6bNnz/rPnDnj" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
105 |
"dzoddO0P8Oo+jY2suDDD1Zv9DA1dfghXVbVBCFEqpcwAKEDTxMSE58SJE8+oqsq3nq/l1X0a" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
106 |
"QihYtNLHLqRET03wuYp7fO9r26mpKlsVUBSl0W63V6/shZTyyIEDB344Njb21JYaG7/5bgkA" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
107 |
"Dm8zTS/+7bHZLy0mSN+7yNztt8nPjYHFwfvXDf1P70zZ0ok0LS0tZy9fvvxNAGswGFQnJyef" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
108 |
"KnM5+NHLzuUDsrFZ7R68zS/hrGon1PcNMPI0BIzs9tcCNvNfDqxW64uqqvqKxWJc6e3trVVV" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
109 |
"leaAk6ryJ5N/9tH3GXv7Je7/5xermN3diMPXCkDfgrkg3UU0txWLxeLw+/1fB1BGR0frbTYb" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
110 |
"TXWWDbNeysUoZKbIRIZBPviOzKU8ejLMHyPFcMprrweQ7iUAXC7XPiGEak2lUk02m42mWn1D" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
111 |
"gfrnTiKNIrbyzSAUjEKWCx+/Mf+HyELBrLBvBhAIKDdgGsrLy+sAv1UIUa1pGv7yxQ0FbGX1" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
112 |
"D+0LQmHW7fVavE5Mo/gAFCCcoOs6NpvNA7gVRVGCmqYRz1hXg7NFU39rjshawjcuvs4P+o/y" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
113 |
"24uvE1+I4VCdfGfXUb76+VdWfQQCkbJSKBQoFApJTdMsCvApQDSlAjCTN7I/y5CNllpq1wqE" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
114 |
"YmPciIzwwdi7BKevreK7Gp5dfbYoFoozJrquo+v6rMViWbQCV4QQzGTsQJY3kzIhvFpgfYte" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
115 |
"7jhCMp9kk7uep+ueWcWj6f8Xqioq8ck0xcIS6XT6vpRy3gqMqKpqRBfKLLNF1ZRV6YBiPDrw" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
116 |
"vduefwTL6hl6b74FgFVR0T4rJTU3jcvlymcymal8Ph+z9vf3p7u6uv5y/vz5bw994ld2fmUH" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
117 |
"7nYFRVG4Gb3Guv8FpmmQzCcIJ+5w8c5HRFL3UYRC+ZKX633j6LpObW3tDcMwrsODq4Jbt27V" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
118 |
"HT58+N7o6KgCYHfY2f2lXfi+6CJbnsAwjUeyXzFFKLgdHqb+mmL8xh22bduWmJycfHN2dvbX" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
119 |
"uVwuoQC0tbXlKisrYytBi/lFZsKzOErtTyQWCOxWO36ljvl/FLk+dJOSkhJTUZR35+fn+3K5" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
120 |
"XAIeXNcASz6fbxzwrxDYVQdqpARvs498IYchDUxpogiBVVFxqE7U/5Zx4c8fEo/FKS0tlR0d" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
121 |
"HZ8ODg6+l06nr6zwrAp4PJ6Qpmlf2L9/fywYDFaOXB0RI1dHaGpuoq29Fa1Uxe62YeZMInei" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
122 |
"jAY/IRqNAtDZ2blUV1fXPzg4+F5VVdU/H6p0eYjqsWPHvnz37t0XwuHw7d27d4eTyeTvLl26" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
123 |
"FJiamnpim6qrq9mzZ094fHz875FI5J3p6ekr631WBARgaWlpCezYsePeuXPnzFAo5Dp58uS+" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
124 |
"dDp91GKxNBYKBW82m3Vomqa7XK7pbDYbnJmZuR2LxYL5fP79WCyWeeys1h/D9e97enqsp06d" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
125 |
"8mWzWU+xWPTkcjmXaZpxwzDCsVhsbqNggP8BMJOU3UUUf+0AAAAASUVORK5CYII=") |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
126 |
|
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
127 |
#---------------------------------------------------------------------- |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
128 |
starticon = PyEmbeddedImage( |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
129 |
"iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAABbpJ" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
130 |
"REFUSIl9lltsFNcdxn9nZnbHs15fd23j9TXYC0UCKzEhMQ+oIS2g1kQ1pbFStX0opFWsovSh" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
131 |
"rUqp2pS2ioTUolaKFOGHqGkiJcKRuDhOaZRiZCsCXyBgCBBfMfbu+oa9s17wzuzl9MH24mDD" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
132 |
"XzoPc/6fft+c72jOGSGlZEVlAU8D9cB20zQ9HR0duRcvXszq7e01EomEUlFREa+srLR8Pl+g" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
133 |
"sbHx3zk5ORcAFfACA8Bt4CFUSomUUkgpS6SUB6SUH5umOXLgwIEHqqrKJfGao7S0VB49ejRo" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
134 |
"2/YnUsrT+/fvb66pqSldYiKlRCytoBB4Gfjx6dOnq5qamjwTExOKqqqU+QrYUJFN7QY32Qbc" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
135 |
"vSeYCGtcux1i5M5dAPx+P1VVVQvnzp0ziouLfx8MBt9cXoAGZABbgZ1HjhwpO378eEEymaSi" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
136 |
"tIBjPy9lU5nKoyWExF2yjy+mN3HsH+/Q3d3NwMCAsZTI9pVaDXgK2Hr27Nn85ubmEpdh8IMX" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
137 |
"ffxirwshVrGXHBQSC/dIRvoZGuz/WkvTtHIhhCGlXABQgI2Tk5P5hw8f3uZwOGj8VjGHXnoC" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
138 |
"HJCpJFbkLtr8FXbX+XC79HRPVVW/qqre9LtIKX/S0NDwy76+vq1lhTr/fM2NAmTk+fHv/dea" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
139 |
"BlZkDHP0PHODH2NHg1gykw8/X7Dfb7vjTNgJqqurT3R1db0GoF2/fl0fGhqqdWca/K7RhZLO" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
140 |
"WSBU55oGGXlVZORVkeV7nsFPDqKL+9TWJCI3n9rojX2mYhjGj4QQv5FSziunTp0qdjqd4hvl" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
141 |
"Lnz5j49lrPMNhv7zM6b63knPuQpryMj3A9A2L++nvDaZXheqqrrXrVu3D0C5detWudPpxO/T" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
142 |
"Hk8HYnOD3J+8yr3bH6XnZNImHg3xfsgenfHo5QAyJwFAdnb2HiGEppmmWa3rOhtKrCcalNT9" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
143 |
"llTSwvBsXISn4nRdbJ5/czRsWvlGhQAEYtFg0kl2dnYZUKgB5U6nk5L82BMNXIU1X3uOWFH5" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
144 |
"eWIuy/YYWcjU4qQAxQ22bWMYhgfIU1RV/UrXdWaiDyOyUiLROktoJfDtC8fZfWQbb//v75ix" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
145 |
"MDlGnvjVC3+gflNDWiMQKPMalmVh2/a8w+HQFKAHIBR2ABCOS+uN6cTMoFstXmlwZbSba7tv" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
146 |
"8hfzT7z+7k+ZnZ0BoK5yR1qjCBV7MoVt29i2PaWqqq0BvUIIQqYORHlrKj6R9BoVj0b04oY9" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
147 |
"nEt+yvz3Y5yR/+Xap3XsDb/EtvV1aY1DdTA7HsW2bCKRyLiUclYBelRVldNWAfPSm4oV5ZQJ" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
148 |
"Vn/G9Zv2oWt6Ous7e4K81XiC1wNNBO6OIWKgB7Mwp000TYuFw+GxWCw2qbS2tk7k5uae/eDD" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
149 |
"Fn594p6SFyxRCjKLUBWF8fBoegTNMVLLm/kwdMyGGON/nePLklv0dl/Cii3gdrtvAzdg8aig" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
150 |
"vb296uDBgwMjIyMCwFvoZXv9NvRnIKqHSckUyQdJrtfexPqm5LGVAuNdVaofcCVywfpexLYD" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
151 |
"CsDOnTvnioqKzGXdzNQMV9tvkJEyUITyeOAjpYyAc9gxYc/GWyK2HYDF4xog6fV6h1i8FwCo" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
152 |
"LK/EncwhkWGxEH9AXLMXM2H1CpQBifI3yeapZ+70d43+cSo4+95yL23g8XiGFUWp3bVrV/Ty" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
153 |
"5ctZnR2ddHZ08uxzz1K9eT1GRhJls1gFlsfieK+WpJ5e/3z7pcuXzmia1rJSs3xlOg8dOvTD" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
154 |
"8fHx7wQCgb4tW7bMm6b55/Pnz+eGw+FFGJDT5iT1XRWlfxHMZ06+/Vz9dCAQeG9kZKR1x44d" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
155 |
"nSdPnkyuZSAArbq6eqOiKAP9/f3xlpaWgra2tlei0eiryWSyKGKa2TcaL+muwcxU5aDf9Gi+" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
156 |
"L0Oh0BehUOiaZVlnAoHAzFr7Ih75bVnVb2pqcvf09Phi0ei6+/rUC6lw1k0p5bSUctThcIwP" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
157 |
"Dw/HnwT4P6CDl+TMvD0JAAAAAElFTkSuQmCC") |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
158 |
|
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
159 |
#---------------------------------------------------------------------- |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
160 |
stopicon = PyEmbeddedImage( |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
161 |
"iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAABPRJ" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
162 |
"REFUSImdlllsVGUUx3/f/e4sd5iZLjNt6XSFdtgkjWFRePABDaCBGgjamIg81CU0aoxbRHww" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
163 |
"+EDkhWjEB5rYGEMUxQTCJg8EoQ2BbgrFCNJWltplgC63naEzd+bO50NLLVAq4STfwz3nfP/f" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
164 |
"PSf3O98VSikmmQ94HFgDLDdNM1BfX5955swZX0tLi5FKpbSSkpJkaWlpIhQKdVdVVX2XkZFx" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
165 |
"EpBAEGgHLgH/iSqlUEoJpVSBUqpaKXXYNM0r1dXVt6WUajx5ylVYWKi2bdvWY1nWUaXUgQ0b" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
166 |
"NtRWVFQUjmuilEKMV5ALvAhsPHDgQFlNTU2gr69Pk1JSFMphTomfRXO8+A243i/oG9I5f6mX" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
167 |
"K1evAxAOhykrKxs9duyYkZ+f/0lPT8/2OwXogBtYDKzYunVr0c6dO3Ns26akMIcdbxQyv0hy" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
168 |
"rwmh8Bas5/eb89nxRR1NTU20t7cb4x1ZPjlXB2YBiw8ePJhdW1tb4DEMXng6xJtrPQhxn/Y4" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
169 |
"QSM12o89fJnOjst3hXRdLxZCGEqpUQANmBuJRLK3bNmy1OFwUPVMPm9VTiMOqLRNYvg6+shv" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
170 |
"rFoWwutxTcSklGEpZXDiXZRSr6xbt+6dtra2xUW5Lr7c7EUD3Flhwmu/nRKQGO7CvHaCwY7D" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
171 |
"WNEeEmoGe0+PWnuOXHWmrBTl5eW7GxsbNwPoFy5ccHV2di7yzjD4uMqDNtFngZDOKQHurDLc" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
172 |
"WWX4Qk/ScfRVXCLGoorU8J+z5gbjxyWGYbwshPhQKTWi7d+/P9/pdIp5xR5C2Q9uS1fDp3T+" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
173 |
"8jo32uomfJ7cCtzZYQCOjKhYOmgxI+hBSumdOXPmegDt4sWLxU6nk3BIf7A6EB/sIBY5R/+l" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
174 |
"nyd8yrZIRnvZ02tduxVwFQOojBQAfr9/tRBC103TLHe5XMwpSEwLKFj2EWk7gRGYOyaeTtJ4" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
175 |
"pnZk+7UhM5FtlAhAIMYAESd+v78IyNWBYqfTSUF2fFqAJ7firufhRFSdTg36rIDhQ6XHnAI0" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
176 |
"L1iWhWEYASBLl1L+JaWcfSuqk+u3AUikRer4ADffg/w7gt80fs35r34k3BYh2xNAarooAJ4d" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
177 |
"vsHgaP8EWMR17GiaVo8r0+Fw6DrQDDzXO+RgQSjBUFIlPh+wB0vLZD6TrLWrkWRXB29fGAK6" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
178 |
"pql1rNXVmrCklJYGtAgh6DXHDsuuG8k+O9M5895tq+atpSwwZ9o2TjZlWTGl1IAGNEsp1c1E" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
179 |
"DiMqmI7nZRQJ7j/G6xZWMS/vsYcGkEzG4vF4RDt06FBfZmbmwR/27uOD3f1aVk+BljMjD6lp" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
180 |
"/DN07a4VTYw8tL4rrQZgbNixadOm90+dOvX82cZmcbaxmWBukOVrlvJudw1R1xDp8a+kuPM6" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
181 |
"Gx8S4LXtCIwNO1asWDGYl5dn3gneunGLc7/+gTttoAntQRrTmgMmpimAHQwGOycnlBaX4rUz" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
182 |
"8LszMRweXLr7kWB35oMdCAT+1jRt0cqVK6Otra2+hvoGGuobWPLEEsoXzkbPkLhvR4CBRwJY" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
183 |
"Xq/3SGVlZbq7u7utsrJyxDTNz06cOJHZ0tRCS1MLAKuRwNQT9v8AyV27dn1fXl7eqmlae11d" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
184 |
"XXLfvn0/+Xy+l6LR6Gu2befFYjFfzrk2FzeHp7mK7jdxz2/LffGamhpvc3NzyLKsbFd3z1PG" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
185 |
"aHyBTKdjum0POGzbFAp7qo0xVOtJZdf/C/wRDnL5FYGSAAAAAElFTkSuQmCC") |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
186 |
|
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
187 |
class ParamsEntryDialog(wx.TextEntryDialog): |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
188 |
if wx.VERSION < (2, 6, 0): |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
189 |
def Bind(self, event, function, id = None): |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
190 |
if id is not None: |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
191 |
event(self, id, function) |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
192 |
else: |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
193 |
event(self, function) |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
194 |
|
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
195 |
|
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
196 |
def __init__(self, parent, message, caption = "Please enter text", defaultValue = "", |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
197 |
style = wx.OK|wx.CANCEL|wx.CENTRE, pos = wx.DefaultPosition): |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
198 |
wx.TextEntryDialog.__init__(self, parent, message, caption, defaultValue, style, pos) |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
199 |
|
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
200 |
self.Tests = [] |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
201 |
if wx.VERSION >= (2, 8, 0): |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
202 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetAffirmativeId()) |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
203 |
elif wx.VERSION >= (2, 6, 0): |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
204 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetAffirmativeButton().GetId()) |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
205 |
else: |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
206 |
self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.GetSizer().GetItem(3).GetSizer().GetChildren()[0].GetSizer().GetChildren()[0].GetWindow().GetId()) |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
207 |
|
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
208 |
def OnOK(self, event): |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
209 |
value = self.GetValue() |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
210 |
texts = {"value" : value} |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
211 |
for function, message in self.Tests: |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
212 |
if not function(value): |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
213 |
message = wx.MessageDialog(self, message%texts, "Error", wx.OK|wx.ICON_ERROR) |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
214 |
message.ShowModal() |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
215 |
message.Destroy() |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
216 |
return |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
217 |
self.EndModal(wx.ID_OK) |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
218 |
|
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
219 |
def GetValue(self): |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
220 |
return self.GetSizer().GetItem(1).GetWindow().GetValue() |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
221 |
|
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
222 |
def SetTests(self, tests): |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
223 |
self.Tests = tests |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
224 |
|
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
225 |
class DemoTaskBarIcon(wx.TaskBarIcon): |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
226 |
TBMENU_CHANGE_NAME = wx.NewId() |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
227 |
TBMENU_CHANGE_PORT = wx.NewId() |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
228 |
TBMENU_CHANGE_INTERFACE = wx.NewId() |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
229 |
TBMENU_CHANGE_WD = wx.NewId() |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
230 |
TBMENU_QUIT = wx.NewId() |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
231 |
|
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
232 |
def __init__(self, pyroserver): |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
233 |
wx.TaskBarIcon.__init__(self) |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
234 |
# Set the image |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
235 |
self.UpdateIcon(None) |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
236 |
|
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
237 |
# bind some events |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
238 |
self.Bind(wx.EVT_MENU, self.OnTaskBarChangeName, id=self.TBMENU_CHANGE_NAME) |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
239 |
self.Bind(wx.EVT_MENU, self.OnTaskBarChangeInterface, id=self.TBMENU_CHANGE_INTERFACE) |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
240 |
self.Bind(wx.EVT_MENU, self.OnTaskBarChangePort, id=self.TBMENU_CHANGE_PORT) |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
241 |
self.Bind(wx.EVT_MENU, self.OnTaskBarChangeWorkingDir, id=self.TBMENU_CHANGE_WD) |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
242 |
self.Bind(wx.EVT_MENU, self.OnTaskBarQuit, id=self.TBMENU_QUIT) |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
243 |
|
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
244 |
def CreatePopupMenu(self): |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
245 |
""" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
246 |
This method is called by the base class when it needs to popup |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
247 |
the menu for the default EVT_RIGHT_DOWN event. Just create |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
248 |
the menu how you want it and return it from this function, |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
249 |
the base class takes care of the rest. |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
250 |
""" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
251 |
menu = wx.Menu() |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
252 |
menu.Append(self.TBMENU_CHANGE_NAME, "Change Name") |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
253 |
menu.Append(self.TBMENU_CHANGE_INTERFACE, "Change IP of interface to bind") |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
254 |
menu.Append(self.TBMENU_CHANGE_PORT, "Change Port Number") |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
255 |
menu.AppendSeparator() |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
256 |
menu.Append(self.TBMENU_CHANGE_WD, "Change working directory") |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
257 |
menu.Append(self.TBMENU_QUIT, "Quit") |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
258 |
return menu |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
259 |
|
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
260 |
def MakeIcon(self, img): |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
261 |
""" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
262 |
The various platforms have different requirements for the |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
263 |
icon size... |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
264 |
""" |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
265 |
if "wxMSW" in wx.PlatformInfo: |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
266 |
img = img.Scale(16, 16) |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
267 |
elif "wxGTK" in wx.PlatformInfo: |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
268 |
img = img.Scale(22, 22) |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
269 |
# wxMac can be any size upto 128x128, so leave the source img alone.... |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
270 |
icon = wx.IconFromBitmap(img.ConvertToBitmap() ) |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
271 |
return icon |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
272 |
|
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
273 |
def OnTaskBarChangeInterface(self,evt): |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
274 |
dlg = ParamsEntryDialog(None, "Enter the ip of the interface to bind", defaultValue=pyroserver.ip) |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
275 |
dlg.SetTests([(re.compile('\d{1,3}(?:\.\d{1,3}){3}$').match, "Ip is not valid!"), |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
276 |
( lambda ip :len([x for x in ip.split(".") if 0 <= int(x) <= 255]) == 4, "Ip is not valid!") |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
277 |
]) |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
278 |
if dlg.ShowModal() == wx.ID_OK: |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
279 |
pyroserver.ip = dlg.GetValue() |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
280 |
pyroserver.Stop() |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
281 |
|
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
282 |
def OnTaskBarChangePort(self,evt): |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
283 |
dlg = ParamsEntryDialog(None, "Enter a port number ", defaultValue=str(pyroserver.port)) |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
284 |
dlg.SetTests([(UnicodeType.isdigit, "Port number must be an integer!"), (lambda port : 0 <= int(port) <= 65535 , "Port number must be 0 <= port <= 65535!")]) |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
285 |
if dlg.ShowModal() == wx.ID_OK: |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
286 |
pyroserver.port = int(dlg.GetValue()) |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
287 |
pyroserver.Stop() |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
288 |
|
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
289 |
|
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
290 |
def OnTaskBarChangeWorkingDir(self,evt): |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
291 |
dlg = wx.DirDialog(None, "Choose a working directory ", pyroserver.workdir, wx.DD_NEW_DIR_BUTTON) |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
292 |
if dlg.ShowModal() == wx.ID_OK: |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
293 |
pyroserver.workdir = dlg.GetPath() |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
294 |
pyroserver.Stop() |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
295 |
|
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
296 |
def OnTaskBarChangeName(self,evt): |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
297 |
dlg = ParamsEntryDialog(None, "Enter a name ", defaultValue=pyroserver.name) |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
298 |
dlg.SetTests([(lambda name : len(name) is not 0 , "Name must not be null!")]) |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
299 |
if dlg.ShowModal() == wx.ID_OK: |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
300 |
pyroserver.name = dlg.GetValue() |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
301 |
pyroserver.Restart() |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
302 |
|
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
303 |
def OnTaskBarQuit(self,evt): |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
304 |
pyroserver.Quit() |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
305 |
self.RemoveIcon() |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
306 |
wx.GetApp().ExitMainLoop() |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
307 |
|
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
308 |
def UpdateIcon(self, plcstatus): |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
309 |
if plcstatus is "Started" : |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
310 |
currenticon = self.MakeIcon(starticon.GetImage()) |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
311 |
elif plcstatus is "Stopped": |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
312 |
currenticon = self.MakeIcon(stopicon.GetImage()) |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
313 |
else: |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
314 |
currenticon = self.MakeIcon(defaulticon.GetImage()) |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
315 |
self.SetIcon(currenticon, "Beremiz Service") |
ea7928fd07da
add the possibility to enable or disable wxTaskbarIcon for Beremiz_service
greg
parents:
269
diff
changeset
|
316 |
|
262 | 317 |
from runtime import PLCObject, ServicePublisher |
318 |
import Pyro.core as pyro |
|
319 |
||
320 |
if not os.path.isdir(WorkingDir): |
|
321 |
os.mkdir(WorkingDir) |
|
322 |
||
323 |
class Server(): |
|
324 |
def __init__(self, name, ip, port, workdir, args): |
|
325 |
self.continueloop = True |
|
326 |
self.daemon = None |
|
327 |
self.name = name |
|
328 |
self.ip = ip |
|
329 |
self.port = port |
|
330 |
self.workdir = workdir |
|
331 |
self.args = args |
|
332 |
self.plcobj = None |
|
263 | 333 |
self.servicepublisher = None |
269
d29c5f71574f
add a TaskBarIcon to configure beremiz_service and display plc states (started, stopped)
greg
parents:
263
diff
changeset
|
334 |
self.statuschange = None |
d29c5f71574f
add a TaskBarIcon to configure beremiz_service and display plc states (started, stopped)
greg
parents:
263
diff
changeset
|
335 |
|
d29c5f71574f
add a TaskBarIcon to configure beremiz_service and display plc states (started, stopped)
greg
parents:
263
diff
changeset
|
336 |
def Loop(self, statuschange=None): |
d29c5f71574f
add a TaskBarIcon to configure beremiz_service and display plc states (started, stopped)
greg
parents:
263
diff
changeset
|
337 |
self.statuschange = statuschange |
262 | 338 |
while self.continueloop: |
339 |
self.Start() |
|
340 |
||
341 |
def Restart(self): |
|
342 |
self.Stop() |
|
343 |
||
344 |
def Quit(self): |
|
345 |
self.continueloop = False |
|
346 |
self.Stop() |
|
347 |
||
348 |
def Start(self): |
|
349 |
pyro.initServer() |
|
350 |
self.daemon=pyro.Daemon(host=self.ip, port=self.port) |
|
269
d29c5f71574f
add a TaskBarIcon to configure beremiz_service and display plc states (started, stopped)
greg
parents:
263
diff
changeset
|
351 |
self.plcobj = PLCObject(self.workdir, self.daemon, self.args, self.statuschange) |
262 | 352 |
uri = self.daemon.connect(self.plcobj,"PLCObject") |
353 |
||
354 |
print "The daemon runs on port :",self.port |
|
355 |
print "The object's uri is :",uri |
|
356 |
print "The working directory :",self.workdir |
|
357 |
||
358 |
# Configure and publish service |
|
359 |
# Not publish service if localhost in address params |
|
360 |
if self.ip != "localhost" and self.ip != "127.0.0.1": |
|
263 | 361 |
print "Publish service on local network" |
362 |
self.servicepublisher = ServicePublisher.ServicePublisher() |
|
262 | 363 |
self.servicepublisher.RegisterService(self.name, self.ip, self.port) |
364 |
||
365 |
sys.stdout.flush() |
|
366 |
||
367 |
self.daemon.requestLoop() |
|
368 |
||
369 |
def Stop(self): |
|
263 | 370 |
if self.servicepublisher is not None: |
371 |
self.servicepublisher.UnRegisterService() |
|
372 |
del self.servicepublisher |
|
262 | 373 |
self.daemon.shutdown(True) |
269
d29c5f71574f
add a TaskBarIcon to configure beremiz_service and display plc states (started, stopped)
greg
parents:
263
diff
changeset
|
374 |
|
262 | 375 |
pyroserver = Server(name, ip, port, WorkingDir, args) |
376 |
||
377 |
if havewx: |
|
378 |
app=wx.App(redirect=False) |
|
379 |
taskbar_instance = DemoTaskBarIcon(pyroserver) |
|
269
d29c5f71574f
add a TaskBarIcon to configure beremiz_service and display plc states (started, stopped)
greg
parents:
263
diff
changeset
|
380 |
def statuschange(status): |
d29c5f71574f
add a TaskBarIcon to configure beremiz_service and display plc states (started, stopped)
greg
parents:
263
diff
changeset
|
381 |
wx.CallAfter(taskbar_instance.UpdateIcon,status) |
d29c5f71574f
add a TaskBarIcon to configure beremiz_service and display plc states (started, stopped)
greg
parents:
263
diff
changeset
|
382 |
pyro_thread=Thread(target=pyroserver.Loop, args=[statuschange]) |
262 | 383 |
pyro_thread.start() |
384 |
app.MainLoop() |
|
385 |
else: |
|
386 |
pyroserver.Loop() |