From f3e5bb69bfe293f4cc5ab3f31b12a911ee874f31 Mon Sep 17 00:00:00 2001 From: atse Date: Mon, 27 Nov 2023 11:51:31 +0800 Subject: [PATCH] Get rid of the setpoint line out-of-range problem --- pytec/tec_qt.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pytec/tec_qt.py b/pytec/tec_qt.py index 2a1f253..dad267c 100644 --- a/pytec/tec_qt.py +++ b/pytec/tec_qt.py @@ -158,6 +158,7 @@ class ChannelGraphs: self._t_line = self._t_widget.getPlotItem().addLine(label='{value} °C') self._t_line.setVisible(False) + self._t_setpoint_plot = LiveLinePlot() # Hack for keeping setpoint line in plot range for graph in t_widget, i_widget: time_axis = LiveAxis('bottom', text="Time since Thermostat reset", **{Axis.TICK_FORMAT: Axis.DURATION}) @@ -179,10 +180,12 @@ class ChannelGraphs: i_widget.addLegend(brush=(50, 50, 200, 150)) t_widget.addItem(self._t_plot) + t_widget.addItem(self._t_setpoint_plot) i_widget.addItem(self._i_plot) i_widget.addItem(self._iset_plot) self.t_connector = DataConnector(self._t_plot, max_points=self.DEFAULT_MAX_SAMPLES) + self.t_setpoint_connector = DataConnector(self._t_setpoint_plot, max_points=1) self.i_connector = DataConnector(self._i_plot, max_points=self.DEFAULT_MAX_SAMPLES) self.iset_connector = DataConnector(self._iset_plot, max_points=self.DEFAULT_MAX_SAMPLES) @@ -196,6 +199,10 @@ class ChannelGraphs: if temperature is not None: self.t_connector.cb_append_data_point(temperature, time) + if self._t_line.isVisible(): + self.t_setpoint_connector.cb_append_data_point(self._t_line.value(), time) + else: + self.t_setpoint_connector.cb_append_data_point(temperature, time) self.i_connector.cb_append_data_point(current, time) self.iset_connector.cb_append_data_point(iset, time)