Abend 10.Aug
This commit is contained in:
parent
0d608f8dda
commit
519b248261
@ -2,7 +2,7 @@ import os
|
||||
|
||||
|
||||
class Measurement:
|
||||
def __init__(self, name, sensors, path=None, comment=None):
|
||||
def __init__(self, name, path=None, comment=None):
|
||||
self.name = name
|
||||
self.path = os.path.join(path or "./meas_values", self.name)
|
||||
os.makedirs(self.path)
|
||||
@ -18,8 +18,8 @@ class Measurement:
|
||||
data: list of tuples: (timestamp, value)
|
||||
"""
|
||||
if sensor_name not in self.data_files:
|
||||
self.data_files[sensor_name] = open(os.path.join(self.path, f"{sensor_name}_data.csv"))
|
||||
for timestamp, value in data:
|
||||
self.data_files[sensor_name] = open(os.path.join(self.path, f"{sensor_name}_data.csv"), "w")
|
||||
for timestamp, value in zip(data[0], data[1]):
|
||||
self.data_files[sensor_name].write(f"{timestamp.isoformat()}, {timestamp.timestamp()}, {value}\n")
|
||||
|
||||
def save_version_text(self, comment):
|
||||
|
46
model.py
46
model.py
@ -5,34 +5,58 @@ Data:
|
||||
- dict with sensor data (temp, pressure, current)
|
||||
- dict with drivers (magnetic field control)
|
||||
"""
|
||||
from datetime import datetime
|
||||
from threading import Event, Thread
|
||||
from time import sleep
|
||||
from sensor import Sensor
|
||||
from measurement import Measurement
|
||||
from plot_data import PlotData
|
||||
|
||||
class DataGrabber(Thread):
|
||||
def __init__(self, sensors, drivers, plot_data):
|
||||
super().__init__()
|
||||
self.measurement = None
|
||||
self.sensors = sensors
|
||||
self.drivers = drivers
|
||||
self.plot_data = plot_data
|
||||
self.exit_request = Event()
|
||||
|
||||
def run(self):
|
||||
while not self.exit_request.is_set():
|
||||
for name, sens in self.sensors.items():
|
||||
dat = sens.get_data
|
||||
self.plot_data.append_data(name,dat)
|
||||
if self.measurement is not None:
|
||||
self.measurement.append_data(name, dat)
|
||||
sleep(1)
|
||||
|
||||
|
||||
class Model:
|
||||
def __init__(self):
|
||||
self.plot_data = PlotData()
|
||||
self.sensors = {"temp": Sensor(), "keks": Sensor()}
|
||||
self.drivers = []
|
||||
self.measurement = None
|
||||
self.plot_data = None
|
||||
pass
|
||||
self.data_grabber = DataGrabber(self.sensors, self.drivers, self.plot_data)
|
||||
self.data_grabber.start()
|
||||
|
||||
def start_measuring(self):
|
||||
for sens in self.sensors.values():
|
||||
sens.start_measuring()
|
||||
def start_measuring(self, meas_name=""):
|
||||
name = meas_name or f"meas_{datetime.utcnow().isoformat().replace(':', '-')}"
|
||||
self.measurement = Measurement(name)
|
||||
self.data_grabber.measurement = self.measurement
|
||||
|
||||
def save_measuring(self, path="temp_temp.csv"):
|
||||
for sens in self.sensors.values():
|
||||
sens.save_measuring()
|
||||
print("Has no use delete me maybe")
|
||||
|
||||
def stop_measuring(self):
|
||||
for sens in self.sensors.values():
|
||||
sens.stop_measuring()
|
||||
self.measurement = None
|
||||
self.data_grabber.measurement = None
|
||||
|
||||
def clear(self):
|
||||
for sens in self.sensors.values():
|
||||
sens.clear()
|
||||
self.plot_data.clear()
|
||||
|
||||
def exit(self):
|
||||
self.data_grabber.exit_request.set()
|
||||
for sens in self.sensors.values():
|
||||
sens.exit()
|
||||
|
||||
|
43
plot_data.py
43
plot_data.py
@ -1,5 +1,6 @@
|
||||
import numpy as np
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
|
||||
class PlotData():
|
||||
def __init__(self):
|
||||
@ -9,7 +10,12 @@ class PlotData():
|
||||
self.start_time = datetime.utcnow()
|
||||
self.queues = {}
|
||||
|
||||
def clear(self):
|
||||
for key in self.data:
|
||||
self.data[key] = np.array([])
|
||||
|
||||
def get(self, key):
|
||||
return self.data.get(key, np.full_like(self.data["time"], np.nan, dtype=np.double))
|
||||
|
||||
def append_data(self, sensor_name, data):
|
||||
"""
|
||||
@ -17,25 +23,37 @@ class PlotData():
|
||||
"""
|
||||
if sensor_name not in self.data:
|
||||
self.queues[sensor_name] = []
|
||||
self.data[sensor_name] = np.full_like(self.data["time"], np.nan)
|
||||
|
||||
for data_tuple in data.values():
|
||||
self.queues[sensor_name].append(data_tuple)
|
||||
self.data[sensor_name] = np.full_like(self.data["time"], np.nan, dtype=np.double)
|
||||
for time, dat in zip(data[0], data[1]):
|
||||
self.queues[sensor_name].append((time, dat))
|
||||
|
||||
running = True
|
||||
while running:
|
||||
#TODO timeout clean
|
||||
# TODO timeout clean and time clean
|
||||
for sensor, que in self.queues.items():
|
||||
index = -1
|
||||
for time, _ in que:
|
||||
if time < self.start_time \
|
||||
+ timedelta(milliseconds=int(self.data["time"][-1]) + self.refresh_rate):
|
||||
index += 1
|
||||
if index >= 0:
|
||||
self.queues[sensor] = que[index:]
|
||||
#TODO timeout not working as intended
|
||||
#if timeout is reached add empty values on sensors
|
||||
#if self.start_time + timedelta(milliseconds=int(self.data["time"][-1])+self.timeout) < datetime.utcnow():
|
||||
# for sensor, que in self.queues.items():
|
||||
# if len(que) == 0:
|
||||
# que.append((self.start_time,np.nan))
|
||||
|
||||
for que in self.queues.values():
|
||||
if len(que) == 0:
|
||||
running = False
|
||||
break
|
||||
return
|
||||
|
||||
for sensor, que in self.queues.items():
|
||||
self.data[sensor] = np.append(self.data[sensor], que[0])
|
||||
que = que[1:]
|
||||
|
||||
|
||||
|
||||
self.data[sensor] = np.append(self.data[sensor], que[0][1])
|
||||
self.queues[sensor] = que[1:]
|
||||
self.data["time"] = np.append(self.data["time"],self.data["time"][-1]+self.refresh_rate)
|
||||
|
||||
"""
|
||||
TODO
|
||||
@ -46,4 +64,3 @@ class PlotData():
|
||||
return
|
||||
update np array
|
||||
"""
|
||||
|
||||
|
40
sensor.py
40
sensor.py
@ -14,18 +14,16 @@ class SensorWorker(Thread):
|
||||
self.message_queue = message_queue
|
||||
self.produceData = Event()
|
||||
self.exit_request = Event()
|
||||
self.file = open("temp.csv", "w")
|
||||
|
||||
def run(self):
|
||||
""" Worker method of a python Thread. Called when the Thread is started. """
|
||||
while not self.exit_request.is_set():
|
||||
if self.produceData.is_set():
|
||||
temp = random()
|
||||
ts = datetime.now()
|
||||
ts = datetime.utcnow()
|
||||
self.message_queue.put((ts, temp))
|
||||
self.file.write(f"{ts} - {temp}\n")
|
||||
else:
|
||||
self.file.flush()
|
||||
pass
|
||||
sleep(1)
|
||||
|
||||
|
||||
@ -34,38 +32,44 @@ class Sensor(object):
|
||||
|
||||
def __init__(self):
|
||||
super(Sensor, self).__init__()
|
||||
self.data = []
|
||||
self.t = []
|
||||
self.measureQueue = Queue()
|
||||
self.measureThread = SensorWorker(self.measureQueue)
|
||||
self.measureThread.start()
|
||||
self.measureThread.produceData.set()
|
||||
|
||||
|
||||
def start_measuring(self):
|
||||
self.measureThread.produceData.set()
|
||||
print("I started meas")
|
||||
|
||||
def save_measuring(self, path="temp_temp.csv"):
|
||||
print("I saved meas")
|
||||
np.savetxt(path, np.array(self.data))
|
||||
|
||||
def stop_measuring(self):
|
||||
self.measureThread.produceData.clear()
|
||||
print("I stopped meas")
|
||||
|
||||
def clear(self):
|
||||
self.data = []
|
||||
self.t = []
|
||||
print("I cleared meas")
|
||||
|
||||
def exit(self):
|
||||
self.stop_measuring()
|
||||
self.measureThread.exit_request.set()
|
||||
|
||||
@property
|
||||
def get_data(self):
|
||||
time = []
|
||||
val = []
|
||||
while not self.measureQueue.empty():
|
||||
t, data = self.measureQueue.get()
|
||||
self.data.append(data)
|
||||
self.t.append(t)
|
||||
print(self.data)
|
||||
return self.t, self.data
|
||||
time.append(t)
|
||||
val.append(data)
|
||||
return time, val
|
||||
|
||||
|
||||
|
||||
|
||||
# def clear(self):
|
||||
# self.data = []
|
||||
# self.t = []
|
||||
# print("I cleared meas")
|
||||
#
|
||||
# def save_measuring(self, path="temp_temp.csv"):
|
||||
# print("I saved meas")
|
||||
# np.savetxt(path, np.array(self.data))
|
||||
|
||||
|
190
trial2/wxglade.wxg
Normal file
190
trial2/wxglade.wxg
Normal file
@ -0,0 +1,190 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- generated by wxGlade 1.0.2 on Sun Jul 4 21:22:59 2021 -->
|
||||
|
||||
<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="./wxglade_out.py" source_extension=".cpp" top_window="frame" use_gettext="0" use_new_namespace="1">
|
||||
<object class="MyFrame" name="frame" base="EditFrame">
|
||||
<size>1920, 1080</size>
|
||||
<title>frame</title>
|
||||
<style>wxDEFAULT_FRAME_STYLE</style>
|
||||
<menubar>1</menubar>
|
||||
<toolbar>1</toolbar>
|
||||
<statusbar>1</statusbar>
|
||||
<object class="wxMenuBar" name="frame_menubar" base="EditMenuBar">
|
||||
<menus>
|
||||
<menu label="File" name="">
|
||||
<item>
|
||||
<label>Quit</label>
|
||||
</item>
|
||||
</menu>
|
||||
</menus>
|
||||
</object>
|
||||
<object class="wxStatusBar" name="frame_statusbar" base="EditStatusBar">
|
||||
<fields>
|
||||
<field width="-1">frame_statusbar</field>
|
||||
</fields>
|
||||
</object>
|
||||
<object class="wxToolBar" name="frame_toolbar" base="EditToolBar">
|
||||
<tools>
|
||||
</tools>
|
||||
</object>
|
||||
<object class="wxPanel" name="panel_1" base="EditPanel">
|
||||
<object class="wxGridBagSizer" name="grid_sizer_1" base="EditGridBagSizer">
|
||||
<rows>2</rows>
|
||||
<cols>3</cols>
|
||||
<vgap>0</vgap>
|
||||
<hgap>0</hgap>
|
||||
<object class="sizeritem">
|
||||
<span>2, 1</span>
|
||||
<border>0</border>
|
||||
<flag>wxEXPAND</flag>
|
||||
<object class="wxBoxSizer" name="sizer_1" base="EditBoxSizer">
|
||||
<orient>wxVERTICAL</orient>
|
||||
<object class="sizeritem">
|
||||
<option>0</option>
|
||||
<border>0</border>
|
||||
<object class="wxStaticText" name="label_1" base="EditStaticText">
|
||||
<label>Text1</label>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<option>0</option>
|
||||
<border>0</border>
|
||||
<object class="wxStaticText" name="label_2" base="EditStaticText">
|
||||
<label>Für</label>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<option>0</option>
|
||||
<border>0</border>
|
||||
<object class="wxStaticText" name="label_3" base="EditStaticText">
|
||||
<label>Statis</label>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<border>0</border>
|
||||
<flag>wxEXPAND</flag>
|
||||
<object class="wxNotebook" name="notebook_1" base="EditNotebook">
|
||||
<style>wxNB_TOP</style>
|
||||
<tabs>
|
||||
<tab window="notebook_1_pane_1">notebook_1_pane_1</tab>
|
||||
<tab window="notebook_1_pane_2">notebook_1_pane_2</tab>
|
||||
<tab window="notebook_1_pane_3">notebook_1_pane_3</tab>
|
||||
<tab window="notebook_1_pane_4">notebook_1_pane_4</tab>
|
||||
</tabs>
|
||||
<object class="wxPanel" name="notebook_1_pane_1" base="EditPanel">
|
||||
<style>wxTAB_TRAVERSAL</style>
|
||||
</object>
|
||||
<object class="wxPanel" name="notebook_1_pane_2" base="EditPanel">
|
||||
<style>wxTAB_TRAVERSAL</style>
|
||||
</object>
|
||||
<object class="wxPanel" name="notebook_1_pane_3" base="EditPanel">
|
||||
<style>wxTAB_TRAVERSAL</style>
|
||||
</object>
|
||||
<object class="wxPanel" name="notebook_1_pane_4" base="EditPanel">
|
||||
<style>wxTAB_TRAVERSAL</style>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<span>2, 1</span>
|
||||
<border>0</border>
|
||||
<flag>wxEXPAND</flag>
|
||||
<object class="wxGridBagSizer" name="grid_sizer_3" base="EditGridBagSizer">
|
||||
<rows>2</rows>
|
||||
<cols>1</cols>
|
||||
<vgap>10</vgap>
|
||||
<hgap>0</hgap>
|
||||
<object class="sizeritem">
|
||||
<border>0</border>
|
||||
<flag>wxEXPAND</flag>
|
||||
<object class="wxGridBagSizer" name="grid_sizer_4" base="EditGridBagSizer">
|
||||
<rows>3</rows>
|
||||
<cols>1</cols>
|
||||
<vgap>0</vgap>
|
||||
<hgap>0</hgap>
|
||||
<object class="sizeritem">
|
||||
<border>0</border>
|
||||
<object class="wxButton" name="button_1" base="EditButton">
|
||||
<label>button_1</label>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<border>0</border>
|
||||
<object class="wxButton" name="button_2" base="EditButton">
|
||||
<label>button_2</label>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<border>0</border>
|
||||
<object class="wxButton" name="button_3" base="EditButton">
|
||||
<label>button_3</label>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<border>0</border>
|
||||
<flag>wxEXPAND</flag>
|
||||
<object class="wxGridBagSizer" name="grid_sizer_5" base="EditGridBagSizer">
|
||||
<rows>3</rows>
|
||||
<cols>1</cols>
|
||||
<vgap>0</vgap>
|
||||
<hgap>0</hgap>
|
||||
<object class="sizeritem">
|
||||
<border>0</border>
|
||||
<object class="wxButton" name="button_7" base="EditButton">
|
||||
<label>button_7</label>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<border>0</border>
|
||||
<object class="wxButton" name="button_8" base="EditButton">
|
||||
<label>button_8</label>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<border>0</border>
|
||||
<object class="wxButton" name="button_9" base="EditButton">
|
||||
<label>button_9</label>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizerslot" />
|
||||
<object class="sizeritem">
|
||||
<border>0</border>
|
||||
<flag>wxEXPAND</flag>
|
||||
<object class="wxGridBagSizer" name="grid_sizer_2" base="EditGridBagSizer">
|
||||
<rows>1</rows>
|
||||
<cols>3</cols>
|
||||
<vgap>0</vgap>
|
||||
<hgap>0</hgap>
|
||||
<object class="sizeritem">
|
||||
<border>0</border>
|
||||
<object class="wxButton" name="button_4" base="EditButton">
|
||||
<label>button_4</label>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<border>0</border>
|
||||
<object class="wxButton" name="button_5" base="EditButton">
|
||||
<label>button_5</label>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<border>0</border>
|
||||
<object class="wxButton" name="button_6" base="EditButton">
|
||||
<label>button_6</label>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizerslot" />
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</application>
|
174
trial2/wxglade.wxg~
Normal file
174
trial2/wxglade.wxg~
Normal file
@ -0,0 +1,174 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- generated by wxGlade 1.0.2 on Sun Jul 4 21:21:09 2021 -->
|
||||
|
||||
<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="./wxglade_out.py" source_extension=".cpp" top_window="frame" use_gettext="0" use_new_namespace="1">
|
||||
<object class="MyFrame" name="frame" base="EditFrame">
|
||||
<size>474, 290</size>
|
||||
<title>frame</title>
|
||||
<style>wxDEFAULT_FRAME_STYLE</style>
|
||||
<menubar>1</menubar>
|
||||
<object class="wxMenuBar" name="frame_menubar" base="EditMenuBar">
|
||||
<menus>
|
||||
</menus>
|
||||
</object>
|
||||
<object class="wxPanel" name="panel_1" base="EditPanel">
|
||||
<object class="wxGridBagSizer" name="grid_sizer_1" base="EditGridBagSizer">
|
||||
<rows>2</rows>
|
||||
<cols>3</cols>
|
||||
<vgap>0</vgap>
|
||||
<hgap>0</hgap>
|
||||
<object class="sizeritem">
|
||||
<span>2, 1</span>
|
||||
<border>0</border>
|
||||
<flag>wxEXPAND</flag>
|
||||
<object class="wxBoxSizer" name="sizer_1" base="EditBoxSizer">
|
||||
<orient>wxVERTICAL</orient>
|
||||
<object class="sizeritem">
|
||||
<option>0</option>
|
||||
<border>0</border>
|
||||
<object class="wxStaticText" name="label_1" base="EditStaticText">
|
||||
<label>Text1</label>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<option>0</option>
|
||||
<border>0</border>
|
||||
<object class="wxStaticText" name="label_2" base="EditStaticText">
|
||||
<label>Für</label>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<option>0</option>
|
||||
<border>0</border>
|
||||
<object class="wxStaticText" name="label_3" base="EditStaticText">
|
||||
<label>Statis</label>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<border>0</border>
|
||||
<flag>wxEXPAND</flag>
|
||||
<object class="wxNotebook" name="notebook_1" base="EditNotebook">
|
||||
<style>wxNB_TOP</style>
|
||||
<tabs>
|
||||
<tab window="notebook_1_pane_1">notebook_1_pane_1</tab>
|
||||
<tab window="notebook_1_pane_2">notebook_1_pane_2</tab>
|
||||
<tab window="notebook_1_pane_3">notebook_1_pane_3</tab>
|
||||
<tab window="notebook_1_pane_4">notebook_1_pane_4</tab>
|
||||
</tabs>
|
||||
<object class="wxPanel" name="notebook_1_pane_1" base="EditPanel">
|
||||
<style>wxTAB_TRAVERSAL</style>
|
||||
</object>
|
||||
<object class="wxPanel" name="notebook_1_pane_2" base="EditPanel">
|
||||
<style>wxTAB_TRAVERSAL</style>
|
||||
</object>
|
||||
<object class="wxPanel" name="notebook_1_pane_3" base="EditPanel">
|
||||
<style>wxTAB_TRAVERSAL</style>
|
||||
</object>
|
||||
<object class="wxPanel" name="notebook_1_pane_4" base="EditPanel">
|
||||
<style>wxTAB_TRAVERSAL</style>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<span>2, 1</span>
|
||||
<border>0</border>
|
||||
<flag>wxEXPAND</flag>
|
||||
<object class="wxGridBagSizer" name="grid_sizer_3" base="EditGridBagSizer">
|
||||
<rows>2</rows>
|
||||
<cols>1</cols>
|
||||
<vgap>10</vgap>
|
||||
<hgap>0</hgap>
|
||||
<object class="sizeritem">
|
||||
<border>0</border>
|
||||
<flag>wxEXPAND</flag>
|
||||
<object class="wxGridBagSizer" name="grid_sizer_4" base="EditGridBagSizer">
|
||||
<rows>3</rows>
|
||||
<cols>1</cols>
|
||||
<vgap>0</vgap>
|
||||
<hgap>0</hgap>
|
||||
<object class="sizeritem">
|
||||
<border>0</border>
|
||||
<object class="wxButton" name="button_1" base="EditButton">
|
||||
<label>button_1</label>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<border>0</border>
|
||||
<object class="wxButton" name="button_2" base="EditButton">
|
||||
<label>button_2</label>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<border>0</border>
|
||||
<object class="wxButton" name="button_3" base="EditButton">
|
||||
<label>button_3</label>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<border>0</border>
|
||||
<flag>wxEXPAND</flag>
|
||||
<object class="wxGridBagSizer" name="grid_sizer_5" base="EditGridBagSizer">
|
||||
<rows>3</rows>
|
||||
<cols>1</cols>
|
||||
<vgap>0</vgap>
|
||||
<hgap>0</hgap>
|
||||
<object class="sizeritem">
|
||||
<border>0</border>
|
||||
<object class="wxButton" name="button_7" base="EditButton">
|
||||
<label>button_7</label>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<border>0</border>
|
||||
<object class="wxButton" name="button_8" base="EditButton">
|
||||
<label>button_8</label>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<border>0</border>
|
||||
<object class="wxButton" name="button_9" base="EditButton">
|
||||
<label>button_9</label>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizerslot" />
|
||||
<object class="sizeritem">
|
||||
<border>0</border>
|
||||
<flag>wxEXPAND</flag>
|
||||
<object class="wxGridBagSizer" name="grid_sizer_2" base="EditGridBagSizer">
|
||||
<rows>1</rows>
|
||||
<cols>3</cols>
|
||||
<vgap>0</vgap>
|
||||
<hgap>0</hgap>
|
||||
<object class="sizeritem">
|
||||
<border>0</border>
|
||||
<object class="wxButton" name="button_4" base="EditButton">
|
||||
<label>button_4</label>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<border>0</border>
|
||||
<object class="wxButton" name="button_5" base="EditButton">
|
||||
<label>button_5</label>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<border>0</border>
|
||||
<object class="wxButton" name="button_6" base="EditButton">
|
||||
<label>button_6</label>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizerslot" />
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</application>
|
138
trial2/wxglade_out.py
Normal file
138
trial2/wxglade_out.py
Normal file
@ -0,0 +1,138 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: UTF-8 -*-
|
||||
#
|
||||
# generated by wxGlade 1.0.2 on Sun Jul 4 21:29:50 2021
|
||||
#
|
||||
|
||||
import wx
|
||||
|
||||
# begin wxGlade: dependencies
|
||||
# end wxGlade
|
||||
|
||||
# begin wxGlade: extracode
|
||||
# end wxGlade
|
||||
|
||||
|
||||
class MyFrame(wx.Frame):
|
||||
def __init__(self, *args, **kwds):
|
||||
# begin wxGlade: MyFrame.__init__
|
||||
kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE
|
||||
wx.Frame.__init__(self, *args, **kwds)
|
||||
self.SetSize((1920, 1080))
|
||||
self.SetTitle("frame")
|
||||
|
||||
# Menu Bar
|
||||
self.frame_menubar = wx.MenuBar()
|
||||
wxglade_tmp_menu = wx.Menu()
|
||||
wxglade_tmp_menu.Append(wx.ID_ANY, "Quit", "")
|
||||
self.frame_menubar.Append(wxglade_tmp_menu, "File")
|
||||
self.SetMenuBar(self.frame_menubar)
|
||||
# Menu Bar end
|
||||
|
||||
self.frame_statusbar = self.CreateStatusBar(1)
|
||||
self.frame_statusbar.SetStatusWidths([-1])
|
||||
# statusbar fields
|
||||
frame_statusbar_fields = ["frame_statusbar"]
|
||||
for i in range(len(frame_statusbar_fields)):
|
||||
self.frame_statusbar.SetStatusText(frame_statusbar_fields[i], i)
|
||||
|
||||
# Tool Bar
|
||||
self.frame_toolbar = wx.ToolBar(self, -1)
|
||||
self.SetToolBar(self.frame_toolbar)
|
||||
self.frame_toolbar.Realize()
|
||||
# Tool Bar end
|
||||
|
||||
self.panel_1 = wx.Panel(self, wx.ID_ANY)
|
||||
|
||||
grid_sizer_1 = wx.GridBagSizer(0, 0)
|
||||
|
||||
sizer_1 = wx.BoxSizer(wx.VERTICAL)
|
||||
grid_sizer_1.Add(sizer_1, (0, 0), (2, 1), wx.EXPAND, 0)
|
||||
|
||||
label_1 = wx.StaticText(self.panel_1, wx.ID_ANY, "Text1")
|
||||
sizer_1.Add(label_1, 0, 0, 0)
|
||||
|
||||
label_2 = wx.StaticText(self.panel_1, wx.ID_ANY, u"Für")
|
||||
sizer_1.Add(label_2, 0, 0, 0)
|
||||
|
||||
label_3 = wx.StaticText(self.panel_1, wx.ID_ANY, "Statis")
|
||||
sizer_1.Add(label_3, 0, 0, 0)
|
||||
|
||||
self.notebook_1 = wx.Notebook(self.panel_1, wx.ID_ANY)
|
||||
grid_sizer_1.Add(self.notebook_1, (0, 1), (1, 1), wx.EXPAND, 0)
|
||||
|
||||
self.notebook_1_pane_1 = wx.Panel(self.notebook_1, wx.ID_ANY)
|
||||
self.notebook_1.AddPage(self.notebook_1_pane_1, "notebook_1_pane_1")
|
||||
|
||||
self.notebook_1_pane_2 = wx.Panel(self.notebook_1, wx.ID_ANY)
|
||||
self.notebook_1.AddPage(self.notebook_1_pane_2, "notebook_1_pane_2")
|
||||
|
||||
self.notebook_1_pane_3 = wx.Panel(self.notebook_1, wx.ID_ANY)
|
||||
self.notebook_1.AddPage(self.notebook_1_pane_3, "notebook_1_pane_3")
|
||||
|
||||
self.notebook_1_pane_4 = wx.Panel(self.notebook_1, wx.ID_ANY)
|
||||
self.notebook_1.AddPage(self.notebook_1_pane_4, "notebook_1_pane_4")
|
||||
|
||||
grid_sizer_3 = wx.GridBagSizer(10, 0)
|
||||
grid_sizer_1.Add(grid_sizer_3, (0, 2), (2, 1), wx.EXPAND, 0)
|
||||
|
||||
grid_sizer_4 = wx.GridBagSizer(0, 0)
|
||||
grid_sizer_3.Add(grid_sizer_4, (0, 0), (1, 1), wx.EXPAND, 0)
|
||||
|
||||
self.button_1 = wx.Button(self.panel_1, wx.ID_ANY, "button_1")
|
||||
grid_sizer_4.Add(self.button_1, (0, 0), (1, 1), 0, 0)
|
||||
|
||||
self.button_2 = wx.Button(self.panel_1, wx.ID_ANY, "button_2")
|
||||
grid_sizer_4.Add(self.button_2, (1, 0), (1, 1), 0, 0)
|
||||
|
||||
self.button_3 = wx.Button(self.panel_1, wx.ID_ANY, "button_3")
|
||||
grid_sizer_4.Add(self.button_3, (2, 0), (1, 1), 0, 0)
|
||||
|
||||
grid_sizer_5 = wx.GridBagSizer(0, 0)
|
||||
grid_sizer_3.Add(grid_sizer_5, (1, 0), (1, 1), wx.EXPAND, 0)
|
||||
|
||||
self.button_7 = wx.Button(self.panel_1, wx.ID_ANY, "button_7")
|
||||
grid_sizer_5.Add(self.button_7, (0, 0), (1, 1), 0, 0)
|
||||
|
||||
self.button_8 = wx.Button(self.panel_1, wx.ID_ANY, "button_8")
|
||||
grid_sizer_5.Add(self.button_8, (1, 0), (1, 1), 0, 0)
|
||||
|
||||
self.button_9 = wx.Button(self.panel_1, wx.ID_ANY, "button_9")
|
||||
grid_sizer_5.Add(self.button_9, (2, 0), (1, 1), 0, 0)
|
||||
|
||||
grid_sizer_2 = wx.GridBagSizer(0, 0)
|
||||
grid_sizer_1.Add(grid_sizer_2, (1, 1), (1, 1), wx.EXPAND, 0)
|
||||
|
||||
self.button_4 = wx.Button(self.panel_1, wx.ID_ANY, "button_4")
|
||||
grid_sizer_2.Add(self.button_4, (0, 0), (1, 1), 0, 0)
|
||||
|
||||
self.button_5 = wx.Button(self.panel_1, wx.ID_ANY, "button_5")
|
||||
grid_sizer_2.Add(self.button_5, (0, 1), (1, 1), 0, 0)
|
||||
|
||||
self.button_6 = wx.Button(self.panel_1, wx.ID_ANY, "button_6")
|
||||
grid_sizer_2.Add(self.button_6, (0, 2), (1, 1), 0, 0)
|
||||
|
||||
self.panel_1.SetSizer(grid_sizer_1)
|
||||
|
||||
self.Layout()
|
||||
|
||||
# end wxGlade
|
||||
|
||||
def test(self, event): # wxGlade: MyFrame.<event_handler>
|
||||
print("Event handler 'test' not implemented!")
|
||||
event.Skip()
|
||||
|
||||
# end of class MyFrame
|
||||
|
||||
class MyApp(wx.App):
|
||||
def OnInit(self):
|
||||
self.frame = MyFrame(None, wx.ID_ANY, "")
|
||||
self.SetTopWindow(self.frame)
|
||||
self.frame.Show()
|
||||
return True
|
||||
|
||||
# end of class MyApp
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = MyApp(0)
|
||||
app.MainLoop()
|
117
trial2/wxglade_out.py~
Normal file
117
trial2/wxglade_out.py~
Normal file
@ -0,0 +1,117 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: UTF-8 -*-
|
||||
#
|
||||
# generated by wxGlade 1.0.2 on Sun Jul 4 21:20:06 2021
|
||||
#
|
||||
|
||||
import wx
|
||||
|
||||
# begin wxGlade: dependencies
|
||||
# end wxGlade
|
||||
|
||||
# begin wxGlade: extracode
|
||||
# end wxGlade
|
||||
|
||||
|
||||
class MyFrame(wx.Frame):
|
||||
def __init__(self, *args, **kwds):
|
||||
# begin wxGlade: MyFrame.__init__
|
||||
kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE
|
||||
wx.Frame.__init__(self, *args, **kwds)
|
||||
self.SetSize((474, 290))
|
||||
self.SetTitle("frame")
|
||||
|
||||
# Menu Bar
|
||||
self.frame_menubar = wx.MenuBar()
|
||||
self.SetMenuBar(self.frame_menubar)
|
||||
# Menu Bar end
|
||||
|
||||
self.panel_1 = wx.Panel(self, wx.ID_ANY)
|
||||
|
||||
grid_sizer_1 = wx.GridBagSizer(0, 0)
|
||||
|
||||
sizer_1 = wx.BoxSizer(wx.VERTICAL)
|
||||
grid_sizer_1.Add(sizer_1, (0, 0), (2, 1), wx.EXPAND, 0)
|
||||
|
||||
label_1 = wx.StaticText(self.panel_1, wx.ID_ANY, "Text1")
|
||||
sizer_1.Add(label_1, 0, 0, 0)
|
||||
|
||||
label_2 = wx.StaticText(self.panel_1, wx.ID_ANY, u"Für")
|
||||
sizer_1.Add(label_2, 0, 0, 0)
|
||||
|
||||
label_3 = wx.StaticText(self.panel_1, wx.ID_ANY, "Statis")
|
||||
sizer_1.Add(label_3, 0, 0, 0)
|
||||
|
||||
self.notebook_1 = wx.Notebook(self.panel_1, wx.ID_ANY)
|
||||
grid_sizer_1.Add(self.notebook_1, (0, 1), (1, 1), wx.EXPAND, 0)
|
||||
|
||||
self.notebook_1_pane_1 = wx.Panel(self.notebook_1, wx.ID_ANY)
|
||||
self.notebook_1.AddPage(self.notebook_1_pane_1, "notebook_1_pane_1")
|
||||
|
||||
self.notebook_1_pane_2 = wx.Panel(self.notebook_1, wx.ID_ANY)
|
||||
self.notebook_1.AddPage(self.notebook_1_pane_2, "notebook_1_pane_2")
|
||||
|
||||
self.notebook_1_pane_3 = wx.Panel(self.notebook_1, wx.ID_ANY)
|
||||
self.notebook_1.AddPage(self.notebook_1_pane_3, "notebook_1_pane_3")
|
||||
|
||||
self.notebook_1_pane_4 = wx.Panel(self.notebook_1, wx.ID_ANY)
|
||||
self.notebook_1.AddPage(self.notebook_1_pane_4, "notebook_1_pane_4")
|
||||
|
||||
grid_sizer_3 = wx.GridBagSizer(10, 0)
|
||||
grid_sizer_1.Add(grid_sizer_3, (0, 2), (2, 1), wx.EXPAND, 0)
|
||||
|
||||
grid_sizer_4 = wx.GridBagSizer(0, 0)
|
||||
grid_sizer_3.Add(grid_sizer_4, (0, 0), (1, 1), wx.EXPAND, 0)
|
||||
|
||||
self.button_1 = wx.Button(self.panel_1, wx.ID_ANY, "button_1")
|
||||
grid_sizer_4.Add(self.button_1, (0, 0), (1, 1), 0, 0)
|
||||
|
||||
self.button_2 = wx.Button(self.panel_1, wx.ID_ANY, "button_2")
|
||||
grid_sizer_4.Add(self.button_2, (1, 0), (1, 1), 0, 0)
|
||||
|
||||
self.button_3 = wx.Button(self.panel_1, wx.ID_ANY, "button_3")
|
||||
grid_sizer_4.Add(self.button_3, (2, 0), (1, 1), 0, 0)
|
||||
|
||||
grid_sizer_5 = wx.GridBagSizer(0, 0)
|
||||
grid_sizer_3.Add(grid_sizer_5, (1, 0), (1, 1), wx.EXPAND, 0)
|
||||
|
||||
self.button_7 = wx.Button(self.panel_1, wx.ID_ANY, "button_7")
|
||||
grid_sizer_5.Add(self.button_7, (0, 0), (1, 1), 0, 0)
|
||||
|
||||
self.button_8 = wx.Button(self.panel_1, wx.ID_ANY, "button_8")
|
||||
grid_sizer_5.Add(self.button_8, (1, 0), (1, 1), 0, 0)
|
||||
|
||||
self.button_9 = wx.Button(self.panel_1, wx.ID_ANY, "button_9")
|
||||
grid_sizer_5.Add(self.button_9, (2, 0), (1, 1), 0, 0)
|
||||
|
||||
grid_sizer_2 = wx.GridBagSizer(0, 0)
|
||||
grid_sizer_1.Add(grid_sizer_2, (1, 1), (1, 1), wx.EXPAND, 0)
|
||||
|
||||
self.button_4 = wx.Button(self.panel_1, wx.ID_ANY, "button_4")
|
||||
grid_sizer_2.Add(self.button_4, (0, 0), (1, 1), 0, 0)
|
||||
|
||||
self.button_5 = wx.Button(self.panel_1, wx.ID_ANY, "button_5")
|
||||
grid_sizer_2.Add(self.button_5, (0, 1), (1, 1), 0, 0)
|
||||
|
||||
self.button_6 = wx.Button(self.panel_1, wx.ID_ANY, "button_6")
|
||||
grid_sizer_2.Add(self.button_6, (0, 2), (1, 1), 0, 0)
|
||||
|
||||
self.panel_1.SetSizer(grid_sizer_1)
|
||||
|
||||
self.Layout()
|
||||
# end wxGlade
|
||||
|
||||
# end of class MyFrame
|
||||
|
||||
class MyApp(wx.App):
|
||||
def OnInit(self):
|
||||
self.frame = MyFrame(None, wx.ID_ANY, "")
|
||||
self.SetTopWindow(self.frame)
|
||||
self.frame.Show()
|
||||
return True
|
||||
|
||||
# end of class MyApp
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = MyApp(0)
|
||||
app.MainLoop()
|
9
view.py
9
view.py
@ -53,8 +53,8 @@ class PlotPanel(wx.Panel):
|
||||
def init_plot_data(self):
|
||||
self.ax = self.fig.add_subplot()
|
||||
self.fig.legend()
|
||||
self.x, self.y = self.model.sensors["temp"].get_data
|
||||
(self.im,) = self.ax.plot(self.x, self.y, "-.",label="temp")
|
||||
dat = self.model.plot_data
|
||||
(self.im,) = self.ax.plot(dat.get("time"), dat.get("temp"), "-.",label="temp")
|
||||
self.toolbar.update() # Not sure why this is needed - ADS
|
||||
|
||||
def get_toolbar(self):
|
||||
@ -63,9 +63,10 @@ class PlotPanel(wx.Panel):
|
||||
return self.toolbar
|
||||
|
||||
def on_paint(self, event):
|
||||
self.x, self.y = self.model.sensors["temp"].get_data
|
||||
dat = self.model.plot_data.data
|
||||
# print(self.x)
|
||||
self.im.set_data(self.x, self.y)
|
||||
|
||||
self.im.set_data(dat.get("time"), dat.get("temp"))
|
||||
self.ax.relim()
|
||||
self.ax.autoscale_view()
|
||||
self.canvas.draw()
|
||||
|
Loading…
Reference in New Issue
Block a user