Commit 7b2c967be8c5939a985b0f5a73d7e75a5ef712ee

Authored by Christopher Stone
1 parent 58501ed7
Exists in master

Cleaning up after writing demo and moving code to separate modules. No major changes

robots/little_john/telemetry/code/monitor/version1/main.py
@@ -40,8 +40,7 @@ else: @@ -40,8 +40,7 @@ else:
40 os='Other' 40 os='Other'
41 logging.info('OS = ' + os) 41 logging.info('OS = ' + os)
42 42
43 -testseries = Series()  
44 -logging.info("Series created") 43 +testseries = Series(points=150, title="Sine wave demo", xname="Time (s)", yname="100sin(t)")
45 plots = [] 44 plots = []
46 plots.append(Plot(testseries)) 45 plots.append(Plot(testseries))
47 46
@@ -62,7 +61,7 @@ def pollSerial(elapsed): @@ -62,7 +61,7 @@ def pollSerial(elapsed):
62 def fakePollSerial(elapsed): 61 def fakePollSerial(elapsed):
63 """This function immitates the behaviour of pollSerial, for testing purposes""" 62 """This function immitates the behaviour of pollSerial, for testing purposes"""
64 timefromstart = (time.time()-starttime) 63 timefromstart = (time.time()-starttime)
65 - values = [timefromstart, 100*math.sin(25*math.radians(timefromstart))] 64 + values = [timefromstart, 100*math.sin(timefromstart)]
66 #logging.info("Generated test data: " + str(values)) 65 #logging.info("Generated test data: " + str(values))
67 testseries.addpoint(values) 66 testseries.addpoint(values)
68 67
robots/little_john/telemetry/code/monitor/version1/plot.py
@@ -57,7 +57,6 @@ class Plot(pyglet.window.Window): @@ -57,7 +57,6 @@ class Plot(pyglet.window.Window):
57 def drawLine(self, series): 57 def drawLine(self, series):
58 xscale = float(self.series.xlimits[1]-self.series.xlimits[0])/(self.bounds[0][1]-self.bounds[0][0]) 58 xscale = float(self.series.xlimits[1]-self.series.xlimits[0])/(self.bounds[0][1]-self.bounds[0][0])
59 yscale = float(self.series.ylimits[1]-self.series.ylimits[0])/(self.bounds[1][1]-self.bounds[1][0]) 59 yscale = float(self.series.ylimits[1]-self.series.ylimits[0])/(self.bounds[1][1]-self.bounds[1][0])
60 - logging.debug("xscale = " + str(xscale) + ", yscale = " + str(yscale))  
61 lmar = int(self.width * self.margins[0]) 60 lmar = int(self.width * self.margins[0])
62 rmar = int(self.width * self.margins[1]) 61 rmar = int(self.width * self.margins[1])
63 tmar = int(self.height * self.margins[0]) 62 tmar = int(self.height * self.margins[0])
robots/little_john/telemetry/code/monitor/version1/series.py
@@ -2,9 +2,10 @@ @@ -2,9 +2,10 @@
2 # Written as a telemetry tool by: 2 # Written as a telemetry tool by:
3 # The UoN Robot Wars Project, 2018 3 # The UoN Robot Wars Project, 2018
4 4
  5 +import logging
5 6
6 class Series: 7 class Series:
7 - def __init__(self, points=300, title="Series title", xname="x-axis name", yname="y-axis name"): 8 + def __init__(self, points=100, title="Series title", xname="x-axis name", yname="y-axis name"):
8 """Set up an object to store a 2D data series""" 9 """Set up an object to store a 2D data series"""
9 # Proposal: 10 # Proposal:
10 # In order to neatly handle multiple lines on the same graph 11 # In order to neatly handle multiple lines on the same graph
@@ -24,6 +25,8 @@ class Series: @@ -24,6 +25,8 @@ class Series:
24 self.data = [] 25 self.data = []
25 self.points = points 26 self.points = points
26 27
  28 + logging.info("Created series: " + title)
  29 +
27 def addpoint(self, point): 30 def addpoint(self, point):
28 """Add a point to the dataset, and remove the oldest, if necessary""" 31 """Add a point to the dataset, and remove the oldest, if necessary"""
29 self.data.append(point) 32 self.data.append(point)