src/DetailiSpindel.cpp

Sat, 11 Feb 2023 15:48:02 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 11 Feb 2023 15:48:02 +0100
changeset 493
520306773450
parent 416
3fac92cb1ee1
child 494
49ac23d25f61
permissions
-rw-r--r--

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.

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
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
68 qDebug() << "DetailiSpindel::refreshTable()";
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
70 query.prepare("SELECT * FROM mon_ispindels WHERE record = :recno");
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71 query.bindValue(":recno", this->recno);
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72 query.exec();
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73 if (query.next()) {
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
75 const QSignalBlocker blocker1(ui->codePick);
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
76 const QSignalBlocker blocker2(ui->modeEdit);
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
78 _node = query.value("node").toString();
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79 _alias = query.value("alias").toString();
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80 _uuid = query.value("uuid").toString();
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81 _beercode = query.value("beercode").toString();
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82 _beername = query.value("beername").toString();
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83
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
84 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
85 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
86 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
87
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88 ui->uuidEdit->setText(_uuid);
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
89 ui->systemEdit->setText(_node+"/"+_alias);
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90 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
91 ui->alarmLED->setChecked(alarm);
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92
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 if (online) {
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94 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
95 ui->statusEdit->setStyleSheet("");
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96 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
97 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
98 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
99
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 ui->powerLED->setChecked(mode);
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101 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
102 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
103 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
104 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
105 } else {
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
106 ui->modeEdit->setCurrentIndex(0);
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107 ui->codePick->show();
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108 }
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
110 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
111 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
112 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
113 double sg = Utils::plato_to_sg(query.value("gravity").toDouble());
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114 ui->sgEdit->setText(QString("%1").arg(sg, 5, 'f', 4, '0'));
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
116 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
117 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
118 double og = Utils::plato_to_sg(o_plato);
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
119 double svg = Utils::calc_svg(og, sg);
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
120
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
121 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
122 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
123 ui->sgVal->setText(QString("%1").arg(sg, 5, 'f', 4, '0'));
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
124 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
125 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
126 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
127 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
128 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
129 } 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
130 /* 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
131 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
132 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
133 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
134 }
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
135 } else {
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136 ui->ogVal->setText("");
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
137 ui->ogVal2->setText("");
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
138 ui->sgVal->setText("");
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
139 ui->sgVal2->setText("");
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
140 ui->svgVal->setText("");
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
141 ui->abvVal->setText("");
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
142 ui->batVal->setText("");
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
143 }
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
144
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
145 double batt = query.value("battery").toDouble() - 3.064; // 0% voltage
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
146 if (batt < 0)
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
147 batt = 0;
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
148 batt = round(batt / 1.17875 * 100.0); // 100% range
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
149 if (batt > 100)
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
150 batt = 100;
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
151 ui->batVal->setText(QString("%1%").arg(batt, 2, 'f', 1, '0'));
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
152
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
153 ui->thermoBox->show();
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
154 ui->thermoMeter->setValue(query.value("temperature").toDouble());
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
155
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
156 } else {
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
157 /* Offline */
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
158 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
159 ui->statusEdit->setStyleSheet("background-color: red");
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
160 ui->powerLED->setChecked(false);
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
161 ui->alarmLED->setChecked(true);
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
162 ui->codePick->hide();
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
163 ui->modeEdit->hide();
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
164 ui->thermoBox->hide();
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
165 ui->logButton->hide();
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
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 DetailiSpindel::~DetailiSpindel()
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
173 {
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
174 delete ui;
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
175 emit entry_changed();
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
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
179 /*
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
180 * Receive signals destined for all co2meters.
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
181 * Check if the signal is for us.
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 void DetailiSpindel::refreshiSpindel(QString data)
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
184 {
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
185 if (_node+"/"+_alias == data) {
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
186 emit refreshTable();
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 }
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
189
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
190
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
191 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
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 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
194 }
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
195
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
196
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
197 void DetailiSpindel::on_quitButton_clicked()
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
198 {
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
199 this->close();
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
200 this->setResult(1);
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
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 void DetailiSpindel::mode_changed(int val)
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
205 {
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
206 QStringList mode ({ "OFF", "ON" });
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
207 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
208 #ifdef DEBUG_MONITOR
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
209 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
210 #endif
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
211 webSocket->sendTextMessage(msg);
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
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 void DetailiSpindel::code_changed(int val)
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
216 {
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
217 QJsonParseError parseError;
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
218 QSqlQuery query;
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
219
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
220 QString msg = QString("{\"device\":\"ispindels\",\"node\":\"" + _node + "\",\"unit\":\"" + _alias + "\",");
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
221 if (val == 0) {
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
222 msg.append(QString("\"beeruuid\":\"") + _uuid + "\",");
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
223 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
224 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
225 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
226 msg.append(QString("\"yeast_hi\":25.0}"));
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
227 } else {
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
228 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
229 for (int i = 0; i < val; i++) {
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
230 query.next();
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
231 }
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
232 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
233 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
234 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
235 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
236 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
237 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
238 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
239 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
240 } 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
241 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
242 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
243 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
244 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
245 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
246 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
247 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
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 }
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
250 }
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
251 }
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
252 msg.append(QString("\"beeruuid\":\"") + query.value("uuid").toString() + "\",");
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
253 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
254 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
255 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
256 msg.append(QString("\"yeast_hi\":%1}").arg(yh));
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
257 }
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
258
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 #ifdef DEBUG_MONITOR
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
260 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
261 #endif
329
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
262 webSocket->sendTextMessage(msg);
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
263 }
b57299738980 Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
264

mercurial