-
Notifications
You must be signed in to change notification settings - Fork 0
/
datamonitor.py
70 lines (59 loc) · 2.27 KB
/
datamonitor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# QUASR Rocket GUI
# Eric Donders
# March 1, 2016
# Datamonitor Class
# displays data on multiple graphs
from config import *
from plot import Plot
from tiltmeter import Tiltmeter
class Datamonitor(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
# create plots for drawing on
self.accel_plot = Plot(self, ylabel="Acceleration (g)", numy=3, xrng=10, name="ACCEL")
self.gyro_plot = Plot(self, ylabel="Angular Velocity (degrees/s)", numy=3, xrng=10, name="GYRO")
self.mag_plot = Plot(self, ylabel="Field Strength", numy=3, xrng=10, name="MAG")
self.plots = (self.accel_plot, self.gyro_plot, self.mag_plot)
self.attitude_plot = Tiltmeter(self)
self.x = 0
self.y = 0
self.width = 0
self.height = 0
self.plotnext = 0
def place(self, x, y, width, height):
# fit all plots in window
self.x = x
self.y = y
self.width = width
self.height = height
figureheight = height/3-4/3*bw
figurewidth = width-2*bw
self.accel_plot.place(x=bw, y=bw, width=figurewidth, height=figureheight)
self.gyro_plot.place(x=bw, y=figureheight+2*bw, width=figurewidth, height=figureheight)
self.mag_plot.place(x=bw, y=2*figureheight+3*bw, width=figurewidth-bw-figureheight, height=figureheight)
self.attitude_plot.place(x=width-figureheight-bw, y=2*figureheight+3*bw, width=figureheight, height=figureheight)
def show(self):
self.accel_plot.show(True)
self.gyro_plot.show(True)
self.mag_plot.show(True)
self.attitude_plot.show(True)
self.update()
def hide(self):
self.accel_plot.show(False)
self.gyro_plot.show(False)
self.mag_plot.show(False)
self.attitude_plot.show(False)
def update(self):
self.place(self.x, self.y, self.width, self.height)
def refresh(self):
self.plots[self.plotnext].draw()
self.plotnext = (self.plotnext + 1) % len(self.plots)
def reset(self):
for plot in self.plots:
plot.reset()
self.attitude_plot.reset()
def destroy(self):
self.accel_plot.destroy()
self.gyro_plot.destroy()
self.mag_plot.destroy()