aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Buesch <m@bues.ch>2018-07-30 19:33:36 +0200
committerMichael Buesch <m@bues.ch>2018-07-30 19:33:36 +0200
commitd694c896a46bc8320c61524f361ab247f0241909 (patch)
tree4b59bbee9069d13aadcc40f86700549946f98b01
parentd6ed6ad0ec302ef11e99b0949d687408c533a036 (diff)
downloadxytronic-lf-d694c896a46bc8320c61524f361ab247f0241909.zip
xytronic-lf-d694c896a46bc8320c61524f361ab247f0241909.tar.xz
simulator: Add PID values
Signed-off-by: Michael Buesch <m@bues.ch>
-rwxr-xr-xfirmware/simulator/xytronic_simulator.py57
-rwxr-xr-xfirmware/simulator/xytronic_simulator_gui.py446
2 files changed, 340 insertions, 163 deletions
diff --git a/firmware/simulator/xytronic_simulator.py b/firmware/simulator/xytronic_simulator.py
index 68b7af8..5da3cb4 100755
--- a/firmware/simulator/xytronic_simulator.py
+++ b/firmware/simulator/xytronic_simulator.py
@@ -172,6 +172,16 @@ class Simulator(object):
self.dbg_filtCurr = 0
self.dbg_measTemp = 0
self.dbg_boostMode = 0
+ self.dbg_pidTempE = 0.0
+ self.dbg_pidTempP = 0.0
+ self.dbg_pidTempI = 0.0
+ self.dbg_pidTempD = 0.0
+ self.dbg_pidTempPrevE = 0.0
+ self.dbg_pidCurrE = 0.0
+ self.dbg_pidCurrP = 0.0
+ self.dbg_pidCurrI = 0.0
+ self.dbg_pidCurrD = 0.0
+ self.dbg_pidCurrPrevE = 0.0
@classmethod
def __parseInt(cls, valStr, valIdent):
@@ -209,34 +219,75 @@ class Simulator(object):
line = line[i+1:].strip()
elems = line.split()
- if len(elems) != 2:
+ if len(elems) < 2 or len(elems) > 3:
self.error("Unknown format: %s" % line)
return
if elems[0] == "cr1":
self.dbg_currentRealR = self.__parseFixpt(elems[1], "cr1") / self.CURR_DIV
+ return
elif elems[0] == "cr2":
self.dbg_currentUsedR = self.__parseFixpt(elems[1], "cr2") / self.CURR_DIV
+ return
elif elems[0] == "rs":
self.dbg_currentRState = self.__parseInt(elems[1], "rs")
+ return
elif elems[0] == "cy":
self.dbg_currentY = self.__parseFixpt(elems[1], "cy") / self.CURR_DIV
+ return
elif elems[0] == "tr":
self.dbg_tempR = self.__parseFixpt(elems[1], "tr")
+ return
elif elems[0] == "ty1":
self.dbg_tempY1 = self.__parseFixpt(elems[1], "ty1")
+ return
elif elems[0] == "ty2":
self.dbg_tempY2 = self.__parseFixpt(elems[1], "ty2") / self.CURR_DIV
+ return
elif elems[0] == "tb":
self.dbg_boostMode = self.__parseInt(elems[1], "tb")
+ return
elif elems[0] == "mc":
self.dbg_measCurr = self.__parseInt(elems[1], "mc")
+ return
elif elems[0] == "fc":
self.dbg_filtCurr = self.__parseInt(elems[1], "fc")
+ return
elif elems[0] == "mt":
self.dbg_measTemp = self.__parseInt(elems[1], "mt")
- else:
- self.error("Unknown elem: %s" % elems[0])
return
+ elif elems[0] == "pid-t" and len(elems) == 3:
+ if elems[1] == "e":
+ self.dbg_pidTempE = self.__parseFixpt(elems[2], "pid-t e")
+ return
+ elif elems[1] == "p":
+ self.dbg_pidTempP = self.__parseFixpt(elems[2], "pid-t p")
+ return
+ elif elems[1] == "i":
+ self.dbg_pidTempI = self.__parseFixpt(elems[2], "pid-t i")
+ return
+ elif elems[1] == "d":
+ self.dbg_pidTempD = self.__parseFixpt(elems[2], "pid-t d")
+ return
+ elif elems[1] == "pe":
+ self.dbg_pidTempPrevE = self.__parseFixpt(elems[2], "pid-t pe")
+ return
+ elif elems[0] == "pid-c" and len(elems) == 3:
+ if elems[1] == "e":
+ self.dbg_pidCurrE = self.__parseFixpt(elems[2], "pid-c e")
+ return
+ elif elems[1] == "p":
+ self.dbg_pidCurrP = self.__parseFixpt(elems[2], "pid-c p")
+ return
+ elif elems[1] == "i":
+ self.dbg_pidCurrI = self.__parseFixpt(elems[2], "pid-c i")
+ return
+ elif elems[1] == "d":
+ self.dbg_pidCurrD = self.__parseFixpt(elems[2], "pid-c d")
+ return
+ elif elems[1] == "pe":
+ self.dbg_pidCurrPrevE = self.__parseFixpt(elems[2], "pid-c pe")
+ return
+ self.error("Unknown elem: %s" % elems[0])
@classmethod
def error(cls, msg):
diff --git a/firmware/simulator/xytronic_simulator_gui.py b/firmware/simulator/xytronic_simulator_gui.py
index 94f21ca..e15a186 100755
--- a/firmware/simulator/xytronic_simulator_gui.py
+++ b/firmware/simulator/xytronic_simulator_gui.py
@@ -46,6 +46,16 @@ class Measurements(object):
dbg_filtCurr = 0
dbg_measTemp = 0
dbg_boostMode = 0
+ dbg_pidTempE = 0.0
+ dbg_pidTempP = 0.0
+ dbg_pidTempI = 0.0
+ dbg_pidTempD = 0.0
+ dbg_pidTempPrevE = 0.0
+ dbg_pidCurrE = 0.0
+ dbg_pidCurrP = 0.0
+ dbg_pidCurrI = 0.0
+ dbg_pidCurrD = 0.0
+ dbg_pidCurrPrevE = 0.0
class SimulatorProcess(multiprocessing.Process):
def __init__(self, *args, **kwargs):
@@ -75,6 +85,16 @@ class SimulatorProcess(multiprocessing.Process):
meas.dbg_filtCurr = self.__sim.dbg_filtCurr
meas.dbg_measTemp = self.__sim.dbg_measTemp
meas.dbg_boostMode = self.__sim.dbg_boostMode
+ meas.dbg_pidTempE = self.__sim.dbg_pidTempE
+ meas.dbg_pidTempP = self.__sim.dbg_pidTempP
+ meas.dbg_pidTempI = self.__sim.dbg_pidTempI
+ meas.dbg_pidTempD = self.__sim.dbg_pidTempD
+ meas.dbg_pidTempPrevE = self.__sim.dbg_pidTempPrevE
+ meas.dbg_pidCurrE = self.__sim.dbg_pidCurrE
+ meas.dbg_pidCurrP = self.__sim.dbg_pidCurrP
+ meas.dbg_pidCurrI = self.__sim.dbg_pidCurrI
+ meas.dbg_pidCurrD = self.__sim.dbg_pidCurrD
+ meas.dbg_pidCurrPrevE = self.__sim.dbg_pidCurrPrevE
self.__responses.put(("meas", meas))
def requestMeasurements(self):
@@ -124,13 +144,189 @@ class SimulatorProcess(multiprocessing.Process):
self.__commands.put(("stop", None))
self.join()
-class MainChart(QChart):
- def __init__(self):
- super().__init__()
+class Chart(QChart):
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+
+class MainChart(Chart):
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+
+ self.lineSeries = {}
+ self.timeAxis = None
+ self.tempAxis = None
+ self.currentAxis = None
+ self.adcAxis = None
+ self.stateAxis = None
+
+ def rebuildChart(self,
+ enaLineCurrentRealR,
+ enaLineCurrentUsedR,
+ enaLineCurrentRState,
+ enaLineCurrentY,
+ enaLineTempR,
+ enaLineTempY1,
+ enaLineTempY2,
+ enaLineMeasCurr,
+ enaLineFiltCurr,
+ enaLineMeasTemp,
+ enaLineBoostMode):
+ self.removeAllSeries()
+
+ if self.timeAxis is None:
+ self.timeAxis = QValueAxis()
+ self.addAxis(self.timeAxis, Qt.AlignBottom)
+ self.timeAxis.setRange(0, 100)
+ self.timeAxis.setLabelFormat("%d s")
+ self.timeAxis.setTickCount(10)
+
+ if self.currentAxis is None:
+ self.currentAxis = QValueAxis()
+ self.addAxis(self.currentAxis, Qt.AlignLeft)
+ self.currentAxis.setLabelFormat("%.1f A")
+ self.currentAxis.setRange(0, 5)
+
+ if self.tempAxis is None:
+ self.tempAxis = QValueAxis()
+ self.addAxis(self.tempAxis, Qt.AlignLeft)
+ self.tempAxis.setLabelFormat("%d *C")
+ self.tempAxis.setRange(0, 600)
+
+ if self.adcAxis is None:
+ self.adcAxis = QValueAxis()
+ self.addAxis(self.adcAxis, Qt.AlignRight)
+ self.adcAxis.setLabelFormat("0x%X")
+ self.adcAxis.setRange(0, 0x3FF)
+
+ if self.stateAxis is None:
+ self.stateAxis = QValueAxis()
+ self.addAxis(self.stateAxis, Qt.AlignRight)
+ self.stateAxis.setTickCount(3)
+ self.stateAxis.setLabelFormat("%d")
+ self.stateAxis.setRange(0, 2)
+
+ self.lineSeries = {}
+ for name, description, ena, axis in (
+ ("crr", "Current real R (A)", enaLineCurrentRealR, self.currentAxis),
+ ("cur", "Current used R (A)", enaLineCurrentUsedR, self.currentAxis),
+ ("crs", "Current R state", enaLineCurrentRState, self.stateAxis),
+ ("cy", "Current Y (A)", enaLineCurrentY, self.currentAxis),
+ ("tr", "Temp R (*C)", enaLineTempR, self.tempAxis),
+ ("ty1", "Temp Y1 (*C)", enaLineTempY1, self.tempAxis),
+ ("ty2", "Temp Y2 (A)", enaLineTempY2, self.currentAxis),
+ ("mc", "Current ADC (hex)", enaLineMeasCurr, self.adcAxis),
+ ("fc", "Filtered current ADC (hex)", enaLineFiltCurr, self.adcAxis),
+ ("mt", "Temp ADC (hex)", enaLineMeasTemp, self.adcAxis),
+ ("bm", "Boost mode", enaLineBoostMode, self.stateAxis)):
+ if ena:
+ line = QLineSeries()
+ line.setName(description)
+ self.addSeries(line)
+ line.attachAxis(self.timeAxis)
+ line.attachAxis(axis)
+ self.lineSeries[name] = line
+
+ def updateChart(self, measurements, chartXCount):
+ for chartLine, value in (
+ (self.lineSeries.get("crr"), measurements.dbg_currentRealR),
+ (self.lineSeries.get("cur"), measurements.dbg_currentUsedR),
+ (self.lineSeries.get("crs"), measurements.dbg_currentRState),
+ (self.lineSeries.get("cy"), measurements.dbg_currentY),
+ (self.lineSeries.get("tr"), measurements.dbg_tempR),
+ (self.lineSeries.get("ty1"), measurements.dbg_tempY1),
+ (self.lineSeries.get("ty2"), measurements.dbg_tempY2),
+ (self.lineSeries.get("mc"), measurements.dbg_measCurr),
+ (self.lineSeries.get("fc"), measurements.dbg_filtCurr),
+ (self.lineSeries.get("mt"), measurements.dbg_measTemp),
+ (self.lineSeries.get("bm"), measurements.dbg_boostMode)):
+ if chartLine is None:
+ continue
+ chartLine.append(chartXCount - 1, value)
+ if chartXCount > 100:
+ chartLine.remove(0)
+ if chartXCount > 100:
+ self.timeAxis.setRange(chartXCount - 100,
+ chartXCount)
+
+class PidChart(Chart):
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+
+ self.lineSeries = {}
+ self.timeAxis = None
+ self.valueAxis = None
+
+ def rebuildChart(self,
+ enaLinePidCE,
+ enaLinePidCP,
+ enaLinePidCI,
+ enaLinePidCD,
+ enaLinePidCPE,
+ enaLinePidTE,
+ enaLinePidTP,
+ enaLinePidTI,
+ enaLinePidTD,
+ enaLinePidTPE):
+ self.removeAllSeries()
+
+ if self.timeAxis is None:
+ self.timeAxis = QValueAxis()
+ self.addAxis(self.timeAxis, Qt.AlignBottom)
+ self.timeAxis.setRange(0, 100)
+ self.timeAxis.setLabelFormat("%d s")
+ self.timeAxis.setTickCount(10)
-class MainChartView(QChartView):
- def __init__(self, chart, parent=None):
- super().__init__(chart, parent)
+ if self.valueAxis is None:
+ self.valueAxis = QValueAxis()
+ self.addAxis(self.valueAxis, Qt.AlignLeft)
+ self.valueAxis.setLabelFormat("%.2f")
+ self.valueAxis.setRange(-100, 100)
+
+ self.lineSeries = {}
+ for name, description, ena, axis in (
+ ("ce", "PID current e", enaLinePidCE, self.valueAxis),
+ ("cp", "PID current p", enaLinePidCP, self.valueAxis),
+ ("ci", "PID current i", enaLinePidCI, self.valueAxis),
+ ("cd", "PID current d", enaLinePidCD, self.valueAxis),
+ ("cpe", "PID current prev. e", enaLinePidCPE, self.valueAxis),
+ ("te", "PID temp e", enaLinePidTE, self.valueAxis),
+ ("tp", "PID temp p", enaLinePidTP, self.valueAxis),
+ ("ti", "PID temp i", enaLinePidTI, self.valueAxis),
+ ("td", "PID temp d", enaLinePidTD, self.valueAxis),
+ ("tpe", "PID temp prev. e", enaLinePidTPE, self.valueAxis)):
+ if ena:
+ line = QLineSeries()
+ line.setName(description)
+ self.addSeries(line)
+ line.attachAxis(self.timeAxis)
+ line.attachAxis(axis)
+ self.lineSeries[name] = line
+
+ def updateChart(self, measurements, chartXCount):
+ for chartLine, value in (
+ (self.lineSeries.get("ce"), measurements.dbg_pidCurrE),
+ (self.lineSeries.get("cp"), measurements.dbg_pidCurrP),
+ (self.lineSeries.get("ci"), measurements.dbg_pidCurrI),
+ (self.lineSeries.get("cd"), measurements.dbg_pidCurrD),
+ (self.lineSeries.get("cpe"), measurements.dbg_pidCurrPrevE),
+ (self.lineSeries.get("te"), measurements.dbg_pidTempE),
+ (self.lineSeries.get("tp"), measurements.dbg_pidTempP),
+ (self.lineSeries.get("ti"), measurements.dbg_pidTempI),
+ (self.lineSeries.get("td"), measurements.dbg_pidTempD),
+ (self.lineSeries.get("tpe"), measurements.dbg_pidTempPrevE)):
+ if chartLine is None:
+ continue
+ chartLine.append(chartXCount - 1, value)
+ if chartXCount > 100:
+ chartLine.remove(0)
+ if chartXCount > 100:
+ self.timeAxis.setRange(chartXCount - 100,
+ chartXCount)
+
+class ChartView(QChartView):
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.setRenderHint(QPainter.Antialiasing)
class MainWidget(QWidget):
def __init__(self, parent=None):
@@ -139,16 +335,17 @@ class MainWidget(QWidget):
self.simProc = None
- self.chart = MainChart()
- self.chartView = MainChartView(self.chart, self)
- self.chartView.setRenderHint(QPainter.Antialiasing)
- self.layout().addWidget(self.chartView, 0, 0, 2, 1)
+ chartVBox = QVBoxLayout()
- self.timeAxis = None
- self.tempAxis = None
- self.currentAxis = None
- self.adcAxis = None
- self.stateAxis = None
+ self.mainChart = MainChart()
+ self.mainChartView = ChartView(self.mainChart, self)
+ chartVBox.addWidget(self.mainChartView)
+
+ self.pidChart = PidChart()
+ self.pidChartView = ChartView(self.pidChart, self)
+ chartVBox.addWidget(self.pidChartView)
+
+ self.layout().addLayout(chartVBox, 0, 0, 2, 1)
self.measGroup = QGroupBox(self)
self.measGroup.setLayout(QGridLayout())
@@ -165,6 +362,21 @@ class MainWidget(QWidget):
self.enaLineCurrentY = QCheckBox("Current-Y", self)
self.measGroup.layout().addWidget(self.enaLineCurrentY, 3, 0)
+ self.enaLinePidCE = QCheckBox("Current PID e", self)
+ self.measGroup.layout().addWidget(self.enaLinePidCE, 4, 0)
+
+ self.enaLinePidCP = QCheckBox("Current PID p", self)
+ self.measGroup.layout().addWidget(self.enaLinePidCP, 5, 0)
+
+ self.enaLinePidCI = QCheckBox("Current PID i", self)
+ self.measGroup.layout().addWidget(self.enaLinePidCI, 6, 0)
+
+ self.enaLinePidCD = QCheckBox("Current PID d", self)
+ self.measGroup.layout().addWidget(self.enaLinePidCD, 7, 0)
+
+ self.enaLinePidCPE = QCheckBox("Current PID prev-e", self)
+ self.measGroup.layout().addWidget(self.enaLinePidCPE, 8, 0)
+
self.enaLineTempR = QCheckBox("Temp R", self)
self.enaLineTempR.setCheckState(Qt.Checked)
self.measGroup.layout().addWidget(self.enaLineTempR, 0, 1)
@@ -176,6 +388,25 @@ class MainWidget(QWidget):
self.enaLineTempY2 = QCheckBox("Temp Y2", self)
self.measGroup.layout().addWidget(self.enaLineTempY2, 2, 1)
+ self.enaLinePidTE = QCheckBox("Temp PID e", self)
+ self.enaLinePidTE.setCheckState(Qt.Checked)
+ self.measGroup.layout().addWidget(self.enaLinePidTE, 3, 1)
+
+ self.enaLinePidTP = QCheckBox("Temp PID p", self)
+ self.enaLinePidTP.setCheckState(Qt.Checked)
+ self.measGroup.layout().addWidget(self.enaLinePidTP, 4, 1)
+
+ self.enaLinePidTI = QCheckBox("Temp PID i", self)
+ self.enaLinePidTI.setCheckState(Qt.Checked)
+ self.measGroup.layout().addWidget(self.enaLinePidTI, 5, 1)
+
+ self.enaLinePidTD = QCheckBox("Temp PID d", self)
+ self.enaLinePidTD.setCheckState(Qt.Checked)
+ self.measGroup.layout().addWidget(self.enaLinePidTD, 6, 1)
+
+ self.enaLinePidTPE = QCheckBox("Temp PID prev-e", self)
+ self.measGroup.layout().addWidget(self.enaLinePidTPE, 7, 1)
+
self.enaLineMeasCurr = QCheckBox("Current ADC", self)
self.measGroup.layout().addWidget(self.enaLineMeasCurr, 0, 2)
@@ -217,9 +448,19 @@ class MainWidget(QWidget):
self.enaLineCurrentUsedR.stateChanged.connect(self.__handleChartChange)
self.enaLineCurrentRState.stateChanged.connect(self.__handleChartChange)
self.enaLineCurrentY.stateChanged.connect(self.__handleChartChange)
+ self.enaLinePidCE.stateChanged.connect(self.__handleChartChange)
+ self.enaLinePidCP.stateChanged.connect(self.__handleChartChange)
+ self.enaLinePidCI.stateChanged.connect(self.__handleChartChange)
+ self.enaLinePidCD.stateChanged.connect(self.__handleChartChange)
+ self.enaLinePidCPE.stateChanged.connect(self.__handleChartChange)
self.enaLineTempR.stateChanged.connect(self.__handleChartChange)
self.enaLineTempY1.stateChanged.connect(self.__handleChartChange)
self.enaLineTempY2.stateChanged.connect(self.__handleChartChange)
+ self.enaLinePidTE.stateChanged.connect(self.__handleChartChange)
+ self.enaLinePidTP.stateChanged.connect(self.__handleChartChange)
+ self.enaLinePidTI.stateChanged.connect(self.__handleChartChange)
+ self.enaLinePidTD.stateChanged.connect(self.__handleChartChange)
+ self.enaLinePidTPE.stateChanged.connect(self.__handleChartChange)
self.enaLineMeasCurr.stateChanged.connect(self.__handleChartChange)
self.enaLineFiltCurr.stateChanged.connect(self.__handleChartChange)
self.enaLineMeasTemp.stateChanged.connect(self.__handleChartChange)
@@ -239,129 +480,31 @@ class MainWidget(QWidget):
self.__handleValueChange()
def __handleChartChange(self):
- self.chart.removeAllSeries()
-
- if self.timeAxis is None:
- self.timeAxis = QValueAxis()
- self.chart.addAxis(self.timeAxis, Qt.AlignBottom)
- self.timeAxis.setRange(0, 100)
- self.timeAxis.setLabelFormat("%d s")
- self.timeAxis.setTickCount(10)
-
- if self.currentAxis is None:
- self.currentAxis = QValueAxis()
- self.chart.addAxis(self.currentAxis, Qt.AlignLeft)
- self.currentAxis.setLabelFormat("%.1f A")
- self.currentAxis.setRange(0, 5)
-
- if self.tempAxis is None:
- self.tempAxis = QValueAxis()
- self.chart.addAxis(self.tempAxis, Qt.AlignLeft)
- self.tempAxis.setLabelFormat("%d *C")
- self.tempAxis.setRange(0, 600)
-
- if self.adcAxis is None:
- self.adcAxis = QValueAxis()
- self.chart.addAxis(self.adcAxis, Qt.AlignRight)
- self.adcAxis.setLabelFormat("0x%X")
- self.adcAxis.setRange(0, 0x3FF)
-
- if self.stateAxis is None:
- self.stateAxis = QValueAxis()
- self.chart.addAxis(self.stateAxis, Qt.AlignRight)
- self.stateAxis.setTickCount(3)
- self.stateAxis.setLabelFormat("%d")
- self.stateAxis.setRange(0, 2)
-
- self.chartLineCurrentRealR = None
- self.chartLineCurrentUsedR = None
- self.chartLineCurrentRState = None
- self.chartLineCurrentY = None
- self.chartLineTempR = None
- self.chartLineTempY1 = None
- self.chartLineTempY2 = None
- self.chartLineMeasCurr = None
- self.chartLineFiltCurr = None
- self.chartLineMeasTemp = None
- self.chartLineBoostMode = None
-
- if self.enaLineCurrentRealR.checkState() == Qt.Checked:
- self.chartLineCurrentRealR = QLineSeries()
- self.chartLineCurrentRealR.setName("Current real R (A)")
- self.chart.addSeries(self.chartLineCurrentRealR)
- self.chartLineCurrentRealR.attachAxis(self.timeAxis)
- self.chartLineCurrentRealR.attachAxis(self.currentAxis)
-
- if self.enaLineCurrentUsedR.checkState() == Qt.Checked:
- self.chartLineCurrentUsedR = QLineSeries()
- self.chartLineCurrentUsedR.setName("Current used R (A)")
- self.chart.addSeries(self.chartLineCurrentUsedR)
- self.chartLineCurrentUsedR.attachAxis(self.timeAxis)
- self.chartLineCurrentUsedR.attachAxis(self.currentAxis)
-
- if self.enaLineCurrentRState.checkState() == Qt.Checked:
- self.chartLineCurrentRState = QLineSeries()
- self.chartLineCurrentRState.setName("Current R state")
- self.chart.addSeries(self.chartLineCurrentRState)
- self.chartLineCurrentRState.attachAxis(self.timeAxis)
- self.chartLineCurrentRState.attachAxis(self.stateAxis)
-
- if self.enaLineCurrentY.checkState() == Qt.Checked:
- self.chartLineCurrentY = QLineSeries()
- self.chartLineCurrentY.setName("Current Y (A)")
- self.chart.addSeries(self.chartLineCurrentY)
- self.chartLineCurrentY.attachAxis(self.timeAxis)
- self.chartLineCurrentY.attachAxis(self.currentAxis)
-
- if self.enaLineTempR.checkState() == Qt.Checked:
- self.chartLineTempR = QLineSeries()
- self.chartLineTempR.setName("Temp R (*C)")
- self.chart.addSeries(self.chartLineTempR)
- self.chartLineTempR.attachAxis(self.timeAxis)
- self.chartLineTempR.attachAxis(self.tempAxis)
-
- if self.enaLineTempY1.checkState() == Qt.Checked:
- self.chartLineTempY1 = QLineSeries()
- self.chartLineTempY1.setName("Temp Y1 (*C)")
- self.chart.addSeries(self.chartLineTempY1)
- self.chartLineTempY1.attachAxis(self.timeAxis)
- self.chartLineTempY1.attachAxis(self.tempAxis)
-
- if self.enaLineTempY2.checkState() == Qt.Checked:
- self.chartLineTempY2 = QLineSeries()
- self.chartLineTempY2.setName("Temp Y2 (A)")
- self.chart.addSeries(self.chartLineTempY2)
- self.chartLineTempY2.attachAxis(self.timeAxis)
- self.chartLineTempY2.attachAxis(self.currentAxis)
-
- if self.enaLineMeasCurr.checkState() == Qt.Checked:
- self.chartLineMeasCurr = QLineSeries()
- self.chartLineMeasCurr.setName("Current ADC (hex)")
- self.chart.addSeries(self.chartLineMeasCurr)
- self.chartLineMeasCurr.attachAxis(self.timeAxis)
- self.chartLineMeasCurr.attachAxis(self.adcAxis)
-
- if self.enaLineFiltCurr.checkState() == Qt.Checked:
- self.chartLineFiltCurr = QLineSeries()
- self.chartLineFiltCurr.setName("Filtered current ADC (hex)")
- self.chart.addSeries(self.chartLineFiltCurr)
- self.chartLineFiltCurr.attachAxis(self.timeAxis)
- self.chartLineFiltCurr.attachAxis(self.adcAxis)
-
- if self.enaLineMeasTemp.checkState() == Qt.Checked:
- self.chartLineMeasTemp = QLineSeries()
- self.chartLineMeasTemp.setName("Temp ADC (hex)")
- self.chart.addSeries(self.chartLineMeasTemp)
- self.chartLineMeasTemp.attachAxis(self.timeAxis)
- self.chartLineMeasTemp.attachAxis(self.adcAxis)
-
- if self.enaLineBoostMode.checkState() == Qt.Checked:
- self.chartLineBoostMode = QLineSeries()
- self.chartLineBoostMode.setName("Boost mode")
- self.chart.addSeries(self.chartLineBoostMode)
- self.chartLineBoostMode.attachAxis(self.timeAxis)
- self.chartLineBoostMode.attachAxis(self.stateAxis)
-
+ self.mainChart.rebuildChart(
+ enaLineCurrentRealR=(self.enaLineCurrentRealR.checkState() == Qt.Checked),
+ enaLineCurrentUsedR=(self.enaLineCurrentUsedR.checkState() == Qt.Checked),
+ enaLineCurrentRState=(self.enaLineCurrentRState.checkState() == Qt.Checked),
+ enaLineCurrentY=(self.enaLineCurrentY.checkState() == Qt.Checked),
+ enaLineTempR=(self.enaLineTempR.checkState() == Qt.Checked),
+ enaLineTempY1=(self.enaLineTempY1.checkState() == Qt.Checked),
+ enaLineTempY2=(self.enaLineTempY2.checkState() == Qt.Checked),
+ enaLineMeasCurr=(self.enaLineMeasCurr.checkState() == Qt.Checked),
+ enaLineFiltCurr=(self.enaLineFiltCurr.checkState() == Qt.Checked),
+ enaLineMeasTemp=(self.enaLineMeasTemp.checkState() == Qt.Checked),
+ enaLineBoostMode=(self.enaLineBoostMode.checkState() == Qt.Checked),
+ )
+ self.pidChart.rebuildChart(
+ enaLinePidCE=(self.enaLinePidCE.checkState() == Qt.Checked),
+ enaLinePidCP=(self.enaLinePidCP.checkState() == Qt.Checked),
+ enaLinePidCI=(self.enaLinePidCI.checkState() == Qt.Checked),
+ enaLinePidCD=(self.enaLinePidCD.checkState() == Qt.Checked),
+ enaLinePidCPE=(self.enaLinePidCPE.checkState() == Qt.Checked),
+ enaLinePidTE=(self.enaLinePidTE.checkState() == Qt.Checked),
+ enaLinePidTP=(self.enaLinePidTP.checkState() == Qt.Checked),
+ enaLinePidTI=(self.enaLinePidTI.checkState() == Qt.Checked),
+ enaLinePidTD=(self.enaLinePidTD.checkState() == Qt.Checked),
+ enaLinePidTPE=(self.enaLinePidTPE.checkState() == Qt.Checked),
+ )
self.chartXCount = 0
def __handleValueChange(self):
@@ -371,28 +514,11 @@ class MainWidget(QWidget):
def __chartUpdate(self):
for ident, args in self.simProc.getResponses():
if ident == "meas":
- meas = args
self.chartXCount += 1
- for chartLine, value in (
- (self.chartLineCurrentRealR, meas.dbg_currentRealR),
- (self.chartLineCurrentUsedR, meas.dbg_currentUsedR),
- (self.chartLineCurrentRState, meas.dbg_currentRState),
- (self.chartLineCurrentY, meas.dbg_currentY),
- (self.chartLineTempR, meas.dbg_tempR),
- (self.chartLineTempY1, meas.dbg_tempY1),
- (self.chartLineTempY2, meas.dbg_tempY2),
- (self.chartLineMeasCurr, meas.dbg_measCurr),
- (self.chartLineFiltCurr, meas.dbg_filtCurr),
- (self.chartLineMeasTemp, meas.dbg_measTemp),
- (self.chartLineBoostMode, meas.dbg_boostMode)):
- if chartLine is None:
- continue
- chartLine.append(self.chartXCount - 1, value)
- if self.chartXCount > 100:
- chartLine.remove(0)
- if self.chartXCount > 100:
- self.chart.axisX().setRange(self.chartXCount - 100,
- self.chartXCount)
+ self.mainChart.updateChart(measurements=args,
+ chartXCount=self.chartXCount)
+ self.pidChart.updateChart(measurements=args,
+ chartXCount=self.chartXCount)
self.simProc.requestMeasurements()
class MainWindow(QMainWindow):
@@ -403,7 +529,7 @@ class MainWindow(QMainWindow):
self.mainWidget = MainWidget(self)
self.setCentralWidget(self.mainWidget)
- self.resize(1100, 500)
+ self.resize(1500, 700)
def closeEvent(self, ev):
self.mainWidget.simProc.shutdown()
bues.ch cgit interface