src/DetailNode.cpp

Sun, 12 Feb 2023 15:05:28 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 12 Feb 2023 15:05:28 +0100
changeset 495
6aa29aaa3f4d
parent 348
c5318497a0b6
permissions
-rw-r--r--

Version 0.4.1. Adjusted monitor nodes debug messages.

346
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * DetailNode.cpp is part of bmsapp.
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * bmsapp is free software: you can redistribute it and/or modify
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * the Free Software Foundation, either version 3 of the License, or
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * (at your option) any later version.
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 *
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * bmsapp is distributed in the hope that it will be useful,
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * GNU General Public License for more details.
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 *
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 */
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 #include "DetailNode.h"
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 #include "ChartCarbonate.h"
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 #include "../ui/ui_DetailNode.h"
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 #include "global.h"
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 #include "MainWindow.h"
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 /*
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 * Results are available via MySQL and websockets. Because we initialize using
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 * MySQL we only use that for the results and up to date status.
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 * Commands are send via websockets only.
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 */
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30 DetailNode::DetailNode(int id, QWidget *parent) : QDialog(parent), ui(new Ui::DetailNode)
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31 {
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 QSqlQuery query;
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33
495
6aa29aaa3f4d Version 0.4.1. Adjusted monitor nodes debug messages.
Michiel Broek <mbroek@mbse.eu>
parents: 348
diff changeset
34 #ifdef DEBUG_MONITOR
346
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 qDebug() << "DetailNode record:" << id;
495
6aa29aaa3f4d Version 0.4.1. Adjusted monitor nodes debug messages.
Michiel Broek <mbroek@mbse.eu>
parents: 348
diff changeset
36 #endif
346
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37 ui->setupUi(this);
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38 this->recno = id;
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39 setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 setWindowTitle(tr("BMSapp - Details System"));
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 connect(ui->rebootButton, SIGNAL(clicked()), this, SLOT(control_reboot()));
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43 connect(ui->rebirthButton, SIGNAL(clicked()), this, SLOT(control_rebirth()));
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 connect(parent, SIGNAL(updateNode(QString)), this, SLOT(refreshNode(QString)));
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 emit refreshTable();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46 }
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
48
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49 void DetailNode::refreshTable()
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50 {
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51 QSqlQuery query;
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53 query.prepare("SELECT * FROM mon_nodes WHERE record = :recno");
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
54 query.bindValue(":recno", this->recno);
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55 query.exec();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
56 if (query.next()) {
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58 _node = query.value("node").toString();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
59 _group_id = query.value("group_id").toString();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
60 _uuid = query.value("uuid").toString();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
61
495
6aa29aaa3f4d Version 0.4.1. Adjusted monitor nodes debug messages.
Michiel Broek <mbroek@mbse.eu>
parents: 348
diff changeset
62 bool online = (query.value("online").toInt() != 0) ? true:false;
6aa29aaa3f4d Version 0.4.1. Adjusted monitor nodes debug messages.
Michiel Broek <mbroek@mbse.eu>
parents: 348
diff changeset
63
346
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 ui->uuidEdit->setText(_uuid);
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
65 ui->systemEdit->setText(_node);
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
66 ui->typeEdit->setText(_group_id);
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
67 ui->firstEdit->setText(query.value("firstseen").toDateTime().toString("dd MMM yyyy HH:mm:ss"));
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
68 ui->lastEdit->setText(query.value("lastseen").toDateTime().toString("dd MMM yyyy HH:mm:ss"));
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69
495
6aa29aaa3f4d Version 0.4.1. Adjusted monitor nodes debug messages.
Michiel Broek <mbroek@mbse.eu>
parents: 348
diff changeset
70 if (online) {
346
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71 ui->statusEdit->setText(tr("Online"));
495
6aa29aaa3f4d Version 0.4.1. Adjusted monitor nodes debug messages.
Michiel Broek <mbroek@mbse.eu>
parents: 348
diff changeset
72 ui->statusEdit->setStyleSheet("");
346
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73 ui->makerEdit->show();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74 ui->modelEdit->show();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
75 ui->osEdit->show();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
76 ui->fwEdit->show();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77 ui->makerLabel->show();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
78 ui->modelLabel->show();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79 ui->osLabel->show();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80 ui->fwLabel->show();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81 ui->intervalLabel->show();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82 ui->intervalEdit->show();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83 ui->makerEdit->setText(query.value("hardwaremake").toString());
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84 ui->modelEdit->setText(query.value("hardwaremodel").toString());
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85 ui->osEdit->setText(query.value("os").toString()+QString(tr(" version: "))+query.value("os_version").toString());
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86 ui->fwEdit->setText(query.value("firmware").toString());
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 ui->intervalEdit->setValue(query.value("up_interval").toInt());
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
89 if (query.value("temperature").toDouble() > 0) {
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90 ui->tempLabel->show();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91 ui->tempEdit->show();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92 ui->tempEdit->setValue(query.value("temperature").toDouble());
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
93 } else {
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94 ui->tempLabel->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95 ui->tempEdit->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96 }
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
97 if (query.value("humidity").toDouble() > 0) {
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
98 ui->humLabel->show();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
99 ui->humEdit->show();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
100 ui->humEdit->setValue(query.value("humidity").toDouble());
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101 } else {
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
102 ui->humLabel->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
103 ui->humEdit->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
104 }
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
105 if (query.value("barometer").toDouble() > 0) {
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
106 ui->baroLabel->show();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107 ui->baroEdit->show();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108 ui->baroEdit->setValue(query.value("barometer").toDouble());
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109 } else {
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
110 ui->baroLabel->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111 ui->baroEdit->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112 }
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114 ui->networkLabel->show();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115 ui->networkEdit->show();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
116 ui->networkEdit->setText(query.value("net_ifname").toString()+" "+query.value("net_address").toString());
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
118 if (query.value("net_ssid").toString() != "") {
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
119 ui->ssidLabel->show();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
120 ui->ssidEdit->show();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
121 ui->ssidEdit->setText(query.value("net_ssid").toString());
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
122 ui->rssiLabel->show();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
123 ui->rssiEdit->show();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
124 if (query.value("net_rssi").toInt() < 0)
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
125 ui->rssiEdit->setValue(query.value("net_rssi").toInt());
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
126 } else {
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
127 ui->ssidLabel->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
128 ui->ssidEdit->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
129 ui->rssiLabel->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
130 ui->rssiEdit->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
131 }
347
4f976d0a4f10 Only fermenters support control commands.
Michiel Broek <mbroek@mbse.eu>
parents: 346
diff changeset
132 if (_group_id == "fermenters") {
4f976d0a4f10 Only fermenters support control commands.
Michiel Broek <mbroek@mbse.eu>
parents: 346
diff changeset
133 /*
4f976d0a4f10 Only fermenters support control commands.
Michiel Broek <mbroek@mbse.eu>
parents: 346
diff changeset
134 * Currently only fermenters support control commands.
4f976d0a4f10 Only fermenters support control commands.
Michiel Broek <mbroek@mbse.eu>
parents: 346
diff changeset
135 */
4f976d0a4f10 Only fermenters support control commands.
Michiel Broek <mbroek@mbse.eu>
parents: 346
diff changeset
136 ui->rebootButton->show();
4f976d0a4f10 Only fermenters support control commands.
Michiel Broek <mbroek@mbse.eu>
parents: 346
diff changeset
137 ui->rebirthButton->show();
4f976d0a4f10 Only fermenters support control commands.
Michiel Broek <mbroek@mbse.eu>
parents: 346
diff changeset
138 } else {
4f976d0a4f10 Only fermenters support control commands.
Michiel Broek <mbroek@mbse.eu>
parents: 346
diff changeset
139 ui->rebootButton->hide();
4f976d0a4f10 Only fermenters support control commands.
Michiel Broek <mbroek@mbse.eu>
parents: 346
diff changeset
140 ui->rebirthButton->hide();
4f976d0a4f10 Only fermenters support control commands.
Michiel Broek <mbroek@mbse.eu>
parents: 346
diff changeset
141 }
346
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
142
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
143 } else {
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
144 /* Offline */
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
145 ui->statusEdit->setText(tr("Offline"));
495
6aa29aaa3f4d Version 0.4.1. Adjusted monitor nodes debug messages.
Michiel Broek <mbroek@mbse.eu>
parents: 348
diff changeset
146 ui->statusEdit->setStyleSheet("background-color: red");
346
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
147 ui->makerEdit->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
148 ui->modelEdit->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
149 ui->osEdit->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
150 ui->fwEdit->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
151 ui->makerLabel->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
152 ui->modelLabel->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
153 ui->osLabel->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
154 ui->fwLabel->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
155 ui->intervalLabel->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
156 ui->intervalEdit->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
157
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
158 ui->tempLabel->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
159 ui->tempEdit->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
160 ui->humLabel->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
161 ui->humEdit->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
162 ui->baroLabel->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
163 ui->baroEdit->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
164
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
165 ui->networkLabel->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
166 ui->networkEdit->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
167 ui->ssidLabel->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
168 ui->ssidEdit->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
169 ui->rssiLabel->hide();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
170 ui->rssiEdit->hide();
347
4f976d0a4f10 Only fermenters support control commands.
Michiel Broek <mbroek@mbse.eu>
parents: 346
diff changeset
171
4f976d0a4f10 Only fermenters support control commands.
Michiel Broek <mbroek@mbse.eu>
parents: 346
diff changeset
172 ui->rebootButton->hide();
4f976d0a4f10 Only fermenters support control commands.
Michiel Broek <mbroek@mbse.eu>
parents: 346
diff changeset
173 ui->rebirthButton->hide();
346
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
174 }
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
175 }
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
176
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
177 }
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
178
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
179
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
180 DetailNode::~DetailNode()
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
181 {
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
182 delete ui;
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
183 emit entry_changed();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
184 }
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
185
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
186
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
187 /*
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
188 * Receive signals destined for all co2meters.
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
189 * Check if the signal is for us.
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
190 */
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
191 void DetailNode::refreshNode(QString data)
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
192 {
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
193 if (_node == data) {
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
194 emit refreshTable();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
195 }
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
196 }
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
197
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
198
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
199 void DetailNode::on_quitButton_clicked()
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
200 {
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
201 this->close();
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
202 this->setResult(1);
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
203 }
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
204
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
205
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
206 void DetailNode::control_reboot()
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
207 {
348
c5318497a0b6 Updated translations
Michiel Broek <mbroek@mbse.eu>
parents: 347
diff changeset
208 int rc = QMessageBox::warning(this, tr("Reboot application"), tr("Remote application is running, really reboot?"),
346
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
209 QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
210
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
211 if (rc == QMessageBox::No)
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
212 return;
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
213
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
214 QString msg = QString("{\"node\":\""+_node+"\",\"group_id\":\""+_group_id+"\",\"control\":\"reboot\"}");
495
6aa29aaa3f4d Version 0.4.1. Adjusted monitor nodes debug messages.
Michiel Broek <mbroek@mbse.eu>
parents: 348
diff changeset
215 #ifdef DEBUG_MONITOR
346
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
216 qDebug() << msg;
495
6aa29aaa3f4d Version 0.4.1. Adjusted monitor nodes debug messages.
Michiel Broek <mbroek@mbse.eu>
parents: 348
diff changeset
217 #endif
346
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
218 webSocket->sendTextMessage(msg);
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
219 }
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
220
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
221
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
222 void DetailNode::control_rebirth()
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
223 {
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
224 QString msg = QString("{\"node\":\""+_node+"\",\"group_id\":\""+_group_id+"\",\"control\":\"rebirth\"}");
495
6aa29aaa3f4d Version 0.4.1. Adjusted monitor nodes debug messages.
Michiel Broek <mbroek@mbse.eu>
parents: 348
diff changeset
225 #ifdef DEBUG_MONITOR
346
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
226 qDebug() << msg;
495
6aa29aaa3f4d Version 0.4.1. Adjusted monitor nodes debug messages.
Michiel Broek <mbroek@mbse.eu>
parents: 348
diff changeset
227 #endif
346
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
228 webSocket->sendTextMessage(msg);
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
229 }
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
230
792058058c2f Added nodes monitor detail screen.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
231

mercurial