Fixed error messages about log and camera buttons. Only show items that are really used.

Thu, 09 Feb 2023 12:53:21 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 09 Feb 2023 12:53:21 +0100
changeset 489
4db768aea3df
parent 488
dc3091338f9b
child 490
b67fb2e5bb41

Fixed error messages about log and camera buttons. Only show items that are really used.

src/DetailFermenter.cpp file | annotate | diff | comparison | revisions
src/DetailFermenter.h file | annotate | diff | comparison | revisions
translations/bmsapp_en.ts file | annotate | diff | comparison | revisions
translations/bmsapp_nl.ts file | annotate | diff | comparison | revisions
--- 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<int>::of(&QComboBox::currentIndexChanged), this, &DetailFermenter::stage_changed);
     connect(ui->codePick, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &DetailFermenter::code_changed);
     connect(ui->profilePick, QOverload<int>::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;
--- a/src/DetailFermenter.h	Mon Feb 06 11:55:53 2023 +0100
+++ b/src/DetailFermenter.h	Thu Feb 09 12:53:21 2023 +0100
@@ -39,8 +39,8 @@
     void stage_changed(int val);
     void code_changed(int val);
     void profile_changed(int val);
-    void on_ChartButton_clicked();
-    void on_WebcamButton_clicked();
+    void on_logButton_clicked();
+    void on_camButton_clicked();
 
 public slots:
     void refreshFermenter(QString);
--- a/translations/bmsapp_en.ts	Mon Feb 06 11:55:53 2023 +0100
+++ b/translations/bmsapp_en.ts	Thu Feb 09 12:53:21 2023 +0100
@@ -622,73 +622,73 @@
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/DetailFermenter.cpp" line="39"/>
+        <location filename="../src/DetailFermenter.cpp" line="38"/>
         <source>BMSapp - Details Fermenter</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/DetailFermenter.cpp" line="74"/>
+        <location filename="../src/DetailFermenter.cpp" line="73"/>
         <source>Erase profile</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/DetailFermenter.cpp" line="135"/>
+        <location filename="../src/DetailFermenter.cpp" line="132"/>
         <source>Online</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/DetailFermenter.cpp" line="247"/>
+        <location filename="../src/DetailFermenter.cpp" line="285"/>
         <source>Start</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/DetailFermenter.cpp" line="253"/>
+        <location filename="../src/DetailFermenter.cpp" line="291"/>
         <source>Profile active %1% done</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/DetailFermenter.cpp" line="255"/>
-        <location filename="../src/DetailFermenter.cpp" line="265"/>
+        <location filename="../src/DetailFermenter.cpp" line="293"/>
+        <location filename="../src/DetailFermenter.cpp" line="303"/>
         <source>Abort</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/DetailFermenter.cpp" line="258"/>
+        <location filename="../src/DetailFermenter.cpp" line="296"/>
         <source>Pause</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/DetailFermenter.cpp" line="263"/>
+        <location filename="../src/DetailFermenter.cpp" line="301"/>
         <source>Profile paused %1% done</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/DetailFermenter.cpp" line="268"/>
-        <source>Continue</source>
-        <translation type="unfinished"></translation>
-    </message>
-    <message>
-        <location filename="../src/DetailFermenter.cpp" line="273"/>
-        <source>Profile ready</source>
-        <translation type="unfinished"></translation>
-    </message>
-    <message>
-        <location filename="../src/DetailFermenter.cpp" line="275"/>
-        <source>Profile Ok</source>
-        <translation type="unfinished"></translation>
-    </message>
-    <message>
         <location filename="../src/DetailFermenter.cpp" line="306"/>
+        <source>Continue</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="../src/DetailFermenter.cpp" line="311"/>
+        <source>Profile ready</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="../src/DetailFermenter.cpp" line="313"/>
+        <source>Profile Ok</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="../src/DetailFermenter.cpp" line="365"/>
         <source>Offline</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/DetailFermenter.cpp" line="439"/>
+        <location filename="../src/DetailFermenter.cpp" line="497"/>
         <source>Profile running</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/DetailFermenter.cpp" line="439"/>
+        <location filename="../src/DetailFermenter.cpp" line="497"/>
         <source>Profile is active, really abort?</source>
         <translation type="unfinished"></translation>
     </message>
--- a/translations/bmsapp_nl.ts	Mon Feb 06 11:55:53 2023 +0100
+++ b/translations/bmsapp_nl.ts	Thu Feb 09 12:53:21 2023 +0100
@@ -695,73 +695,73 @@
         <translation>Camera</translation>
     </message>
     <message>
-        <location filename="../src/DetailFermenter.cpp" line="39"/>
+        <location filename="../src/DetailFermenter.cpp" line="38"/>
         <source>BMSapp - Details Fermenter</source>
         <translation>BMSapp - Details klimaatkast</translation>
     </message>
     <message>
-        <location filename="../src/DetailFermenter.cpp" line="74"/>
+        <location filename="../src/DetailFermenter.cpp" line="73"/>
         <source>Erase profile</source>
         <translation>Wis profiel</translation>
     </message>
     <message>
-        <location filename="../src/DetailFermenter.cpp" line="135"/>
+        <location filename="../src/DetailFermenter.cpp" line="132"/>
         <source>Online</source>
         <translation>Online</translation>
     </message>
     <message>
-        <location filename="../src/DetailFermenter.cpp" line="247"/>
+        <location filename="../src/DetailFermenter.cpp" line="285"/>
         <source>Start</source>
         <translation>Start</translation>
     </message>
     <message>
-        <location filename="../src/DetailFermenter.cpp" line="253"/>
+        <location filename="../src/DetailFermenter.cpp" line="291"/>
         <source>Profile active %1% done</source>
         <translation>Profiel aktief %1% gereed</translation>
     </message>
     <message>
-        <location filename="../src/DetailFermenter.cpp" line="255"/>
-        <location filename="../src/DetailFermenter.cpp" line="265"/>
+        <location filename="../src/DetailFermenter.cpp" line="293"/>
+        <location filename="../src/DetailFermenter.cpp" line="303"/>
         <source>Abort</source>
         <translation>Stoppen</translation>
     </message>
     <message>
-        <location filename="../src/DetailFermenter.cpp" line="258"/>
+        <location filename="../src/DetailFermenter.cpp" line="296"/>
         <source>Pause</source>
         <translation>Pauze</translation>
     </message>
     <message>
-        <location filename="../src/DetailFermenter.cpp" line="263"/>
+        <location filename="../src/DetailFermenter.cpp" line="301"/>
         <source>Profile paused %1% done</source>
         <translation>Profiel pauze %1% gereed</translation>
     </message>
     <message>
-        <location filename="../src/DetailFermenter.cpp" line="268"/>
-        <source>Continue</source>
-        <translation>Ga door</translation>
-    </message>
-    <message>
-        <location filename="../src/DetailFermenter.cpp" line="273"/>
-        <source>Profile ready</source>
-        <translation>Profiel gereed</translation>
-    </message>
-    <message>
-        <location filename="../src/DetailFermenter.cpp" line="275"/>
-        <source>Profile Ok</source>
-        <translation>Profiel Ok</translation>
-    </message>
-    <message>
         <location filename="../src/DetailFermenter.cpp" line="306"/>
+        <source>Continue</source>
+        <translation>Ga door</translation>
+    </message>
+    <message>
+        <location filename="../src/DetailFermenter.cpp" line="311"/>
+        <source>Profile ready</source>
+        <translation>Profiel gereed</translation>
+    </message>
+    <message>
+        <location filename="../src/DetailFermenter.cpp" line="313"/>
+        <source>Profile Ok</source>
+        <translation>Profiel Ok</translation>
+    </message>
+    <message>
+        <location filename="../src/DetailFermenter.cpp" line="365"/>
         <source>Offline</source>
         <translation>Offline</translation>
     </message>
     <message>
-        <location filename="../src/DetailFermenter.cpp" line="439"/>
+        <location filename="../src/DetailFermenter.cpp" line="497"/>
         <source>Profile running</source>
         <translation>Profiel draait</translation>
     </message>
     <message>
-        <location filename="../src/DetailFermenter.cpp" line="439"/>
+        <location filename="../src/DetailFermenter.cpp" line="497"/>
         <source>Profile is active, really abort?</source>
         <translation>Profiel is aktief, echt stoppen?</translation>
     </message>

mercurial