GUI and protocol separeted from libraries and implemented in the application
This commit is contained in:
parent
3a8daea936
commit
8dd3ee46b9
@ -1 +1 @@
|
|||||||
Subproject commit 88c3b5676f0f670e1b68bb327d844e9d67dddda6
|
Subproject commit ae391a4698abc0834519cfade3c96b06a59a22d9
|
158
gui.py
Executable file
158
gui.py
Executable file
@ -0,0 +1,158 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: UTF-8 -*-
|
||||||
|
#
|
||||||
|
# generated by wxGlade 0.9.3 on Mon Sep 7 11:55:26 2020
|
||||||
|
#
|
||||||
|
|
||||||
|
import wx
|
||||||
|
|
||||||
|
# begin wxGlade: dependencies
|
||||||
|
# end wxGlade
|
||||||
|
|
||||||
|
# begin wxGlade: extracode
|
||||||
|
# end wxGlade
|
||||||
|
|
||||||
|
|
||||||
|
class Wetation(wx.Frame):
|
||||||
|
def __init__(self, *args, **kwds):
|
||||||
|
# begin wxGlade: Wetation.__init__
|
||||||
|
kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE
|
||||||
|
wx.Frame.__init__(self, *args, **kwds)
|
||||||
|
self.SetSize((800, 628))
|
||||||
|
self.date = wx.StaticText(self, wx.ID_ANY, "xx.xx.xxxx", style=wx.ALIGN_LEFT)
|
||||||
|
self.time = wx.StaticText(self, wx.ID_ANY, "xx:xx", style=wx.ALIGN_RIGHT)
|
||||||
|
self.heading_out_envdata = wx.StaticText(self, wx.ID_ANY, u"Außentemperatur")
|
||||||
|
self.out_humidity = wx.StaticText(self, wx.ID_ANY, "- %", style=wx.ALIGN_RIGHT)
|
||||||
|
self.out_pressure = wx.StaticText(self, wx.ID_ANY, "- mbar", style=wx.ALIGN_RIGHT)
|
||||||
|
self.out_temperature_min = wx.StaticText(self, wx.ID_ANY, u"-.- °C", style=wx.ALIGN_RIGHT)
|
||||||
|
self.out_temperature_max = wx.StaticText(self, wx.ID_ANY, u"-.- °C", style=wx.ALIGN_RIGHT)
|
||||||
|
self.out_temperature = wx.StaticText(self, wx.ID_ANY, u"-.- °C", style=wx.ALIGN_RIGHT)
|
||||||
|
self.heading_in_envdata = wx.StaticText(self, wx.ID_ANY, "Innentemperatur")
|
||||||
|
self.in_humidity = wx.StaticText(self, wx.ID_ANY, "- %", style=wx.ALIGN_RIGHT)
|
||||||
|
self.in_pressure = wx.StaticText(self, wx.ID_ANY, "- mbar", style=wx.ALIGN_RIGHT)
|
||||||
|
self.in_temperature_min = wx.StaticText(self, wx.ID_ANY, u"-.- °C", style=wx.ALIGN_RIGHT)
|
||||||
|
self.in_temperature_max = wx.StaticText(self, wx.ID_ANY, u"-.- °C", style=wx.ALIGN_RIGHT)
|
||||||
|
self.in_temperature = wx.StaticText(self, wx.ID_ANY, u"-.- °C", style=wx.ALIGN_RIGHT)
|
||||||
|
self.heading_garage = wx.StaticText(self, wx.ID_ANY, "Garage")
|
||||||
|
self.gate_oc = wx.Button(self, wx.ID_ANY, "Garage")
|
||||||
|
self.gate_close = wx.StaticText(self, wx.ID_ANY, "Close")
|
||||||
|
self.gate_position = wx.Slider(self, wx.ID_ANY, 50, 0, 100)
|
||||||
|
self.gate_open = wx.StaticText(self, wx.ID_ANY, "Open")
|
||||||
|
|
||||||
|
self.__set_properties()
|
||||||
|
self.__do_layout()
|
||||||
|
|
||||||
|
self.Bind(wx.EVT_BUTTON, self.gate_oc_evt, self.gate_oc)
|
||||||
|
# end wxGlade
|
||||||
|
|
||||||
|
def __set_properties(self):
|
||||||
|
# begin wxGlade: Wetation.__set_properties
|
||||||
|
self.SetTitle("frame")
|
||||||
|
self.SetBackgroundColour(wx.Colour(250, 249, 255))
|
||||||
|
self.SetForegroundColour(wx.Colour(35, 35, 142))
|
||||||
|
self.date.SetBackgroundColour(wx.Colour(35, 35, 142))
|
||||||
|
self.date.SetForegroundColour(wx.Colour(255, 255, 255))
|
||||||
|
self.date.SetFont(wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
||||||
|
self.time.SetBackgroundColour(wx.Colour(35, 35, 142))
|
||||||
|
self.time.SetForegroundColour(wx.Colour(255, 255, 255))
|
||||||
|
self.time.SetFont(wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
||||||
|
self.heading_out_envdata.SetBackgroundColour(wx.Colour(35, 35, 142))
|
||||||
|
self.heading_out_envdata.SetForegroundColour(wx.Colour(250, 249, 255))
|
||||||
|
self.heading_out_envdata.SetFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
||||||
|
self.out_humidity.SetFont(wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
||||||
|
self.out_pressure.SetFont(wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
||||||
|
self.out_temperature_min.SetFont(wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
||||||
|
self.out_temperature_max.SetFont(wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
||||||
|
self.out_temperature.SetFont(wx.Font(48, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
||||||
|
self.heading_in_envdata.SetBackgroundColour(wx.Colour(35, 35, 142))
|
||||||
|
self.heading_in_envdata.SetForegroundColour(wx.Colour(250, 249, 255))
|
||||||
|
self.heading_in_envdata.SetFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
||||||
|
self.in_humidity.SetFont(wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
||||||
|
self.in_pressure.SetFont(wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
||||||
|
self.in_temperature_min.SetFont(wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
||||||
|
self.in_temperature_max.SetFont(wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
||||||
|
self.in_temperature.SetFont(wx.Font(48, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
||||||
|
self.heading_garage.SetBackgroundColour(wx.Colour(35, 35, 142))
|
||||||
|
self.heading_garage.SetForegroundColour(wx.Colour(250, 249, 255))
|
||||||
|
self.heading_garage.SetFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
||||||
|
self.heading_garage.Hide()
|
||||||
|
self.gate_oc.Hide()
|
||||||
|
self.gate_close.Hide()
|
||||||
|
self.gate_position.Enable(False)
|
||||||
|
self.gate_position.Hide()
|
||||||
|
self.gate_open.Hide()
|
||||||
|
# end wxGlade
|
||||||
|
|
||||||
|
def __do_layout(self):
|
||||||
|
# begin wxGlade: Wetation.__do_layout
|
||||||
|
sizer_main = wx.BoxSizer(wx.VERTICAL)
|
||||||
|
sizer_8 = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
|
sizer_env_data_in = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
|
sizer_9 = wx.BoxSizer(wx.VERTICAL)
|
||||||
|
sizer_5 = wx.BoxSizer(wx.VERTICAL)
|
||||||
|
sizer_env_data_out = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
|
sizer_7 = wx.BoxSizer(wx.VERTICAL)
|
||||||
|
sizer_4 = wx.BoxSizer(wx.VERTICAL)
|
||||||
|
sizer_date_time = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
|
spacer_1 = wx.StaticText(self, wx.ID_ANY, "")
|
||||||
|
spacer_1.SetBackgroundColour(wx.Colour(35, 35, 142))
|
||||||
|
spacer_1.SetFont(wx.Font(5, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
||||||
|
sizer_main.Add(spacer_1, 0, wx.EXPAND, 0)
|
||||||
|
sizer_date_time.Add(self.date, 1, wx.EXPAND | wx.LEFT, 0)
|
||||||
|
sizer_date_time.Add(self.time, 1, wx.EXPAND | wx.RIGHT, 0)
|
||||||
|
sizer_main.Add(sizer_date_time, 0, wx.EXPAND, 0)
|
||||||
|
spacer_2 = wx.StaticText(self, wx.ID_ANY, "")
|
||||||
|
spacer_2.SetBackgroundColour(wx.Colour(35, 35, 142))
|
||||||
|
spacer_2.SetFont(wx.Font(5, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
||||||
|
sizer_main.Add(spacer_2, 0, wx.EXPAND, 0)
|
||||||
|
sizer_main.Add((20, 20), 0, 0, 0)
|
||||||
|
sizer_main.Add(self.heading_out_envdata, 0, wx.EXPAND, 0)
|
||||||
|
sizer_4.Add(self.out_humidity, 1, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, 0)
|
||||||
|
sizer_4.Add(self.out_pressure, 1, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, 0)
|
||||||
|
sizer_env_data_out.Add(sizer_4, 1, wx.EXPAND, 0)
|
||||||
|
sizer_7.Add(self.out_temperature_min, 1, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, 0)
|
||||||
|
sizer_7.Add(self.out_temperature_max, 1, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, 0)
|
||||||
|
sizer_env_data_out.Add(sizer_7, 1, wx.EXPAND, 0)
|
||||||
|
sizer_env_data_out.Add((50, 20), 0, 0, 0)
|
||||||
|
sizer_env_data_out.Add(self.out_temperature, 2, wx.ALIGN_RIGHT | wx.RIGHT, 0)
|
||||||
|
sizer_main.Add(sizer_env_data_out, 0, wx.EXPAND, 0)
|
||||||
|
sizer_main.Add((20, 20), 0, 0, 0)
|
||||||
|
sizer_main.Add(self.heading_in_envdata, 0, wx.EXPAND, 0)
|
||||||
|
sizer_5.Add(self.in_humidity, 1, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, 0)
|
||||||
|
sizer_5.Add(self.in_pressure, 1, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, 0)
|
||||||
|
sizer_env_data_in.Add(sizer_5, 1, wx.EXPAND, 0)
|
||||||
|
sizer_9.Add(self.in_temperature_min, 1, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, 0)
|
||||||
|
sizer_9.Add(self.in_temperature_max, 1, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, 0)
|
||||||
|
sizer_env_data_in.Add(sizer_9, 1, wx.EXPAND, 0)
|
||||||
|
sizer_env_data_in.Add((50, 20), 0, 0, 0)
|
||||||
|
sizer_env_data_in.Add(self.in_temperature, 2, wx.ALIGN_RIGHT | wx.RIGHT, 0)
|
||||||
|
sizer_main.Add(sizer_env_data_in, 0, wx.EXPAND, 0)
|
||||||
|
sizer_main.Add((10, 10), 1, 0, 0)
|
||||||
|
sizer_main.Add(self.heading_garage, 0, wx.EXPAND, 0)
|
||||||
|
sizer_8.Add(self.gate_oc, 0, 0, 0)
|
||||||
|
sizer_8.Add(self.gate_close, 0, wx.ALIGN_CENTER, 0)
|
||||||
|
sizer_8.Add(self.gate_position, 1, wx.EXPAND, 0)
|
||||||
|
sizer_8.Add(self.gate_open, 0, wx.ALIGN_CENTER, 0)
|
||||||
|
sizer_main.Add(sizer_8, 0, wx.EXPAND, 0)
|
||||||
|
self.SetSizer(sizer_main)
|
||||||
|
self.Layout()
|
||||||
|
# end wxGlade
|
||||||
|
|
||||||
|
def gate_oc_evt(self, event): # wxGlade: Wetation.<event_handler>
|
||||||
|
print("Event handler 'gate_oc_evt' not implemented!")
|
||||||
|
event.Skip()
|
||||||
|
|
||||||
|
# end of class Wetation
|
||||||
|
|
||||||
|
class MyApp(wx.App):
|
||||||
|
def OnInit(self):
|
||||||
|
self.wetation = Wetation(None, wx.ID_ANY, "")
|
||||||
|
self.SetTopWindow(self.wetation)
|
||||||
|
self.wetation.Show()
|
||||||
|
return True
|
||||||
|
|
||||||
|
# end of class MyApp
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app = MyApp(0)
|
||||||
|
app.MainLoop()
|
@ -1,9 +1,9 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<!-- generated by wxGlade 0.9.3 on Sun Sep 6 14:34:01 2020 -->
|
<!-- generated by wxGlade 0.9.3 on Mon Sep 7 11:55:31 2020 -->
|
||||||
|
|
||||||
<application class="MyApp" encoding="UTF-8" for_version="3.0" header_extension=".h" indent_amount="4" indent_symbol="space" is_template="0" language="python" mark_blocks="1" name="app" option="0" overwrite="0" path="./smarthome.py" source_extension=".cpp" top_window="wetation" use_gettext="0" use_new_namespace="1">
|
<application class="MyApp" encoding="UTF-8" for_version="3.0" header_extension=".h" indent_amount="4" indent_symbol="space" is_template="0" language="python" mark_blocks="1" name="app" option="0" overwrite="1" path="./gui.py" source_extension=".cpp" top_window="wetation" use_gettext="0" use_new_namespace="1">
|
||||||
<object class="Wetation" name="wetation" base="EditFrame">
|
<object class="Wetation" name="wetation" base="EditFrame">
|
||||||
<size>800, 600</size>
|
<size>800, 628</size>
|
||||||
<background>#faf9ff</background>
|
<background>#faf9ff</background>
|
||||||
<foreground>#23238e</foreground>
|
<foreground>#23238e</foreground>
|
||||||
<title>frame</title>
|
<title>frame</title>
|
||||||
@ -49,6 +49,7 @@
|
|||||||
</font>
|
</font>
|
||||||
<style>wxALIGN_LEFT</style>
|
<style>wxALIGN_LEFT</style>
|
||||||
<label>xx.xx.xxxx</label>
|
<label>xx.xx.xxxx</label>
|
||||||
|
<attribute>1</attribute>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
<object class="sizeritem">
|
<object class="sizeritem">
|
||||||
@ -68,6 +69,7 @@
|
|||||||
</font>
|
</font>
|
||||||
<style>wxALIGN_RIGHT</style>
|
<style>wxALIGN_RIGHT</style>
|
||||||
<label>xx:xx</label>
|
<label>xx:xx</label>
|
||||||
|
<attribute>1</attribute>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
@ -88,12 +90,20 @@
|
|||||||
</font>
|
</font>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
|
<object class="sizeritem">
|
||||||
|
<option>0</option>
|
||||||
|
<border>0</border>
|
||||||
|
<object class="spacer" name="spacer" base="EditSpacer">
|
||||||
|
<width>20</width>
|
||||||
|
<height>20</height>
|
||||||
|
</object>
|
||||||
|
</object>
|
||||||
<object class="sizeritem">
|
<object class="sizeritem">
|
||||||
<option>0</option>
|
<option>0</option>
|
||||||
<border>0</border>
|
<border>0</border>
|
||||||
<flag>wxEXPAND</flag>
|
<flag>wxEXPAND</flag>
|
||||||
<object class="wxStaticText" name="spacer_3" base="EditStaticText">
|
<object class="wxStaticText" name="heading_out_envdata" base="EditStaticText">
|
||||||
<background>#000000</background>
|
<background>#23238e</background>
|
||||||
<foreground>#faf9ff</foreground>
|
<foreground>#faf9ff</foreground>
|
||||||
<font>
|
<font>
|
||||||
<size>12</size>
|
<size>12</size>
|
||||||
@ -104,6 +114,7 @@
|
|||||||
<face />
|
<face />
|
||||||
</font>
|
</font>
|
||||||
<label>Außentemperatur</label>
|
<label>Außentemperatur</label>
|
||||||
|
<attribute>1</attribute>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
<object class="sizeritem">
|
<object class="sizeritem">
|
||||||
@ -133,6 +144,7 @@
|
|||||||
</font>
|
</font>
|
||||||
<style>wxALIGN_RIGHT</style>
|
<style>wxALIGN_RIGHT</style>
|
||||||
<label>- %</label>
|
<label>- %</label>
|
||||||
|
<attribute>1</attribute>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
<object class="sizeritem">
|
<object class="sizeritem">
|
||||||
@ -150,6 +162,7 @@
|
|||||||
</font>
|
</font>
|
||||||
<style>wxALIGN_RIGHT</style>
|
<style>wxALIGN_RIGHT</style>
|
||||||
<label>- mbar</label>
|
<label>- mbar</label>
|
||||||
|
<attribute>1</attribute>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
@ -175,6 +188,7 @@
|
|||||||
</font>
|
</font>
|
||||||
<style>wxALIGN_RIGHT</style>
|
<style>wxALIGN_RIGHT</style>
|
||||||
<label>-.- °C</label>
|
<label>-.- °C</label>
|
||||||
|
<attribute>1</attribute>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
<object class="sizeritem">
|
<object class="sizeritem">
|
||||||
@ -192,6 +206,7 @@
|
|||||||
</font>
|
</font>
|
||||||
<style>wxALIGN_RIGHT</style>
|
<style>wxALIGN_RIGHT</style>
|
||||||
<label>-.- °C</label>
|
<label>-.- °C</label>
|
||||||
|
<attribute>1</attribute>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
@ -219,16 +234,25 @@
|
|||||||
</font>
|
</font>
|
||||||
<style>wxALIGN_RIGHT</style>
|
<style>wxALIGN_RIGHT</style>
|
||||||
<label>-.- °C</label>
|
<label>-.- °C</label>
|
||||||
|
<attribute>1</attribute>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
|
<object class="sizeritem">
|
||||||
|
<option>0</option>
|
||||||
|
<border>0</border>
|
||||||
|
<object class="spacer" name="spacer" base="EditSpacer">
|
||||||
|
<width>20</width>
|
||||||
|
<height>20</height>
|
||||||
|
</object>
|
||||||
|
</object>
|
||||||
<object class="sizeritem">
|
<object class="sizeritem">
|
||||||
<option>0</option>
|
<option>0</option>
|
||||||
<border>0</border>
|
<border>0</border>
|
||||||
<flag>wxEXPAND</flag>
|
<flag>wxEXPAND</flag>
|
||||||
<object class="wxStaticText" name="spacer_4" base="EditStaticText">
|
<object class="wxStaticText" name="heading_in_envdata" base="EditStaticText">
|
||||||
<background>#000000</background>
|
<background>#23238e</background>
|
||||||
<foreground>#faf9ff</foreground>
|
<foreground>#faf9ff</foreground>
|
||||||
<font>
|
<font>
|
||||||
<size>12</size>
|
<size>12</size>
|
||||||
@ -239,6 +263,7 @@
|
|||||||
<face />
|
<face />
|
||||||
</font>
|
</font>
|
||||||
<label>Innentemperatur</label>
|
<label>Innentemperatur</label>
|
||||||
|
<attribute>1</attribute>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
<object class="sizeritem">
|
<object class="sizeritem">
|
||||||
@ -268,6 +293,7 @@
|
|||||||
</font>
|
</font>
|
||||||
<style>wxALIGN_RIGHT</style>
|
<style>wxALIGN_RIGHT</style>
|
||||||
<label>- %</label>
|
<label>- %</label>
|
||||||
|
<attribute>1</attribute>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
<object class="sizeritem">
|
<object class="sizeritem">
|
||||||
@ -285,6 +311,7 @@
|
|||||||
</font>
|
</font>
|
||||||
<style>wxALIGN_RIGHT</style>
|
<style>wxALIGN_RIGHT</style>
|
||||||
<label>- mbar</label>
|
<label>- mbar</label>
|
||||||
|
<attribute>1</attribute>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
@ -310,6 +337,7 @@
|
|||||||
</font>
|
</font>
|
||||||
<style>wxALIGN_RIGHT</style>
|
<style>wxALIGN_RIGHT</style>
|
||||||
<label>-.- °C</label>
|
<label>-.- °C</label>
|
||||||
|
<attribute>1</attribute>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
<object class="sizeritem">
|
<object class="sizeritem">
|
||||||
@ -327,6 +355,7 @@
|
|||||||
</font>
|
</font>
|
||||||
<style>wxALIGN_RIGHT</style>
|
<style>wxALIGN_RIGHT</style>
|
||||||
<label>-.- °C</label>
|
<label>-.- °C</label>
|
||||||
|
<attribute>1</attribute>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
@ -354,6 +383,7 @@
|
|||||||
</font>
|
</font>
|
||||||
<style>wxALIGN_RIGHT</style>
|
<style>wxALIGN_RIGHT</style>
|
||||||
<label>-.- °C</label>
|
<label>-.- °C</label>
|
||||||
|
<attribute>1</attribute>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
@ -370,8 +400,8 @@
|
|||||||
<option>0</option>
|
<option>0</option>
|
||||||
<border>0</border>
|
<border>0</border>
|
||||||
<flag>wxEXPAND</flag>
|
<flag>wxEXPAND</flag>
|
||||||
<object class="wxStaticText" name="spacer_5" base="EditStaticText">
|
<object class="wxStaticText" name="heading_garage" base="EditStaticText">
|
||||||
<background>#000000</background>
|
<background>#23238e</background>
|
||||||
<foreground>#faf9ff</foreground>
|
<foreground>#faf9ff</foreground>
|
||||||
<font>
|
<font>
|
||||||
<size>12</size>
|
<size>12</size>
|
||||||
@ -381,7 +411,9 @@
|
|||||||
<underlined>0</underlined>
|
<underlined>0</underlined>
|
||||||
<face />
|
<face />
|
||||||
</font>
|
</font>
|
||||||
|
<hidden>1</hidden>
|
||||||
<label>Garage</label>
|
<label>Garage</label>
|
||||||
|
<attribute>1</attribute>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
<object class="sizeritem">
|
<object class="sizeritem">
|
||||||
@ -393,10 +425,11 @@
|
|||||||
<object class="sizeritem">
|
<object class="sizeritem">
|
||||||
<option>0</option>
|
<option>0</option>
|
||||||
<border>0</border>
|
<border>0</border>
|
||||||
<object class="wxButton" name="garage_oc" base="EditButton">
|
<object class="wxButton" name="gate_oc" base="EditButton">
|
||||||
<events>
|
<events>
|
||||||
<handler event="EVT_BUTTON">garage_oc_evt</handler>
|
<handler event="EVT_BUTTON">gate_oc_evt</handler>
|
||||||
</events>
|
</events>
|
||||||
|
<hidden>1</hidden>
|
||||||
<label>Garage</label>
|
<label>Garage</label>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
@ -404,8 +437,10 @@
|
|||||||
<option>0</option>
|
<option>0</option>
|
||||||
<border>0</border>
|
<border>0</border>
|
||||||
<flag>wxALIGN_CENTER</flag>
|
<flag>wxALIGN_CENTER</flag>
|
||||||
<object class="wxStaticText" name="gate__open" base="EditStaticText">
|
<object class="wxStaticText" name="gate_close" base="EditStaticText">
|
||||||
|
<hidden>1</hidden>
|
||||||
<label>Close</label>
|
<label>Close</label>
|
||||||
|
<attribute>1</attribute>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
<object class="sizeritem">
|
<object class="sizeritem">
|
||||||
@ -414,6 +449,7 @@
|
|||||||
<flag>wxEXPAND</flag>
|
<flag>wxEXPAND</flag>
|
||||||
<object class="wxSlider" name="gate_position" base="EditSlider">
|
<object class="wxSlider" name="gate_position" base="EditSlider">
|
||||||
<disabled>1</disabled>
|
<disabled>1</disabled>
|
||||||
|
<hidden>1</hidden>
|
||||||
<style>wxSL_HORIZONTAL</style>
|
<style>wxSL_HORIZONTAL</style>
|
||||||
<range>0, 100</range>
|
<range>0, 100</range>
|
||||||
<value>50</value>
|
<value>50</value>
|
||||||
@ -424,7 +460,9 @@
|
|||||||
<border>0</border>
|
<border>0</border>
|
||||||
<flag>wxALIGN_CENTER</flag>
|
<flag>wxALIGN_CENTER</flag>
|
||||||
<object class="wxStaticText" name="gate_open" base="EditStaticText">
|
<object class="wxStaticText" name="gate_open" base="EditStaticText">
|
||||||
|
<hidden>1</hidden>
|
||||||
<label>Open</label>
|
<label>Open</label>
|
||||||
|
<attribute>1</attribute>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
267
smarthome.py
267
smarthome.py
@ -1,184 +1,119 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: UTF-8 -*-
|
# -*- coding: UTF-8 -*-
|
||||||
#
|
#
|
||||||
# generated by wxGlade 0.9.4 on Fri Sep 4 13:21:47 2020
|
|
||||||
#
|
|
||||||
|
|
||||||
import wx
|
|
||||||
|
|
||||||
import config
|
import config
|
||||||
|
import rpi_envsens as envsens
|
||||||
|
import garage_protocol
|
||||||
|
import gui
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import time
|
|
||||||
import garage_protocol
|
|
||||||
import wetation_protocol
|
|
||||||
import report
|
import report
|
||||||
import tcp_socket
|
|
||||||
import task
|
import task
|
||||||
from config import FULL_SCRREN
|
import tcp_socket
|
||||||
|
import time
|
||||||
|
import wetation_protocol
|
||||||
|
import wx
|
||||||
|
|
||||||
# begin wxGlade: dependencies
|
logger = logging.getLogger('APP')
|
||||||
# end wxGlade
|
|
||||||
|
|
||||||
# begin wxGlade: extracode
|
|
||||||
# end wxGlade
|
|
||||||
|
|
||||||
|
|
||||||
class Wetation(wx.Frame):
|
class WetationFrameProt(gui.Wetation):
|
||||||
def __init__(self, *args, **kwds):
|
def __init__(self, *args, **kwds):
|
||||||
# begin wxGlade: Wetation.__init__
|
gui.Wetation.__init__(self, *args, **kwds)
|
||||||
kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE
|
self.__task_data_request__ = task.periodic(10, self.__initiate_data_request__)
|
||||||
wx.Frame.__init__(self, *args, **kwds)
|
self.__init__communication__()
|
||||||
self.SetSize((800, 600))
|
|
||||||
self.garage_oc = wx.Button(self, wx.ID_ANY, "Garage")
|
|
||||||
self.gate_position = wx.Slider(self, wx.ID_ANY, 50, 0, 100)
|
|
||||||
|
|
||||||
self.__set_properties()
|
def __init__communication__(self):
|
||||||
self.__do_layout()
|
|
||||||
|
|
||||||
self.Bind(wx.EVT_BUTTON, self.garage_oc_evt, self.garage_oc)
|
|
||||||
# end wxGlade
|
|
||||||
self.ShowFullScreen(FULL_SCRREN)
|
|
||||||
|
|
||||||
def __set_properties(self):
|
|
||||||
# begin wxGlade: Wetation.__set_properties
|
|
||||||
self.SetTitle("frame")
|
|
||||||
self.SetBackgroundColour(wx.Colour(250, 249, 255))
|
|
||||||
self.SetForegroundColour(wx.Colour(35, 35, 142))
|
|
||||||
self.gate_position.Enable(False)
|
|
||||||
# end wxGlade
|
|
||||||
|
|
||||||
def __do_layout(self):
|
|
||||||
# begin wxGlade: Wetation.__do_layout
|
|
||||||
sizer_main = wx.BoxSizer(wx.VERTICAL)
|
|
||||||
sizer_8 = wx.BoxSizer(wx.HORIZONTAL)
|
|
||||||
sizer_env_data_in = wx.BoxSizer(wx.HORIZONTAL)
|
|
||||||
sizer_9 = wx.BoxSizer(wx.VERTICAL)
|
|
||||||
sizer_5 = wx.BoxSizer(wx.VERTICAL)
|
|
||||||
sizer_env_data_out = wx.BoxSizer(wx.HORIZONTAL)
|
|
||||||
sizer_7 = wx.BoxSizer(wx.VERTICAL)
|
|
||||||
sizer_4 = wx.BoxSizer(wx.VERTICAL)
|
|
||||||
sizer_date_time = wx.BoxSizer(wx.HORIZONTAL)
|
|
||||||
spacer_1 = wx.StaticText(self, wx.ID_ANY, "")
|
|
||||||
spacer_1.SetBackgroundColour(wx.Colour(35, 35, 142))
|
|
||||||
spacer_1.SetFont(wx.Font(5, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
|
||||||
sizer_main.Add(spacer_1, 0, wx.EXPAND, 0)
|
|
||||||
date = wx.StaticText(self, wx.ID_ANY, "xx.xx.xxxx", style=wx.ALIGN_LEFT)
|
|
||||||
date.SetBackgroundColour(wx.Colour(35, 35, 142))
|
|
||||||
date.SetForegroundColour(wx.Colour(255, 255, 255))
|
|
||||||
date.SetFont(wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
|
||||||
sizer_date_time.Add(date, 1, wx.EXPAND | wx.LEFT, 0)
|
|
||||||
time = wx.StaticText(self, wx.ID_ANY, "xx:xx", style=wx.ALIGN_RIGHT)
|
|
||||||
time.SetBackgroundColour(wx.Colour(35, 35, 142))
|
|
||||||
time.SetForegroundColour(wx.Colour(255, 255, 255))
|
|
||||||
time.SetFont(wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
|
||||||
sizer_date_time.Add(time, 1, wx.EXPAND | wx.RIGHT, 0)
|
|
||||||
sizer_main.Add(sizer_date_time, 0, wx.EXPAND, 0)
|
|
||||||
spacer_2 = wx.StaticText(self, wx.ID_ANY, "")
|
|
||||||
spacer_2.SetBackgroundColour(wx.Colour(35, 35, 142))
|
|
||||||
spacer_2.SetFont(wx.Font(5, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
|
||||||
sizer_main.Add(spacer_2, 0, wx.EXPAND, 0)
|
|
||||||
spacer_3 = wx.StaticText(self, wx.ID_ANY, u"Außentemperatur")
|
|
||||||
spacer_3.SetBackgroundColour(wx.Colour(0, 0, 0))
|
|
||||||
spacer_3.SetForegroundColour(wx.Colour(250, 249, 255))
|
|
||||||
spacer_3.SetFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
|
||||||
sizer_main.Add(spacer_3, 0, wx.EXPAND, 0)
|
|
||||||
out_humidity = wx.StaticText(self, wx.ID_ANY, "- %", style=wx.ALIGN_RIGHT)
|
|
||||||
out_humidity.SetFont(wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
|
||||||
sizer_4.Add(out_humidity, 1, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, 0)
|
|
||||||
out_pressure = wx.StaticText(self, wx.ID_ANY, "- mbar", style=wx.ALIGN_RIGHT)
|
|
||||||
out_pressure.SetFont(wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
|
||||||
sizer_4.Add(out_pressure, 1, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, 0)
|
|
||||||
sizer_env_data_out.Add(sizer_4, 1, wx.EXPAND, 0)
|
|
||||||
out_temperature_min = wx.StaticText(self, wx.ID_ANY, u"-.- °C", style=wx.ALIGN_RIGHT)
|
|
||||||
out_temperature_min.SetFont(wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
|
||||||
sizer_7.Add(out_temperature_min, 1, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, 0)
|
|
||||||
out_temperature_max = wx.StaticText(self, wx.ID_ANY, u"-.- °C", style=wx.ALIGN_RIGHT)
|
|
||||||
out_temperature_max.SetFont(wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
|
||||||
sizer_7.Add(out_temperature_max, 1, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, 0)
|
|
||||||
sizer_env_data_out.Add(sizer_7, 1, wx.EXPAND, 0)
|
|
||||||
sizer_env_data_out.Add((50, 20), 0, 0, 0)
|
|
||||||
out_temperature = wx.StaticText(self, wx.ID_ANY, u"-.- °C", style=wx.ALIGN_RIGHT)
|
|
||||||
out_temperature.SetFont(wx.Font(48, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
|
||||||
sizer_env_data_out.Add(out_temperature, 2, wx.ALIGN_RIGHT | wx.RIGHT, 0)
|
|
||||||
sizer_main.Add(sizer_env_data_out, 0, wx.EXPAND, 0)
|
|
||||||
spacer_4 = wx.StaticText(self, wx.ID_ANY, "Innentemperatur")
|
|
||||||
spacer_4.SetBackgroundColour(wx.Colour(0, 0, 0))
|
|
||||||
spacer_4.SetForegroundColour(wx.Colour(250, 249, 255))
|
|
||||||
spacer_4.SetFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
|
||||||
sizer_main.Add(spacer_4, 0, wx.EXPAND, 0)
|
|
||||||
in_humidity = wx.StaticText(self, wx.ID_ANY, "- %", style=wx.ALIGN_RIGHT)
|
|
||||||
in_humidity.SetFont(wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
|
||||||
sizer_5.Add(in_humidity, 1, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, 0)
|
|
||||||
in_pressure = wx.StaticText(self, wx.ID_ANY, "- mbar", style=wx.ALIGN_RIGHT)
|
|
||||||
in_pressure.SetFont(wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
|
||||||
sizer_5.Add(in_pressure, 1, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, 0)
|
|
||||||
sizer_env_data_in.Add(sizer_5, 1, wx.EXPAND, 0)
|
|
||||||
in_temperature_min = wx.StaticText(self, wx.ID_ANY, u"-.- °C", style=wx.ALIGN_RIGHT)
|
|
||||||
in_temperature_min.SetFont(wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
|
||||||
sizer_9.Add(in_temperature_min, 1, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, 0)
|
|
||||||
in_temperature_max = wx.StaticText(self, wx.ID_ANY, u"-.- °C", style=wx.ALIGN_RIGHT)
|
|
||||||
in_temperature_max.SetFont(wx.Font(24, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
|
||||||
sizer_9.Add(in_temperature_max, 1, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, 0)
|
|
||||||
sizer_env_data_in.Add(sizer_9, 1, wx.EXPAND, 0)
|
|
||||||
sizer_env_data_in.Add((50, 20), 0, 0, 0)
|
|
||||||
in_temperature = wx.StaticText(self, wx.ID_ANY, u"-.- °C", style=wx.ALIGN_RIGHT)
|
|
||||||
in_temperature.SetFont(wx.Font(48, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
|
||||||
sizer_env_data_in.Add(in_temperature, 2, wx.ALIGN_RIGHT | wx.RIGHT, 0)
|
|
||||||
sizer_main.Add(sizer_env_data_in, 0, wx.EXPAND, 0)
|
|
||||||
sizer_main.Add((10, 10), 1, 0, 0)
|
|
||||||
spacer_5 = wx.StaticText(self, wx.ID_ANY, "Garage")
|
|
||||||
spacer_5.SetBackgroundColour(wx.Colour(0, 0, 0))
|
|
||||||
spacer_5.SetForegroundColour(wx.Colour(250, 249, 255))
|
|
||||||
spacer_5.SetFont(wx.Font(12, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, ""))
|
|
||||||
sizer_main.Add(spacer_5, 0, wx.EXPAND, 0)
|
|
||||||
sizer_8.Add(self.garage_oc, 0, 0, 0)
|
|
||||||
gate__open = wx.StaticText(self, wx.ID_ANY, "Close")
|
|
||||||
sizer_8.Add(gate__open, 0, wx.ALIGN_CENTER, 0)
|
|
||||||
sizer_8.Add(self.gate_position, 1, wx.EXPAND, 0)
|
|
||||||
gate_open = wx.StaticText(self, wx.ID_ANY, "Open")
|
|
||||||
sizer_8.Add(gate_open, 0, wx.ALIGN_CENTER, 0)
|
|
||||||
sizer_main.Add(sizer_8, 0, wx.EXPAND, 0)
|
|
||||||
self.SetSizer(sizer_main)
|
|
||||||
self.Layout()
|
|
||||||
# end wxGlade
|
|
||||||
self.date = date
|
|
||||||
self.time = time
|
|
||||||
#
|
#
|
||||||
self.out_humidity = out_humidity
|
# Start TCP-Clients
|
||||||
self.out_pressure = out_pressure
|
c_tcp = tcp_socket.tcp_client_stp(config.server_out_ip, config.server_out_port, rx_log_lvl=logging.DEBUG)
|
||||||
|
self.prot_out = wetation_protocol.my_base_protocol_tcp(c_tcp, config.server_out_secret)
|
||||||
|
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)
|
||||||
|
if config.server_out_secret is not None:
|
||||||
|
self.prot_out.authentificate()
|
||||||
|
|
||||||
self.out_temperature = out_temperature
|
c_tcp = tcp_socket.tcp_client_stp(config.server_in_ip, config.server_in_port, rx_log_lvl=logging.DEBUG)
|
||||||
self.out_temperature_min = out_temperature_min
|
self.prot_in = wetation_protocol.my_base_protocol_tcp(c_tcp, config.server_in_secret)
|
||||||
self.out_temperature_max = out_temperature_max
|
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)
|
||||||
|
if config.server_in_secret is not None:
|
||||||
|
self.prot_in.authentificate()
|
||||||
|
|
||||||
|
c_tcp = tcp_socket.tcp_client_stp(config.server_garage_ip, config.server_garage_port, rx_log_lvl=logging.DEBUG)
|
||||||
|
self.prot_garage = garage_protocol.my_base_protocol_tcp(c_tcp, config.server_garage_secret)
|
||||||
|
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)
|
||||||
|
if config.server_garage_secret is not None:
|
||||||
|
self.prot_garage.authentificate()
|
||||||
|
|
||||||
|
def __update_current_envdata__(self, msg, temperature, humidity, pressure):
|
||||||
|
if msg.get_status() == wetation_protocol.my_base_protocol_tcp.STATUS_OKAY:
|
||||||
|
env_data = msg.get_data()
|
||||||
|
wx.CallAfter(temperature.SetLabel, "%.1f °C" % env_data[envsens.KEY_TEMPERATURE])
|
||||||
|
wx.CallAfter(humidity.SetLabel, "%.1f %%" % env_data[envsens.KEY_HUMIDITY])
|
||||||
|
wx.CallAfter(pressure.SetLabel, "%.0f mbar" % env_data[envsens.KEY_PRESSURE])
|
||||||
|
wx.CallAfter(self.Layout)
|
||||||
|
return wetation_protocol.my_base_protocol_tcp.STATUS_OKAY, None
|
||||||
|
else:
|
||||||
|
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())))
|
||||||
|
return wetation_protocol.my_base_protocol_tcp.STATUS_SERVICE_OR_DATA_UNKNOWN, None
|
||||||
|
|
||||||
|
def update_current_env_data_out(self, msg):
|
||||||
|
return self.__update_current_envdata__(msg, self.out_temperature, self.out_humidity, self.out_pressure)
|
||||||
|
|
||||||
|
def update_current_env_data_in(self, msg):
|
||||||
|
return self.__update_current_envdata__(msg, self.in_temperature, self.in_humidity, self.in_pressure)
|
||||||
|
|
||||||
|
def update_gate_position(self, msg):
|
||||||
|
if msg.get_status() == garage_protocol.my_base_protocol_tcp.STATUS_OKAY:
|
||||||
#
|
#
|
||||||
self.in_humidity = in_humidity
|
# show gate section in GUI
|
||||||
self.in_pressure = in_pressure
|
#
|
||||||
|
self.heading_garage.show(True)
|
||||||
self.in_temperature = in_temperature
|
self.gate_oc.show(True)
|
||||||
|
self.gate_open.show(True)
|
||||||
|
self.gate_position.show(True)
|
||||||
|
self.gate_close.show(True)
|
||||||
|
#
|
||||||
|
# update gate position
|
||||||
|
#
|
||||||
|
wx.CallAfter(self.gate_position.SetValue, msg.get_data() * 100)
|
||||||
|
wx.CallAfter(self.Layout)
|
||||||
|
return garage_protocol.my_base_protocol_tcp.STATUS_OKAY, None
|
||||||
|
else:
|
||||||
|
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())))
|
||||||
|
return garage_protocol.my_base_protocol_tcp.STATUS_SERVICE_OR_DATA_UNKNOWN, None
|
||||||
|
|
||||||
def garage_oc_evt(self, event): # wxGlade: Wetation.<event_handler>
|
def garage_oc_evt(self, event): # wxGlade: Wetation.<event_handler>
|
||||||
self.prot_garage.send(prot_garage.SID_EXECUTE_REQUEST, prot_garage.OPEN_CLOSE_GATE, None)
|
self.prot_garage.send(garage_protocol.my_base_protocol_tcp.SID_EXECUTE_REQUEST, garage_protocol.my_base_protocol_tcp.OPEN_CLOSE_GATE, None)
|
||||||
event.Skip()
|
event.Skip()
|
||||||
# end of class Wetation
|
|
||||||
|
def __initiate_data_request__(self, rt):
|
||||||
|
self.prot_out.send(wetation_protocol.my_base_protocol_tcp.SID_READ_REQUEST, wetation_protocol.my_base_protocol_tcp.CURRENT_ENVDATA, None)
|
||||||
|
self.prot_in.send(wetation_protocol.my_base_protocol_tcp.SID_READ_REQUEST, wetation_protocol.my_base_protocol_tcp.CURRENT_ENVDATA, None)
|
||||||
|
self.prot_garage.send(garage_protocol.my_base_protocol_tcp.SID_READ_REQUEST, garage_protocol.my_base_protocol_tcp.GATE_POSITION, None)
|
||||||
|
# TODO: Move the following three lines to the wx idle task
|
||||||
|
wx.CallAfter(self.time.SetLabel, time.strftime("%H:%M"))
|
||||||
|
wx.CallAfter(self.date.SetLabel, time.strftime("%d.%m.%Y"))
|
||||||
|
wx.CallAfter(self.Layout)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
self.__task_data_request__.run()
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
self.__task_data_request__.stop()
|
||||||
|
self.__task_data_request__.join()
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
self.close()
|
||||||
|
|
||||||
|
|
||||||
class MyApp(wx.App):
|
class MyApp(wx.App):
|
||||||
def OnInit(self):
|
def OnInit(self):
|
||||||
self.frame = Wetation(None, wx.ID_ANY, "")
|
self.frame = WetationFrameProt(None, wx.ID_ANY, "")
|
||||||
self.SetTopWindow(self.frame)
|
self.SetTopWindow(self.frame)
|
||||||
self.frame.Show()
|
self.frame.Show()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# end of class MyApp
|
|
||||||
|
|
||||||
def initiate_update(rt, frame, prot_out, prot_in, prot_garage):
|
|
||||||
prot_out.send(wetation_protocol.my_base_protocol_tcp.SID_READ_REQUEST, wetation_protocol.my_base_protocol_tcp.CURRENT_ENVDATA, None)
|
|
||||||
prot_in.send(wetation_protocol.my_base_protocol_tcp.SID_READ_REQUEST, wetation_protocol.my_base_protocol_tcp.CURRENT_ENVDATA, None)
|
|
||||||
prot_garage.send(garage_protocol.my_base_protocol_tcp.SID_READ_REQUEST, garage_protocol.my_base_protocol_tcp.GATE_POSITION, None)
|
|
||||||
wx.CallAfter(frame.time.SetLabel, time.strftime("%H:%M"))
|
|
||||||
wx.CallAfter(frame.date.SetLabel, time.strftime("%d.%m.%Y"))
|
|
||||||
wx.CallAfter(frame.Layout)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -186,26 +121,6 @@ if __name__ == "__main__":
|
|||||||
report.appLoggingConfigure(os.path.dirname(__file__), config.LOGTARGET, config.loggers)
|
report.appLoggingConfigure(os.path.dirname(__file__), config.LOGTARGET, config.loggers)
|
||||||
#
|
#
|
||||||
app = MyApp(0)
|
app = MyApp(0)
|
||||||
#
|
app.frame.run()
|
||||||
# Start TCP-Clients
|
|
||||||
c_tcp = tcp_socket.tcp_client_stp(config.server_out_ip, config.server_out_port, rx_log_lvl=logging.DEBUG)
|
|
||||||
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)
|
|
||||||
if config.server_out_secret is not None:
|
|
||||||
prot_out.authentificate()
|
|
||||||
c_tcp = tcp_socket.tcp_client_stp(config.server_in_ip, config.server_in_port, rx_log_lvl=logging.DEBUG)
|
|
||||||
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)
|
|
||||||
if config.server_in_secret is not None:
|
|
||||||
prot_in.authentificate()
|
|
||||||
c_tcp = tcp_socket.tcp_client_stp(config.server_garage_ip, config.server_garage_port, rx_log_lvl=logging.DEBUG)
|
|
||||||
prot_garage = garage_protocol.my_smarthome_gui_client_protocol_tcp(c_tcp, app.frame.gate_position, app.frame.Layout, config.server_garage_secret)
|
|
||||||
if config.server_garage_secret is not None:
|
|
||||||
prot_garage.authentificate()
|
|
||||||
app.frame.prot_garage = prot_garage
|
|
||||||
pt = task.periodic(10, initiate_update, app.frame, prot_out, prot_in, prot_garage)
|
|
||||||
pt.run()
|
|
||||||
app.MainLoop()
|
app.MainLoop()
|
||||||
pt.stop()
|
app.frame.close()
|
||||||
try:
|
|
||||||
pt.join()
|
|
||||||
finally:
|
|
||||||
pt.stop()
|
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 4a2f461be4ac53984aded6e4b7d128f3fb5b0c39
|
Subproject commit 53e4523c140b5f51dedb3b128048eb59c1a5da4c
|
Loading…
x
Reference in New Issue
Block a user