Sun, 23 Jun 2024 11:35:42 +0200
Better sort logic in ProdOnDate screen.
310 | 1 | /** |
2 | * MoniSpindels.cpp is part of bmsapp. | |
3 | * | |
4 | * bmsapp is free software: you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License as published by | |
6 | * the Free Software Foundation, either version 3 of the License, or | |
7 | * (at your option) any later version. | |
8 | * | |
9 | * bmsapp is distributed in the hope that it will be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License | |
15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | */ | |
17 | #include "MoniSpindels.h" | |
329
b57299738980
Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
312
diff
changeset
|
18 | #include "DetailiSpindel.h" |
503
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
19 | #include "CalibrateiSpindel.h" |
310 | 20 | #include "MainWindow.h" |
311
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
21 | #include "Utils.h" |
310 | 22 | #include "config.h" |
23 | ||
24 | ||
25 | ||
26 | /* | |
27 | * Build the table and buttons on the mainscreen. | |
28 | * Don't use a ui file, do it dynamicly. | |
29 | */ | |
30 | MoniSpindels::MoniSpindels(QWidget *parent) : QDialog(parent) | |
31 | { | |
492
c3a781b4d35b
ChartCarbonate saves the image path in the settings file. Conditional debug messages in a lot on monitor files. In Fermenter monitor details make the status background red if offline. A lot more generic variables instead of continuous expensive calls to MySQL. If fermenter values for the thermometers are not OK, then do not show anything.
Michiel Broek <mbroek@mbse.eu>
parents:
329
diff
changeset
|
32 | #ifdef DEBUG_MONITOR |
310 | 33 | qDebug() << "MoniSpindels start"; |
492
c3a781b4d35b
ChartCarbonate saves the image path in the settings file. Conditional debug messages in a lot on monitor files. In Fermenter monitor details make the status background red if offline. A lot more generic variables instead of continuous expensive calls to MySQL. If fermenter values for the thermometers are not OK, then do not show anything.
Michiel Broek <mbroek@mbse.eu>
parents:
329
diff
changeset
|
34 | #endif |
310 | 35 | |
36 | gridLayout = new QGridLayout(this); | |
37 | gridLayout->setObjectName(QString::fromUtf8("gridLayout")); | |
311
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
38 | tableiSpindels = new QTableWidget(this); |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
39 | tableiSpindels->setObjectName(QString::fromUtf8("tableiSpindels")); |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
40 | tableiSpindels->setEnabled(true); |
310 | 41 | QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); |
42 | sizePolicy.setHorizontalStretch(0); | |
43 | sizePolicy.setVerticalStretch(0); | |
311
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
44 | sizePolicy.setHeightForWidth(tableiSpindels->sizePolicy().hasHeightForWidth()); |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
45 | tableiSpindels->setSizePolicy(sizePolicy); |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
46 | tableiSpindels->setMinimumSize(QSize(1054, 0)); |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
47 | gridLayout->addWidget(tableiSpindels, 0, 0, 1, 1); |
310 | 48 | |
49 | groupBox = new QGroupBox(this); | |
50 | groupBox->setObjectName(QString::fromUtf8("groupBox")); | |
51 | groupBox->setEnabled(true); | |
52 | groupBox->setFlat(false); | |
53 | horizontalLayout = new QHBoxLayout(groupBox); | |
54 | horizontalLayout->setSpacing(6); | |
55 | horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); | |
56 | horizontalLayout->setContentsMargins(0, 0, 0, 0); | |
57 | quitButton = new QPushButton(groupBox); | |
58 | quitButton->setObjectName(QString::fromUtf8("quitButton")); | |
59 | quitButton->setMinimumSize(QSize(80, 24)); | |
60 | quitButton->setText(tr("Quit")); | |
61 | QIcon icon; | |
62 | icon.addFile(QString::fromUtf8(":icons/silk/door_out.png"), QSize(), QIcon::Normal, QIcon::Off); | |
63 | quitButton->setIcon(icon); | |
311
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
64 | horizontalLayout->addWidget(quitButton, 0, Qt::AlignCenter); |
310 | 65 | gridLayout->addWidget(groupBox, 1, 0, 1, 1); |
66 | ||
67 | connect(quitButton, SIGNAL(clicked()), parent, SLOT(fromMoniSpindels())); | |
68 | connect(this, SIGNAL(setStatus(QString)), parent, SLOT(statusMsg(QString))); | |
311
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
69 | connect(parent, SIGNAL(updateiSpindels(QString)), this, SLOT(refreshiSpindels(QString))); |
310 | 70 | emit refreshTable(); |
71 | } | |
72 | ||
73 | ||
74 | void MoniSpindels::refreshTable() | |
75 | { | |
311
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
76 | QTableWidgetItem *item; |
537
48de0f61e5ea
The iSpindel monitor, detail and chart screens try to use the polynomial calibration data to show the SG. Fallback to already logged data if this fails.
Michiel Broek <mbroek@mbse.eu>
parents:
503
diff
changeset
|
77 | double plato, poly[4]; |
311
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
78 | |
537
48de0f61e5ea
The iSpindel monitor, detail and chart screens try to use the polynomial calibration data to show the SG. Fallback to already logged data if this fails.
Michiel Broek <mbroek@mbse.eu>
parents:
503
diff
changeset
|
79 | QSqlQuery query("SELECT record,alias,node,online,mode,temperature,gravity,angle,calibrate,beercode,beername FROM mon_ispindels ORDER BY alias"); |
503
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
80 | const QStringList labels({tr("Unit"), tr("Node"), tr("Status"), tr("Beer"), tr("Temperature"), tr("SG"), tr("Cal"), tr("Details")}); |
310 | 81 | |
503
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
82 | this->tableiSpindels->setColumnCount(8); |
311
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
83 | this->tableiSpindels->setColumnWidth(0, 150); /* Alias */ |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
84 | this->tableiSpindels->setColumnWidth(1, 120); /* Node */ |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
85 | this->tableiSpindels->setColumnWidth(2, 100); /* Status */ |
503
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
86 | this->tableiSpindels->setColumnWidth(3, 330); /* Beer */ |
311
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
87 | this->tableiSpindels->setColumnWidth(4, 90); /* Temperature */ |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
88 | this->tableiSpindels->setColumnWidth(5, 90); /* Gravity */ |
503
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
89 | this->tableiSpindels->setColumnWidth(6, 60); /* Calibrate */ |
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
90 | this->tableiSpindels->setColumnWidth(7, 90); /* Edit button */ |
311
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
91 | this->tableiSpindels->setRowCount(query.size()); |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
92 | this->tableiSpindels->setHorizontalHeaderLabels(labels); |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
93 | this->tableiSpindels->verticalHeader()->hide(); |
310 | 94 | /* Set the widget size to 1054 x 575 in the ui. */ |
95 | ||
96 | query.first(); | |
311
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
97 | for (int i = 0 ; i < query.size() ; i++ ) { |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
98 | this->tableiSpindels->setItem(i, 0, new QTableWidgetItem(query.value("alias").toString())); |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
99 | this->tableiSpindels->setItem(i, 1, new QTableWidgetItem(query.value("node").toString())); |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
100 | |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
101 | if (query.value("online").toInt()) { |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
102 | item = new QTableWidgetItem(QString("Ok")); |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
103 | } else { |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
104 | item = new QTableWidgetItem(QString("Offline")); |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
105 | item->setForeground(QBrush(QColor(Qt::red))); |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
106 | } |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
107 | item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
108 | this->tableiSpindels->setItem(i, 2, item); |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
109 | |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
110 | if (query.value("mode").toString() == "ON") { |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
111 | item = new QTableWidgetItem(query.value("beercode").toString()+" - "+query.value("beername").toString()); |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
112 | this->tableiSpindels->setItem(i, 3, item); |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
113 | } else { |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
114 | this->tableiSpindels->setItem(i, 3, new QTableWidgetItem(QString(""))); |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
115 | } |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
116 | |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
117 | if (query.value("online").toInt()) { |
537
48de0f61e5ea
The iSpindel monitor, detail and chart screens try to use the polynomial calibration data to show the SG. Fallback to already logged data if this fails.
Michiel Broek <mbroek@mbse.eu>
parents:
503
diff
changeset
|
118 | /* |
48de0f61e5ea
The iSpindel monitor, detail and chart screens try to use the polynomial calibration data to show the SG. Fallback to already logged data if this fails.
Michiel Broek <mbroek@mbse.eu>
parents:
503
diff
changeset
|
119 | * Try to use the calibrate poly to recalcultate the SG. |
48de0f61e5ea
The iSpindel monitor, detail and chart screens try to use the polynomial calibration data to show the SG. Fallback to already logged data if this fails.
Michiel Broek <mbroek@mbse.eu>
parents:
503
diff
changeset
|
120 | */ |
48de0f61e5ea
The iSpindel monitor, detail and chart screens try to use the polynomial calibration data to show the SG. Fallback to already logged data if this fails.
Michiel Broek <mbroek@mbse.eu>
parents:
503
diff
changeset
|
121 | plato = query.value("gravity").toDouble(); |
48de0f61e5ea
The iSpindel monitor, detail and chart screens try to use the polynomial calibration data to show the SG. Fallback to already logged data if this fails.
Michiel Broek <mbroek@mbse.eu>
parents:
503
diff
changeset
|
122 | QJsonParseError parseError; |
48de0f61e5ea
The iSpindel monitor, detail and chart screens try to use the polynomial calibration data to show the SG. Fallback to already logged data if this fails.
Michiel Broek <mbroek@mbse.eu>
parents:
503
diff
changeset
|
123 | const auto& json = query.value("calibrate").toString(); |
48de0f61e5ea
The iSpindel monitor, detail and chart screens try to use the polynomial calibration data to show the SG. Fallback to already logged data if this fails.
Michiel Broek <mbroek@mbse.eu>
parents:
503
diff
changeset
|
124 | if (!json.trimmed().isEmpty()) { |
48de0f61e5ea
The iSpindel monitor, detail and chart screens try to use the polynomial calibration data to show the SG. Fallback to already logged data if this fails.
Michiel Broek <mbroek@mbse.eu>
parents:
503
diff
changeset
|
125 | const auto& formattedJson = QString("%1").arg(json); |
48de0f61e5ea
The iSpindel monitor, detail and chart screens try to use the polynomial calibration data to show the SG. Fallback to already logged data if this fails.
Michiel Broek <mbroek@mbse.eu>
parents:
503
diff
changeset
|
126 | QJsonDocument jsonResponse = QJsonDocument::fromJson(formattedJson.toUtf8(), &parseError); |
48de0f61e5ea
The iSpindel monitor, detail and chart screens try to use the polynomial calibration data to show the SG. Fallback to already logged data if this fails.
Michiel Broek <mbroek@mbse.eu>
parents:
503
diff
changeset
|
127 | QJsonObject jsonObj = jsonResponse.object(); |
48de0f61e5ea
The iSpindel monitor, detail and chart screens try to use the polynomial calibration data to show the SG. Fallback to already logged data if this fails.
Michiel Broek <mbroek@mbse.eu>
parents:
503
diff
changeset
|
128 | QJsonArray polyData = jsonObj.value("polyData").toArray(); |
48de0f61e5ea
The iSpindel monitor, detail and chart screens try to use the polynomial calibration data to show the SG. Fallback to already logged data if this fails.
Michiel Broek <mbroek@mbse.eu>
parents:
503
diff
changeset
|
129 | if (polyData.size() == 4) { |
48de0f61e5ea
The iSpindel monitor, detail and chart screens try to use the polynomial calibration data to show the SG. Fallback to already logged data if this fails.
Michiel Broek <mbroek@mbse.eu>
parents:
503
diff
changeset
|
130 | for (int i = 0; i < polyData.size(); i++) { |
48de0f61e5ea
The iSpindel monitor, detail and chart screens try to use the polynomial calibration data to show the SG. Fallback to already logged data if this fails.
Michiel Broek <mbroek@mbse.eu>
parents:
503
diff
changeset
|
131 | poly[i] = polyData.at(i).toDouble(); |
48de0f61e5ea
The iSpindel monitor, detail and chart screens try to use the polynomial calibration data to show the SG. Fallback to already logged data if this fails.
Michiel Broek <mbroek@mbse.eu>
parents:
503
diff
changeset
|
132 | } |
48de0f61e5ea
The iSpindel monitor, detail and chart screens try to use the polynomial calibration data to show the SG. Fallback to already logged data if this fails.
Michiel Broek <mbroek@mbse.eu>
parents:
503
diff
changeset
|
133 | double angle = query.value("angle").toDouble(); |
48de0f61e5ea
The iSpindel monitor, detail and chart screens try to use the polynomial calibration data to show the SG. Fallback to already logged data if this fails.
Michiel Broek <mbroek@mbse.eu>
parents:
503
diff
changeset
|
134 | /* New plato from current polynomial */ |
48de0f61e5ea
The iSpindel monitor, detail and chart screens try to use the polynomial calibration data to show the SG. Fallback to already logged data if this fails.
Michiel Broek <mbroek@mbse.eu>
parents:
503
diff
changeset
|
135 | plato = (poly[0] * pow(angle, 3)) + (poly[1] * pow(angle, 2)) + (poly[2] * angle) + poly[3]; |
48de0f61e5ea
The iSpindel monitor, detail and chart screens try to use the polynomial calibration data to show the SG. Fallback to already logged data if this fails.
Michiel Broek <mbroek@mbse.eu>
parents:
503
diff
changeset
|
136 | } |
48de0f61e5ea
The iSpindel monitor, detail and chart screens try to use the polynomial calibration data to show the SG. Fallback to already logged data if this fails.
Michiel Broek <mbroek@mbse.eu>
parents:
503
diff
changeset
|
137 | } |
48de0f61e5ea
The iSpindel monitor, detail and chart screens try to use the polynomial calibration data to show the SG. Fallback to already logged data if this fails.
Michiel Broek <mbroek@mbse.eu>
parents:
503
diff
changeset
|
138 | |
311
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
139 | item = new QTableWidgetItem(QString("%1°C").arg(query.value("temperature").toDouble(), 4, 'f', 3, '0')); |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
140 | item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
141 | this->tableiSpindels->setItem(i, 4, item); |
537
48de0f61e5ea
The iSpindel monitor, detail and chart screens try to use the polynomial calibration data to show the SG. Fallback to already logged data if this fails.
Michiel Broek <mbroek@mbse.eu>
parents:
503
diff
changeset
|
142 | double sg = Utils::plato_to_sg(plato); |
311
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
143 | item = new QTableWidgetItem(QString("%1").arg(sg, 5, 'f', 4, '0')); |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
144 | item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
145 | this->tableiSpindels->setItem(i, 5, item); |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
146 | } else { |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
147 | this->tableiSpindels->setItem(i, 4, new QTableWidgetItem(QString(""))); |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
148 | this->tableiSpindels->setItem(i, 5, new QTableWidgetItem(QString(""))); |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
149 | } |
310 | 150 | |
503
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
151 | /* Add the Calibrate button */ |
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
152 | QWidget* cWidget = new QWidget(); |
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
153 | QPushButton* btn_cal = new QPushButton(); |
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
154 | btn_cal->setObjectName(QString("%1").arg(query.value("record").toString())); /* Send record with the button */ |
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
155 | btn_cal->setText(tr("Cal")); |
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
156 | connect(btn_cal, SIGNAL(clicked()), this, SLOT(on_calButton_clicked())); |
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
157 | QHBoxLayout* cLayout = new QHBoxLayout(cWidget); |
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
158 | cLayout->addWidget(btn_cal); |
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
159 | cLayout->setContentsMargins(5, 0, 5, 0); |
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
160 | cWidget->setLayout(cLayout); |
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
161 | this->tableiSpindels->setCellWidget(i, 6, cWidget); |
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
162 | |
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
163 | /* Add the Details button */ |
310 | 164 | QWidget* pWidget = new QWidget(); |
165 | QPushButton* btn_edit = new QPushButton(); | |
311
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
166 | btn_edit->setObjectName(QString("%1").arg(query.value("record").toString())); /* Send record with the button */ |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
167 | btn_edit->setText(tr("Details")); |
310 | 168 | connect(btn_edit, SIGNAL(clicked()), this, SLOT(on_editButton_clicked())); |
169 | QHBoxLayout* pLayout = new QHBoxLayout(pWidget); | |
170 | pLayout->addWidget(btn_edit); | |
171 | pLayout->setContentsMargins(5, 0, 5, 0); | |
172 | pWidget->setLayout(pLayout); | |
503
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
173 | this->tableiSpindels->setCellWidget(i, 7, pWidget); |
310 | 174 | query.next(); |
175 | } | |
176 | emit setStatus(QString(tr("Total items: %1")).arg(query.size())); | |
177 | } | |
178 | ||
179 | ||
180 | MoniSpindels::~MoniSpindels() {} | |
181 | ||
182 | ||
311
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
183 | void MoniSpindels::refreshiSpindels(QString data) |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
184 | { |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
185 | emit refreshTable(); |
329
b57299738980
Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
312
diff
changeset
|
186 | emit updateiSpindel(data); |
311
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
187 | } |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
188 | |
449116c083bd
Respond to websocket ping. Added iSpindels monitor overview.
Michiel Broek <mbroek@mbse.eu>
parents:
310
diff
changeset
|
189 | |
310 | 190 | void MoniSpindels::edit(int recno) |
191 | { | |
329
b57299738980
Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
312
diff
changeset
|
192 | DetailiSpindel dialog(recno, this); |
b57299738980
Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
312
diff
changeset
|
193 | dialog.setModal(true); |
b57299738980
Added iSpindel detail screen
Michiel Broek <mbroek@mbse.eu>
parents:
312
diff
changeset
|
194 | dialog.exec(); |
310 | 195 | } |
196 | ||
197 | ||
198 | void MoniSpindels::on_editButton_clicked() | |
199 | { | |
200 | QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender()); | |
201 | int recno = pb->objectName().toInt(); | |
202 | edit(recno); | |
203 | } | |
204 | ||
205 | ||
503
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
206 | void MoniSpindels::cal(int recno) |
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
207 | { |
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
208 | CalibrateiSpindel dialog(recno, this); |
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
209 | dialog.setModal(true); |
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
210 | dialog.exec(); |
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
211 | } |
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
212 | |
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
213 | |
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
214 | void MoniSpindels::on_calButton_clicked() |
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
215 | { |
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
216 | QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender()); |
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
217 | int recno = pb->objectName().toInt(); |
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
218 | cal(recno); |
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
219 | } |
61c114afb0ee
Basic setup for iSpindel calibration.
Michiel Broek <mbroek@mbse.eu>
parents:
492
diff
changeset
|
220 |