Basic setup for iSpindel calibration.

Fri, 13 Oct 2023 14:47:21 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Fri, 13 Oct 2023 14:47:21 +0200
changeset 503
61c114afb0ee
parent 502
0f15edebc665
child 504
ea7cf64c9a6c

Basic setup for iSpindel calibration.

CMakeLists.txt file | annotate | diff | comparison | revisions
src/CalibrateiSpindel.cpp file | annotate | diff | comparison | revisions
src/CalibrateiSpindel.h file | annotate | diff | comparison | revisions
src/MoniSpindels.cpp file | annotate | diff | comparison | revisions
src/MoniSpindels.h file | annotate | diff | comparison | revisions
translations/bmsapp_en.ts file | annotate | diff | comparison | revisions
translations/bmsapp_nl.ts file | annotate | diff | comparison | revisions
ui/CalibrateiSpindel.ui file | annotate | diff | comparison | revisions
ui/DetailiSpindel.ui file | annotate | diff | comparison | revisions
--- a/CMakeLists.txt	Thu Oct 12 17:03:50 2023 +0200
+++ b/CMakeLists.txt	Fri Oct 13 14:47:21 2023 +0200
@@ -230,6 +230,7 @@
     ${SRCDIR}/ChartCarbonate.cpp
     ${SRCDIR}/ChartFermenter.cpp
     ${SRCDIR}/ChartiSpindel.cpp
+    ${SRCDIR}/CalibrateiSpindel.cpp
     ${SRCDIR}/Webcam.cpp
     ${SRCDIR}/EditProduct.cpp
     ${SRCDIR}/ImportXML.cpp
@@ -298,6 +299,7 @@
     ${SRCDIR}/ChartCarbonate.h
     ${SRCDIR}/ChartFermenter.h
     ${SRCDIR}/ChartiSpindel.h
+    ${SRCDIR}/CalibrateiSpindel.h
     ${SRCDIR}/Webcam.h
     ${SRCDIR}/EditProduct.h
     ${SRCDIR}/ImportXML.h
@@ -342,6 +344,7 @@
     ${UIDIR}/DetailFermenter.ui
     ${UIDIR}/DetailCO2meter.ui
     ${UIDIR}/DetailiSpindel.ui
+    ${UIDIR}/CalibrateiSpindel.ui
     ${UIDIR}/ImportXML.ui
     ${UIDIR}/ImportBrew.ui
     ${UIDIR}/MainWindow.ui
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/CalibrateiSpindel.cpp	Fri Oct 13 14:47:21 2023 +0200
@@ -0,0 +1,73 @@
+/**
+ * CalibrateiSpindel.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 "CalibrateiSpindel.h"
+#include "../ui/ui_CalibrateiSpindel.h"
+#include "global.h"
+#include "Utils.h"
+#include "MainWindow.h"
+
+
+
+CalibrateiSpindel::CalibrateiSpindel(int id, QWidget *parent) : QDialog(parent), ui(new Ui::CalibrateiSpindel)
+{
+    QSqlQuery query;
+
+#ifdef DEBUG_MONITOR
+    qDebug() << "CalibrateiSpindel record:" << id;
+#endif
+    ui->setupUi(this);
+    this->recno = id;
+    setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
+    setWindowTitle(tr("BMSapp - Calibrate iSpindel"));
+
+    connect(parent, SIGNAL(updateiSpindel(QString)), this, SLOT(refreshiSpindel(QString)));
+    emit refreshTable();
+}
+
+
+void CalibrateiSpindel::refreshTable()
+{
+    QSqlQuery query;
+
+    query.prepare("SELECT node,alias,calibrate FROM mon_ispindels WHERE record = :recno");
+    query.bindValue(":recno", this->recno);
+    query.exec();
+    if (query.next()) {
+
+	_node = query.value("node").toString();
+	_alias = query.value("alias").toString();
+	_data_old = query.value("calibrate").toString();
+	_data_new = query.value("calibrate").toString();
+
+    }
+
+}
+
+
+CalibrateiSpindel::~CalibrateiSpindel()
+{
+    delete ui;
+}
+
+
+void CalibrateiSpindel::on_quitButton_clicked()
+{
+    this->close();
+    this->setResult(1);
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/CalibrateiSpindel.h	Fri Oct 13 14:47:21 2023 +0200
@@ -0,0 +1,35 @@
+#ifndef _CALIBRATEISPINDEL_H
+#define _CALIBRATEISPINDEL_H
+
+#include <QDialog>
+#include <QDoubleSpinBox>
+#include <QCheckBox>
+#include <QComboBox>
+#include <QRadioButton>
+#include <QLineEdit>
+#include <QDialogButtonBox>
+
+
+namespace Ui {
+class CalibrateiSpindel;
+}
+
+class CalibrateiSpindel : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit CalibrateiSpindel(int id, QWidget *parent = 0);
+    ~CalibrateiSpindel();
+
+private slots:
+    void on_quitButton_clicked();
+    void refreshTable(void);
+
+private:
+    Ui::CalibrateiSpindel *ui;
+    QString _node, _alias, _data_old, _data_new;
+    int recno;
+};
+
+#endif
--- a/src/MoniSpindels.cpp	Thu Oct 12 17:03:50 2023 +0200
+++ b/src/MoniSpindels.cpp	Fri Oct 13 14:47:21 2023 +0200
@@ -16,6 +16,7 @@
  */
 #include "MoniSpindels.h"
 #include "DetailiSpindel.h"
