GUI protocol moved to the application
This commit is contained in:
джерело
4a2f461be4
коміт
53e4523c14
17
__init__.py
17
__init__.py
@ -27,14 +27,10 @@ class my_server_protocol_tcp(my_base_protocol_tcp):
|
||||
return self.STATUS_OKAY, self.envsens.get_env_data()
|
||||
|
||||
|
||||
class my_smarthome_gui_client_protocol_tcp(my_base_protocol_tcp):
|
||||
class my_client_protocol_tcp(my_base_protocol_tcp):
|
||||
START_ROUTINE_DATA_IDS = []
|
||||
|
||||
def __init__(self, comm_instance, cb_temperature, cb_humidity, cb_pressure, cb_layout, secret=None):
|
||||
self.cb_temperature = cb_temperature
|
||||
self.cb_humidity = cb_humidity
|
||||
self.cb_pressure = cb_pressure
|
||||
self.cb_layout = cb_layout
|
||||
def __init__(self, comm_instance, secret=None):
|
||||
socket_protocol.pure_json_protocol.__init__(self, comm_instance, secret)
|
||||
self.register_callback(self.SID_READ_RESPONSE, self.CURRENT_ENVDATA, self.read_current_envdata)
|
||||
|
||||
@ -46,14 +42,11 @@ class my_smarthome_gui_client_protocol_tcp(my_base_protocol_tcp):
|
||||
return my_base_protocol_tcp.__authentificate_process_feedback__(self, msg)
|
||||
|
||||
def read_current_envdata(self, msg):
|
||||
import wx
|
||||
|
||||
if msg.get_status() == self.STATUS_OKAY:
|
||||
env_data = msg.get_data()
|
||||
wx.CallAfter(self.cb_temperature.SetLabel, "%.1f °C" % env_data[envsens.KEY_TEMPERATURE])
|
||||
wx.CallAfter(self.cb_humidity.SetLabel, "%.1f %%" % env_data[envsens.KEY_HUMIDITY])
|
||||
wx.CallAfter(self.cb_pressure.SetLabel, "%.0f mbar" % env_data[envsens.KEY_PRESSURE])
|
||||
wx.CallAfter(self.cb_layout)
|
||||
print("Temperature: %6.1f °C" % env_data[envsens.KEY_TEMPERATURE])
|
||||
print("Humidity: %6.1f %%" % env_data[envsens.KEY_HUMIDITY])
|
||||
print("Pressure: %6.1f mbar" % env_data[envsens.KEY_PRESSURE])
|
||||
return self.STATUS_OKAY, None
|
||||
else:
|
||||
print('No environmental data received!')
|
||||
|
Завантаження…
x
Посилання в новій задачі
Block a user