Thu, 30 Jun 2022 10:38:03 +0200
Translated to English.
317 | 1 | /** |
2 | * DetailFermenter.cpp is part of bmsapp. | |
3 | * | |
4 | * bmsapp is free software: you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License as published by | |
6 | * the Free Software Foundation, either version 3 of the License, or | |
7 | * (at your option) any later version. | |
8 | * | |
9 | * bmsapp is distributed in the hope that it will be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License | |
15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | */ | |
17 | #include "DetailFermenter.h" | |
18 | #include "../ui/ui_DetailFermenter.h" | |
19 | #include "MainWindow.h" | |
20 | ||
21 | ||
22 | DetailFermenter::DetailFermenter(int id, QWidget *parent) : QDialog(parent), ui(new Ui::DetailFermenter) | |
23 | { | |
24 | qDebug() << "DetailFermenter record:" << id; | |
25 | ui->setupUi(this); | |
26 | this->recno = id; | |
27 | ||
28 | WindowTitle(); | |
29 | ||
318
ff02aca2b63c
Removed LED plugin, now using the one from the AnalogWidgets.
Michiel Broek <mbroek@mbse.eu>
parents:
317
diff
changeset
|
30 | // srcMode = ['OFF', 'NONE', 'FRIDGE', 'BEER', 'PROFILE']; |
ff02aca2b63c
Removed LED plugin, now using the one from the AnalogWidgets.
Michiel Broek <mbroek@mbse.eu>
parents:
317
diff
changeset
|
31 | // srcStage = ['PRIMARY', 'SECONDARY', 'TERTIARY', 'CARBONATION']; |
ff02aca2b63c
Removed LED plugin, now using the one from the AnalogWidgets.
Michiel Broek <mbroek@mbse.eu>
parents:
317
diff
changeset
|
32 | // |
317 | 33 | // connect(ui->nameEdit, &QLineEdit::textChanged, this, &DetailFermenter::is_changed); |
34 | // connect(ui->unlimitedEdit, &QCheckBox::stateChanged, this, &DetailFermenter::is_changed); | |
35 | // connect(ui->caEdit, &QDoubleSpinBox::textChanged, this, &DetailFermenter::water_changed); | |
36 | ||
37 | emit refreshTable(); | |
38 | } | |
39 | ||
40 | ||
41 | void DetailFermenter::refreshTable() | |
42 | { | |
43 | QSqlQuery query; | |
44 | ||
45 | qDebug() << "refreshTable fermenter" << this->recno; | |
46 | ||
47 | query.prepare("SELECT * FROM mon_fermenters WHERE record = :recno"); | |
48 | query.bindValue(":recno", this->recno); | |
49 | query.exec(); | |
50 | if (query.next()) { | |
51 | ||
318
ff02aca2b63c
Removed LED plugin, now using the one from the AnalogWidgets.
Michiel Broek <mbroek@mbse.eu>
parents:
317
diff
changeset
|
52 | ui->uuidEdit->setText(query.value("uuid").toString()); |
ff02aca2b63c
Removed LED plugin, now using the one from the AnalogWidgets.
Michiel Broek <mbroek@mbse.eu>
parents:
317
diff
changeset
|
53 | ui->systemEdit->setText(query.value("node").toString()+"/"+query.value("alias").toString()); |
ff02aca2b63c
Removed LED plugin, now using the one from the AnalogWidgets.
Michiel Broek <mbroek@mbse.eu>
parents:
317
diff
changeset
|
54 | |
317 | 55 | if (query.value("online").toInt()) { |
318
ff02aca2b63c
Removed LED plugin, now using the one from the AnalogWidgets.
Michiel Broek <mbroek@mbse.eu>
parents:
317
diff
changeset
|
56 | ui->statusEdit->setText(tr("Online")); |
ff02aca2b63c
Removed LED plugin, now using the one from the AnalogWidgets.
Michiel Broek <mbroek@mbse.eu>
parents:
317
diff
changeset
|
57 | ui->codeEdit->setText(query.value("beercode").toString()+" - "+query.value("beername").toString()); |
ff02aca2b63c
Removed LED plugin, now using the one from the AnalogWidgets.
Michiel Broek <mbroek@mbse.eu>
parents:
317
diff
changeset
|
58 | |
317 | 59 | if (query.value("mode").toString() == "OFF") { |
60 | ui->powerLED->setChecked(false); | |
61 | // disable dropdowns select beer. | |
62 | } else { | |
63 | ui->powerLED->setChecked(true); | |
64 | // enable beerslect | |
65 | } | |
66 | ui->alarmLED->setChecked((query.value("alarm").toInt() != 0) ? true:false); | |
67 | ||
68 | if (query.value("air_state").toString() == "OK") { | |
69 | ui->airThermo->setValue(query.value("air_temperature").toDouble()); | |
70 | } | |
71 | if (query.value("beer_state").toString() == "OK") { | |
72 | ui->beerThermo->setValue(query.value("beer_temperature").toDouble()); | |
73 | } | |
74 | ||
75 | } else { | |
76 | /* Offline */ | |
77 | ui->powerLED->setChecked(false); | |
78 | ui->alarmLED->setChecked(true); | |
79 | ||
80 | } | |
81 | } | |
82 | ||
83 | } | |
84 | ||
85 | ||
86 | DetailFermenter::~DetailFermenter() | |
87 | { | |
88 | qDebug() << "DetailFermenter done"; | |
89 | delete ui; | |
90 | emit entry_changed(); | |
91 | } | |
92 | ||
93 | ||
94 | /* | |
95 | * Window header, mark any change with '**' | |
96 | */ | |
97 | void DetailFermenter::WindowTitle() | |
98 | { | |
99 | QString txt; | |
100 | ||
101 | txt = QString(tr("BMSapp - Edit brewing water %1").arg(this->recno)); | |
102 | setWindowTitle(txt); | |
103 | } | |
104 | ||
105 | ||
106 | void DetailFermenter::on_quitButton_clicked() | |
107 | { | |
108 | this->close(); | |
109 | this->setResult(1); | |
110 | } |