diff -r dc3091338f9b -r 4db768aea3df src/DetailFermenter.cpp --- a/src/DetailFermenter.cpp Mon Feb 06 11:55:53 2023 +0100 +++ b/src/DetailFermenter.cpp Thu Feb 09 12:53:21 2023 +0100 @@ -32,7 +32,6 @@ { QSqlQuery query; - qDebug() << "DetailFermenter record:" << id; ui->setupUi(this); this->recno = id; setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint); @@ -88,8 +87,6 @@ connect(ui->stageEdit, QOverload::of(&QComboBox::currentIndexChanged), this, &DetailFermenter::stage_changed); connect(ui->codePick, QOverload::of(&QComboBox::currentIndexChanged), this, &DetailFermenter::code_changed); connect(ui->profilePick, QOverload::of(&QComboBox::currentIndexChanged), this, &DetailFermenter::profile_changed); - connect(ui->logButton, SIGNAL(clicked()), this, SLOT(on_ChartButton_clicked())); - connect(ui->camButton, SIGNAL(clicked()), this, SLOT(on_WebcamButton_clicked())); connect(parent, SIGNAL(updateFermenter(QString)), this, SLOT(refreshFermenter(QString))); emit refreshTable(); } @@ -190,43 +187,84 @@ ui->alarmLED->setChecked((query.value("alarm").toInt() != 0) ? true:false); ui->tempsetBox->show(); - if ((query.value("mode").toString() == "FRIDGE") || (query.value("mode").toString() == "BEER")) { - ui->loEdit->setReadOnly(false); - ui->loEdit->setButtonSymbols(QAbstractSpinBox::UpDownArrows); - ui->hiEdit->setReadOnly(false); - ui->hiEdit->setButtonSymbols(QAbstractSpinBox::UpDownArrows); + if ((query.value("mode").toString() == "OFF") || (query.value("mode").toString() == "NONE")) { + ui->loEdit->hide(); + ui->loLabel->hide(); + ui->hiEdit->hide(); + ui->hiLabel->hide(); } else { - ui->loEdit->setReadOnly(true); - ui->loEdit->setButtonSymbols(QAbstractSpinBox::NoButtons); - ui->hiEdit->setReadOnly(true); - ui->hiEdit->setButtonSymbols(QAbstractSpinBox::NoButtons); + ui->loEdit->show(); + ui->loLabel->show(); + ui->hiEdit->show(); + ui->hiLabel->show(); + if ((query.value("mode").toString() == "FRIDGE") || (query.value("mode").toString() == "BEER")) { + ui->loEdit->setReadOnly(false); + ui->loEdit->setButtonSymbols(QAbstractSpinBox::UpDownArrows); + ui->hiEdit->setReadOnly(false); + ui->hiEdit->setButtonSymbols(QAbstractSpinBox::UpDownArrows); + } else { + ui->loEdit->setReadOnly(true); + ui->loEdit->setButtonSymbols(QAbstractSpinBox::NoButtons); + ui->hiEdit->setReadOnly(true); + ui->hiEdit->setButtonSymbols(QAbstractSpinBox::NoButtons); + } + lo_set = query.value("setpoint_low").toDouble(); + hi_set = query.value("setpoint_high").toDouble(); + ui->loEdit->setValue(lo_set); + ui->hiEdit->setValue(hi_set); } - lo_set = query.value("setpoint_low").toDouble(); - hi_set = query.value("setpoint_high").toDouble(); - ui->loEdit->setValue(lo_set); - ui->hiEdit->setValue(hi_set); ui->switchBox->show(); - ui->heatLED->setChecked((query.value("heater_state").toInt() != 0) ? true:false); - ui->coolLED->setChecked((query.value("cooler_state").toInt() != 0) ? true:false); - ui->fanLED->setChecked((query.value("fan_state").toInt() != 0) ? true:false); - - if (query.value("mode").toString() == "NONE") { - ui->heatSwitch->show(); - ui->coolSwitch->show(); - ui->fanSwitch->show(); - heat_state = (query.value("heater_state").toInt()) ? true:false; - cool_state = (query.value("cooler_state").toInt()) ? true:false; - fan_state = (query.value("fan_state").toInt()) ? true:false; - ui->heatSwitch->setChecked(heat_state); - ui->coolSwitch->setChecked(cool_state); - ui->fanSwitch->setChecked(fan_state); - // Copy state values to variables and set the switches. + if (query.value("heater_address").toString().length() == 36) { + ui->heatLED->show(); + ui->heatLabel->show(); + ui->heatLED->setChecked((query.value("heater_state").toInt() != 0) ? true:false); + if (query.value("mode").toString() == "NONE") { + ui->heatSwitch->show(); + heat_state = (query.value("heater_state").toInt()) ? true:false; + ui->heatSwitch->setChecked(heat_state); + } else { + ui->heatSwitch->hide(); + heat_state = false; + } } else { + ui->heatLED->hide(); + ui->heatLabel->hide(); ui->heatSwitch->hide(); - ui->coolSwitch->hide(); - ui->fanSwitch->hide(); - heat_state = cool_state = fan_state = false; + } + if (query.value("cooler_address").toString().length() == 36) { + ui->coolLED->show(); + ui->coolLabel->show(); + ui->coolLED->setChecked((query.value("cooler_state").toInt() != 0) ? true:false); + if (query.value("mode").toString() == "NONE") { + ui->coolSwitch->show(); + cool_state = (query.value("cooler_state").toInt()) ? true:false; + ui->coolSwitch->setChecked(cool_state); + } else { + ui->coolSwitch->hide(); + cool_state = false; + } + } else { + ui->coolLED->hide(); + ui->coolLabel->hide(); + ui->coolSwitch->hide(); + } + if (query.value("fan_address").toString().length() == 36) { + ui->fanLED->show(); + ui->fanLabel->show(); + ui->fanLED->setChecked((query.value("fan_state").toInt() != 0) ? true:false); + if (query.value("mode").toString() == "NONE") { + ui->fanSwitch->show(); + fan_state = (query.value("fan_state").toInt()) ? true:false; + ui->fanSwitch->setChecked(fan_state); + } else { + ui->fanSwitch->hide(); + fan_state = false; + } + } else { + ui->fanLED->hide(); + ui->fanLabel->hide(); + ui->fanSwitch->hide(); } if (query.value("profile_name").toString() == "") { @@ -291,14 +329,35 @@ } ui->thermoBox->show(); - if (query.value("air_state").toString() == "OK") { - ui->airThermo->setValue(query.value("air_temperature").toDouble()); + if (query.value("air_address").toString().length() == 36) { + ui->airThermo->show(); + ui->airLabel->show(); + if (query.value("air_state").toString() == "OK") { + ui->airThermo->setValue(query.value("air_temperature").toDouble()); + } + } else { + ui->airThermo->hide(); + ui->airLabel->hide(); } - if (query.value("beer_state").toString() == "OK") { - ui->beerThermo->setValue(query.value("beer_temperature").toDouble()); - } - if (query.value("chiller_state").toString() == "OK") { - ui->chillerThermo->setValue(query.value("chiller_temperature").toDouble()); + if (query.value("beer_address").toString().length() == 36) { + ui->beerThermo->show(); + ui->beerLabel->show(); + if (query.value("beer_state").toString() == "OK") { + ui->beerThermo->setValue(query.value("beer_temperature").toDouble()); + } + } else { + ui->beerThermo->hide(); + ui->beerLabel->hide(); + } + if (query.value("chiller_address").toString().length() == 36) { + ui->chillerThermo->show(); + ui->chillerLabel->show(); + if (query.value("chiller_state").toString() == "OK") { + ui->chillerThermo->setValue(query.value("chiller_temperature").toDouble()); + } + } else { + ui->chillerThermo->hide(); + ui->chillerLabel->hide(); } } else { @@ -322,13 +381,11 @@ ui->logButton->hide(); } } - } DetailFermenter::~DetailFermenter() { - qDebug() << "DetailFermenter done"; delete ui; emit entry_changed(); } @@ -346,16 +403,18 @@ } -void DetailFermenter::on_ChartButton_clicked() +void DetailFermenter::on_logButton_clicked() { ChartFermenter dialog(_beercode, _beername, this); } -void DetailFermenter::on_WebcamButton_clicked() +void DetailFermenter::on_camButton_clicked() { - QString msg = QString("{\"device\":\"fermenters\",\"node\":\""+_node+"\",\"unit\":\""+_alias+"\",\"light_state\":100}"); - webSocket->sendTextMessage(msg); + if (_webcam_light) { + QString msg = QString("{\"device\":\"fermenters\",\"node\":\""+_node+"\",\"unit\":\""+_alias+"\",\"light_state\":100}"); + webSocket->sendTextMessage(msg); + } Webcam dialog(_webcam_url, this); } @@ -397,7 +456,6 @@ { QString msg=QString("{\"device\":\"fermenters\",\"node\":\""+_node+"\",\"unit\":\""+_alias+"\",\"heater_state\":%1,\"cooler_state\":%2,\"fan_state\":%3}") .arg((heat_state)?100:0).arg((cool_state)?100:0).arg((fan_state)?100:0); - //qDebug() << msg; webSocket->sendTextMessage(msg); } @@ -470,7 +528,6 @@ { QStringList mode ({ "OFF", "NONE", "FRIDGE", "BEER", "PROFILE" }); QString msg = QString("{\"device\":\"fermenters\",\"node\":\"" + _node + "\",\"unit\":\"" + _alias + "\",\"mode\":\"" + mode[val] + "\"}"); - //qDebug() << "mode_changed" << val << msg; webSocket->sendTextMessage(msg); } @@ -479,7 +536,6 @@ { QStringList stage ({ "PRIMARY", "SECONDARY", "TERTIARY", "CARBONATION" }); QString msg = QString("{\"device\":\"fermenters\",\"node\":\"" + _node + "\",\"unit\":\"" + _alias + "\",\"stage\":\"" + stage[val] + "\"}"); - //qDebug() << "stage_changed" << val << msg; webSocket->sendTextMessage(msg); } @@ -590,7 +646,6 @@ } payload.append(QString("]}")); -// qDebug() << query.value("steps").toString(); } QString msg = QString("{\"device\":\"fermenters\",\"node\":\"" + _node + "\",\"unit\":\"" + _alias + "\",%1}").arg(payload); qDebug() << "profile_changed" << val << msg;