src/ChartiSpindel.cpp

changeset 498
c6f957fa7442
parent 494
49ac23d25f61
child 501
a01ae5ff0e96
--- a/src/ChartiSpindel.cpp	Fri Jul 07 20:17:21 2023 +0200
+++ b/src/ChartiSpindel.cpp	Sat Aug 19 16:58:03 2023 +0200
@@ -17,13 +17,14 @@
 #include "ChartiSpindel.h"
 #include "callout.h"
 #include "MainWindow.h"
+#include "Utils.h"
 
 
 ChartiSpindel::ChartiSpindel(QString code, QString name, QWidget *parent) : QDialog(parent)
 {
     QSqlQuery query;
     double timestamp;
-    double sg_min = 1.2, sg_max = 0.8, sg;
+    double sg_min = 1.2, sg_max = 0.8, mg, sg;
     double temp_min = 100, temp_max = 0, temp;
     double batt_min = 4.5, batt_max = 3.0, batt;
 
@@ -57,18 +58,22 @@
     while (query.next()) {
         timestamp = query.value("datetime").toDateTime().toSecsSinceEpoch() * 1000;
 
-	sg = query.value("sg").toDouble();
-	if ((ceil(sg * 100) / 100) > sg_max)
-	    sg_max = ceil(sg * 100) / 100;
-	if ((floor(sg * 100) / 100) < sg_min)
-	    sg_min = floor(sg * 100) / 100;
-
+	mg = query.value("sg").toDouble();
 	temp = query.value("temperature").toDouble();
 	if (ceil(temp) > temp_max)
 	    temp_max = ceil(temp);
 	if (floor(temp) < temp_min)
 	    temp_min = floor(temp);
 
+	/*
+	 * Correct the SG plotline for temperature.
+	 */
+	sg = Utils::HydroCorrection(mg, temp, 20.0);
+	if ((ceil(sg * 100) / 100) > sg_max)
+            sg_max = ceil(sg * 100) / 100;
+        if ((floor(sg * 100) / 100) < sg_min)
+            sg_min = floor(sg * 100) / 100;
+
 	batt = round(query.value("battery").toDouble() * 500) / 500;
 	if ((ceil(batt * 10) / 10) > batt_max)
 	    batt_max = ceil(batt * 10) / 10;

mercurial