Explorar el Código

Module Update

mod_update
Dirk Alders hace 4 años
padre
commit
fdef5e6a9e
Se han modificado 6 ficheros con 34 adiciones y 39 borrados
  1. 4
    10
      config_example/config.py
  2. 1
    1
      garage_protocol
  3. 26
    25
      smarthome.py
  4. 1
    1
      socket_protocol
  5. 1
    1
      stringtools
  6. 1
    1
      wetation_protocol

+ 4
- 10
config_example/config.py Ver fichero

@@ -9,24 +9,18 @@ FULL_SCREEN = False
9 9
 # TCP-Server
10 10
 #
11 11
 server_out_secret = None  # or set a secret to require client authentification: b'give_a_secret_string_here'
12
-server_out_ip = '192.168.0.121'
12
+server_out_ip = 'localhost'
13 13
 server_out_port = 37000
14 14
 server_in_secret = None  # or set a secret to require client authentification: b'give_a_secret_string_here'
15
-server_in_ip = '192.168.0.120'
16
-server_in_port = 37000
15
+server_in_ip = 'localhost'
16
+server_in_port = 47000
17 17
 
18 18
 server_garage_secret = None  # or set a secret to require client authentification: b'give_a_secret_string_here'
19
-server_garage_ip = '192.168.0.13'
19
+server_garage_ip = 'localhost'
20 20
 server_garage_port = 10000
21 21
 # Logging
22 22
 #
23 23
 LOGTARGET = 'stdout'   # possible choices are: 'logfile' or 'stdout'
24
-SHORT_FMT = "%(asctime)s: %(levelname)-7s - %(message)s"
25
-""" A short formatter including the most important information"""
26
-LONG_FMT = """~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27
-File "%(pathname)s", line %(lineno)d, in %(funcName)s
28
-%(asctime)s: %(levelname)-7s - %(message)s"""
29
-""" A long formatter which results in links to the source code inside Eclipse"""
30 24
 
31 25
 # Logging
32 26
 #

+ 1
- 1
garage_protocol

@@ -1 +1 @@
1
-Subproject commit c5f4e0323aa0a07d996372f94c9652be6fad3919
1
+Subproject commit 882ea5a033338b0da86d312266ee93179133ff41

+ 26
- 25
smarthome.py Ver fichero

@@ -12,6 +12,7 @@ import logging
12 12
 import numbers
13 13
 import os
14 14
 import report
15
+import socket_protocol
15 16
 import task
16 17
 import tcp_socket
17 18
 import time
@@ -63,22 +64,22 @@ class WetationFrameProt(gui.Wetation):
63 64
     REQUEST_MSGS_SLOW = {
64 65
         PROT_ID_IN: [
65 66
             {
66
-                'service_id': wetation_protocol.my_base_protocol_tcp.SID_READ_REQUEST,
67
-                'data_id': wetation_protocol.my_base_protocol_tcp.ENVDATA_STATISTIC_DHT,
67
+                'service_id': socket_protocol.SID_READ_REQUEST,
68
+                'data_id': wetation_protocol.ENVDATA_STATISTIC_DHT,
68 69
             },
69 70
             {
70
-                'service_id': wetation_protocol.my_base_protocol_tcp.SID_READ_REQUEST,
71
-                'data_id': wetation_protocol.my_base_protocol_tcp.ENVDATA_STATISTIC_BMP,
71
+                'service_id': socket_protocol.SID_READ_REQUEST,
72
+                'data_id': wetation_protocol.ENVDATA_STATISTIC_BMP,
72 73
             },
73 74
         ],
74 75
         PROT_ID_OUT: [
75 76
             {
76
-                'service_id': wetation_protocol.my_base_protocol_tcp.SID_READ_REQUEST,
77
-                'data_id': wetation_protocol.my_base_protocol_tcp.ENVDATA_STATISTIC_DHT,
77
+                'service_id': socket_protocol.SID_READ_REQUEST,
78
+                'data_id': wetation_protocol.ENVDATA_STATISTIC_DHT,
78 79
             },
79 80
             {
80
-                'service_id': wetation_protocol.my_base_protocol_tcp.SID_READ_REQUEST,
81
-                'data_id': wetation_protocol.my_base_protocol_tcp.ENVDATA_STATISTIC_BMP,
81
+                'service_id': socket_protocol.SID_READ_REQUEST,
82
+                'data_id': wetation_protocol.ENVDATA_STATISTIC_BMP,
82 83
             },
83 84
         ],
84 85
     }
