Commit 9f35a9a4 authored by Pedro Henrique Kopper's avatar Pedro Henrique Kopper

Interface now auto-pans instead of rescaling

parent f6397c49
# Este arquivo define a interface a ser utilizada # Este arquivo define a interface a ser utilizada
device: device:
type: mock type: instrument-interface
location: "/dev/ttyUSB0" location: "/dev/ttyUSB0"
channels: channels:
- id: 0 - id: 0
...@@ -27,7 +27,7 @@ class Graph(QThread): ...@@ -27,7 +27,7 @@ class Graph(QThread):
def run(self): def run(self):
while self.running: while self.running:
data = self.interface.readAll() data = self.interface.readAll()
#print(len(self.dataX[0])) self.graph.getPlotItem().getViewBox().setRange(xRange=(self.dataX[0][-1] - 10, self.dataX[0][-1])) # Força atualização do range do x com span de 5 segundos
for i, channel in enumerate(self.plots): for i, channel in enumerate(self.plots):
self.dataX[i].append(self.dataX[i][-1] + self.interval) self.dataX[i].append(self.dataX[i][-1] + self.interval)
self.dataY[i].append(data[i]) self.dataY[i].append(data[i])
...@@ -42,7 +42,12 @@ class Graph(QThread): ...@@ -42,7 +42,12 @@ class Graph(QThread):
def _configurePlots(self): def _configurePlots(self):
first = True first = True
self.graph.getPlotItem().addLegend() pltItem = self.graph.getPlotItem()
self.logger("[GRAPH]", "Found new device {}".format(self.config["device"]["type"])) self.logger("[GRAPH]", "Found new device {}".format(self.config["device"]["type"]))
for channel in self.config["device"]["channels"]: for channel in self.config["device"]["channels"]:
self.logger("[GRAPH]", "Added channel {}".format(channel["name"])) self.logger("[GRAPH]", "Added channel {}".format(channel["name"]))
...@@ -51,9 +56,9 @@ class Graph(QThread): ...@@ -51,9 +56,9 @@ class Graph(QThread):
plot = self.graph.plot(pen=mkPen(mkColor(channel["color"]), width=2), name=channel["name"]) plot = self.graph.plot(pen=mkPen(mkColor(channel["color"]), width=2), name=channel["name"])
self.plots.append(plot) self.plots.append(plot)
if first: if first:
self.graph.getPlotItem().setLabel("left", text=channel["name"], units=channel["unit"]) pltItem.setLabel("left", text=channel["name"], units=channel["unit"])
first = False first = False
else: else:
self.graph.getPlotItem().setLabel("right", text=channel["name"], units=channel["unit"]) pltItem.setLabel("right", text=channel["name"], units=channel["unit"])
self.graph.getPlotItem().setLabel("bottom", text="Tempo", units="s") pltItem.setLabel("bottom", text="Tempo", units="s")
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment