src/DetailiSpindel.cpp

Sun, 12 Feb 2023 13:58:36 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 12 Feb 2023 13:58:36 +0100
changeset 494
49ac23d25f61
parent 493
520306773450
child 499
10d208fa6c74
permissions
-rw-r--r--

In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.

329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * DetailiSpindel.cpp is part of bmsapp.
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * bmsapp is free software: you can redistribute it and/or modify
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * the Free Software Foundation, either version 3 of the License, or
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * (at your option) any later version.
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 *
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * bmsapp is distributed in the hope that it will be useful,
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * GNU General Public License for more details.
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 *
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 */
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 #include "DetailiSpindel.h"
333
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents: 329
diff changeset
18 #include "ChartiSpindel.h"
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 #include "../ui/ui_DetailiSpindel.h"
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 #include "global.h"
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 #include "Utils.h"
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 #include "MainWindow.h"
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 /*
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 * Results are available via MySQL and websockets. Because we initialize using
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 * MySQL we only use that for the results and up to date status.
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 * Commands are send via websockets only.
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 */
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31 DetailiSpindel::DetailiSpindel(int id, QWidget *parent) : QDialog(parent), ui(new Ui::DetailiSpindel)
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 {
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33 QSqlQuery query;
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34
493
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
35 #ifdef DEBUG_MONITOR
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36 qDebug() << "DetailiSpindel record:" << id;
493
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
37 #endif
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38 ui->setupUi(this);
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39 this->recno = id;
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 setWindowTitle(tr("BMSapp - Details iSpindel"));
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43 ui->thermoMeter->setMaximum(40.0);
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 ui->thermoMeter->setNominal(20.0);
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 ui->thermoMeter->setCritical(25.0);
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46 ui->thermoMeter->setSuffix(QString("°C"));
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
48 ui->modeEdit->addItem("OFF");
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49 ui->modeEdit->addItem("ON");
b57299738980 Added iSpindel 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: 333
diff changeset
51 ui->codePick->addItem("Erase beer");
329
b57299738980 Added iSpindel 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");
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53 while (query.next()) {
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
54 ui->codePick->addItem(query.value("code").toString()+" - "+query.value("name").toString());
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55 }
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
56
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57 connect(ui->codePick, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &DetailiSpindel::code_changed);
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58 connect(ui->modeEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &DetailiSpindel::mode_changed);
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
59 connect(parent, SIGNAL(updateiSpindel(QString)), this, SLOT(refreshiSpindel(QString)));
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
60 emit refreshTable();
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
61 }
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
62
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 void DetailiSpindel::refreshTable()
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
65 {
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
66 QSqlQuery query;
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
67
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
68 query.prepare("SELECT * FROM mon_ispindels WHERE record = :recno");
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69 query.bindValue(":recno", this->recno);
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
70 query.exec();
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71 if (query.next()) {
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73 const QSignalBlocker blocker1(ui->codePick);
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74 const QSignalBlocker blocker2(ui->modeEdit);
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
75
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
76 _node = query.value("node").toString();
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77 _alias = query.value("alias").toString();
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
78 _uuid = query.value("uuid").toString();
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79 _beercode = query.value("beercode").toString();
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80 _beername = query.value("beername").toString();
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81
493
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
82 bool alarm = (query.value("alarm").toInt() != 0) ? true:false;
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
83 bool online = (query.value("online").toInt() != 0) ? true:false;
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
84 bool mode = (query.value("mode").toString() == "ON") ? true:false;
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
85
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86 ui->uuidEdit->setText(_uuid);
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 ui->systemEdit->setText(_node+"/"+_alias);
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88 ui->codePick->setItemText(0, _alias.toUpper()+" - "+_alias);
493
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
89 ui->alarmLED->setChecked(alarm);
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90
493
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
91 if (online) {
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92 ui->statusEdit->setText(tr("Online"));
493
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
93 ui->statusEdit->setStyleSheet("");
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94 ui->codeEdit->setText(_beercode+" - "+_beername);
493
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
95 ui->thermoMeter->setNominal(query.value("yeast_lo").toDouble());
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
96 ui->thermoMeter->setCritical(query.value("yeast_hi").toDouble());
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
97
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
98 ui->powerLED->setChecked(mode);
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
99 ui->modeEdit->show();
493
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
100 if (mode) {
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
101 ui->modeEdit->setCurrentIndex(1);
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
102 ui->codePick->hide();
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
103 } else {
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
104 ui->modeEdit->setCurrentIndex(0);
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
105 ui->codePick->show();
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
106 }
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108 ui->voltEdit->setText(QString("%1").arg(query.value("battery").toDouble(), 4, 'f', 3, '0'));
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109 ui->tiltEdit->setText(QString("%1").arg(query.value("angle").toDouble(), 6, 'f', 5, '0'));
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
110 ui->platoEdit->setText(QString("%1").arg(query.value("gravity").toDouble(), 4, 'f', 3, '0'));
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111 double sg = Utils::plato_to_sg(query.value("gravity").toDouble());
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112 ui->sgEdit->setText(QString("%1").arg(sg, 5, 'f', 4, '0'));
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114 if (query.value("gravity").toDouble()) {
493
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
115 double o_plato = query.value("og_gravity").toDouble();
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
116 double og = Utils::plato_to_sg(o_plato);
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117 double svg = Utils::calc_svg(og, sg);
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
118
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
119 ui->ogVal->setText(QString("%1").arg(og, 5, 'f', 4, '0'));
493
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
120 ui->ogVal2->setText(QString("%1°P").arg(o_plato, 4, 'f', 3, '0'));
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
121 ui->sgVal->setText(QString("%1").arg(sg, 5, 'f', 4, '0'));
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
122 ui->sgVal2->setText(QString("%1°P").arg(query.value("gravity").toDouble(), 4, 'f', 3, '0'));
493
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
123 if (o_plato > 0.1) {
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
124 ui->svgVal->setText(QString("%1%").arg(svg, 2, 'f', 1, '0'));
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
125 ui->svgBar->setValue(svg);
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
126 ui->abvVal->setText(QString("%1%").arg(Utils::abvol(og, sg), 3, 'f', 2, '0'));
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
127 } else {
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
128 /* o_plato is 0 if a new beer is selected. */
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
129 ui->svgVal->setText("");
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
130 ui->svgBar->setValue(0);
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
131 ui->abvVal->setText("");
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
132 }
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
133 } else {
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
134 ui->ogVal->setText("");
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
135 ui->ogVal2->setText("");
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136 ui->sgVal->setText("");
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
137 ui->sgVal2->setText("");
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
138 ui->svgVal->setText("");
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
139 ui->abvVal->setText("");
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
140 ui->batVal->setText("");
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
141 }
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
142
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
143 double batt = query.value("battery").toDouble() - 3.064; // 0% voltage
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
144 if (batt < 0)
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
145 batt = 0;
494
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 493
diff changeset
146 batt = round(batt / 1.17875 * 1000.0) / 10; // 100% range
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
147 if (batt > 100)
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
148 batt = 100;
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
149 ui->batVal->setText(QString("%1%").arg(batt, 2, 'f', 1, '0'));
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
150
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
151 ui->thermoBox->show();
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
152 ui->thermoMeter->setValue(query.value("temperature").toDouble());
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
153
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
154 } else {
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
155 /* Offline */
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
156 ui->statusEdit->setText(tr("Offline"));
493
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
157 ui->statusEdit->setStyleSheet("background-color: red");
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
158 ui->powerLED->setChecked(false);
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
159 ui->alarmLED->setChecked(true);
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
160 ui->codePick->hide();
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
161 ui->modeEdit->hide();
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
162 ui->thermoBox->hide();
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
163 ui->logButton->hide();
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
164 }
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
165 }
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
166
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
167 }
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
168
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
169
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
170 DetailiSpindel::~DetailiSpindel()
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
171 {
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
172 delete ui;
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
173 emit entry_changed();
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
174 }
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
175
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
176
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
177 /*
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
178 * Receive signals destined for all co2meters.
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
179 * Check if the signal is for us.
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
180 */
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
181 void DetailiSpindel::refreshiSpindel(QString data)
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
182 {
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
183 if (_node+"/"+_alias == data) {
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
184 emit refreshTable();
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
185 }
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
186 }
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
187
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
188
493
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
189 void DetailiSpindel::on_logButton_clicked()
333
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents: 329
diff changeset
190 {
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents: 329
diff changeset
191 ChartiSpindel dialog(_beercode, _beername, this);
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents: 329
diff changeset
192 }
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents: 329
diff changeset
193
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents: 329
diff changeset
194
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
195 void DetailiSpindel::on_quitButton_clicked()
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
196 {
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
197 this->close();
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
198 this->setResult(1);
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
199 }
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
200
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
201
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
202 void DetailiSpindel::mode_changed(int val)
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
203 {
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
204 QStringList mode ({ "OFF", "ON" });
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
205 QString msg = QString("{\"device\":\"ispindels\",\"node\":\"" + _node + "\",\"unit\":\"" + _alias + "\",\"mode\":\"" + mode[val] + "\"}");
493
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
206 #ifdef DEBUG_MONITOR
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
207 qDebug() << "mode_changed" << val << msg;
493
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
208 #endif
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
209 webSocket->sendTextMessage(msg);
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
210 }
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
211
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
212
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
213 void DetailiSpindel::code_changed(int val)
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
214 {
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
215 QJsonParseError parseError;
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
216 QSqlQuery query;
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
217
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
218 QString msg = QString("{\"device\":\"ispindels\",\"node\":\"" + _node + "\",\"unit\":\"" + _alias + "\",");
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
219 if (val == 0) {
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
220 msg.append(QString("\"beeruuid\":\"") + _uuid + "\",");
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
221 msg.append(QString("\"beercode\":\"") + _alias.toUpper() + "\",");
493
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
222 msg.append(QString("\"beername\":\"") + _alias + "\",");
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
223 msg.append(QString("\"yeast_lo\":20.0,"));
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
224 msg.append(QString("\"yeast_hi\":25.0}"));
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
225 } else {
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
226 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");
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
227 for (int i = 0; i < val; i++) {
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
228 query.next();
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
229 }
493
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
230 double yl = 0;
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
231 double yh = 40;
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
232 const auto& y_json = query.value("json_yeasts").toString();
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
233 if (! y_json.trimmed().isEmpty()) {
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
234 const auto& formattedJson = QString("%1").arg(y_json);
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
235 QJsonDocument yeasts = QJsonDocument::fromJson(formattedJson.toUtf8(), &parseError);
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
236 if (parseError.error != QJsonParseError::NoError) {
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
237 qWarning() << "Parse error: " << parseError.errorString() << "at" << parseError.offset ;
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
238 } else if (yeasts.isArray()) {
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
239 for (int i = 0; i < yeasts.array().size(); i++) {
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
240 QJsonObject obj = yeasts.array().at(i).toObject();
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
241 if (obj["y_use"].toInt() == 0) { // Primary yeast
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
242 if (obj["y_min_temperature"].toDouble() > yl)
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
243 yl = obj["y_min_temperature"].toDouble();
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
244 if (obj["y_max_temperature"].toDouble() < yh)
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
245 yh = obj["y_max_temperature"].toDouble();
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
246 }
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
247 }
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
248 }
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
249 }
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
250 msg.append(QString("\"beeruuid\":\"") + query.value("uuid").toString() + "\",");
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
251 msg.append(QString("\"beercode\":\"") + query.value("code").toString() + "\",");
493
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
252 msg.append(QString("\"beername\":\"") + query.value("name").toString() + "\",");
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
253 msg.append(QString("\"yeast_lo\":%1,").arg(yl));
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
254 msg.append(QString("\"yeast_hi\":%1}").arg(yh));
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
255 }
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
256
493
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
257 #ifdef DEBUG_MONITOR
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
258 qDebug() << "code_changed" << val << msg;
493
520306773450 Monitor iSpindels: use global variables instead of repeated expensive MySQL calls. Use the yeast temperature ranges for the colors on the thermometer scale. Don't show SVG and ABV if the OG is not yet known. Turn statusfield red if offline. Extra mon_ispindles fields yeast_lo and yeast_hi. Need at least bmsd version 0.3.42. If a websocket message is received that cannot be parsed, show the whole received message.
Michiel Broek <mbroek@mbse.eu>
parents: 416
diff changeset
259 #endif
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
260 webSocket->sendTextMessage(msg);
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
261 }
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
262

mercurial