@@ -86,8 +87,8 @@ class WetationFrameProt(gui.Wetation):
86 87
     REQUEST_MSGS_FAST = {
87 88
         PROT_ID_GARAGE: [
88 89
             {
89
-                'service_id': garage_protocol.my_base_protocol_tcp.SID_READ_REQUEST,
90
-                'data_id': garage_protocol.my_base_protocol_tcp.GATE_POSITION,
90
+                'service_id': socket_protocol.SID_READ_REQUEST,
91
+                'data_id': garage_protocol.GATE_POSITION,
91 92
             },
92 93
         ],
93 94
     }
@@ -162,13 +163,13 @@ class WetationFrameProt(gui.Wetation):
162 163
         cn = self.PROT_NAMES[prot_id]
163 164
         logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__ + '.' + cn)
164 165
         if prot_id == self.PROT_ID_GARAGE:
165
-            if service_id == garage_protocol.my_base_protocol_tcp.SID_READ_RESPONSE and data_id == garage_protocol.my_base_protocol_tcp.GATE_POSITION:
166
+            if service_id == socket_protocol.SID_READ_RESPONSE and data_id == garage_protocol.GATE_POSITION:
166 167
                 rv = isinstance(data, numbers.Number)
167
-            elif service_id == garage_protocol.my_base_protocol_tcp.SID_EXECUTE_RESPONSE and data_id == garage_protocol.my_base_protocol_tcp.OPEN_CLOSE_GATE:
168
+            elif service_id == socket_protocol.SID_EXECUTE_RESPONSE and data_id == garage_protocol.OPEN_CLOSE_GATE:
168 169
                 if data is True:
169 170
                     rv = True
170 171
         elif prot_id in [self.PROT_ID_IN, self.PROT_ID_OUT]:
171
-            if service_id == wetation_protocol.my_base_protocol_tcp.SID_READ_RESPONSE and data_id == wetation_protocol.my_base_protocol_tcp.ENVDATA_STATISTIC_BMP:
172
+            if service_id == socket_protocol.SID_READ_RESPONSE and data_id == wetation_protocol.ENVDATA_STATISTIC_BMP:
172 173
                 rv = True
173 174
                 for main_key in [bmp_180.KEY_PRESSURE, bmp_180.KEY_TEMPERATURE, bmp_180.KEY_TIME]:
174 175
                     if main_key not in data:
@@ -179,7 +180,7 @@ class WetationFrameProt(gui.Wetation):
179 180
                             if not isinstance(data[main_key].get(sub_key), numbers.Number):
180 181
                                 rv = False
181 182
                                 break
182
-            elif service_id == wetation_protocol.my_base_protocol_tcp.SID_READ_RESPONSE and data_id == wetation_protocol.my_base_protocol_tcp.ENVDATA_STATISTIC_DHT:
183
+            elif service_id == socket_protocol.SID_READ_RESPONSE and data_id == wetation_protocol.ENVDATA_STATISTIC_DHT:
183 184
                 rv = True
184 185
                 for main_key in [dht_22.KEY_HUMIDITY, dht_22.KEY_TEMPERATURE, dht_22.KEY_TIME]:
185 186
                     if main_key not in data:
@@ -200,16 +201,16 @@ class WetationFrameProt(gui.Wetation):
200 201
         data = msg.get_data()
