Added power useage to the brew log.

Sat, 18 Jun 2022 19:15:22 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 18 Jun 2022 19:15:22 +0200
changeset 295
4b2ac345b982
parent 294
afc763d9fd89
child 296
2f4e250cfed9

Added power useage to the brew log.

src/EditProductTab9.cpp file | annotate | diff | comparison | revisions
--- a/src/EditProductTab9.cpp	Thu Jun 16 11:45:20 2022 +0200
+++ b/src/EditProductTab9.cpp	Sat Jun 18 19:15:22 2022 +0200
@@ -29,7 +29,7 @@
  *           days from the start.
  *        4. startdate and enddate and times are set and valid. Block
  *           the startdate setting. But only after setting a lot of
- *           brewdata move the fase to primary.
+ *           brewdata and acknowledge set the fase to primary.
  *
  */
 void EditProduct::updateBrewday()
@@ -475,8 +475,11 @@
     pv_mlt->setName("MLT");
     QLineSeries *sp_mlt = new QLineSeries();
     sp_mlt->setName("Set");
+    sp_mlt->setOpacity(0.75);
     QLineSeries *pv_hlt = new QLineSeries();
     pv_hlt->setName("HLT");
+    QLineSeries *pwm_mlt1 = new QLineSeries();	// Top side of area
+    QLineSeries *pwm_mlt0 = new QLineSeries();	// Bottom side of area
 
     query.prepare("SELECT * FROM log_brews WHERE code=:code ORDER BY datetime");
     query.bindValue(":code", product->code);
@@ -485,14 +488,25 @@
 	timestamp = query.value("datetime").toDateTime().toSecsSinceEpoch() * 1000;
 	pv_mlt->append(timestamp, query.value("pv_mlt").toDouble());
 	sp_mlt->append(timestamp, query.value("sp_mlt").toDouble());
-	pv_hlt->append(timestamp, query.value("pv_hlt").toDouble());
+	if (query.value("pv_hlt").toDouble() > 0)
+	    pv_hlt->append(timestamp, query.value("pv_hlt").toDouble());
+	pwm_mlt0->append(timestamp, 0);
+	pwm_mlt1->append(timestamp, query.value("pwm_mlt").toInt());
     }
 
+    QPen pen(QColorConstants::Svg::navy);
+    pen.setWidth(3);
+    pv_mlt->setPen(pen);
+    QAreaSeries *pwm_mlt = new QAreaSeries(pwm_mlt0, pwm_mlt1);
+    pwm_mlt->setName("MLT pwr");
+    pwm_mlt->setOpacity(0.25);
+
     QChart *chart = new QChart();
     chart->setTitle(QString("%1 \"%2\"").arg(product->code).arg(product->name));
-    chart->addSeries(pv_mlt); //  Add dataset to chart
+    chart->addSeries(pwm_mlt);	// Order is important, first drawn is lowest layer.
     chart->addSeries(sp_mlt);
     chart->addSeries(pv_hlt);
+    chart->addSeries(pv_mlt);	// Top layer.
 
     QDateTimeAxis *axisX = new QDateTimeAxis;
     axisX->setTickCount(20);
@@ -501,22 +515,24 @@
     axisX->setLabelsFont(QFont("Helvetica", 8, QFont::Normal));
     chart->addAxis(axisX, Qt::AlignBottom);
     pv_mlt->attachAxis(axisX);
+    pv_hlt->attachAxis(axisX);
 
     QValueAxis *axisY = new QValueAxis;
-    axisY->setRange(5, 105);
-    axisY->setTickCount(11);
+    axisY->setRange(0, 110);
+    axisY->setTickCount(12);
     axisY->setMinorTickCount(1);
     axisY->setLabelFormat("%i");
-    axisY->setTitleText("Temp");
+    axisY->setTitleText("Temp/Power");
     axisY->setLabelsFont(QFont("Helvetica", 8, QFont::Normal));
     chart->addAxis(axisY, Qt::AlignLeft);
+
+    pwm_mlt->attachAxis(axisY);
     pv_mlt->attachAxis(axisY);
     sp_mlt->attachAxis(axisY);
     pv_hlt->attachAxis(axisY);
 
     QChartView *chartView = new QChartView(chart);
     chartView->setRenderHint(QPainter::Antialiasing);
-//    chartView->chart()->setTheme(QChart::ChartThemeBlueCerulean);
     dialog->setLayout(new QVBoxLayout);
     dialog->layout()->addWidget(chartView);
     dialog->layout()->addWidget(buttonBox);

mercurial