diff --git a/model.py b/model.py index 3e2c421..19b5a68 100644 --- a/model.py +++ b/model.py @@ -10,7 +10,7 @@ from sensor import Sensor class Model: def __init__(self): - self.sensors = {"temp": Sensor()} + self.sensors = {"temp": Sensor(), "keks": Sensor()} self.drivers = [] self.measurement = None self.plot_data = None diff --git a/plot_data.py b/plot_data.py index c47b480..3e8abfa 100644 --- a/plot_data.py +++ b/plot_data.py @@ -19,9 +19,24 @@ class PlotData(): self.queues[sensor_name] = [] self.data[sensor_name] = np.full_like(self.data["time"], np.nan) - for data_tuple in data: + for data_tuple in data.values(): self.queues[sensor_name].append(data_tuple) + running = True + while running: + #TODO timeout clean + for que in self.queues.values(): + if len(que) == 0: + running = False + break + + for sensor,que in self.queues.items(): + self.data[sensor] = np.append(self.data[sensor], que[0]) + que = que[1:] + + + + """ TODO while true @@ -29,6 +44,6 @@ class PlotData(): for q in que: if q is empty return - update np array + update np array """ diff --git a/view.py b/view.py index 520229f..93da7d1 100644 --- a/view.py +++ b/view.py @@ -32,7 +32,7 @@ class PlotPanel(wx.Panel): def __init__(self, parent, model): super().__init__(parent, -1) self.model = model - self.fig = Figure((3, 3), 75) + self.fig = Figure((15, 10), 75) self.canvas = FigureCanvas(self, -1, self.fig) self.toolbar = NavigationToolbar(self.canvas) # matplotlib toolbar self.toolbar.Realize() @@ -52,8 +52,9 @@ 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, "-.") + (self.im,) = self.ax.plot(self.x, self.y, "-.",label="temp") self.toolbar.update() # Not sure why this is needed - ADS def get_toolbar(self):