|
@@ -0,0 +1,206 @@
|
|
1
|
+#!/usr/bin/env python
|
|
2
|
+# -*- coding: UTF-8 -*-
|
|
3
|
+#
|
|
4
|
+# generated by wxGlade 0.9.4 on Fri Sep 4 13:21:47 2020
|
|
5
|
+#
|
|
6
|
+
|
|
7
|
+import wx
|
|
8
|
+
|
|
9
|
+import config
|
|
10
|
+import logging
|
|
11
|
+import os
|
|
12
|
+
|
|
13
|
+import time
|
|
14
|
+import garage_protocol
|
|
15
|
+import wetation_protocol
|
|
16
|
+import report
|
|
17
|
+import tcp_socket
|
|
18
|
+import task
|
|
19
|
+from config import FULL_SCRREN
|
|
20
|
+
|
|
21
|
+# begin wxGlade: dependencies
|
|
22
|
+# end wxGlade
|
|
23
|
+
|
|
24
|
+# begin wxGlade: extracode
|
|
25
|
+# end wxGlade
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+class Wetation(wx.Frame):
|
|
29
|
+ 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, 0, 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
|
|
151
|
+
|
|
152
|
+ self.out_temperature = out_temperature
|
|
153
|
+ self.out_temperature_min = out_temperature_min
|
|
154
|
+ self.out_temperature_max = out_temperature_max
|
|
155
|
+ #
|
|
156
|
+ self.in_humidity = in_humidity
|
|
157
|
+ self.in_pressure = in_pressure
|
|
158
|
+
|
|
159
|
+ self.in_temperature = in_temperature
|
|
160
|
+
|
|
161
|
+ 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)
|
|
163
|
+ event.Skip()
|
|
164
|
+# end of class Wetation
|
|
165
|
+
|
|
166
|
+class MyApp(wx.App):
|
|
167
|
+ def OnInit(self):
|
|
168
|
+ self.frame = Wetation(None, wx.ID_ANY, "")
|
|
169
|
+ self.SetTopWindow(self.frame)
|
|
170
|
+ self.frame.Show()
|
|
171
|
+ return True
|
|
172
|
+
|
|
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
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+if __name__ == "__main__":
|
|
186
|
+ report.appLoggingConfigure(os.path.dirname(__file__), 'stdout', config.loggers)
|
|
187
|
+ #
|
|
188
|
+ 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
|
+ c_tcp = tcp_socket.tcp_client_stp(config.server_in_ip, config.server_in_port, rx_log_lvl=logging.DEBUG)
|
|
194
|
+ 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)
|
|
195
|
+ c_tcp = tcp_socket.tcp_client_stp(config.server_garage_ip, config.server_garage_port, rx_log_lvl=logging.DEBUG)
|
|
196
|
+ prot_garage = garage_protocol.my_smarthome_gui_client_protocol_tcp(c_tcp, app.frame.gate_position, app.frame.Layout, config.server_garage_secret)
|
|
197
|
+ prot_garage.authentificate()
|
|
198
|
+ app.frame.prot_garage = prot_garage
|
|
199
|
+ pt = task.periodic(10, initiate_update, app.frame, prot_out, prot_in, prot_garage)
|
|
200
|
+ pt.run()
|
|
201
|
+ app.MainLoop()
|
|
202
|
+ pt.stop()
|
|
203
|
+ try:
|
|
204
|
+ pt.join()
|
|
205
|
+ finally:
|
|
206
|
+ pt.stop()
|