|
@@ -1,184 +1,119 @@
|
1
|
1
|
#!/usr/bin/env python
|
2
|
2
|
# -*- coding: UTF-8 -*-
|
3
|
3
|
#
|
4
|
|
-# generated by wxGlade 0.9.4 on Fri Sep 4 13:21:47 2020
|
5
|
|
-#
|
6
|
|
-
|
7
|
|
-import wx
|
8
|
4
|
|
9
|
5
|
import config
|
|
6
|
+import rpi_envsens as envsens
|
|
7
|
+import garage_protocol
|
|
8
|
+import gui
|
10
|
9
|
import logging
|
11
|
10
|
import os
|
12
|
|
-
|
13
|
|
-import time
|
14
|
|
-import garage_protocol
|
15
|
|
-import wetation_protocol
|
16
|
11
|
import report
|
17
|
|
-import tcp_socket
|
18
|
12
|
import task
|
19
|
|
-from config import FULL_SCRREN
|
20
|
|
-
|
21
|
|
-# begin wxGlade: dependencies
|
22
|
|
-# end wxGlade
|
|
13
|
+import tcp_socket
|
|
14
|
+import time
|
|
15
|
+import wetation_protocol
|
|
16
|
+import wx
|
23
|
17
|
|
24
|
|
-# begin wxGlade: extracode
|
25
|
|
-# end wxGlade
|
|
18
|
+logger = logging.getLogger('APP')
|
26
|
19
|
|
27
|
20
|
|
28
|
|
-class Wetation(wx.Frame):
|
|
21
|
+class WetationFrameProt(gui.Wetation):
|
29
|
22
|
def __init__(self, *args, **kwds):
|
30
|
|
- # begin wxGlade: Wetation.__init__
|
31
|
|
- kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE
|
32
|
|
- wx.Frame.__init__(self, *args, **kwds)
|
33
|
|
- self.SetSize((800, 600))
|
34
|
|
- self.garage_oc = wx.Button(self, wx.ID_ANY, "Garage")
|
35
|
|
- self.gate_position = wx.Slider(self, wx.ID_ANY, 50, 0, 100)
|
36
|
|
-
|
37
|
|
- self.__set_properties()
|
38
|
|
- self.__do_layout()
|
39
|
|
-
|
40
|
|
- self.Bind(wx.EVT_BUTTON, self.garage_oc_evt, self.garage_oc)
|
41
|
|
- # end wxGlade
|
42
|
|
- self.ShowFullScreen(FULL_SCRREN)
|
43
|
|
-
|
44
|
|
- def __set_properties(self):
|
45
|
|
- # begin wxGlade: Wetation.__set_properties
|
46
|
|
- self.SetTitle("frame")
|
47
|
|
- self.SetBackgroundColour(wx.Colour(250, 249, 255))
|
48
|
|
- self.SetForegroundColour(wx.Colour(35, 35, 142))
|
49
|
|
- self.gate_position.Enable(False)
|
50
|
|
- # end wxGlade
|
51
|
|
-
|
52
|
|
- def __do_layout(self):
|
53
|
|
- # begin wxGlade: Wetation.__do_layout
|
54
|
|
- sizer_main = wx.BoxSizer(wx.VERTICAL)
|
55
|
|
- sizer_8 = wx.BoxSizer(wx.HORIZONTAL)
|
56
|
|
- sizer_env_data_in = wx.BoxSizer(wx.HORIZONTAL)
|
57
|
|
- sizer_9 = wx.BoxSizer(wx.VERTICAL)
|
58
|
|
- sizer_5 = wx.BoxSizer(wx.VERTICAL)
|
59
|
|
- sizer_env_data_out = wx.BoxSizer(wx.HORIZONTAL)
|
60
|
|
- sizer_7 = wx.BoxSizer(wx.VERTICAL)
|
61
|
|
- sizer_4 = wx.BoxSizer(wx.VERTICAL)
|
62
|
|
- sizer_date_time = wx.BoxSizer(wx.HORIZONTAL)
|
63
|
|
- spacer_1 = wx.StaticText(self, wx.ID_ANY, "")
|
64
|
|
- spacer_1.SetBackgroundColour(wx.Colour(35, 35, 142))
|
65
|
|
- spacer_1.SetFont(wx.Font(5, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
66
|
|
- sizer_main.Add(spacer_1, 0, wx.EXPAND, 0)
|
67
|
|
- date = wx.StaticText(self, wx.ID_ANY, "xx.xx.xxxx", style=wx.ALIGN_LEFT)
|
68
|
|
- date.SetBackgroundColour(wx.Colour(35, 35, 142))
|
69
|
|
- date.SetForegroundColour(wx.Colour(255, 255, 255))
|
70
|
|
- date.SetFont(wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
71
|
|
- sizer_date_time.Add(date, 1, wx.EXPAND | wx.LEFT, 0)
|
72
|
|
- time = wx.StaticText(self, wx.ID_ANY, "xx:xx", style=wx.ALIGN_RIGHT)
|
73
|
|
- time.SetBackgroundColour(wx.Colour(35, 35, 142))
|
74
|
|
- time.SetForegroundColour(wx.Colour(255, 255, 255))
|
75
|
|
- time.SetFont(wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
76
|
|
- sizer_date_time.Add(time, 1, wx.EXPAND | wx.RIGHT, 0)
|
77
|
|
- sizer_main.Add(sizer_date_time, 0, wx.EXPAND, 0)
|
78
|
|
- spacer_2 = wx.StaticText(self, wx.ID_ANY, "")
|
79
|
|
- spacer_2.SetBackgroundColour(wx.Colour(35, 35, 142))
|
80
|
|
- spacer_2.SetFont(wx.Font(5, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
81
|
|
- sizer_main.Add(spacer_2, 0, wx.EXPAND, 0)
|
82
|
|
- spacer_3 = wx.StaticText(self, wx.ID_ANY, u"Außentemperatur")
|
83
|
|
- spacer_3.SetBackgroundColour(wx.Colour(0, 0, 0))
|
84
|
|
- spacer_3.SetForegroundColour(wx.Colour(250, 249, 255))
|
85
|
|
- spacer_3.SetFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
86
|
|
- sizer_main.Add(spacer_3, 0, wx.EXPAND, 0)
|
87
|
|
- out_humidity = wx.StaticText(self, wx.ID_ANY, "- %", style=wx.ALIGN_RIGHT)
|
88
|
|
- out_humidity.SetFont(wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
89
|
|
- sizer_4.Add(out_humidity, 1, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, 0)
|
90
|
|
- out_pressure = wx.StaticText(self, wx.ID_ANY, "- mbar", style=wx.ALIGN_RIGHT)
|
91
|
|
- out_pressure.SetFont(wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
92
|
|
- sizer_4.Add(out_pressure, 1, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, 0)
|
93
|
|
- sizer_env_data_out.Add(sizer_4, 1, wx.EXPAND, 0)
|
94
|
|
- out_temperature_min = wx.StaticText(self, wx.ID_ANY, u"-.- °C", style=wx.ALIGN_RIGHT)
|
95
|
|
- out_temperature_min.SetFont(wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
96
|
|
- sizer_7.Add(out_temperature_min, 1, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, 0)
|
97
|
|
- out_temperature_max = wx.StaticText(self, wx.ID_ANY, u"-.- °C", style=wx.ALIGN_RIGHT)
|
98
|
|
- out_temperature_max.SetFont(wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
99
|
|
- sizer_7.Add(out_temperature_max, 1, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, 0)
|
100
|
|
- sizer_env_data_out.Add(sizer_7, 1, wx.EXPAND, 0)
|
101
|
|
- sizer_env_data_out.Add((50, 20), 0, 0, 0)
|
102
|
|
- out_temperature = wx.StaticText(self, wx.ID_ANY, u"-.- °C", style=wx.ALIGN_RIGHT)
|
103
|
|
- out_temperature.SetFont(wx.Font(48, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
104
|
|
- sizer_env_data_out.Add(out_temperature, 2, wx.ALIGN_RIGHT | wx.RIGHT, 0)
|
105
|
|
- sizer_main.Add(sizer_env_data_out, 0, wx.EXPAND, 0)
|
106
|
|
- spacer_4 = wx.StaticText(self, wx.ID_ANY, "Innentemperatur")
|
107
|
|
- spacer_4.SetBackgroundColour(wx.Colour(0, 0, 0))
|
108
|
|
- spacer_4.SetForegroundColour(wx.Colour(250, 249, 255))
|
109
|
|
- spacer_4.SetFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
110
|
|
- sizer_main.Add(spacer_4, 0, wx.EXPAND, 0)
|
111
|
|
- in_humidity = wx.StaticText(self, wx.ID_ANY, "- %", style=wx.ALIGN_RIGHT)
|
112
|
|
- in_humidity.SetFont(wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
113
|
|
- sizer_5.Add(in_humidity, 1, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, 0)
|
114
|
|
- in_pressure = wx.StaticText(self, wx.ID_ANY, "- mbar", style=wx.ALIGN_RIGHT)
|
115
|
|
- in_pressure.SetFont(wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
116
|
|
- sizer_5.Add(in_pressure, 1, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, 0)
|
117
|
|
- sizer_env_data_in.Add(sizer_5, 1, wx.EXPAND, 0)
|
118
|
|
- in_temperature_min = wx.StaticText(self, wx.ID_ANY, u"-.- °C", style=wx.ALIGN_RIGHT)
|
119
|
|
- in_temperature_min.SetFont(wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
120
|
|
- sizer_9.Add(in_temperature_min, 1, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, 0)
|
121
|
|
- in_temperature_max = wx.StaticText(self, wx.ID_ANY, u"-.- °C", style=wx.ALIGN_RIGHT)
|
122
|
|
- in_temperature_max.SetFont(wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
123
|
|
- sizer_9.Add(in_temperature_max, 1, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, 0)
|
124
|
|
- sizer_env_data_in.Add(sizer_9, 1, wx.EXPAND, 0)
|
125
|
|
- sizer_env_data_in.Add((50, 20), 0, 0, 0)
|
126
|
|
- in_temperature = wx.StaticText(self, wx.ID_ANY, u"-.- °C", style=wx.ALIGN_RIGHT)
|
127
|
|
- in_temperature.SetFont(wx.Font(48, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
128
|
|
- sizer_env_data_in.Add(in_temperature, 2, wx.ALIGN_RIGHT | wx.RIGHT, 0)
|
129
|
|
- sizer_main.Add(sizer_env_data_in, 0, wx.EXPAND, 0)
|
130
|
|
- sizer_main.Add((10, 10), 1, 0, 0)
|
131
|
|
- spacer_5 = wx.StaticText(self, wx.ID_ANY, "Garage")
|
132
|
|
- spacer_5.SetBackgroundColour(wx.Colour(0, 0, 0))
|
133
|
|
- spacer_5.SetForegroundColour(wx.Colour(250, 249, 255))
|
134
|
|
- spacer_5.SetFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
135
|
|
- sizer_main.Add(spacer_5, 0, wx.EXPAND, 0)
|
136
|
|
- sizer_8.Add(self.garage_oc, 0, 0, 0)
|
137
|
|
- gate__open = wx.StaticText(self, wx.ID_ANY, "Close")
|
138
|
|
- sizer_8.Add(gate__open, 0, wx.ALIGN_CENTER, 0)
|
139
|
|
- sizer_8.Add(self.gate_position, 1, wx.EXPAND, 0)
|
140
|
|
- gate_open = wx.StaticText(self, wx.ID_ANY, "Open")
|
141
|
|
- sizer_8.Add(gate_open, 0, wx.ALIGN_CENTER, 0)
|
142
|
|
- sizer_main.Add(sizer_8, 0, wx.EXPAND, 0)
|
143
|
|
- self.SetSizer(sizer_main)
|
144
|
|
- self.Layout()
|
145
|
|
- # end wxGlade
|
146
|
|
- self.date = date
|
147
|
|
- self.time = time
|
148
|
|
- #
|
149
|
|
- self.out_humidity = out_humidity
|
150
|
|
- self.out_pressure = out_pressure
|
|
23
|
+ gui.Wetation.__init__(self, *args, **kwds)
|
|
24
|
+ self.__task_data_request__ = task.periodic(10, self.__initiate_data_request__)
|
|
25
|
+ self.__init__communication__()
|
151
|
26
|
|
152
|
|
- self.out_temperature = out_temperature
|
153
|
|
- self.out_temperature_min = out_temperature_min
|
154
|
|
- self.out_temperature_max = out_temperature_max
|
|
27
|
+ def __init__communication__(self):
|
155
|
28
|
#
|
156
|
|
- self.in_humidity = in_humidity
|
157
|
|
- self.in_pressure = in_pressure
|
158
|
|
-
|
159
|
|
- self.in_temperature = in_temperature
|
|
29
|
+ # Start TCP-Clients
|
|
30
|
+ c_tcp = tcp_socket.tcp_client_stp(config.server_out_ip, config.server_out_port, rx_log_lvl=logging.DEBUG)
|
|
31
|
+ self.prot_out = wetation_protocol.my_base_protocol_tcp(c_tcp, config.server_out_secret)
|
|
32
|
+ self.prot_out.register_callback(wetation_protocol.my_base_protocol_tcp.SID_READ_RESPONSE, wetation_protocol.my_base_protocol_tcp.CURRENT_ENVDATA, self.update_current_env_data_out)
|
|
33
|
+ if config.server_out_secret is not None:
|
|
34
|
+ self.prot_out.authentificate()
|
|
35
|
+
|
|
36
|
+ c_tcp = tcp_socket.tcp_client_stp(config.server_in_ip, config.server_in_port, rx_log_lvl=logging.DEBUG)
|
|
37
|
+ self.prot_in = wetation_protocol.my_base_protocol_tcp(c_tcp, config.server_in_secret)
|
|
38
|
+ self.prot_in.register_callback(wetation_protocol.my_base_protocol_tcp.SID_READ_RESPONSE, wetation_protocol.my_base_protocol_tcp.CURRENT_ENVDATA, self.update_current_env_data_in)
|
|
39
|
+ if config.server_in_secret is not None:
|
|
40
|
+ self.prot_in.authentificate()
|
|
41
|
+
|
|
42
|
+ c_tcp = tcp_socket.tcp_client_stp(config.server_garage_ip, config.server_garage_port, rx_log_lvl=logging.DEBUG)
|
|
43
|
+ self.prot_garage = garage_protocol.my_base_protocol_tcp(c_tcp, config.server_garage_secret)
|
|
44
|
+ self.prot_garage.register_callback(garage_protocol.my_base_protocol_tcp.SID_READ_RESPONSE, garage_protocol.my_base_protocol_tcp.GATE_POSITION, self.update_gate_position)
|
|
45
|
+ if config.server_garage_secret is not None:
|
|
46
|
+ self.prot_garage.authentificate()
|
|
47
|
+
|
|
48
|
+ def __update_current_envdata__(self, msg, temperature, humidity, pressure):
|
|
49
|
+ if msg.get_status() == wetation_protocol.my_base_protocol_tcp.STATUS_OKAY:
|
|
50
|
+ env_data = msg.get_data()
|
|
51
|
+ wx.CallAfter(temperature.SetLabel, "%.1f °C" % env_data[envsens.KEY_TEMPERATURE])
|
|
52
|
+ wx.CallAfter(humidity.SetLabel, "%.1f %%" % env_data[envsens.KEY_HUMIDITY])
|
|
53
|
+ wx.CallAfter(pressure.SetLabel, "%.0f mbar" % env_data[envsens.KEY_PRESSURE])
|
|
54
|
+ wx.CallAfter(self.Layout)
|
|
55
|
+ return wetation_protocol.my_base_protocol_tcp.STATUS_OKAY, None
|
|
56
|
+ else:
|
|
57
|
+ logger.error('No environmental data received! MSG_STATUS was %s', wetation_protocol.my_base_protocol_tcp.STATUS_NAMES.get(msg.get_status(), repr(msg.get_status())))
|
|
58
|
+ return wetation_protocol.my_base_protocol_tcp.STATUS_SERVICE_OR_DATA_UNKNOWN, None
|
|
59
|
+
|
|
60
|
+ def update_current_env_data_out(self, msg):
|
|
61
|
+ return self.__update_current_envdata__(msg, self.out_temperature, self.out_humidity, self.out_pressure)
|
|
62
|
+
|
|
63
|
+ def update_current_env_data_in(self, msg):
|
|
64
|
+ return self.__update_current_envdata__(msg, self.in_temperature, self.in_humidity, self.in_pressure)
|
|
65
|
+
|
|
66
|
+ def update_gate_position(self, msg):
|
|
67
|
+ if msg.get_status() == garage_protocol.my_base_protocol_tcp.STATUS_OKAY:
|
|
68
|
+ #
|
|
69
|
+ # show gate section in GUI
|
|
70
|
+ #
|
|
71
|
+ self.heading_garage.show(True)
|
|
72
|
+ self.gate_oc.show(True)
|
|
73
|
+ self.gate_open.show(True)
|
|
74
|
+ self.gate_position.show(True)
|
|
75
|
+ self.gate_close.show(True)
|
|
76
|
+ #
|
|
77
|
+ # update gate position
|
|
78
|
+ #
|
|
79
|
+ wx.CallAfter(self.gate_position.SetValue, msg.get_data() * 100)
|
|
80
|
+ wx.CallAfter(self.Layout)
|
|
81
|
+ return garage_protocol.my_base_protocol_tcp.STATUS_OKAY, None
|
|
82
|
+ else:
|
|
83
|
+ logger.error('No gate position received! MSG_STATUS was %s', garage_protocol.my_base_protocol_tcp.STATUS_NAMES.get(msg.get_status(), repr(msg.get_status())))
|
|
84
|
+ return garage_protocol.my_base_protocol_tcp.STATUS_SERVICE_OR_DATA_UNKNOWN, None
|
160
|
85
|
|
161
|
86
|
def garage_oc_evt(self, event): # wxGlade: Wetation.<event_handler>
|
162
|
|
- self.prot_garage.send(prot_garage.SID_EXECUTE_REQUEST, prot_garage.OPEN_CLOSE_GATE, None)
|
|
87
|
+ self.prot_garage.send(garage_protocol.my_base_protocol_tcp.SID_EXECUTE_REQUEST, garage_protocol.my_base_protocol_tcp.OPEN_CLOSE_GATE, None)
|
163
|
88
|
event.Skip()
|
164
|
|
-# end of class Wetation
|
|
89
|
+
|
|
90
|
+ def __initiate_data_request__(self, rt):
|
|
91
|
+ self.prot_out.send(wetation_protocol.my_base_protocol_tcp.SID_READ_REQUEST, wetation_protocol.my_base_protocol_tcp.CURRENT_ENVDATA, None)
|
|
92
|
+ self.prot_in.send(wetation_protocol.my_base_protocol_tcp.SID_READ_REQUEST, wetation_protocol.my_base_protocol_tcp.CURRENT_ENVDATA, None)
|
|
93
|
+ self.prot_garage.send(garage_protocol.my_base_protocol_tcp.SID_READ_REQUEST, garage_protocol.my_base_protocol_tcp.GATE_POSITION, None)
|
|
94
|
+ # TODO: Move the following three lines to the wx idle task
|
|
95
|
+ wx.CallAfter(self.time.SetLabel, time.strftime("%H:%M"))
|
|
96
|
+ wx.CallAfter(self.date.SetLabel, time.strftime("%d.%m.%Y"))
|
|
97
|
+ wx.CallAfter(self.Layout)
|
|
98
|
+
|
|
99
|
+ def run(self):
|
|
100
|
+ self.__task_data_request__.run()
|
|
101
|
+
|
|
102
|
+ def close(self):
|
|
103
|
+ self.__task_data_request__.stop()
|
|
104
|
+ self.__task_data_request__.join()
|
|
105
|
+
|
|
106
|
+ def __del__(self):
|
|
107
|
+ self.close()
|
|
108
|
+
|
165
|
109
|
|
166
|
110
|
class MyApp(wx.App):
|
167
|
111
|
def OnInit(self):
|
168
|
|
- self.frame = Wetation(None, wx.ID_ANY, "")
|
|
112
|
+ self.frame = WetationFrameProt(None, wx.ID_ANY, "")
|
169
|
113
|
self.SetTopWindow(self.frame)
|
170
|
114
|
self.frame.Show()
|
171
|
115
|
return True
|
172
|
116
|
|
173
|
|
-# end of class MyApp
|
174
|
|
-
|
175
|
|
-def initiate_update(rt, frame, prot_out, prot_in, prot_garage):
|
176
|
|
- prot_out.send(wetation_protocol.my_base_protocol_tcp.SID_READ_REQUEST, wetation_protocol.my_base_protocol_tcp.CURRENT_ENVDATA, None)
|
177
|
|
- prot_in.send(wetation_protocol.my_base_protocol_tcp.SID_READ_REQUEST, wetation_protocol.my_base_protocol_tcp.CURRENT_ENVDATA, None)
|
178
|
|
- prot_garage.send(garage_protocol.my_base_protocol_tcp.SID_READ_REQUEST, garage_protocol.my_base_protocol_tcp.GATE_POSITION, None)
|
179
|
|
- wx.CallAfter(frame.time.SetLabel, time.strftime("%H:%M"))
|
180
|
|
- wx.CallAfter(frame.date.SetLabel, time.strftime("%d.%m.%Y"))
|
181
|
|
- wx.CallAfter(frame.Layout)
|
182
|
117
|
|
183
|
118
|
|
184
|
119
|
|
|
@@ -186,26 +121,6 @@ if __name__ == "__main__":
|
186
|
121
|
report.appLoggingConfigure(os.path.dirname(__file__), config.LOGTARGET, config.loggers)
|
187
|
122
|
#
|
188
|
123
|
app = MyApp(0)
|
189
|
|
- #
|
190
|
|
- # Start TCP-Clients
|
191
|
|
- c_tcp = tcp_socket.tcp_client_stp(config.server_out_ip, config.server_out_port, rx_log_lvl=logging.DEBUG)
|
192
|
|
- prot_out = wetation_protocol.my_smarthome_gui_client_protocol_tcp(c_tcp, app.frame.out_temperature, app.frame.out_humidity, app.frame.out_pressure, app.frame.Layout, config.server_out_secret)
|
193
|
|
- if config.server_out_secret is not None:
|
194
|
|
- prot_out.authentificate()
|
195
|
|
- c_tcp = tcp_socket.tcp_client_stp(config.server_in_ip, config.server_in_port, rx_log_lvl=logging.DEBUG)
|
196
|
|
- prot_in = wetation_protocol.my_smarthome_gui_client_protocol_tcp(c_tcp, app.frame.in_temperature, app.frame.in_humidity, app.frame.in_pressure, app.frame.Layout, config.server_in_secret)
|
197
|
|
- if config.server_in_secret is not None:
|
198
|
|
- prot_in.authentificate()
|
199
|
|
- c_tcp = tcp_socket.tcp_client_stp(config.server_garage_ip, config.server_garage_port, rx_log_lvl=logging.DEBUG)
|
200
|
|
- prot_garage = garage_protocol.my_smarthome_gui_client_protocol_tcp(c_tcp, app.frame.gate_position, app.frame.Layout, config.server_garage_secret)
|
201
|
|
- if config.server_garage_secret is not None:
|
202
|
|
- prot_garage.authentificate()
|
203
|
|
- app.frame.prot_garage = prot_garage
|
204
|
|
- pt = task.periodic(10, initiate_update, app.frame, prot_out, prot_in, prot_garage)
|
205
|
|
- pt.run()
|
|
124
|
+ app.frame.run()
|
206
|
125
|
app.MainLoop()
|
207
|
|
- pt.stop()
|
208
|
|
- try:
|
209
|
|
- pt.join()
|
210
|
|
- finally:
|
211
|
|
- pt.stop()
|
|
126
|
+ app.frame.close()
|