201 202
         if self.__validate_response_data__(prot_id, service_id, data_id, data):
202 203
             wx.CallAfter(self.__data__, prot_id, service_id, data_id, data)
203
-            return wetation_protocol.my_base_protocol_tcp.STATUS_OKAY, None
204
+            return socket_protocol.STATUS_OKAY, None
204 205
         else:
205 206
             wx.CallAfter(self.__no_data__, prot_id, service_id, data_id)
206
-            return wetation_protocol.my_base_protocol_tcp.STATUS_SERVICE_OR_DATA_UNKNOWN, None
207
+            return socket_protocol.STATUS_SERVICE_OR_DATA_UNKNOWN, None
207 208
 
208 209
     def __no_data__(self, prot_id, service_id, data_id):
209 210
         cn = self.PROT_NAMES[prot_id]
210 211
         logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__ + '.' + cn)
211 212
         if prot_id == self.PROT_ID_GARAGE:
212
-            if service_id == garage_protocol.my_base_protocol_tcp.SID_READ_RESPONSE and data_id == garage_protocol.my_base_protocol_tcp.GATE_POSITION:
213
+            if service_id == socket_protocol.SID_READ_RESPONSE and data_id == garage_protocol.GATE_POSITION:
213 214
                 logger.warning('Resetting GUI elements for %s', cn)
214 215
                 self.heading_garage.Show(False)
215 216
                 self.gate_oc.Show(False)
@@ -218,10 +219,10 @@ class WetationFrameProt(gui.Wetation):
218 219
                 self.gate_close.Show(False)
219 220
                 self.Layout()
220 221
                 return
221
-            elif service_id == garage_protocol.my_base_protocol_tcp.SID_EXECUTE_RESPONSE and data_id == garage_protocol.my_base_protocol_tcp.OPEN_CLOSE_GATE:
222
+            elif service_id == socket_protocol.SID_EXECUTE_RESPONSE and data_id == garage_protocol.OPEN_CLOSE_GATE:
222 223
                 return
223 224
         elif prot_id in [self.PROT_ID_IN, self.PROT_ID_OUT]:
224
-            if service_id == wetation_protocol.my_base_protocol_tcp.SID_READ_RESPONSE and data_id == wetation_protocol.my_base_protocol_tcp.ENVDATA_STATISTIC_BMP:
225
+            if service_id == socket_protocol.SID_READ_RESPONSE and data_id == wetation_protocol.ENVDATA_STATISTIC_BMP:
225 226
                 logger.warning('Resetting GUI elements for %s', cn)
226 227
                 txt_pressure = '- hPa'
227 228
                 if prot_id == self.PROT_ID_IN:
@@ -230,7 +231,7 @@ class WetationFrameProt(gui.Wetation):
230 231
                     self.out_pressure.SetLabel(txt_pressure)
231 232
                 self.Layout()
232 233
                 return
233
-            elif service_id == wetation_protocol.my_base_protocol_tcp.SID_READ_RESPONSE and data_id == wetation_protocol.my_base_protocol_tcp.ENVDATA_STATISTIC_DHT:
234
+            elif service_id == socket_protocol.SID_READ_RESPONSE and data_id == wetation_protocol.ENVDATA_STATISTIC_DHT:
234 235
                 logger.warning('Resetting GUI elements for %s', cn)
235 236
                 txt_temperature = '-.- °C'
236 237
                 txt_humidity = '-.- %'
@@ -248,7 +249,7 @@ class WetationFrameProt(gui.Wetation):
248 249
         cn = self.PROT_NAMES[prot_id]
249 250
         logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__ + '.' + cn)
250 251
         if prot_id == self.PROT_ID_GARAGE:
251
-            if service_id == garage_protocol.my_base_protocol_tcp.SID_READ_RESPONSE and data_id == garage_protocol.my_base_protocol_tcp.GATE_POSITION:
252
+            if service_id == socket_protocol.SID_READ_RESPONSE and data_id == garage_protocol.GATE_POSITION:
252 253
                 logger.debug('Setting %s position to %3d', cn, int(data * 100))