+#include "CalibrateiSpindel.h"
 #include "MainWindow.h"
 #include "Utils.h"
 #include "config.h"
@@ -75,16 +76,17 @@
     QTableWidgetItem *item;
 
     QSqlQuery query("SELECT record,alias,node,online,mode,temperature,gravity,beercode,beername FROM mon_ispindels ORDER BY alias");
-    const QStringList labels({tr("Unit"), tr("Node"), tr("Status"), tr("Beer"), tr("Temperature"), tr("SG"), tr("Details")});
+    const QStringList labels({tr("Unit"), tr("Node"), tr("Status"), tr("Beer"), tr("Temperature"), tr("SG"), tr("Cal"), tr("Details")});
 
-    this->tableiSpindels->setColumnCount(7);
+    this->tableiSpindels->setColumnCount(8);
     this->tableiSpindels->setColumnWidth(0, 150);	/* Alias	*/
     this->tableiSpindels->setColumnWidth(1, 120);	/* Node		*/
     this->tableiSpindels->setColumnWidth(2, 100);	/* Status	*/
-    this->tableiSpindels->setColumnWidth(3, 390);	/* Beer		*/
+    this->tableiSpindels->setColumnWidth(3, 330);	/* Beer		*/
     this->tableiSpindels->setColumnWidth(4,  90);	/* Temperature	*/
     this->tableiSpindels->setColumnWidth(5,  90);	/* Gravity	*/
-    this->tableiSpindels->setColumnWidth(6,  90);	/* Edit button	*/
+    this->tableiSpindels->setColumnWidth(6,  60);	/* Calibrate	*/
+    this->tableiSpindels->setColumnWidth(7,  90);	/* Edit button  */
     this->tableiSpindels->setRowCount(query.size());
     this->tableiSpindels->setHorizontalHeaderLabels(labels);
     this->tableiSpindels->verticalHeader()->hide();
@@ -124,7 +126,19 @@
             this->tableiSpindels->setItem(i, 5, new QTableWidgetItem(QString("")));
 	}
 
-	/* Add the Edit button */
+	/* Add the Calibrate button */
+        QWidget* cWidget = new QWidget();
+        QPushButton* btn_cal = new QPushButton();
+        btn_cal->setObjectName(QString("%1").arg(query.value("record").toString()));   /* Send record with the button */
+        btn_cal->setText(tr("Cal"));
+        connect(btn_cal, SIGNAL(clicked()), this, SLOT(on_calButton_clicked()));
+        QHBoxLayout* cLayout = new QHBoxLayout(cWidget);
+        cLayout->addWidget(btn_cal);
+        cLayout->setContentsMargins(5, 0, 5, 0);
+        cWidget->setLayout(cLayout);
+        this->tableiSpindels->setCellWidget(i, 6, cWidget);
+
+	/* Add the Details button */
 	QWidget* pWidget = new QWidget();
 	QPushButton* btn_edit = new QPushButton();
 	btn_edit->setObjectName(QString("%1").arg(query.value("record").toString()));	/* Send record with the button */
