From 7b2c967be8c5939a985b0f5a73d7e75a5ef712ee Mon Sep 17 00:00:00 2001 From: Christopher Stone Date: Fri, 9 Mar 2018 20:08:36 +0000 Subject: [PATCH] Cleaning up after writing demo and moving code to separate modules. No major changes --- robots/little_john/telemetry/code/monitor/version1/main.py | 5 ++--- robots/little_john/telemetry/code/monitor/version1/plot.py | 1 - robots/little_john/telemetry/code/monitor/version1/series.py | 5 ++++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/robots/little_john/telemetry/code/monitor/version1/main.py b/robots/little_john/telemetry/code/monitor/version1/main.py index 7ed6615..ae527fb 100755 --- a/robots/little_john/telemetry/code/monitor/version1/main.py +++ b/robots/little_john/telemetry/code/monitor/version1/main.py @@ -40,8 +40,7 @@ else: os='Other' logging.info('OS = ' + os) -testseries = Series() -logging.info("Series created") +testseries = Series(points=150, title="Sine wave demo", xname="Time (s)", yname="100sin(t)") plots = [] plots.append(Plot(testseries)) @@ -62,7 +61,7 @@ def pollSerial(elapsed): def fakePollSerial(elapsed): """This function immitates the behaviour of pollSerial, for testing purposes""" timefromstart = (time.time()-starttime) - values = [timefromstart, 100*math.sin(25*math.radians(timefromstart))] + values = [timefromstart, 100*math.sin(timefromstart)] #logging.info("Generated test data: " + str(values)) testseries.addpoint(values) diff --git a/robots/little_john/telemetry/code/monitor/version1/plot.py b/robots/little_john/telemetry/code/monitor/version1/plot.py index 4154b91..7f00256 100644 --- a/robots/little_john/telemetry/code/monitor/version1/plot.py +++ b/robots/little_john/telemetry/code/monitor/version1/plot.py @@ -57,7 +57,6 @@ class Plot(pyglet.window.Window): def drawLine(self, series): xscale = float(self.series.xlimits[1]-self.series.xlimits[0])/(self.bounds[0][1]-self.bounds[0][0]) yscale = float(self.series.ylimits[1]-self.series.ylimits[0])/(self.bounds[1][1]-self.bounds[1][0]) - logging.debug("xscale = " + str(xscale) + ", yscale = " + str(yscale)) lmar = int(self.width * self.margins[0]) rmar = int(self.width * self.margins[1]) tmar = int(self.height * self.margins[0]) diff --git a/robots/little_john/telemetry/code/monitor/version1/series.py b/robots/little_john/telemetry/code/monitor/version1/series.py index 517a26a..a19e990 100644 --- a/robots/little_john/telemetry/code/monitor/version1/series.py +++ b/robots/little_john/telemetry/code/monitor/version1/series.py @@ -2,9 +2,10 @@ # Written as a telemetry tool by: # The UoN Robot Wars Project, 2018 +import logging class Series: - def __init__(self, points=300, title="Series title", xname="x-axis name", yname="y-axis name"): + def __init__(self, points=100, title="Series title", xname="x-axis name", yname="y-axis name"): """Set up an object to store a 2D data series""" # Proposal: # In order to neatly handle multiple lines on the same graph @@ -24,6 +25,8 @@ class Series: self.data = [] self.points = points + logging.info("Created series: " + title) + def addpoint(self, point): """Add a point to the dataset, and remove the oldest, if necessary""" self.data.append(point) -- libgit2 0.21.2