253 254
                 self.heading_garage.Show(True)
254 255
                 self.gate_oc.Show(True)
@@ -258,10 +259,10 @@ class WetationFrameProt(gui.Wetation):
258 259
                 self.gate_position.SetValue(int(data * 100))
259 260
                 self.Layout()
260 261
                 return
261
-            elif service_id == garage_protocol.my_base_protocol_tcp.SID_EXECUTE_RESPONSE and data_id == garage_protocol.my_base_protocol_tcp.OPEN_CLOSE_GATE:
262
+            elif service_id == socket_protocol.SID_EXECUTE_RESPONSE and data_id == garage_protocol.OPEN_CLOSE_GATE:
262 263
                 return
263 264
         elif prot_id in [self.PROT_ID_IN, self.PROT_ID_OUT]:
264
-            if service_id == wetation_protocol.my_base_protocol_tcp.SID_READ_RESPONSE and data_id == wetation_protocol.my_base_protocol_tcp.ENVDATA_STATISTIC_BMP:
265
+            if service_id == socket_protocol.SID_READ_RESPONSE and data_id == wetation_protocol.ENVDATA_STATISTIC_BMP:
265 266
                 data = helpers.continues_statistic_multivalue(**data)
266 267
                 logger.debug('Setting %s pressure to %4d hPa', cn, data[bmp_180.KEY_PRESSURE].mean)
267 268
                 #
@@ -271,7 +272,7 @@ class WetationFrameProt(gui.Wetation):
271 272
                 else:
272 273
                     wx.CallAfter(self.update_current_bmp_env_data, data, self.out_pressure)
273 274
                 return
274
-            elif service_id == wetation_protocol.my_base_protocol_tcp.SID_READ_RESPONSE and data_id == wetation_protocol.my_base_protocol_tcp.ENVDATA_STATISTIC_DHT:
275
+            elif service_id == socket_protocol.SID_READ_RESPONSE and data_id == wetation_protocol.ENVDATA_STATISTIC_DHT:
275 276
                 data = helpers.continues_statistic_multivalue(**data)
276 277
                 #
277 278
                 # Current environmental data
@@ -321,7 +322,7 @@ class WetationFrameProt(gui.Wetation):
321 322
         ).ShowModal()
322 323
         if r == wx.ID_YES:
323 324
             logger.debug("Gate open/close request")
324
-            self.__prot__[self.PROT_ID_GARAGE].send(garage_protocol.my_base_protocol_tcp.SID_EXECUTE_REQUEST, garage_protocol.my_base_protocol_tcp.OPEN_CLOSE_GATE, None)
325
+            self.__prot__[self.PROT_ID_GARAGE].send(socket_protocol.SID_EXECUTE_REQUEST, garage_protocol.OPEN_CLOSE_GATE, None)
325 326
         event.Skip()
326 327
 
327 328
     def reset_in_temp_minmax_evt(self, event):

+ 1
- 1
socket_protocol

@@ -1 +1 @@
1
-Subproject commit 7c02c8dd3cc5b24a1ba8ce71c0b7396f3759671e
1
+Subproject commit 35d9f688a4f080a8cae70a18e27036b55399edde

+ 1
- 1
stringtools

@@ -1 +1 @@
1
-Subproject commit 76d8ae9b1bfd894bc5f4b830394ce0552120a508
1
+Subproject commit 5ac92e2b864cd27bd4026352ba9149f4d23ca019

+ 1
- 1
wetation_protocol

@@ -1 +1 @@
1
-Subproject commit cdc9912f3d26edea9e0a36b0fccfc7d3bfd6b868
1
+Subproject commit 07357d33ad5dbed4807fef6ef088abd5b005e363

Loading…
Cancelar
Guardar