@@ -134,7 +148,7 @@
 	pLayout->addWidget(btn_edit);
 	pLayout->setContentsMargins(5, 0, 5, 0);
 	pWidget->setLayout(pLayout);
-	this->tableiSpindels->setCellWidget(i, 6, pWidget);
+	this->tableiSpindels->setCellWidget(i, 7, pWidget);
 	query.next();
     }
     emit setStatus(QString(tr("Total items: %1")).arg(query.size()));
@@ -167,3 +181,18 @@
 }
 
 
+void MoniSpindels::cal(int recno)
+{
+    CalibrateiSpindel dialog(recno, this);
+    dialog.setModal(true);
+    dialog.exec();
+}
+
+
+void MoniSpindels::on_calButton_clicked()
+{
+    QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
+    int recno = pb->objectName().toInt();
+    cal(recno);
+}
+
--- a/src/MoniSpindels.h	Thu Oct 12 17:03:50 2023 +0200
+++ b/src/MoniSpindels.h	Fri Oct 13 14:47:21 2023 +0200
@@ -27,6 +27,7 @@
 
 private slots:
     void on_editButton_clicked();
+    void on_calButton_clicked();
     void refreshTable(void);
 
 public slots:
@@ -40,6 +41,7 @@
     QPushButton *quitButton;
 
     void edit(int recno);
+    void cal(int recno);
 };
 
 #endif
--- a/translations/bmsapp_en.ts	Thu Oct 12 17:03:50 2023 +0200
+++ b/translations/bmsapp_en.ts	Fri Oct 13 14:47:21 2023 +0200
@@ -48,6 +48,24 @@
     </message>
 </context>
 <context>
+    <name>CalibrateiSpindel</name>
+    <message>
+        <location filename="../ui/CalibrateiSpindel.ui" line="14"/>
+        <source>Dialog</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="../ui/CalibrateiSpindel.ui" line="44"/>
+        <source>Quit</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="../src/CalibrateiSpindel.cpp" line="35"/>
+        <source>BMSapp - Calibrate iSpindel</source>
+        <translation type="unfinished"></translation>
+    </message>
+</context>
+<context>
     <name>ChartCarbonate</name>
     <message>
         <location filename="../src/ChartCarbonate.cpp" line="30"/>
@@ -1002,11 +1020,6 @@
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../ui/DetailiSpindel.ui" line="766"/>
-        <source>Calibrate</source>
-        <translation type="unfinished"></translation>
-    </message>
-    <message>
         <location filename="../src/DetailiSpindel.cpp" line="41"/>
         <source>BMSapp - Details iSpindel</source>
         <translation type="unfinished"></translation>
@@ -10107,48 +10120,54 @@
 <context>
     <name>MoniSpindels</name>
     <message>
-        <location filename="../src/MoniSpindels.cpp" line="59"/>
+        <location filename="../src/MoniSpindels.cpp" line="60"/>
         <source>Quit</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/MoniSpindels.cpp" line="78"/>
+        <location filename="../src/MoniSpindels.cpp" line="79"/>
         <source>Unit</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/MoniSpindels.cpp" line="78"/>
+        <location filename="../src/MoniSpindels.cpp" line="79"/>
         <source>Node</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/MoniSpindels.cpp" line="78"/>
+        <location filename="../src/MoniSpindels.cpp" line="79"/>
         <source>Status</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/MoniSpindels.cpp" line="78"/>
+        <location filename="../src/MoniSpindels.cpp" line="79"/>
         <source>Beer</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/MoniSpindels.cpp" line="78"/>
+        <location filename="../src/MoniSpindels.cpp" line="79"/>
         <source>Temperature</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/MoniSpindels.cpp" line="78"/>
+        <location filename="../src/MoniSpindels.cpp" line="79"/>
         <source>SG</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/MoniSpindels.cpp" line="78"/>
-        <location filename="../src/MoniSpindels.cpp" line="131"/>
+        <location filename="../src/MoniSpindels.cpp" line="79"/>
+        <location filename="../src/MoniSpindels.cpp" line="145"/>
         <source>Details</source>
         <translation type="unfinished"></translation>
     </message>
     <message>
