Module Update
This commit is contained in:
parent
e1656eaa1a
commit
fdef5e6a9e
@ -9,24 +9,18 @@ FULL_SCREEN = False
|
|||||||
# TCP-Server
|
# TCP-Server
|
||||||
#
|
#
|
||||||
server_out_secret = None # or set a secret to require client authentification: b'give_a_secret_string_here'
|
server_out_secret = None # or set a secret to require client authentification: b'give_a_secret_string_here'
|
||||||
server_out_ip = '192.168.0.121'
|
server_out_ip = 'localhost'
|
||||||
server_out_port = 37000
|
server_out_port = 37000
|
||||||
server_in_secret = None # or set a secret to require client authentification: b'give_a_secret_string_here'
|
server_in_secret = None # or set a secret to require client authentification: b'give_a_secret_string_here'
|
||||||
server_in_ip = '192.168.0.120'
|
server_in_ip = 'localhost'
|
||||||
server_in_port = 37000
|
server_in_port = 47000
|
||||||
|
|
||||||
server_garage_secret = None # or set a secret to require client authentification: b'give_a_secret_string_here'
|
server_garage_secret = None # or set a secret to require client authentification: b'give_a_secret_string_here'
|
||||||
server_garage_ip = '192.168.0.13'
|
server_garage_ip = 'localhost'
|
||||||
server_garage_port = 10000
|
server_garage_port = 10000
|
||||||
# Logging
|
# Logging
|
||||||
#
|
#
|
||||||
LOGTARGET = 'stdout' # possible choices are: 'logfile' or 'stdout'
|
LOGTARGET = 'stdout' # possible choices are: 'logfile' or 'stdout'
|
||||||
SHORT_FMT = "%(asctime)s: %(levelname)-7s - %(message)s"
|
|
||||||
""" A short formatter including the most important information"""
|
|
||||||
LONG_FMT = """~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
File "%(pathname)s", line %(lineno)d, in %(funcName)s
|
|
||||||
%(asctime)s: %(levelname)-7s - %(message)s"""
|
|
||||||
""" A long formatter which results in links to the source code inside Eclipse"""
|
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
#
|
#
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit c5f4e0323aa0a07d996372f94c9652be6fad3919
|
Subproject commit 882ea5a033338b0da86d312266ee93179133ff41
|
51
smarthome.py
51
smarthome.py
@ -12,6 +12,7 @@ import logging
|
|||||||
import numbers
|
import numbers
|
||||||
import os
|
import os
|
||||||
import report
|
import report
|
||||||
|
import socket_protocol
|
||||||
import task
|
import task
|
||||||
import tcp_socket
|
import tcp_socket
|
||||||
import time
|
import time
|
||||||
@ -63,22 +64,22 @@ class WetationFrameProt(gui.Wetation):
|
|||||||
REQUEST_MSGS_SLOW = {
|
REQUEST_MSGS_SLOW = {
|
||||||
PROT_ID_IN: [
|
PROT_ID_IN: [
|
||||||
{
|
{
|
||||||
'service_id': wetation_protocol.my_base_protocol_tcp.SID_READ_REQUEST,
|
'service_id': socket_protocol.SID_READ_REQUEST,
|
||||||
'data_id': wetation_protocol.my_base_protocol_tcp.ENVDATA_STATISTIC_DHT,
|
'data_id': wetation_protocol.ENVDATA_STATISTIC_DHT,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'service_id': wetation_protocol.my_base_protocol_tcp.SID_READ_REQUEST,
|
'service_id': socket_protocol.SID_READ_REQUEST,
|
||||||
'data_id': wetation_protocol.my_base_protocol_tcp.ENVDATA_STATISTIC_BMP,
|
'data_id': wetation_protocol.ENVDATA_STATISTIC_BMP,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
PROT_ID_OUT: [
|
PROT_ID_OUT: [
|
||||||
{
|
{
|
||||||
'service_id': wetation_protocol.my_base_protocol_tcp.SID_READ_REQUEST,
|
'service_id': socket_protocol.SID_READ_REQUEST,
|
||||||
'data_id': wetation_protocol.my_base_protocol_tcp.ENVDATA_STATISTIC_DHT,
|
'data_id': wetation_protocol.ENVDATA_STATISTIC_DHT,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'service_id': wetation_protocol.my_base_protocol_tcp.SID_READ_REQUEST,
|
'service_id': socket_protocol.SID_READ_REQUEST,
|
||||||
'data_id': wetation_protocol.my_base_protocol_tcp.ENVDATA_STATISTIC_BMP,
|
'data_id': wetation_protocol.ENVDATA_STATISTIC_BMP,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
@ -86,8 +87,8 @@ class WetationFrameProt(gui.Wetation):
|
|||||||
REQUEST_MSGS_FAST = {
|
REQUEST_MSGS_FAST = {
|
||||||
PROT_ID_GARAGE: [
|
PROT_ID_GARAGE: [
|
||||||
{
|
{
|
||||||
'service_id': garage_protocol.my_base_protocol_tcp.SID_READ_REQUEST,
|
'service_id': socket_protocol.SID_READ_REQUEST,
|
||||||
'data_id': garage_protocol.my_base_protocol_tcp.GATE_POSITION,
|
'data_id': garage_protocol.GATE_POSITION,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
@ -162,13 +163,13 @@ class WetationFrameProt(gui.Wetation):
|
|||||||
cn = self.PROT_NAMES[prot_id]
|
cn = self.PROT_NAMES[prot_id]
|
||||||
logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__ + '.' + cn)
|
logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__ + '.' + cn)
|
||||||
if prot_id == self.PROT_ID_GARAGE:
|
if prot_id == self.PROT_ID_GARAGE:
|
||||||
if service_id == garage_protocol.my_base_protocol_tcp.SID_READ_RESPONSE and data_id == garage_protocol.my_base_protocol_tcp.GATE_POSITION:
|
if service_id == socket_protocol.SID_READ_RESPONSE and data_id == garage_protocol.GATE_POSITION:
|
||||||
rv = isinstance(data, numbers.Number)
|
rv = isinstance(data, numbers.Number)
|
||||||
elif service_id == garage_protocol.my_base_protocol_tcp.SID_EXECUTE_RESPONSE and data_id == garage_protocol.my_base_protocol_tcp.OPEN_CLOSE_GATE:
|
elif service_id == socket_protocol.SID_EXECUTE_RESPONSE and data_id == garage_protocol.OPEN_CLOSE_GATE:
|
||||||
if data is True:
|
if data is True:
|
||||||
rv = True
|
rv = True
|
||||||
elif prot_id in [self.PROT_ID_IN, self.PROT_ID_OUT]:
|
elif prot_id in [self.PROT_ID_IN, self.PROT_ID_OUT]:
|
||||||
if service_id == wetation_protocol.my_base_protocol_tcp.SID_READ_RESPONSE and data_id == wetation_protocol.my_base_protocol_tcp.ENVDATA_STATISTIC_BMP:
|
if service_id == socket_protocol.SID_READ_RESPONSE and data_id == wetation_protocol.ENVDATA_STATISTIC_BMP:
|
||||||
rv = True
|
rv = True
|
||||||
for main_key in [bmp_180.KEY_PRESSURE, bmp_180.KEY_TEMPERATURE, bmp_180.KEY_TIME]:
|
for main_key in [bmp_180.KEY_PRESSURE, bmp_180.KEY_TEMPERATURE, bmp_180.KEY_TIME]:
|
||||||
if main_key not in data:
|
if main_key not in data:
|
||||||
@ -179,7 +180,7 @@ class WetationFrameProt(gui.Wetation):
|
|||||||
if not isinstance(data[main_key].get(sub_key), numbers.Number):
|
if not isinstance(data[main_key].get(sub_key), numbers.Number):
|
||||||
rv = False
|
rv = False
|
||||||
break
|
break
|
||||||
elif service_id == wetation_protocol.my_base_protocol_tcp.SID_READ_RESPONSE and data_id == wetation_protocol.my_base_protocol_tcp.ENVDATA_STATISTIC_DHT:
|
elif service_id == socket_protocol.SID_READ_RESPONSE and data_id == wetation_protocol.ENVDATA_STATISTIC_DHT:
|
||||||
rv = True
|
rv = True
|
||||||
for main_key in [dht_22.KEY_HUMIDITY, dht_22.KEY_TEMPERATURE, dht_22.KEY_TIME]:
|
for main_key in [dht_22.KEY_HUMIDITY, dht_22.KEY_TEMPERATURE, dht_22.KEY_TIME]:
|
||||||
if main_key not in data:
|
if main_key not in data:
|
||||||
@ -200,16 +201,16 @@ class WetationFrameProt(gui.Wetation):
|
|||||||
data = msg.get_data()
|
data = msg.get_data()
|
||||||
if self.__validate_response_data__(prot_id, service_id, data_id, data):
|
if self.__validate_response_data__(prot_id, service_id, data_id, data):
|
||||||
wx.CallAfter(self.__data__, prot_id, service_id, data_id, data)
|
wx.CallAfter(self.__data__, prot_id, service_id, data_id, data)
|
||||||
return wetation_protocol.my_base_protocol_tcp.STATUS_OKAY, None
|
return socket_protocol.STATUS_OKAY, None
|
||||||
else:
|
else:
|
||||||
wx.CallAfter(self.__no_data__, prot_id, service_id, data_id)
|
wx.CallAfter(self.__no_data__, prot_id, service_id, data_id)
|
||||||
return wetation_protocol.my_base_protocol_tcp.STATUS_SERVICE_OR_DATA_UNKNOWN, None
|
return socket_protocol.STATUS_SERVICE_OR_DATA_UNKNOWN, None
|
||||||
|
|
||||||
def __no_data__(self, prot_id, service_id, data_id):
|
def __no_data__(self, prot_id, service_id, data_id):
|
||||||
cn = self.PROT_NAMES[prot_id]
|
cn = self.PROT_NAMES[prot_id]
|
||||||
logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__ + '.' + cn)
|
logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__ + '.' + cn)
|
||||||
if prot_id == self.PROT_ID_GARAGE:
|
if prot_id == self.PROT_ID_GARAGE:
|
||||||
if service_id == garage_protocol.my_base_protocol_tcp.SID_READ_RESPONSE and data_id == garage_protocol.my_base_protocol_tcp.GATE_POSITION:
|
if service_id == socket_protocol.SID_READ_RESPONSE and data_id == garage_protocol.GATE_POSITION:
|
||||||
logger.warning('Resetting GUI elements for %s', cn)
|
logger.warning('Resetting GUI elements for %s', cn)
|
||||||
self.heading_garage.Show(False)
|
self.heading_garage.Show(False)
|
||||||
self.gate_oc.Show(False)
|
self.gate_oc.Show(False)
|
||||||
@ -218,10 +219,10 @@ class WetationFrameProt(gui.Wetation):
|
|||||||
self.gate_close.Show(False)
|
self.gate_close.Show(False)
|
||||||
self.Layout()
|
self.Layout()
|
||||||
return
|
return
|
||||||
elif service_id == garage_protocol.my_base_protocol_tcp.SID_EXECUTE_RESPONSE and data_id == garage_protocol.my_base_protocol_tcp.OPEN_CLOSE_GATE:
|
elif service_id == socket_protocol.SID_EXECUTE_RESPONSE and data_id == garage_protocol.OPEN_CLOSE_GATE:
|
||||||
return
|
return
|
||||||
elif prot_id in [self.PROT_ID_IN, self.PROT_ID_OUT]:
|
elif prot_id in [self.PROT_ID_IN, self.PROT_ID_OUT]:
|
||||||
if service_id == wetation_protocol.my_base_protocol_tcp.SID_READ_RESPONSE and data_id == wetation_protocol.my_base_protocol_tcp.ENVDATA_STATISTIC_BMP:
|
if service_id == socket_protocol.SID_READ_RESPONSE and data_id == wetation_protocol.ENVDATA_STATISTIC_BMP:
|
||||||
logger.warning('Resetting GUI elements for %s', cn)
|
logger.warning('Resetting GUI elements for %s', cn)
|
||||||
txt_pressure = '- hPa'
|
txt_pressure = '- hPa'
|
||||||
if prot_id == self.PROT_ID_IN:
|
if prot_id == self.PROT_ID_IN:
|
||||||
@ -230,7 +231,7 @@ class WetationFrameProt(gui.Wetation):
|
|||||||
self.out_pressure.SetLabel(txt_pressure)
|
self.out_pressure.SetLabel(txt_pressure)
|
||||||
self.Layout()
|
self.Layout()
|
||||||
return
|
return
|
||||||
elif service_id == wetation_protocol.my_base_protocol_tcp.SID_READ_RESPONSE and data_id == wetation_protocol.my_base_protocol_tcp.ENVDATA_STATISTIC_DHT:
|
elif service_id == socket_protocol.SID_READ_RESPONSE and data_id == wetation_protocol.ENVDATA_STATISTIC_DHT:
|
||||||
logger.warning('Resetting GUI elements for %s', cn)
|
logger.warning('Resetting GUI elements for %s', cn)
|
||||||
txt_temperature = '-.- °C'
|
txt_temperature = '-.- °C'
|
||||||
txt_humidity = '-.- %'
|
txt_humidity = '-.- %'
|
||||||
@ -248,7 +249,7 @@ class WetationFrameProt(gui.Wetation):
|
|||||||
cn = self.PROT_NAMES[prot_id]
|
cn = self.PROT_NAMES[prot_id]
|
||||||
logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__ + '.' + cn)
|
logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__ + '.' + cn)
|
||||||
if prot_id == self.PROT_ID_GARAGE:
|
if prot_id == self.PROT_ID_GARAGE:
|
||||||
if service_id == garage_protocol.my_base_protocol_tcp.SID_READ_RESPONSE and data_id == garage_protocol.my_base_protocol_tcp.GATE_POSITION:
|
if service_id == socket_protocol.SID_READ_RESPONSE and data_id == garage_protocol.GATE_POSITION:
|
||||||
logger.debug('Setting %s position to %3d', cn, int(data * 100))
|
logger.debug('Setting %s position to %3d', cn, int(data * 100))
|
||||||
self.heading_garage.Show(True)
|
self.heading_garage.Show(True)
|
||||||
self.gate_oc.Show(True)
|
self.gate_oc.Show(True)
|
||||||
@ -258,10 +259,10 @@ class WetationFrameProt(gui.Wetation):
|
|||||||
self.gate_position.SetValue(int(data * 100))
|
self.gate_position.SetValue(int(data * 100))
|
||||||
self.Layout()
|
self.Layout()
|
||||||
return
|
return
|
||||||
elif service_id == garage_protocol.my_base_protocol_tcp.SID_EXECUTE_RESPONSE and data_id == garage_protocol.my_base_protocol_tcp.OPEN_CLOSE_GATE:
|
elif service_id == socket_protocol.SID_EXECUTE_RESPONSE and data_id == garage_protocol.OPEN_CLOSE_GATE:
|
||||||
return
|
return
|
||||||
elif prot_id in [self.PROT_ID_IN, self.PROT_ID_OUT]:
|
elif prot_id in [self.PROT_ID_IN, self.PROT_ID_OUT]:
|
||||||
if service_id == wetation_protocol.my_base_protocol_tcp.SID_READ_RESPONSE and data_id == wetation_protocol.my_base_protocol_tcp.ENVDATA_STATISTIC_BMP:
|
if service_id == socket_protocol.SID_READ_RESPONSE and data_id == wetation_protocol.ENVDATA_STATISTIC_BMP:
|
||||||
data = helpers.continues_statistic_multivalue(**data)
|
data = helpers.continues_statistic_multivalue(**data)
|
||||||
logger.debug('Setting %s pressure to %4d hPa', cn, data[bmp_180.KEY_PRESSURE].mean)
|
logger.debug('Setting %s pressure to %4d hPa', cn, data[bmp_180.KEY_PRESSURE].mean)
|
||||||
#
|
#
|
||||||
@ -271,7 +272,7 @@ class WetationFrameProt(gui.Wetation):
|
|||||||
else:
|
else:
|
||||||
wx.CallAfter(self.update_current_bmp_env_data, data, self.out_pressure)
|
wx.CallAfter(self.update_current_bmp_env_data, data, self.out_pressure)
|
||||||
return
|
return
|
||||||
elif service_id == wetation_protocol.my_base_protocol_tcp.SID_READ_RESPONSE and data_id == wetation_protocol.my_base_protocol_tcp.ENVDATA_STATISTIC_DHT:
|
elif service_id == socket_protocol.SID_READ_RESPONSE and data_id == wetation_protocol.ENVDATA_STATISTIC_DHT:
|
||||||
data = helpers.continues_statistic_multivalue(**data)
|
data = helpers.continues_statistic_multivalue(**data)
|
||||||
#
|
#
|
||||||
# Current environmental data
|
# Current environmental data
|
||||||
@ -321,7 +322,7 @@ class WetationFrameProt(gui.Wetation):
|
|||||||
).ShowModal()
|
).ShowModal()
|
||||||
if r == wx.ID_YES:
|
if r == wx.ID_YES:
|
||||||
logger.debug("Gate open/close request")
|
logger.debug("Gate open/close request")
|
||||||
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)
|
self.__prot__[self.PROT_ID_GARAGE].send(socket_protocol.SID_EXECUTE_REQUEST, garage_protocol.OPEN_CLOSE_GATE, None)
|
||||||
event.Skip()
|
event.Skip()
|
||||||
|
|
||||||
def reset_in_temp_minmax_evt(self, event):
|
def reset_in_temp_minmax_evt(self, event):
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 7c02c8dd3cc5b24a1ba8ce71c0b7396f3759671e
|
Subproject commit 35d9f688a4f080a8cae70a18e27036b55399edde
|
@ -1 +1 @@
|
|||||||
Subproject commit 76d8ae9b1bfd894bc5f4b830394ce0552120a508
|
Subproject commit 5ac92e2b864cd27bd4026352ba9149f4d23ca019
|
@ -1 +1 @@
|
|||||||
Subproject commit cdc9912f3d26edea9e0a36b0fccfc7d3bfd6b868
|
Subproject commit 07357d33ad5dbed4807fef6ef088abd5b005e363
|
Loading…
x
Reference in New Issue
Block a user