Sat, 08 Jun 2024 15:54:30 +0200
Version 0.4.6a1. Added HLT equipment volume and deadspace settings. In EditProduct the target water selection is now sticky. Changed the water treatment tab. Added a row wich displays the salt adjustments. This can be selected between actual and target values. The treated water show can select between mash or sparge water. The total line will become the final water in the boil kettle. Database update function is expanded with the new settings. Added a popup message warning that the database is upgraded and user action is required for the equipment profiles.
/** * DetailNode.cpp is part of bmsapp. * * bmsapp is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * bmsapp is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "DetailNode.h" #include "ChartCarbonate.h" #include "../ui/ui_DetailNode.h" #include "global.h" #include "MainWindow.h" /* * Results are available via MySQL and websockets. Because we initialize using * MySQL we only use that for the results and up to date status. * Commands are send via websockets only. */ DetailNode::DetailNode(int id, QWidget *parent) : QDialog(parent), ui(new Ui::DetailNode) { QSqlQuery query; #ifdef DEBUG_MONITOR qDebug() << "DetailNode record:" << id; #endif ui->setupUi(this); this->recno = id; setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint); setWindowTitle(tr("BMSapp - Details System")); connect(ui->rebootButton, SIGNAL(clicked()), this, SLOT(control_reboot())); connect(ui->rebirthButton, SIGNAL(clicked()), this, SLOT(control_rebirth())); connect(parent, SIGNAL(updateNode(QString)), this, SLOT(refreshNode(QString))); emit refreshTable(); } void DetailNode::refreshTable() { QSqlQuery query; query.prepare("SELECT * FROM mon_nodes WHERE record = :recno"); query.bindValue(":recno", this->recno); query.exec(); if (query.next()) { _node = query.value("node").toString(); _group_id = query.value("group_id").toString(); _uuid = query.value("uuid").toString(); bool online = (query.value("online").toInt() != 0) ? true:false; ui->uuidEdit->setText(_uuid); ui->systemEdit->setText(_node); ui->typeEdit->setText(_group_id); ui->firstEdit->setText(query.value("firstseen").toDateTime().toString("dd MMM yyyy HH:mm:ss")); ui->lastEdit->setText(query.value("lastseen").toDateTime().toString("dd MMM yyyy HH:mm:ss")); if (online) { ui->statusEdit->setText(tr("Online")); ui->statusEdit->setStyleSheet(""); ui->makerEdit->show(); ui->modelEdit->show(); ui->osEdit->show(); ui->fwEdit->show(); ui->makerLabel->show(); ui->modelLabel->show(); ui->osLabel->show(); ui->fwLabel->show(); ui->intervalLabel->show(); ui->intervalEdit->show(); ui->makerEdit->setText(query.value("hardwaremake").toString()); ui->modelEdit->setText(query.value("hardwaremodel").toString()); ui->osEdit->setText(query.value("os").toString()+QString(tr(" version: "))+query.value("os_version").toString()); ui->fwEdit->setText(query.value("firmware").toString()); ui->intervalEdit->setValue(query.value("up_interval").toInt()); if (query.value("temperature").toDouble() > 0) { ui->tempLabel->show(); ui->tempEdit->show(); ui->tempEdit->setValue(query.value("temperature").toDouble()); } else { ui->tempLabel->hide(); ui->tempEdit->hide(); } if (query.value("humidity").toDouble() > 0) { ui->humLabel->show(); ui->humEdit->show(); ui->humEdit->setValue(query.value("humidity").toDouble()); } else { ui->humLabel->hide(); ui->humEdit->hide(); } if (query.value("barometer").toDouble() > 0) { ui->baroLabel->show(); ui->baroEdit->show(); ui->baroEdit->setValue(query.value("barometer").toDouble()); } else { ui->baroLabel->hide(); ui->baroEdit->hide(); } ui->networkLabel->show(); ui->networkEdit->show(); ui->networkEdit->setText(query.value("net_ifname").toString()+" "+query.value("net_address").toString()); if (query.value("net_ssid").toString() != "") { ui->ssidLabel->show(); ui->ssidEdit->show(); ui->ssidEdit->setText(query.value("net_ssid").toString()); ui->rssiLabel->show(); ui->rssiEdit->show(); if (query.value("net_rssi").toInt() < 0) ui->rssiEdit->setValue(query.value("net_rssi").toInt()); } else { ui->ssidLabel->hide(); ui->ssidEdit->hide(); ui->rssiLabel->hide(); ui->rssiEdit->hide(); } if (_group_id == "fermenters") { /* * Currently only fermenters support control commands. */ ui->rebootButton->show(); ui->rebirthButton->show(); } else { ui->rebootButton->hide(); ui->rebirthButton->hide(); } } else { /* Offline */ ui->statusEdit->setText(tr("Offline")); ui->statusEdit->setStyleSheet("background-color: red"); ui->makerEdit->hide(); ui->modelEdit->hide(); ui->osEdit->hide(); ui->fwEdit->hide(); ui->makerLabel->hide(); ui->modelLabel->hide(); ui->osLabel->hide(); ui->fwLabel->hide(); ui->intervalLabel->hide(); ui->intervalEdit->hide(); ui->tempLabel->hide(); ui->tempEdit->hide(); ui->humLabel->hide(); ui->humEdit->hide(); ui->baroLabel->hide(); ui->baroEdit->hide(); ui->networkLabel->hide(); ui->networkEdit->hide(); ui->ssidLabel->hide(); ui->ssidEdit->hide(); ui->rssiLabel->hide(); ui->rssiEdit->hide(); ui->rebootButton->hide(); ui->rebirthButton->hide(); } } } DetailNode::~DetailNode() { delete ui; emit entry_changed(); } /* * Receive signals destined for all co2meters. * Check if the signal is for us. */ void DetailNode::refreshNode(QString data) { if (_node == data) { emit refreshTable(); } } void DetailNode::on_quitButton_clicked() { this->close(); this->setResult(1); } void DetailNode::control_reboot() { int rc = QMessageBox::warning(this, tr("Reboot application"), tr("Remote application is running, really reboot?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No); if (rc == QMessageBox::No) return; QString msg = QString("{\"node\":\""+_node+"\",\"group_id\":\""+_group_id+"\",\"control\":\"reboot\"}"); #ifdef DEBUG_MONITOR qDebug() << msg; #endif webSocket->sendTextMessage(msg); } void DetailNode::control_rebirth() { QString msg = QString("{\"node\":\""+_node+"\",\"group_id\":\""+_group_id+"\",\"control\":\"rebirth\"}"); #ifdef DEBUG_MONITOR qDebug() << msg; #endif webSocket->sendTextMessage(msg); }