src/DetailCO2meter.cpp

Fri, 10 Feb 2023 14:06:47 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Fri, 10 Feb 2023 14:06:47 +0100
changeset 491
76f3a96e82b5
parent 444
4f626d0bb4d4
child 492
c3a781b4d35b
permissions
-rw-r--r--

Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.

328
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * DetailCO2meter.cpp is part of bmsapp.
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * bmsapp is free software: you can redistribute it and/or modify
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * the Free Software Foundation, either version 3 of the License, or
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * (at your option) any later version.
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 *
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * bmsapp is distributed in the hope that it will be useful,
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * GNU General Public License for more details.
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 *
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 */
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 #include "DetailCO2meter.h"
332
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents: 328
diff changeset
18 #include "ChartCarbonate.h"
328
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 #include "../ui/ui_DetailCO2meter.h"
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 #include "global.h"
443
3c195eb4e7a1 Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
21 #include "Utils.h"
328
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 #include "MainWindow.h"
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 /*
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 * Results are available via MySQL and websockets. Because we initialize using
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 * MySQL we only use that for the results and up to date status.
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 * Commands are send via websockets only.
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 */
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31 DetailCO2meter::DetailCO2meter(int id, QWidget *parent) : QDialog(parent), ui(new Ui::DetailCO2meter)
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 {
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33 QSqlQuery query;
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 qDebug() << "DetailCO2meter record:" << id;
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36 ui->setupUi(this);
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37 this->recno = id;
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38 setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39 setWindowTitle(tr("BMSapp - Details Carbonation"));
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 ui->thermoMeter->setMaximum(40.0);
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 ui->thermoMeter->setNominal(20.0);
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43 ui->thermoMeter->setCritical(25.0);
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 ui->thermoMeter->setSuffix(QString("°C"));
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46 ui->barMeter->setMaximum(6.0);
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47 ui->barMeter->setNominal(1.0);
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
48 ui->barMeter->setCritical(3.0);
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49 ui->barMeter->setSuffix(QString(" bar"));
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50
416
3fac92cb1ee1 Handle choose beer if it needs to be cleared better in details iSpindels and CO2meters.
Michiel Broek <mbroek@mbse.eu>
parents: 332
diff changeset
51 ui->codePick->addItem("Erase beer");
328
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52 query.exec("SELECT code,name FROM products WHERE stage='1' OR stage='2' OR stage='3' OR stage='4' OR stage='5' OR stage='6' OR stage='7' ORDER BY code");
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53 while (query.next()) {
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
54 ui->codePick->addItem(query.value("code").toString()+" - "+query.value("name").toString());
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55 }
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
56
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57 connect(ui->codePick, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &DetailCO2meter::code_changed);
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58 connect(parent, SIGNAL(updateCO2meter(QString)), this, SLOT(refreshCO2meter(QString)));
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
59 emit refreshTable();
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
60 }
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
61
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
62
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63 void DetailCO2meter::refreshTable()
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 {
443
3c195eb4e7a1 Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
65 QSqlQuery query, query2;
3c195eb4e7a1 Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
66 QString sql = "";
328
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
67
491
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
68 // qDebug() << "refreshTable co2meter rec:" << this->recno;
328
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
70 query.prepare("SELECT * FROM mon_co2meters WHERE record = :recno");
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71 query.bindValue(":recno", this->recno);
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72 query.exec();
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73 if (query.next()) {
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
75 const QSignalBlocker blocker1(ui->codePick);
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
76 const QSignalBlocker blocker2(ui->modeEdit);
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
78 _node = query.value("node").toString();
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79 _alias = query.value("alias").toString();
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80 _uuid = query.value("uuid").toString();
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81 _beercode = query.value("beercode").toString();
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82 _beername = query.value("beername").toString();
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83
443
3c195eb4e7a1 Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
84 sql = "SELECT "
444
4f626d0bb4d4 Toon ook de gewenste en verwachte hergisting druk.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
85 "st_carb_min,st_carb_max,secondary_temp,primary_end_temp,bottle_carbonation_temp,"
4f626d0bb4d4 Toon ook de gewenste en verwachte hergisting druk.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
86 "bottle_carbonation"
443
3c195eb4e7a1 Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
87 " FROM products WHERE code=:code AND name=:name";
3c195eb4e7a1 Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
88 query2.prepare(sql);
3c195eb4e7a1 Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
89 query2.bindValue(":code", _beercode);
3c195eb4e7a1 Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
90 query2.bindValue(":name", _beername);
3c195eb4e7a1 Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
91 query2.exec();
3c195eb4e7a1 Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
92 if (query2.next()) {
3c195eb4e7a1 Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
93 /* Get highest fermentation temperature. */
3c195eb4e7a1 Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
94 double TSec = query2.value("secondary_temp").toDouble();
3c195eb4e7a1 Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
95 if (TSec < 1)
3c195eb4e7a1 Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
96 TSec = query2.value("primary_end_temp").toDouble();
3c195eb4e7a1 Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
97 if (TSec < 1)
3c195eb4e7a1 Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
98 TSec = 18;
3c195eb4e7a1 Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
99
3c195eb4e7a1 Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
100 double carbtemp = query2.value("bottle_carbonation_temp").toDouble();
444
4f626d0bb4d4 Toon ook de gewenste en verwachte hergisting druk.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
101 double barmin = Utils::GetPressureBar(Utils::CarbCO2toS(query2.value("st_carb_min").toDouble(), TSec, 1), carbtemp);
4f626d0bb4d4 Toon ook de gewenste en verwachte hergisting druk.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
102 double barmax = Utils::GetPressureBar(Utils::CarbCO2toS(query2.value("st_carb_max").toDouble(), TSec, 1), carbtemp);
4f626d0bb4d4 Toon ook de gewenste en verwachte hergisting druk.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
103 double barthis = Utils::GetPressureBar(Utils::CarbCO2toS(query2.value("bottle_carbonation").toDouble(), TSec, 1), carbtemp);
443
3c195eb4e7a1 Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
104 ui->minVol->setValue(query2.value("st_carb_min").toDouble());
3c195eb4e7a1 Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
105 ui->maxVol->setValue(query2.value("st_carb_max").toDouble());
444
4f626d0bb4d4 Toon ook de gewenste en verwachte hergisting druk.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
106 ui->thisVol->setValue(query2.value("bottle_carbonation").toDouble());
443
3c195eb4e7a1 Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
107 ui->minBar->setValue(barmin);
3c195eb4e7a1 Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
108 ui->maxBar->setValue(barmax);
444
4f626d0bb4d4 Toon ook de gewenste en verwachte hergisting druk.
Michiel Broek <mbroek@mbse.eu>
parents: 443
diff changeset
109 ui->thisBar->setValue(barthis);
491
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
110 // qDebug() << " beerdata" << TSec << carbtemp << barmin << barmax << barthis;
443
3c195eb4e7a1 Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
111
3c195eb4e7a1 Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
112 ui->barMeter->setNominal(barmin);
3c195eb4e7a1 Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
113 ui->barMeter->setCritical(barmax);
3c195eb4e7a1 Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
114 }
3c195eb4e7a1 Details CO2 monitor shows the style limits for the specific beer. Adjust the scale of the pressure widget to the beer limits. Moved more functions to the global Utils. Fix expected pressure in the package screen for other priming sugars. Disabled some debug log messages.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
115
491
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
116 bool alarm = (query.value("alarm").toInt() != 0) ? true:false;
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
117 bool online = (query.value("online").toInt() != 0) ? true:false;
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
118 bool mode = (query.value("mode").toString() == "ON") ? true:false;
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
119
328
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
120 ui->uuidEdit->setText(_uuid);
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
121 ui->systemEdit->setText(_node+"/"+_alias);
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
122 ui->codePick->setItemText(0, _alias.toUpper()+" - "+_alias);
491
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
123 ui->alarmLED->setChecked(alarm);
328
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
124
491
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
125 if (online) {
328
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
126 ui->statusEdit->setText(tr("Online"));
491
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
127 ui->statusEdit->setStyleSheet("");
328
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
128 ui->codeEdit->setText(_beercode+" - "+_beername);
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
129 ui->modeEdit->setText(query.value("mode").toString());
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
130 ui->modeEdit->show();
491
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
131 ui->powerLED->setChecked(mode);
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
132 if (mode)
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
133 ui->codePick->hide();
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
134 else
328
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
135 ui->codePick->show();
491
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
136
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
137 if (query.value("temperature_address").toString().length() == 16) {
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
138 ui->thermoBox->show();
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
139 ui->logButton->show();
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
140 if (! alarm && query.value("temperature_state").toString() == "OK") {
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
141 ui->thermoMeter->setValue(query.value("temperature").toDouble());
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
142 } else {
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
143 ui->thermoMeter->setValue(NAN);
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
144 }
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
145 if (! alarm && query.value("pressure_state").toString() == "OK") {
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
146 ui->barMeter->setValue(query.value("pressure_bar").toDouble());
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
147 } else {
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
148 ui->barMeter->setValue(NAN);
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
149 }
328
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
150 } else {
491
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
151 ui->thermoBox->hide();
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
152 ui->logButton->hide();
328
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
153 }
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
154
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
155 } else {
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
156 /* Offline */
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
157 ui->statusEdit->setText(tr("Offline"));
491
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
158 ui->statusEdit->setStyleSheet("background-color: red");
328
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
159 ui->powerLED->setChecked(false);
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
160 ui->alarmLED->setChecked(true);
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
161 ui->codePick->hide();
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
162 ui->modeEdit->hide();
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
163 ui->thermoBox->hide();
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
164 ui->logButton->hide();
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
165 }
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
166 }
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
167
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
168 }
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
169
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
170
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
171 DetailCO2meter::~DetailCO2meter()
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
172 {
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
173 delete ui;
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
174 emit entry_changed();
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
175 }
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
176
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
177
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
178 /*
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
179 * Receive signals destined for all co2meters.
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
180 * Check if the signal is for us.
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
181 */
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
182 void DetailCO2meter::refreshCO2meter(QString data)
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
183 {
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
184 if (_node+"/"+_alias == data) {
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
185 emit refreshTable();
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
186 }
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
187 }
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
188
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
189
491
76f3a96e82b5 Monitor CO2 meters: better display and hide of values and widgets. Minor adjustments of the window layout. When offline, the status background will be red.
Michiel Broek <mbroek@mbse.eu>
parents: 444
diff changeset
190 void DetailCO2meter::on_logButton_clicked()
332
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents: 328
diff changeset
191 {
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents: 328
diff changeset
192 ChartCarbonate dialog(_beercode, _beername, this);
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents: 328
diff changeset
193 }
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents: 328
diff changeset
194
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents: 328
diff changeset
195
328
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
196 void DetailCO2meter::on_quitButton_clicked()
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
197 {
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
198 this->close();
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
199 this->setResult(1);
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
200 }
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
201
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
202
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
203 void DetailCO2meter::code_changed(int val)
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
204 {
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
205 QJsonParseError parseError;
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
206 QSqlQuery query;
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
207
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
208 QString msg = QString("{\"device\":\"co2meters\",\"node\":\"" + _node + "\",\"unit\":\"" + _alias + "\",");
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
209 if (val == 0) {
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
210 msg.append(QString("\"beeruuid\":\"") + _uuid + "\",");
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
211 msg.append(QString("\"beercode\":\"") + _alias.toUpper() + "\",");
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
212 msg.append(QString("\"beername\":\"") + _alias + "\"}");
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
213 } else {
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
214 query.exec("SELECT code,name,uuid,stage,json_yeasts FROM products WHERE stage='1' OR stage='2' OR stage='3' OR stage='4' OR stage='5' OR stage='6' OR stage='7' ORDER BY code");
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
215 for (int i = 0; i < val; i++) {
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
216 query.next();
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
217 }
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
218 msg.append(QString("\"beeruuid\":\"") + query.value("uuid").toString() + "\",");
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
219 msg.append(QString("\"beercode\":\"") + query.value("code").toString() + "\",");
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
220 msg.append(QString("\"beername\":\"") + query.value("name").toString() + "\"}");
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
221 }
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
222
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
223 qDebug() << "code_changed" << val << msg;
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
224 webSocket->sendTextMessage(msg);
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
225 }
ee2c8b29f389 Added CO2 meter monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
226

mercurial