|
@@ -27,10 +27,14 @@ class my_server_protocol_tcp(my_base_protocol_tcp):
|
27
|
27
|
return self.STATUS_OKAY, self.envsens.get_env_data()
|
28
|
28
|
|
29
|
29
|
|
30
|
|
-class my_client_protocol_tcp(my_base_protocol_tcp):
|
|
30
|
+class my_smarthome_gui_client_protocol_tcp(my_base_protocol_tcp):
|
31
|
31
|
START_ROUTINE_DATA_IDS = []
|
32
|
32
|
|
33
|
|
- def __init__(self, comm_instance, secret=None):
|
|
33
|
+ def __init__(self, comm_instance, cb_temperature, cb_humidity, cb_pressure, cb_layout, secret=None):
|
|
34
|
+ self.cb_temperature = cb_temperature
|
|
35
|
+ self.cb_humidity = cb_humidity
|
|
36
|
+ self.cb_pressure = cb_pressure
|
|
37
|
+ self.cb_layout = cb_layout
|
34
|
38
|
socket_protocol.pure_json_protocol.__init__(self, comm_instance, secret)
|
35
|
39
|
self.register_callback(self.SID_READ_RESPONSE, self.CURRENT_ENVDATA, self.read_current_envdata)
|
36
|
40
|
|
|
@@ -42,11 +46,14 @@ class my_client_protocol_tcp(my_base_protocol_tcp):
|
42
|
46
|
return my_base_protocol_tcp.__authentificate_process_feedback__(self, msg)
|
43
|
47
|
|
44
|
48
|
def read_current_envdata(self, msg):
|
|
49
|
+ import wx
|
|
50
|
+
|
45
|
51
|
if msg.get_status() == self.STATUS_OKAY:
|
46
|
52
|
env_data = msg.get_data()
|
47
|
|
- print("Temperature: %6.1f °C" % env_data[envsens.KEY_TEMPERATURE])
|
48
|
|
- print("Humidity: %6.1f %%" % env_data[envsens.KEY_HUMIDITY])
|
49
|
|
- print("Pressure: %6.1f mbar" % env_data[envsens.KEY_PRESSURE])
|
|
53
|
+ wx.CallAfter(self.cb_temperature.SetLabel, "%.1f °C" % env_data[envsens.KEY_TEMPERATURE])
|
|
54
|
+ wx.CallAfter(self.cb_humidity.SetLabel, "%.1f %%" % env_data[envsens.KEY_HUMIDITY])
|
|
55
|
+ wx.CallAfter(self.cb_pressure.SetLabel, "%.0f mbar" % env_data[envsens.KEY_PRESSURE])
|
|
56
|
+ wx.CallAfter(self.cb_layout)
|
50
|
57
|
return self.STATUS_OKAY, None
|
51
|
58
|
else:
|
52
|
59
|
print('No environmental data received!')
|