|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef MONITOROVOZEZ_H
|
|
|
|
|
#define MONITOROVOZEZ_H
|
|
|
|
|
|
|
|
|
@ -19,7 +19,7 @@
|
|
|
|
|
|
|
|
|
|
#include "MonitorTagUI.h"
|
|
|
|
|
#include "../HTTPClient/client.h"
|
|
|
|
|
#pragma execution_character_set("utf-8")
|
|
|
|
|
//#pragma execution_character_set("utf-8")
|
|
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
|
|
|
|
@ -40,10 +40,11 @@ public:
|
|
|
|
|
QPushButton *runButton;
|
|
|
|
|
QWidget *fillWidget;
|
|
|
|
|
|
|
|
|
|
int state;
|
|
|
|
|
int state = 0;
|
|
|
|
|
int curDisplayCount = 0;
|
|
|
|
|
QTimer *viewTimer;
|
|
|
|
|
QTimer *dataTimer;
|
|
|
|
|
QList<QList<MonitorTag*>> tagList;
|
|
|
|
|
QList<MonitorTag*> tagList;
|
|
|
|
|
vector<QString> displayList;
|
|
|
|
|
|
|
|
|
|
void setupUi(QWidget *MonitorWidget)
|
|
|
|
@ -150,12 +151,12 @@ public:
|
|
|
|
|
retranslateUi(MonitorWidget);
|
|
|
|
|
|
|
|
|
|
updateData();
|
|
|
|
|
addTag();
|
|
|
|
|
updateTag();
|
|
|
|
|
|
|
|
|
|
viewTimer = new QTimer(MonitorWidget);
|
|
|
|
|
QObject::connect(viewTimer, &QTimer::timeout, [&]() {
|
|
|
|
|
// 计时器超时时更新标签
|
|
|
|
|
addTag();
|
|
|
|
|
updateTag();
|
|
|
|
|
});
|
|
|
|
|
viewTimer->start(2500);
|
|
|
|
|
|
|
|
|
@ -173,12 +174,12 @@ public:
|
|
|
|
|
failureButton->setCheckable(true);
|
|
|
|
|
runButton->setCheckable(true);
|
|
|
|
|
|
|
|
|
|
connect(interruptedButton, &QPushButton::clicked, this, [=](){this->updateDisplay();});
|
|
|
|
|
connect(normalButton, &QPushButton::clicked, this, [=](){this->updateDisplay();});
|
|
|
|
|
connect(standbyButton, &QPushButton::clicked, this, [=](){this->updateDisplay();});
|
|
|
|
|
connect(hutdownButton, &QPushButton::clicked, this, [=](){this->updateDisplay();});
|
|
|
|
|
connect(failureButton, &QPushButton::clicked, this, [=](){this->updateDisplay();});
|
|
|
|
|
connect(runButton, &QPushButton::clicked, this, [=](){this->updateDisplay();});
|
|
|
|
|
connect(interruptedButton, &QPushButton::clicked, this, [=](){this->updateTag();});
|
|
|
|
|
connect(normalButton, &QPushButton::clicked, this, [=](){this->updateTag();});
|
|
|
|
|
connect(standbyButton, &QPushButton::clicked, this, [=](){this->updateTag();});
|
|
|
|
|
connect(hutdownButton, &QPushButton::clicked, this, [=](){this->updateTag();});
|
|
|
|
|
connect(failureButton, &QPushButton::clicked, this, [=](){this->updateTag();});
|
|
|
|
|
connect(runButton, &QPushButton::clicked, this, [=](){this->updateTag();});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// connect(exchangeButton, &QPushButton::clicked, this, [=](){this->exchangeClicked();});
|
|
|
|
@ -221,45 +222,78 @@ public:
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void addTag()
|
|
|
|
|
void updateTag()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
map allFans = fans.allFans;
|
|
|
|
|
updateDisplay();
|
|
|
|
|
// 获取与 clicked() 信号相关的接收器数量
|
|
|
|
|
|
|
|
|
|
while (QLayoutItem *item = monitorLayout->takeAt(0)) {
|
|
|
|
|
if (QWidget *widget = item->widget()) {
|
|
|
|
|
widget->deleteLater(); // 或使用 delete 关键字删除控件的内存
|
|
|
|
|
}
|
|
|
|
|
delete item;
|
|
|
|
|
}
|
|
|
|
|
tagList.clear();
|
|
|
|
|
// while (QLayoutItem *item = monitorLayout->takeAt(0)) {
|
|
|
|
|
// if (QWidget *widget = item->widget()) {
|
|
|
|
|
// widget->deleteLater(); // 或使用 delete 关键字删除控件的内存
|
|
|
|
|
// }
|
|
|
|
|
// delete item;
|
|
|
|
|
// }
|
|
|
|
|
// tagList.clear();
|
|
|
|
|
int count = 0;
|
|
|
|
|
int index = 0;
|
|
|
|
|
QList<MonitorTag*> tags;
|
|
|
|
|
for (auto it = allFans.begin(); it != allFans.end(); ++it) {
|
|
|
|
|
if(!shouldDisplay(it->second.fanCode)){
|
|
|
|
|
continue;
|
|
|
|
|
int curCount = curDisplayCount;
|
|
|
|
|
int displayLSize = displayList.size();
|
|
|
|
|
// qDebug() << curCount;
|
|
|
|
|
// qDebug() << displayLSize;
|
|
|
|
|
if (displayLSize < curCount){
|
|
|
|
|
for (int i = curCount - 1; i >= displayLSize; i--) {
|
|
|
|
|
int row = i / 7;
|
|
|
|
|
int column = i % 7;
|
|
|
|
|
QLayoutItem *item = monitorLayout->itemAtPosition(row, column);
|
|
|
|
|
// QLayoutItem *item = monitorLayout->itemAt(i);
|
|
|
|
|
monitorLayout->removeItem(item);
|
|
|
|
|
delete item->widget();
|
|
|
|
|
delete item;
|
|
|
|
|
// tagList.erase(tagList.begin() + i);
|
|
|
|
|
}
|
|
|
|
|
if (index == 6){
|
|
|
|
|
tagList.append(tags);
|
|
|
|
|
tags.clear();
|
|
|
|
|
index = 0;
|
|
|
|
|
count++;
|
|
|
|
|
// qDebug() << tagList;
|
|
|
|
|
// qDebug() << monitorLayout->count();
|
|
|
|
|
|
|
|
|
|
} else if (displayList.size() > curCount) {
|
|
|
|
|
// 添加新的控件
|
|
|
|
|
for (int i = curCount; i < displayList.size(); i++) {
|
|
|
|
|
int row = i / 7;
|
|
|
|
|
int column = i % 7;
|
|
|
|
|
// qDebug() << row;
|
|
|
|
|
// qDebug() << column;
|
|
|
|
|
MonitorTag *newTag = new MonitorTag(state);
|
|
|
|
|
// connect(newTag->stateBox, QOverload<int>::of(&QComboBox::currentIndexChanged), [this](int index) {updateDisplay();});
|
|
|
|
|
monitorLayout->addWidget(newTag, row, column);
|
|
|
|
|
// tagList.append(newTag);
|
|
|
|
|
}
|
|
|
|
|
MonitorTag *newTag = new MonitorTag(it->second, state);
|
|
|
|
|
connect(newTag->stateBox, QOverload<int>::of(&QComboBox::currentIndexChanged), [this](int index) {addTag();});
|
|
|
|
|
monitorLayout->addWidget(newTag, count, index);
|
|
|
|
|
tags.append(newTag);
|
|
|
|
|
// qDebug() << tagList;
|
|
|
|
|
}
|
|
|
|
|
curDisplayCount = displayList.size();
|
|
|
|
|
// qDebug() << displayList;
|
|
|
|
|
// qDebug() << displayList;
|
|
|
|
|
for (auto it = displayList.begin(); it != displayList.end(); ++it) {
|
|
|
|
|
// qDebug() << displayList;
|
|
|
|
|
QLayoutItem *item = monitorLayout->itemAtPosition(index / 7, index % 7);
|
|
|
|
|
MonitorTag* tag = dynamic_cast<MonitorTag*>(item->widget());
|
|
|
|
|
tag->fan = allFans[*it];
|
|
|
|
|
tag->changeContent();
|
|
|
|
|
// tagList[index]->fan = allFans[*it];
|
|
|
|
|
// tagList[index]->changeContent();
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
if (allFans.size() < 28){
|
|
|
|
|
count = (curDisplayCount - 1) / 7;
|
|
|
|
|
index = curDisplayCount % 7;
|
|
|
|
|
if (monitorLayout->count() < 8){
|
|
|
|
|
fillWidget->setFixedHeight(228 * 4);
|
|
|
|
|
for (int i = 0; i < 28 - allFans.size(); i++) {
|
|
|
|
|
for (int i = 0; i < 28 - curDisplayCount; i++) {
|
|
|
|
|
if (index == 6){
|
|
|
|
|
index = 0;
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
QWidget *w = new QWidget();
|
|
|
|
|
|
|
|
|
|
monitorLayout->addWidget(w, count, index);
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
@ -267,14 +301,14 @@ public:
|
|
|
|
|
monitorLayout->setRowStretch(1, 1);
|
|
|
|
|
monitorLayout->setRowStretch(2, 1);
|
|
|
|
|
monitorLayout->setRowStretch(3, 1);
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
fillWidget->setFixedHeight(228 * ceil(allFans.size() / 4));
|
|
|
|
|
// fillWidget->setFixedHeight(228 * ceil(monitorLayout->count() / 4));
|
|
|
|
|
}
|
|
|
|
|
fillWidget->setFixedWidth(1900);
|
|
|
|
|
setButtonMes();
|
|
|
|
|
// int c = monitorLayout->count();
|
|
|
|
|
// qDebug() << c;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void updateData(){
|
|
|
|
@ -316,13 +350,26 @@ public:
|
|
|
|
|
|
|
|
|
|
void updateDisplay(){
|
|
|
|
|
displayList.clear();
|
|
|
|
|
if (!interruptedButton->isChecked() && !normalButton->isChecked() && !standbyButton->isChecked() && !hutdownButton->isChecked() && !failureButton->isChecked() && !runButton->isChecked()){
|
|
|
|
|
displayList.insert(displayList.end(), fans.interruptedFans.begin(), fans.interruptedFans.end());
|
|
|
|
|
displayList.insert(displayList.end(), fans.normalFans.begin(), fans.normalFans.end());
|
|
|
|
|
displayList.insert(displayList.end(), fans.standbyFans.begin(), fans.standbyFans.end());
|
|
|
|
|
displayList.insert(displayList.end(), fans.hutdownFans.begin(), fans.hutdownFans.end());
|
|
|
|
|
displayList.insert(displayList.end(), fans.failureFans.begin(), fans.failureFans.end());
|
|
|
|
|
displayList.insert(displayList.end(), fans.runFans.begin(), fans.runFans.end());
|
|
|
|
|
// qDebug() << displayList;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (interruptedButton->isChecked()){displayList.insert(displayList.end(), fans.interruptedFans.begin(), fans.interruptedFans.end());}
|
|
|
|
|
if (normalButton->isChecked()){displayList.insert(displayList.end(), fans.normalFans.begin(), fans.normalFans.end());}
|
|
|
|
|
if (standbyButton->isChecked()){displayList.insert(displayList.end(), fans.standbyFans.begin(), fans.standbyFans.end());}
|
|
|
|
|
if (hutdownButton->isChecked()){displayList.insert(displayList.end(), fans.hutdownFans.begin(), fans.hutdownFans.end());}
|
|
|
|
|
if (failureButton->isChecked()){displayList.insert(displayList.end(), fans.failureFans.begin(), fans.failureFans.end());}
|
|
|
|
|
if (runButton->isChecked()){displayList.insert(displayList.end(), fans.runFans.begin(), fans.runFans.end());}
|
|
|
|
|
addTag();
|
|
|
|
|
// qDebug() << displayList;
|
|
|
|
|
setButtonMes();
|
|
|
|
|
// updateTag();
|
|
|
|
|
// qDebug() << displayList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MonitorWidget()
|
|
|
|
|