-        <location filename="../src/MoniSpindels.cpp" line="140"/>
+        <location filename="../src/MoniSpindels.cpp" line="79"/>
+        <location filename="../src/MoniSpindels.cpp" line="133"/>
+        <source>Cal</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="../src/MoniSpindels.cpp" line="154"/>
         <source>Total items: %1</source>
         <translation type="unfinished"></translation>
     </message>
--- a/translations/bmsapp_nl.ts	Thu Oct 12 17:03:50 2023 +0200
+++ b/translations/bmsapp_nl.ts	Fri Oct 13 14:47:21 2023 +0200
@@ -78,6 +78,36 @@
     </message>
 </context>
 <context>
+    <name>CalibrateiSpindel</name>
+    <message>
+        <location filename="../ui/CalibrateiSpindel.ui" line="14"/>
+        <source>Dialog</source>
+        <translation type="unfinished">Dialog</translation>
+    </message>
+    <message>
+        <source>Uuid:</source>
+        <translation type="obsolete">Uuid:</translation>
+    </message>
+    <message>
+        <source>System and unit:</source>
+        <translation type="obsolete">Systeem en unit:</translation>
+    </message>
+    <message>
+        <source>iSpindel overview</source>
+        <translation type="obsolete">iSpindel overzicht</translation>
+    </message>
+    <message>
+        <location filename="../ui/CalibrateiSpindel.ui" line="44"/>
+        <source>Quit</source>
+        <translation type="unfinished">Terug</translation>
+    </message>
+    <message>
+        <location filename="../src/CalibrateiSpindel.cpp" line="35"/>
+        <source>BMSapp - Calibrate iSpindel</source>
+        <translation type="unfinished"></translation>
+    </message>
+</context>
+<context>
     <name>ChartCarbonate</name>
     <message>
         <location filename="../src/ChartCarbonate.cpp" line="30"/>
@@ -1037,11 +1067,6 @@
         <translation>Toont de temperatuur</translation>
     </message>
     <message>
-        <location filename="../ui/DetailiSpindel.ui" line="766"/>
-        <source>Calibrate</source>
-        <translation type="unfinished"></translation>
-    </message>
-    <message>
         <source>Shows the air temperature</source>
         <translation type="obsolete">Toont de lucht temperatuur</translation>
     </message>
@@ -11223,48 +11248,54 @@
 <context>
     <name>MoniSpindels</name>
     <message>
-        <location filename="../src/MoniSpindels.cpp" line="59"/>
+        <location filename="../src/MoniSpindels.cpp" line="60"/>
         <source>Quit</source>
         <translation>Terug</translation>
     </message>
     <message>
-        <location filename="../src/MoniSpindels.cpp" line="78"/>
+        <location filename="../src/MoniSpindels.cpp" line="79"/>
         <source>Unit</source>
         <translation>Eenheid</translation>
     </message>
     <message>
-        <location filename="../src/MoniSpindels.cpp" line="78"/>
+        <location filename="../src/MoniSpindels.cpp" line="79"/>
         <source>Node</source>
         <translation>Systeem</translation>
     </message>
     <message>
-        <location filename="../src/MoniSpindels.cpp" line="78"/>
+        <location filename="../src/MoniSpindels.cpp" line="79"/>
         <source>Status</source>
         <translation>Status</translation>
     </message>
     <message>
-        <location filename="../src/MoniSpindels.cpp" line="78"/>
+        <location filename="../src/MoniSpindels.cpp" line="79"/>
         <source>Beer</source>
         <translation>Bier</translation>
     </message>
     <message>
-        <location filename="../src/MoniSpindels.cpp" line="78"/>
+        <location filename="../src/MoniSpindels.cpp" line="79"/>
         <source>Temperature</source>
         <translation>Temperatuur</translation>
     </message>
     <message>
-        <location filename="../src/MoniSpindels.cpp" line="78"/>
+        <location filename="../src/MoniSpindels.cpp" line="79"/>
         <source>SG</source>
         <translation>SG</translation>
     </message>
     <message>
-        <location filename="../src/MoniSpindels.cpp" line="78"/>
-        <location filename="../src/MoniSpindels.cpp" line="131"/>
+        <location filename="../src/MoniSpindels.cpp" line="79"/>
+        <location filename="../src/MoniSpindels.cpp" line="145"/>
         <source>Details</source>
         <translation>Details</translation>
     </message>
     <message>
-        <location filename="../src/MoniSpindels.cpp" line="140"/>
+        <location filename="../src/MoniSpindels.cpp" line="79"/>
+        <location filename="../src/MoniSpindels.cpp" line="133"/>
+        <source>Cal</source>
+        <translation type="unfinished"></translation>
+    </message>
+    <message>
+        <location filename="../src/MoniSpindels.cpp" line="154"/>
         <source>Total items: %1</source>
         <translation>Totaal items: %1</translation>
     </message>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ui/CalibrateiSpindel.ui	Fri Oct 13 14:47:21 2023 +0200
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>CalibrateiSpindel</class>
+ <widget class="QDialog" name="CalibrateiSpindel">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>1024</width>
+    <height>560</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="0">
+    <widget class="QWidget" name="topWidget" native="true">
+     <widget class="QGroupBox" name="buttonBox">
+      <property name="geometry">
+       <rect>
+        <x>740</x>
+        <y>370</y>
+        <width>261</width>
+        <height>161</height>
+       </rect>
+      </property>
+      <widget class="QPushButton" name="quitButton">
+       <property name="geometry">
+        <rect>
+         <x>90</x>
+         <y>120</y>
+         <width>80</width>
+         <height>23</height>
+        </rect>
+       </property>
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="text">
+        <string>Quit</string>
+       </property>
+       <property name="icon">
+        <iconset>
+         <normaloff>:icons/silk/door_out.png</normaloff>:icons/silk/door_out.png</iconset>
+       </property>
+      </widget>
+     </widget>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <tabstops>
+  <tabstop>quitButton</tabstop>
+ </tabstops>
+ <resources>
+  <include location="../../../../../../home/mbroek/MyProjects/bmsapp/resources/icons.qrc"/>
+ </resources>
+ <connections/>
+</ui>
--- a/ui/DetailiSpindel.ui	Thu Oct 12 17:03:50 2023 +0200
+++ b/ui/DetailiSpindel.ui	Fri Oct 13 14:47:21 2023 +0200
@@ -542,7 +542,7 @@
         <x>740</x>
         <y>130</y>
         <width>261</width>
-        <height>231</height>
+        <height>281</height>
        </rect>
       </property>
       <widget class="QLabel" name="progressLabel">
@@ -708,16 +708,16 @@
       <property name="geometry">
        <rect>
         <x>740</x>
-        <y>370</y>
+        <y>420</y>
         <width>261</width>
-        <height>161</height>
+        <height>111</height>
        </rect>
       </property>
       <widget class="QPushButton" name="quitButton">
        <property name="geometry">
         <rect>
          <x>90</x>
-         <y>120</y>
+         <y>70</y>
          <width>80</width>
          <height>23</height>
         </rect>
@@ -740,7 +740,7 @@
        <property name="geometry">
         <rect>
          <x>90</x>
-         <y>70</y>
+         <y>20</y>
          <width>80</width>
          <height>23</height>
         </rect>
@@ -753,23 +753,6 @@
          <normaloff>:/icons/silk/chart_line.png</normaloff>:/icons/silk/chart_line.png</iconset>
        </property>
       </widget>
-      <widget class="QPushButton" name="calButton">
-       <property name="geometry">
-        <rect>
-         <x>90</x>
-         <y>20</y>
-         <width>80</width>
-         <height>23</height>
-        </rect>
-       </property>
-       <property name="text">
-        <string>Calibrate</string>
-       </property>
-       <property name="icon">
-        <iconset resource="../../../../../../home/mbroek/MyProjects/bmsapp/resources/icons.qrc">
-         <normaloff>:/icons/silk/wrench.png</normaloff>:/icons/silk/wrench.png</iconset>
-       </property>
-      </widget>
      </widget>
     </widget>
    </item>
@@ -801,7 +784,6 @@
   <tabstop>tiltEdit</tabstop>
   <tabstop>sgEdit</tabstop>
   <tabstop>logButton</tabstop>
-  <tabstop>calButton</tabstop>
  </tabstops>
  <resources>
   <include location="../../../../../../home/mbroek/MyProjects/bmsapp/resources/icons.qrc"/>

mercurial