From 2f4b591421e73d23924b13510e4acf0a49849084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Czcw=E2=80=9D?= Date: Mon, 14 Aug 2023 11:20:41 +0800 Subject: [PATCH] =?UTF-8?q?0814=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AnalyticUI/ClearanceAnalyticUI.h | 107 ++++++++++++++++- AnalyticUI/FlangeAnalyticUI.h | 193 ++++++++++++++++++++----------- AnalyticUI/FlangeItem.h | 184 +++++++++++++++++++++++++++++ AnalyticUI/GyroscopeAnalyticUI.h | 98 ++++++++++++++-- AnalyticUI/tools.h | 26 +++++ CMakeLists.txt | 4 +- DAM.qrc | 4 +- HTTPClient/client.cpp | 83 ++++++++----- HTTPClient/client.h | 48 +++++++- MainWindow.cpp | 2 +- MainWindow.h | 63 ++++++---- MonitorUI/MonitorTagUI.h | 12 +- MonitorUI/MonitorUI.h | 87 +++++++++----- Static/DamQSS.Qss | 28 +++-- Static/error.png | Bin 0 -> 237 bytes Static/normal.png | Bin 0 -> 237 bytes main.cpp | 4 +- 17 files changed, 762 insertions(+), 181 deletions(-) create mode 100644 AnalyticUI/FlangeItem.h create mode 100644 AnalyticUI/tools.h create mode 100644 Static/error.png create mode 100644 Static/normal.png diff --git a/AnalyticUI/ClearanceAnalyticUI.h b/AnalyticUI/ClearanceAnalyticUI.h index 52785b5..a7a989d 100644 --- a/AnalyticUI/ClearanceAnalyticUI.h +++ b/AnalyticUI/ClearanceAnalyticUI.h @@ -9,10 +9,20 @@ #include #include #include +#include +#include +#include +#include +#include +#include + +#include "../HTTPClient/client.h" +#include "../MonitorUI/MonitorUI.h" +#include "tools.h" QT_BEGIN_NAMESPACE -class Ui_ClearanceAnalyticWidget:public QWidget +class ClearanceAnalyticWidget:public QWidget { public: QHBoxLayout *horizontalLayout; @@ -23,6 +33,11 @@ public: QVBoxLayout *verticalLayout; QLabel *infoLabel; QLabel *trendLabel; + QStandardItemModel *deviceModel; + QTimer* timer; + + MonitorWidget* monitor; + int curId; void setupUi(QWidget *ClearanceAnalyticWidget) { @@ -38,9 +53,13 @@ public: horizontalLayout = new QHBoxLayout(ClearanceAnalyticWidget); horizontalLayout->setSpacing(0); horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); + horizontalLayout->setContentsMargins(20, 20, 20, 20); deviceList = new QListView(ClearanceAnalyticWidget); deviceList->setObjectName(QString::fromUtf8("deviceList")); + deviceModel = new QStandardItemModel(); + deviceList->setModel(deviceModel); + deviceList->setEditTriggers(QAbstractItemView::NoEditTriggers); horizontalLayout->addWidget(deviceList); @@ -79,16 +98,94 @@ public: retranslateUi(ClearanceAnalyticWidget); QMetaObject::connectSlotsByName(ClearanceAnalyticWidget); + + addDevice(); + QModelIndex index = deviceList->model()->index(0, 0); // 获取第2行的索引 + deviceList->setCurrentIndex(index); + + timer = new QTimer(); + QObject::connect(timer, &QTimer::timeout, [&]() { + // 计时器超时时更新标签 + addDevice(); + httpClient.getHeadroomList(curId); + addHearoomFeature(curId); + }); + timer->start(3000); + + + connect(deviceList, &QListView::doubleClicked, [&](const QModelIndex& index) { + if (index.isValid()) { + QString fanCode = index.data().toString(); + curId = fans.allFans[fanCode].fanId; + httpClient.getHeadroomList(curId); + addHearoomFeature(curId); + } + }); } // setupUi void retranslateUi(QWidget *ClearanceAnalyticWidget) { ClearanceAnalyticWidget->setWindowTitle(QCoreApplication::translate("ClearanceAnalyticWidget", "Form", nullptr)); - infoLabel->setText(QCoreApplication::translate("ClearanceAnalyticWidget", "\345\256\236\346\227\266\344\277\241\346\201\257", nullptr)); +// infoLabel->setText(QCoreApplication::translate("ClearanceAnalyticWidget", "\345\256\236\346\227\266\344\277\241\346\201\257", nullptr)); trendLabel->setText(QCoreApplication::translate("ClearanceAnalyticWidget", "\345\233\276\350\241\250\344\277\241\346\201\257", nullptr)); } // retranslateUi - Ui_ClearanceAnalyticWidget() + void addDevice(){ +// httpClient.getFanList(); + map allFans = fans.states; + if (!monitor->isInitState()){ + if (monitor->displayList.size() > deviceModel->rowCount()){ + for (int i = 0; i <= allFans.size() - deviceModel->rowCount() + 1; i++) { + QStandardItem* emptyItem = new QStandardItem(""); + deviceModel->appendRow(emptyItem); + } + }else if (monitor->displayList.size() < deviceModel->rowCount()){ + for (int i = 0; i <= deviceModel->rowCount() - allFans.size() + 2; i++) { + deviceModel->removeRow(0); + } + } + }else{ + if (allFans.size() > deviceModel->rowCount()){ + for (int i = 0; i <= allFans.size() - deviceModel->rowCount() + 1; i++) { + QStandardItem* emptyItem = new QStandardItem(""); + deviceModel->appendRow(emptyItem); + } + }else if (allFans.size() < deviceModel->rowCount()){ + for (int i = 0; i <= deviceModel->rowCount() - allFans.size() + 2; i++) { + deviceModel->removeRow(0); + } + } + } + + int count = 0; + for (auto it = allFans.begin(); it != allFans.end(); ++it) { + if (monitor->shouldDisplay(it->first)){ + QStandardItem* item = deviceModel->item(count); + + // 修改QStandardItem对象的文本和图标 + item->setText(it->first); + item->setIcon(getDevIcon(it->second)); + count++; + } + } + + } + + void addHearoomFeature(int fanId){ + vector headrooms = fans.idMaps[fanId].headrooms; + QString text; + for (auto it = headrooms.begin(); it != headrooms.end(); ++it) { + if (it->featureValue != 0){ + text += it->featureName + " : " + QString::number(it->featureValue) + "\n"; + // qDebug() << it->featureName; + }else{ + text += it->featureName + " : " + QString("数据为空") + "\n"; + } + } + infoLabel->setText(text); + } + + ClearanceAnalyticWidget(MonitorWidget* monitor) : monitor(monitor) { setupUi(this); } @@ -96,9 +193,7 @@ public: }; -namespace Ui { - class ClearanceAnalyticWidget: public Ui_ClearanceAnalyticWidget {}; -} // namespace Ui + QT_END_NAMESPACE diff --git a/AnalyticUI/FlangeAnalyticUI.h b/AnalyticUI/FlangeAnalyticUI.h index 2c3e7e8..00d0819 100644 --- a/AnalyticUI/FlangeAnalyticUI.h +++ b/AnalyticUI/FlangeAnalyticUI.h @@ -14,21 +14,33 @@ #include #include #include +#include #include #include #include #include - +#include +#include +#include +#include +#include +#include +#include + +#include "../HTTPClient/client.h" +#include "../MonitorUI/MonitorUI.h" +#include "FlangeItem.h" +#include "tools.h" QT_BEGIN_NAMESPACE -class Ui_FlangeAnalyticWidget:public QWidget +class FlangeAnalyticWidget:public QWidget { public: QHBoxLayout *horizontalLayout; QListView *deviceList; QWidget *displayWidget; QGridLayout *gridLayout; - QListView *flangeList; + QListWidget *flangeList; QSpacerItem *verticalSpacer; QSpacerItem *horizontalSpacer; QWidget *infoWidget; @@ -37,6 +49,14 @@ public: QLabel *flangePiclabel; QLabel *infoLabel; QLabel *trendLabel; + QStandardItemModel *deviceModel; + QTimer* timer; + + QWidget *flangeWidget; + QVBoxLayout *veticalLayout; + + MonitorWidget* monitor; + int curId; void setupUi(QWidget *FlangeAnalyticWidget) { @@ -47,93 +67,136 @@ public: horizontalLayout->setSpacing(0); horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); horizontalLayout->setContentsMargins(20, 20, 20, 20); + deviceList = new QListView(FlangeAnalyticWidget); deviceList->setObjectName(QString::fromUtf8("deviceList")); + deviceModel = new QStandardItemModel(); + deviceList->setModel(deviceModel); + deviceList->setEditTriggers(QAbstractItemView::NoEditTriggers); horizontalLayout->addWidget(deviceList); - displayWidget = new QWidget(FlangeAnalyticWidget); - displayWidget->setObjectName(QString::fromUtf8("displayWidget")); - gridLayout = new QGridLayout(displayWidget); - gridLayout->setObjectName(QString::fromUtf8("gridLayout")); - gridLayout->setContentsMargins(20, 0, 0, 0); - flangeList = new QListView(displayWidget); + flangeList = new QListWidget (FlangeAnalyticWidget); flangeList->setObjectName(QString::fromUtf8("flangeList")); + flangeList->setEditTriggers(QAbstractItemView::NoEditTriggers); - gridLayout->addWidget(flangeList, 0, 0, 1, 1); - - verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); - - gridLayout->addItem(verticalSpacer, 1, 0, 1, 1); - - horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - - gridLayout->addItem(horizontalSpacer, 0, 1, 1, 1); - - gridLayout->setRowStretch(0, 1); - gridLayout->setRowStretch(1, 2); - gridLayout->setColumnStretch(0, 1); - gridLayout->setColumnStretch(1, 2); - - horizontalLayout->addWidget(displayWidget); - - infoWidget = new QWidget(FlangeAnalyticWidget); - infoWidget->setObjectName(QString::fromUtf8("infoWidget")); - verticalLayout = new QVBoxLayout(infoWidget); - verticalLayout->setSpacing(0); - verticalLayout->setObjectName(QString::fromUtf8("verticalLayout")); - verticalLayout->setContentsMargins(0, 0, 0, 0); - horizontalLayout_2 = new QHBoxLayout(); - horizontalLayout_2->setSpacing(0); - horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout_2")); - flangePiclabel = new QLabel(infoWidget); - flangePiclabel->setObjectName(QString::fromUtf8("flangePiclabel")); + flangeWidget = new QWidget (FlangeAnalyticWidget); + infoLabel = new QLabel (flangeWidget); + infoLabel->setAlignment(Qt::AlignCenter); + infoLabel->setObjectName("infoLabel"); - horizontalLayout_2->addWidget(flangePiclabel); + veticalLayout = new QVBoxLayout(flangeWidget); + veticalLayout->addWidget(infoLabel); + veticalLayout->addWidget(flangeList); - infoLabel = new QLabel(infoWidget); - infoLabel->setObjectName(QString::fromUtf8("infoLabel")); + horizontalLayout->addWidget(flangeWidget); - horizontalLayout_2->addWidget(infoLabel); + horizontalLayout->setStretch(0, 1); + horizontalLayout->setStretch(1, 5); + QMetaObject::connectSlotsByName(FlangeAnalyticWidget); - verticalLayout->addLayout(horizontalLayout_2); + addDevice(); + addFlanges(deviceModel->data(deviceModel->index(0, 0)).toString()); + QModelIndex index = deviceList->model()->index(0, 0); // 获取第2行的索引 + deviceList->setCurrentIndex(index); + timer = new QTimer(); + QObject::connect(timer, &QTimer::timeout, [&]() { + // 计时器超时时更新标签 + addDevice(); + QModelIndex currentIndex = deviceList->currentIndex(); + QString fanCode = currentIndex.data().toString(); + addFlanges(fanCode); + }); + timer->start(3000); + + connect(deviceList, &QListView::doubleClicked, [&](const QModelIndex& index) { + if (index.isValid()) { + QString fanCode = index.data().toString(); + curId = fans.allFans[fanCode].fanId; + addFlanges(fanCode); + } + }); - trendLabel = new QLabel(infoWidget); - trendLabel->setObjectName(QString::fromUtf8("trendLabel")); + } // setupUi - verticalLayout->addWidget(trendLabel); - horizontalLayout->addWidget(infoWidget); + void addDevice(){ +// httpClient.getFanList(); + map allFans = fans.states; + if (!monitor->isInitState()){ + if (monitor->displayList.size() > deviceModel->rowCount()){ + for (int i = 0; i <= allFans.size() - deviceModel->rowCount() + 1; i++) { + QStandardItem* emptyItem = new QStandardItem(""); + deviceModel->appendRow(emptyItem); + } + }else if (monitor->displayList.size() < deviceModel->rowCount()){ + for (int i = 0; i <= deviceModel->rowCount() - allFans.size() + 2; i++) { + deviceModel->removeRow(0); + } + } + }else{ + if (allFans.size() > deviceModel->rowCount()){ + for (int i = 0; i <= allFans.size() - deviceModel->rowCount() + 1; i++) { + QStandardItem* emptyItem = new QStandardItem(""); + deviceModel->appendRow(emptyItem); + } + }else if (allFans.size() < deviceModel->rowCount()){ + for (int i = 0; i <= deviceModel->rowCount() - allFans.size() + 2; i++) { + deviceModel->removeRow(0); + } + } + } + + int count = 0; + for (auto it = allFans.begin(); it != allFans.end(); ++it) { + if (monitor->shouldDisplay(it->first)){ + QStandardItem* item = deviceModel->item(count); + + // 修改QStandardItem对象的文本和图标 + item->setText(it->first); + item->setIcon(getDevIcon(it->second)); + count++; + } + } + } - horizontalLayout->setStretch(0, 5); - horizontalLayout->setStretch(1, 10); - horizontalLayout->setStretch(2, 5); + void addFlanges(QString fanCode){ + int fanId = fans.allFans[fanCode].fanId; + httpClient.getFlangeList(fanId); + map flanges = fans.idMaps[fans.allFans[fanCode].fanId].flanges; + flangeList->clear(); + int normalCount = 0; + int errorCount = 0; + for (auto flange = flanges.begin(); flange != flanges.end(); ++flange){ + FlangeItem *item = new FlangeItem(flange->second); + QListWidgetItem* listItem = new QListWidgetItem(); + listItem->setSizeHint(QSize(200,120)); + flangeList->addItem(listItem); + flangeList->setItemWidget(listItem, item); + if (flange->second.flangeState == QString("正常")){ + normalCount++; + }else if (flange->second.flangeState == QString("故障")){ + errorCount++; + } + } + infoLabel->setText(QString("总览 (正常: %1/%2 报警: %3/%4)") + .arg(normalCount).arg(flanges.size()).arg(errorCount).arg(flanges.size())); + } - retranslateUi(FlangeAnalyticWidget); + void addFeatures(QString flangeId){ + map flanges = fans.idMaps[curId].flanges; - QMetaObject::connectSlotsByName(FlangeAnalyticWidget); - } // setupUi - - void retranslateUi(QWidget *FlangeAnalyticWidget) - { - FlangeAnalyticWidget->setWindowTitle(QCoreApplication::translate("FlangeAnalyticWidget", "Form", nullptr)); - flangePiclabel->setText(QCoreApplication::translate("FlangeAnalyticWidget", "\346\230\276\347\244\272\346\263\225\345\205\260", nullptr)); - infoLabel->setText(QCoreApplication::translate("FlangeAnalyticWidget", "\345\256\236\346\227\266\344\277\241\346\201\257\347\233\221\346\265\213", nullptr)); - trendLabel->setText(QCoreApplication::translate("FlangeAnalyticWidget", "\345\233\276\350\241\250\344\277\241\346\201\257", nullptr)); - } // retranslateUi + } - Ui_FlangeAnalyticWidget() - { + FlangeAnalyticWidget(MonitorWidget* monitor) : monitor(monitor){ setupUi(this); } + }; -namespace Ui { - class FlangeAnalyticWidget: public Ui_FlangeAnalyticWidget {}; -} // namespace Ui QT_END_NAMESPACE diff --git a/AnalyticUI/FlangeItem.h b/AnalyticUI/FlangeItem.h new file mode 100644 index 0000000..7e5d4ea --- /dev/null +++ b/AnalyticUI/FlangeItem.h @@ -0,0 +1,184 @@ +#ifndef FLANGEITEMBJXPGW_H +#define FLANGEITEMBJXPGW_H + +#include +#include +#include +#include +#include +#include +#include "../HTTPClient/client.h" +#include "tools.h" + +#include +QT_BEGIN_NAMESPACE + +class FlangeItem:public QWidget +{ +public: + QHBoxLayout *horizontalLayout_2; + QLabel *flangePic; + QHBoxLayout *horizontalLayout; + QLabel *state1; + QLabel *state2; + QLabel *state3; + QLabel *state4; + QLabel *state5; + QLabel *state6; + QLabel *state7; + QLabel *state8; + QLabel *state9; + QLabel *state10; + QLabel *state11; + QLabel *state12; + QPushButton *pushButton; + + FlangeClass flange; + + void setupUi(QWidget *FlangeItem) + { + if (FlangeItem->objectName().isEmpty()) + FlangeItem->setObjectName(QString::fromUtf8("FlangeItem")); + FlangeItem->resize(960, 500); + horizontalLayout_2 = new QHBoxLayout(FlangeItem); + horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout_2")); + flangePic = new QLabel(FlangeItem); + flangePic->setObjectName(QString::fromUtf8("flangePic")); + flangePic->setScaledContents(true); + + horizontalLayout_2->addWidget(flangePic); + + horizontalLayout = new QHBoxLayout(); + horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); + state1 = new QLabel(FlangeItem); + state1->setObjectName(QString::fromUtf8("state1")); + state1->setScaledContents(true); + + horizontalLayout->addWidget(state1); + + state2 = new QLabel(FlangeItem); + state2->setObjectName(QString::fromUtf8("state2")); + state2->setScaledContents(true); + + horizontalLayout->addWidget(state2); + + state3 = new QLabel(FlangeItem); + state3->setObjectName(QString::fromUtf8("state3")); + state3->setScaledContents(true); + + horizontalLayout->addWidget(state3); + + state4 = new QLabel(FlangeItem); + state4->setObjectName(QString::fromUtf8("state4")); + state4->setScaledContents(true); + + horizontalLayout->addWidget(state4); + + state5 = new QLabel(FlangeItem); + state5->setObjectName(QString::fromUtf8("state5")); + state5->setScaledContents(true); + + horizontalLayout->addWidget(state5); + + state6 = new QLabel(FlangeItem); + state6->setObjectName(QString::fromUtf8("state6")); + state6->setScaledContents(true); + + horizontalLayout->addWidget(state6); + + state7 = new QLabel(FlangeItem); + state7->setObjectName(QString::fromUtf8("state7")); + state7->setScaledContents(true); + + horizontalLayout->addWidget(state7); + + state8 = new QLabel(FlangeItem); + state8->setObjectName(QString::fromUtf8("state8")); + state8->setScaledContents(true); + + horizontalLayout->addWidget(state8); + + state9 = new QLabel(FlangeItem); + state9->setObjectName(QString::fromUtf8("state9")); + state9->setScaledContents(true); + + horizontalLayout->addWidget(state9); + + state10 = new QLabel(FlangeItem); + state10->setObjectName(QString::fromUtf8("state10")); + state10->setScaledContents(true); + + horizontalLayout->addWidget(state10); + + state11 = new QLabel(FlangeItem); + state11->setObjectName(QString::fromUtf8("state11")); + state11->setScaledContents(true); + + horizontalLayout->addWidget(state11); + + state12 = new QLabel(FlangeItem); + state12->setObjectName(QString::fromUtf8("state12")); + state12->setScaledContents(true); + + horizontalLayout->addWidget(state12); + horizontalLayout->setSpacing(3); + + + horizontalLayout_2->addLayout(horizontalLayout); + + pushButton = new QPushButton(FlangeItem); + pushButton->setObjectName(QString::fromUtf8("pushButton")); + + horizontalLayout_2->addWidget(pushButton); + + horizontalLayout_2->setStretch(0, 1); + horizontalLayout_2->setStretch(1, 10); + horizontalLayout_2->setStretch(2, 1); + + retranslateUi(FlangeItem); + + QMetaObject::connectSlotsByName(FlangeItem); + setIcon(); + + } // setupUi + + void retranslateUi(QWidget *FlangeItem) + { + FlangeItem->setWindowTitle(QCoreApplication::translate("FlangeItem", "Form", nullptr)); + pushButton->setText(QCoreApplication::translate("FlangeItem", "\346\232\202\347\225\231", nullptr)); + } // retranslateUi + + void setIcon() + { + if (flange.flangeState == QString("故障")){ + QPixmap pixmap(":/Static/flangeError.png"); + flangePic->setPixmap(pixmap); + }else if (flange.flangeState == QString("正常")){ + QPixmap pixmap(":/Static/flangeNromal.png"); + flangePic->setPixmap(pixmap); + } + QPixmap normalPix(":/Static/normal.png"); + QPixmap errorPixmap(":/Static/error.png"); + state1->setPixmap(normalPix); + state2->setPixmap(normalPix); + state3->setPixmap(normalPix); + state4->setPixmap(normalPix); + state5->setPixmap(normalPix); + state6->setPixmap(normalPix); + state7->setPixmap(normalPix); + state8->setPixmap(normalPix); + state9->setPixmap(normalPix); + state10->setPixmap(normalPix); + state11->setPixmap(normalPix); + state12->setPixmap(normalPix); + } + + FlangeItem(FlangeClass flange) : flange(flange){ + setupUi(this); + } + +}; + +QT_END_NAMESPACE + +#endif // FLANGEITEMBJXPGW_H diff --git a/AnalyticUI/GyroscopeAnalyticUI.h b/AnalyticUI/GyroscopeAnalyticUI.h index 679b573..0289a7e 100644 --- a/AnalyticUI/GyroscopeAnalyticUI.h +++ b/AnalyticUI/GyroscopeAnalyticUI.h @@ -17,10 +17,20 @@ #include #include #include +#include +#include +#include +#include +#include +#include + +#include "../HTTPClient/client.h" +#include "../MonitorUI/MonitorUI.h" +#include "tools.h" QT_BEGIN_NAMESPACE -class Ui_GyroscopeAnalyticWidget:public QWidget +class GyroscopeAnalyticWidget:public QWidget { public: QHBoxLayout *horizontalLayout; @@ -31,6 +41,11 @@ public: QVBoxLayout *verticalLayout; QLabel *infoLabel; QLabel *trendLabel; + QStandardItemModel *deviceModel; + QTimer* timer; + int curId; + + MonitorWidget* monitor; void setupUi(QWidget *GyroscopeAnalyticWidget) { @@ -40,8 +55,12 @@ public: horizontalLayout->setSpacing(0); horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); horizontalLayout->setContentsMargins(20, 20, 20, 20); + deviceList = new QListView(GyroscopeAnalyticWidget); deviceList->setObjectName(QString::fromUtf8("deviceList")); + deviceModel = new QStandardItemModel(); + deviceList->setModel(deviceModel); + deviceList->setEditTriggers(QAbstractItemView::NoEditTriggers); horizontalLayout->addWidget(deviceList); @@ -80,25 +99,90 @@ public: retranslateUi(GyroscopeAnalyticWidget); QMetaObject::connectSlotsByName(GyroscopeAnalyticWidget); + addDevice(); + QModelIndex index = deviceList->model()->index(0, 0); // 获取第2行的索引 + deviceList->setCurrentIndex(index); + timer = new QTimer(); + QObject::connect(timer, &QTimer::timeout, [&]() { + // 计时器超时时更新标签 + addDevice(); + httpClient.getGyroList(curId); + addGyroFeature(curId); + }); + timer->start(3000); + + connect(deviceList, &QListView::doubleClicked, [&](const QModelIndex& index) { + if (index.isValid()) { + QString fanCode = index.data().toString(); + curId = fans.allFans[fanCode].fanId; + httpClient.getGyroList(curId); + addGyroFeature(curId); + } + }); } // setupUi void retranslateUi(QWidget *GyroscopeAnalyticWidget) { - GyroscopeAnalyticWidget->setWindowTitle(QCoreApplication::translate("GyroscopeAnalyticWidget", "Form", nullptr)); - infoLabel->setText(QCoreApplication::translate("GyroscopeAnalyticWidget", "\345\256\236\346\227\266\344\277\241\346\201\257", nullptr)); trendLabel->setText(QCoreApplication::translate("GyroscopeAnalyticWidget", "\345\233\276\350\241\250\344\277\241\346\201\257", nullptr)); } // retranslateUi - Ui_GyroscopeAnalyticWidget() + void addDevice(){ +// httpClient.getFanList(); + map allFans = fans.states; + if (!monitor->isInitState()){ + if (monitor->displayList.size() > deviceModel->rowCount()){ + for (int i = 0; i <= allFans.size() - deviceModel->rowCount() + 1; i++) { + QStandardItem* emptyItem = new QStandardItem(""); + deviceModel->appendRow(emptyItem); + } + }else if (monitor->displayList.size() < deviceModel->rowCount()){ + for (int i = 0; i <= deviceModel->rowCount() - allFans.size() + 2; i++) { + deviceModel->removeRow(0); + } + } + }else{ + if (allFans.size() > deviceModel->rowCount()){ + for (int i = 0; i <= allFans.size() - deviceModel->rowCount() + 1; i++) { + QStandardItem* emptyItem = new QStandardItem(""); + deviceModel->appendRow(emptyItem); + } + }else if (allFans.size() < deviceModel->rowCount()){ + for (int i = 0; i <= deviceModel->rowCount() - allFans.size() + 2; i++) { + deviceModel->removeRow(0); + } + } + } + + int count = 0; + for (auto it = allFans.begin(); it != allFans.end(); ++it) { + if (monitor->shouldDisplay(it->first)){ + QStandardItem* item = deviceModel->item(count); + + // 修改QStandardItem对象的文本和图标 + item->setText(it->first); + item->setIcon(getDevIcon(it->second)); + count++; + } + } + } + + void addGyroFeature(int fanId){ + vector gyros = fans.idMaps[fanId].gyros; + QString text; + for (auto it = gyros.begin(); it != gyros.end(); ++it) { + text += it->featureName + " : " + QString::number(it->featureValue) + "\n"; +// qDebug() << it->featureName; + } + infoLabel->setText(text); + } + + GyroscopeAnalyticWidget(MonitorWidget* monitor) : monitor(monitor) { setupUi(this); } }; -namespace Ui { - class GyroscopeAnalyticWidget: public Ui_GyroscopeAnalyticWidget {}; -} // namespace Ui QT_END_NAMESPACE diff --git a/AnalyticUI/tools.h b/AnalyticUI/tools.h new file mode 100644 index 0000000..7130483 --- /dev/null +++ b/AnalyticUI/tools.h @@ -0,0 +1,26 @@ + +#ifndef TOOLS_H +#define TOOLS_H + +#include +#include + +QIcon getDevIcon(QString states){ + if (states == QString("正常运行")){ + return QIcon(":/Static/fanNormal.png"); + }else if (states == QString("通讯中断")){ + return QIcon(":/Static/fanfanInterrupted.png"); + }else if (states == QString("待机等风")){ + return QIcon(":/Static/fanStandby.png"); + }else if (states == QString("停机维护")){ + return QIcon(":/Static/fanHutdown.png"); + }else if (states == QString("故障停机")){ + return QIcon(":/Static/fanError.png"); + }else if (states == QString("启动")){ + return QIcon(":/Static/fanRun.png"); + }else{ + return QIcon(":/Static/fanNormal.png"); + } +} + +#endif // TOOLS_H diff --git a/CMakeLists.txt b/CMakeLists.txt index 64e6ec3..44eb928 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) #定义两个变量,表示头文件路径和库路径 -set(OPENSSL_ROOT_DIR "D:/openssl/OpenSSL-Win64") +set(OPENSSL_ROOT_DIR "F:/OpenSSL-Win64") set(OPENSSL_INCLUDE_DIR "${OPENSSL_ROOT_DIR}/include") set(OPENSSL_LIB_DIR "${OPENSSL_ROOT_DIR}/lib") find_package(OpenSSL REQUIRED) @@ -33,6 +33,8 @@ set(PROJECT_SOURCES ./AnalyticUI/FlangeAnalyticUI.h ./AnalyticUI/ClearanceAnalyticUI.h ./AnalyticUI/GyroscopeAnalyticUI.h + ./AnalyticUI/tools.h + ./AnalyticUI/FlangeItem.h ./HTTPClient/client.h ./HTTPClient/client.cpp ./LoginUI/Login.h diff --git a/DAM.qrc b/DAM.qrc index a2790bc..03ad19e 100644 --- a/DAM.qrc +++ b/DAM.qrc @@ -2,7 +2,6 @@ Static/close.png Static/min.png - Static/DamQSS.Qss Static/fanNormal.png Static/fanError.png Static/fanHutdown.png @@ -19,5 +18,8 @@ Static/down.png Static/background.png Static/scrollBar.png + Static/error.png + Static/normal.png + Static/DamQSS.Qss diff --git a/HTTPClient/client.cpp b/HTTPClient/client.cpp index 53d2c60..87b226f 100644 --- a/HTTPClient/client.cpp +++ b/HTTPClient/client.cpp @@ -39,6 +39,7 @@ bool isInLists(QString element) { header = {{"GroupId", "dam"}}; loginIndex = "/services/application/api/fan_app/login"; fanListIndex = "/services/application/api/fan_app/fanList"; + flangeIndex = "/services/application/api/fan_app/flangeList"; headroomDetailIndex = "/services/application/api/fan_app/headroomDetail"; gyroDetailIndex = "/services/application/api/fan_app/gyroDetail"; featureHistoryIndex = "/services/application/api/fan_app/featureHistory"; @@ -50,7 +51,9 @@ bool isInLists(QString element) { json resJson = json::parse(res->body); for (const auto& data : resJson["data"]) { FanClass fan; + //cout << data["fanId"]; fan.fanCode = QString::fromStdString(data["fanCode"]); + fan.fanId = data["fanId"]; if (data["functions"]["gyro"]["features"][0]["featureValue"].is_number()) { fan.angle = data["functions"]["gyro"]["features"][0]["featureValue"].get(); } @@ -61,6 +64,8 @@ bool isInLists(QString element) { fan.flangeState = QString::fromStdString(data["functions"]["gyro"]["state"]); fan.headroomState = QString::fromStdString(data["functions"]["headRoom"]["state"]); fans.allFans[fan.fanCode] = fan; + fans.idMaps[fan.fanId] = fan; + if (isInLists(fan.fanCode)){ return; } @@ -81,41 +86,58 @@ bool isInLists(QString element) { } } - } +} - QString HTTPClient::getFlangeList(int fanId) { - json bodyJson = {{"fanId",fanId}}; - std::string body = bodyJson.dump(); - if (auto res = client.Post(headroomDetailIndex, header, body, "application/json")) { - QString body = QString::fromStdString(res->body); - return body; - } - else { - return QString("error"); - } - } +void HTTPClient::getFlangeList(int fanId) { + json bodyJson = {{"fanId",fanId}}; + std::string body = bodyJson.dump(); + fans.idMaps[fanId].flanges.clear(); + if (auto res = client.Post(flangeIndex, header, body, "application/json")) { + json resJson = json::parse(res->body); + QString body = QString::fromStdString(res->body); +// qDebug() << body; + for (const auto& data : resJson["data"]) { + FlangeClass flange; + flange.flangeId = QString::fromStdString(data["flangeId"].dump()); + flange.flangeState = QString::fromStdString(data["flangeState"]); + for (const auto& feature : data["features"]){ + flange.features[QString::fromStdString(feature["featureName"].dump())] = QString::fromStdString(feature["featureValue"].dump()); + } + fans.idMaps[fanId].flanges[flange.flangeId] = flange; + } + } +} - QString HTTPClient::getHeadroomList(int fanId) { - json bodyJson = { {"fanId",fanId} }; - std::string body = bodyJson.dump(); - if (auto res = client.Post(headroomDetailIndex, header, body, "application/json")) { - QString body = QString::fromStdString(res->body); - return body; - } - else { - return QString("error"); - } + void HTTPClient::getHeadroomList(int fanId) { + json bodyJson = { {"fanId",fanId} }; + std::string body = bodyJson.dump(); + if (auto res = client.Post(headroomDetailIndex, header, body, "application/json")) { + QString body = QString::fromStdString(res->body); + json resJson = json::parse(res->body); + fans.idMaps[fanId].headrooms.clear(); + for (const auto& data : resJson["data"][0]["features"]) { + HeadroomClass headroom; + headroom.featureName = QString::fromStdString(data["featureName"]); + if (data["featureValue"].is_number()){ + headroom.featureValue = data["featureValue"].get(); + } + fans.idMaps[fanId].headrooms.push_back(headroom); + } + } } - QString HTTPClient::getGyroList(int fanId) { + void HTTPClient::getGyroList(int fanId) { json bodyJson = { {"fanId",fanId} }; std::string body = bodyJson.dump(); if (auto res = client.Post(gyroDetailIndex, header, body, "application/json")) { - QString body = QString::fromStdString(res->body); - return body; - } - else { - return QString("error"); + json resJson = json::parse(res->body); + fans.idMaps[fanId].gyros.clear(); + for (const auto& data : resJson["data"][0]["features"]) { + GyroClass gyro; + gyro.featureName = QString::fromStdString(data["featureName"]); + gyro.featureValue = data["featureValue"].get(); + fans.idMaps[fanId].gyros.push_back(gyro); + } } } @@ -131,3 +153,8 @@ bool isInLists(QString element) { + //int main(){ + // httpClient.getFanList(); + // httpClient.getFlangeList(1055); + // return 0; + //} diff --git a/HTTPClient/client.h b/HTTPClient/client.h index f9b5910..5484e10 100644 --- a/HTTPClient/client.h +++ b/HTTPClient/client.h @@ -10,11 +10,44 @@ #include #include #include -#include + using namespace std; void delNameFromList(QString element); +class FlangeClass // 法兰类 +{ +public: + int errorCode; + QString flangeId; + QString errorInfo; + QString fanCode; + QString flangeState; + std::map features; +}; + +class HeadroomClass // 净空类 +{ +public: + int errorCode; + int flangeId; + QString errorInfo; + QString fanCode; + QString featureName; + double featureValue = 0; +}; + +class GyroClass // 陀螺仪类 +{ +public: + int errorCode; + int flangeId; + QString errorInfo; + QString fanCode; + QString featureName; + double featureValue; +}; + class FanClass // 风机类 { public: @@ -27,13 +60,19 @@ public: QString flangeState; QString headroomState; QString gyroState; + std::map flanges; + std::vector gyros; + std::vector headrooms; }; + + class FanManage // 所有风机管理类 { public: std::map allFans; // 所有风机 + std::map idMaps; // 根据ID获取风机 std::map states; // 风机状态 std::vector interruptedFans; // 通讯中断 std::vector standbyFans; // 待机等风 @@ -54,14 +93,15 @@ private: string headroomDetailIndex; string gyroDetailIndex; string featureHistoryIndex; + string flangeIndex; public: httplib::Client client; HTTPClient(); void getFanList(); - QString getFlangeList(int fanId); - QString getHeadroomList(int fanId); - QString getGyroList(int fanId); + void getFlangeList(int fanId); + void getHeadroomList(int fanId); + void getGyroList(int fanId); QString getHistoryList(int fanId); }; diff --git a/MainWindow.cpp b/MainWindow.cpp index 635afce..584ba87 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -1,5 +1,5 @@ -#include "MainWindow.h" + diff --git a/MainWindow.h b/MainWindow.h index b57fe37..7352813 100644 --- a/MainWindow.h +++ b/MainWindow.h @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -8,11 +8,13 @@ #include #include #include +#include #include "./MonitorUI/MonitorUI.h" #include "./AnalyticUI/ClearanceAnalyticUI.h" #include "./AnalyticUI/FlangeAnalyticUI.h" #include "./AnalyticUI/GyroscopeAnalyticUI.h" +#pragma execution_character_set("utf-8") @@ -32,10 +34,10 @@ public: QPushButton *clearanceButton; QPushButton *gyroscopeButton; QStackedWidget *stackedWidget; - MonitorWidget *monitorPage; - Ui::ClearanceAnalyticWidget *clearancePage; - Ui::FlangeAnalyticWidget *flangePage; - Ui::GyroscopeAnalyticWidget *gyroscopePage; + MonitorWidget* monitorPage; + ClearanceAnalyticWidget *clearancePage; + FlangeAnalyticWidget* flangePage; + GyroscopeAnalyticWidget *gyroscopePage; @@ -57,7 +59,7 @@ public: horizontalLayout = new QHBoxLayout(titleWidget); horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); horizontalLayout->setContentsMargins(0, 0, 10, 20); - horizontalLayout->setSpacing(10); + horizontalLayout->setSpacing(5); horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); horizontalLayout->addItem(horizontalSpacer); @@ -83,33 +85,36 @@ public: tabLayout = new QHBoxLayout(); tabLayout->setObjectName(QString::fromUtf8("tabLayout")); - tabLayout->setSpacing(15); - tabLayout->setContentsMargins(20, 0, 20, 0); + + tabLayout->setContentsMargins(20, 0, 20, 20); + tabLayout->addStretch(); monitorButton = new QPushButton(centralwidget); monitorButton->setObjectName(QString::fromUtf8("monitorButton")); - tabLayout->addWidget(monitorButton); flangeButton = new QPushButton(centralwidget); flangeButton->setObjectName(QString::fromUtf8("flangeButton")); + tabLayout->addStretch(); tabLayout->addWidget(flangeButton); clearanceButton = new QPushButton(centralwidget); clearanceButton->setObjectName(QString::fromUtf8("clearanceButton")); + tabLayout->addStretch(); tabLayout->addWidget(clearanceButton); gyroscopeButton = new QPushButton(centralwidget); gyroscopeButton->setObjectName(QString::fromUtf8("gyroscopeButton")); + tabLayout->addStretch(); tabLayout->addWidget(gyroscopeButton); + tabLayout->addStretch(); - verticalLayout->addLayout(tabLayout); stackedWidget = new QStackedWidget(centralwidget); stackedWidget->setObjectName(QString::fromUtf8("stackedWidget")); @@ -118,31 +123,43 @@ public: monitorPage->setObjectName(QString::fromUtf8("monitorPage")); stackedWidget->addWidget(monitorPage); - flangePage = new Ui::FlangeAnalyticWidget(); + flangePage = new FlangeAnalyticWidget(monitorPage); flangePage->setObjectName(QString::fromUtf8("flangePage")); stackedWidget->addWidget(flangePage); - clearancePage = new Ui::ClearanceAnalyticWidget(); + clearancePage = new ClearanceAnalyticWidget(monitorPage); clearancePage->setObjectName(QString::fromUtf8("clearancePage")); stackedWidget->addWidget(clearancePage); - gyroscopePage = new Ui::GyroscopeAnalyticWidget(); + gyroscopePage = new GyroscopeAnalyticWidget(monitorPage); gyroscopePage->setObjectName(QString::fromUtf8("gyroscopePage")); stackedWidget->addWidget(gyroscopePage); verticalLayout->addWidget(stackedWidget); + verticalLayout->addLayout(tabLayout); verticalLayout->setStretch(0, 2); - verticalLayout->setStretch(1, 3); - verticalLayout->setStretch(2, 40); + verticalLayout->setStretch(1, 40); + verticalLayout->setStretch(2, 3); + + tabLayout->setStretch(0, 1); + tabLayout->setStretch(1, 1); + tabLayout->setStretch(2, 3); + tabLayout->setStretch(3, 1); + tabLayout->setStretch(4, 3); + tabLayout->setStretch(5, 1); + tabLayout->setStretch(6, 3); + tabLayout->setStretch(7, 1); + tabLayout->setStretch(8, 1); + tabLayout->setSpacing(5); MainWindow->setCentralWidget(centralwidget); setButtonMes(); - // ðťת + // ???e????????????? connect(closeButton, &QPushButton::clicked, MainWindow, &QMainWindow::close); -// ޱ߿򴰿 +// ?????????? MainWindow->setWindowFlags(Qt::FramelessWindowHint); QMetaObject::connectSlotsByName(MainWindow); @@ -151,16 +168,20 @@ public: void setButtonMes() { - monitorButton->setText(u8" "); - flangeButton->setText(u8" "); - clearanceButton->setText(u8" "); - gyroscopeButton->setText(u8" "); + monitorButton->setText(QString("监控总览")); + flangeButton->setText(QString("法兰分析")); + clearanceButton->setText(QString("净空区域")); + gyroscopeButton->setText(QString("陀螺仪监测")); connect(monitorButton, &QPushButton::clicked, this, [=](){this->stackedWidget->setCurrentIndex(0); }); connect(flangeButton, &QPushButton::clicked, this, [=](){this->stackedWidget->setCurrentIndex(1); }); connect(clearanceButton, &QPushButton::clicked, this, [=](){this->stackedWidget->setCurrentIndex(2); }); connect(gyroscopeButton, &QPushButton::clicked, this, [=](){this->stackedWidget->setCurrentIndex(3); }); +// connect(flangeButton, &QPushButton::clicked, this, [=](){this->flangePage->addDevice(); }); +// connect(clearanceButton, &QPushButton::clicked, this, [=](){this->clearancePage->addDevice(); }); +// connect(gyroscopeButton, &QPushButton::clicked, this, [=](){this->gyroscopePage->addDevice(); }); + connect(monitorButton, &QPushButton::clicked, this, [=](){this->clearButton();}); connect(flangeButton, &QPushButton::clicked, this, [=](){this->clearButton();}); connect(clearanceButton, &QPushButton::clicked, this, [=](){this->clearButton();}); diff --git a/MonitorUI/MonitorTagUI.h b/MonitorUI/MonitorTagUI.h index af8b0eb..a5e61fe 100644 --- a/MonitorUI/MonitorTagUI.h +++ b/MonitorUI/MonitorTagUI.h @@ -199,37 +199,37 @@ public: pixmap = pixmap.scaled(100, 100, Qt::KeepAspectRatio); pictureLabel->setPixmap(pixmap); pictureLabel_2->setPixmap(pixmap); - this->setStyleSheet("QWidget#MonitorTag{background-color: #374065;border-radius: 5px;border: 3px solid;border-color: #1AFA29;}"); + this->setStyleSheet("QWidget#MonitorTag{background-color: rgba(55, 64, 101, 60%);border-radius: 5px;border: 3px solid;border-color: #1AFA29;}"); }else if (fans.states[fan.fanCode] == QString("通讯中断")){ QPixmap pixmap(":/Static/fanfanInterrupted.png"); pixmap = pixmap.scaled(100, 100, Qt::KeepAspectRatio); pictureLabel->setPixmap(pixmap); pictureLabel_2->setPixmap(pixmap); - this->setStyleSheet("QWidget#MonitorTag{background-color: #374065;border-radius: 5px;border: 3px solid;border-color: white;}"); + this->setStyleSheet("QWidget#MonitorTag{background-color: rgba(55, 64, 101, 60%);border-radius: 5px;border: 3px solid;border-color: white;}"); }else if (fans.states[fan.fanCode] == QString("待机等风")){ QPixmap pixmap(":/Static/fanStandby.png"); pixmap = pixmap.scaled(100, 100, Qt::KeepAspectRatio); pictureLabel->setPixmap(pixmap); pictureLabel_2->setPixmap(pixmap); - this->setStyleSheet("QWidget#MonitorTag{background-color: #374065;border-radius: 5px;border: 3px solid;border-color: #F4EA2A;}"); + this->setStyleSheet("QWidget#MonitorTag{background-color: rgba(55, 64, 101, 60%);border-radius: 5px;border: 3px solid;border-color: #F4EA2A;}"); }else if (fans.states[fan.fanCode] == QString("停机维护")){ QPixmap pixmap(":/Static/fanHutdown.png"); pixmap = pixmap.scaled(100, 100, Qt::KeepAspectRatio); pictureLabel->setPixmap(pixmap); pictureLabel_2->setPixmap(pixmap); - this->setStyleSheet("QWidget#MonitorTag{background-color: #374065;border-radius: 5px;border: 3px solid;border-color: #C0397C;}"); + this->setStyleSheet("QWidget#MonitorTag{background-color: rgba(55, 64, 101, 60%);border-radius: 5px;border: 3px solid;border-color: #C0397C;}"); }else if (fans.states[fan.fanCode] == QString("故障停机")){ QPixmap pixmap(":/Static/fanError.png"); pixmap = pixmap.scaled(100, 100, Qt::KeepAspectRatio); pictureLabel->setPixmap(pixmap); pictureLabel_2->setPixmap(pixmap); - this->setStyleSheet("QWidget#MonitorTag{background-color: #374065;border-radius: 5px;border: 3px solid;border-color: #d81e06;}"); + this->setStyleSheet("QWidget#MonitorTag{background-color: rgba(55, 64, 101, 60%);border-radius: 5px;border: 3px solid;border-color: #d81e06;}"); }else if (fans.states[fan.fanCode] == QString("启动")){ QPixmap pixmap(":/Static/fanRun.png"); pixmap = pixmap.scaled(100, 100, Qt::KeepAspectRatio); pictureLabel->setPixmap(pixmap); pictureLabel_2->setPixmap(pixmap); - this->setStyleSheet("QWidget#MonitorTag{background-color: #374065;border-radius: 5px;border: 3px solid;border-color: #0caba2;}"); + this->setStyleSheet("QWidget#MonitorTag{background-color: rgba(55, 64, 101, 60%);border-radius: 5px;border: 3px solid;border-color: #0caba2;}"); } diff --git a/MonitorUI/MonitorUI.h b/MonitorUI/MonitorUI.h index 923e778..5ddafbf 100644 --- a/MonitorUI/MonitorUI.h +++ b/MonitorUI/MonitorUI.h @@ -38,10 +38,12 @@ public: QPushButton *failureButton; QPushButton *runButton; QWidget *fillWidget; - int state; + int state; + QTimer *viewTimer; + QTimer *dataTimer; QList> tagList; - QTimer *timer; + vector displayList; void setupUi(QWidget *MonitorWidget) { @@ -91,7 +93,7 @@ public: scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); scrollArea->setObjectName(QString::fromUtf8("scrollArea")); - verticalLayout->addWidget(scrollArea); + filterlLayout = new QHBoxLayout(); filterlLayout->setObjectName(QString::fromUtf8("filterlLayout")); @@ -132,9 +134,10 @@ public: filterlLayout->addWidget(runButton); filterlLayout->setContentsMargins(30, 10, 30, 30); - filterlLayout->setSpacing(50); + filterlLayout->setSpacing(150); verticalLayout->addLayout(filterlLayout); + verticalLayout->addWidget(scrollArea); verticalLayout->setStretch(0, 2); verticalLayout->setStretch(1, 30); @@ -145,13 +148,22 @@ public: QMetaObject::connectSlotsByName(MonitorWidget); retranslateUi(MonitorWidget); + updateData(); addTag(); - timer = new QTimer(MonitorWidget); - QObject::connect(timer, &QTimer::timeout, [&]() { + + viewTimer = new QTimer(MonitorWidget); + QObject::connect(viewTimer, &QTimer::timeout, [&]() { // 计时器超时时更新标签 addTag(); }); - timer->start(5000); + viewTimer->start(2500); + + dataTimer = new QTimer(MonitorWidget); + QObject::connect(dataTimer, &QTimer::timeout, [&]() { + // 计时器超时时更新数据 + updateData(); + }); + dataTimer->start(2000); interruptedButton->setCheckable(true); normalButton->setCheckable(true); @@ -160,12 +172,12 @@ public: failureButton->setCheckable(true); runButton->setCheckable(true); - connect(interruptedButton, &QPushButton::clicked, this, [=](){this->addTag();}); - connect(normalButton, &QPushButton::clicked, this, [=](){this->addTag();}); - connect(standbyButton, &QPushButton::clicked, this, [=](){this->addTag();}); - connect(hutdownButton, &QPushButton::clicked, this, [=](){this->addTag();}); - connect(failureButton, &QPushButton::clicked, this, [=](){this->addTag();}); - connect(runButton, &QPushButton::clicked, this, [=](){this->addTag();}); + 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(exchangeButton, &QPushButton::clicked, this, [=](){this->exchangeClicked();}); @@ -210,7 +222,6 @@ public: void addTag() { - httpClient.getFanList(); map allFans = fans.allFans; // 获取与 clicked() 信号相关的接收器数量 @@ -265,23 +276,31 @@ public: } + void updateData(){ + httpClient.getFanList(); + } + void setButtonMes(){ - interruptedButton->setText(QString("通讯中断 ") + QString::number(fans.interruptedFans.size())); - normalButton->setText(QString("正常运行 ") + QString::number(fans.normalFans.size())); - standbyButton->setText(QString("待机等风 ") + QString::number(fans.standbyFans.size())); - hutdownButton->setText(QString("停机维护 ") + QString::number(fans.hutdownFans.size())); - failureButton->setText(QString("故障停机 ") + QString::number(fans.interruptedFans.size())); - runButton->setText(QString("启动 ") + QString::number(fans.runFans.size())); + interruptedButton->setText(QString("通讯中断 %1/%2").arg(fans.interruptedFans.size()).arg(fans.allFans.size())); + normalButton->setText(QString("正常运行 %1/%2").arg(fans.normalFans.size()).arg(fans.allFans.size())); + standbyButton->setText(QString("待机等风 %1/%2").arg(fans.standbyFans.size()).arg(fans.allFans.size())); + hutdownButton->setText(QString("停机维护 %1/%2").arg(fans.hutdownFans.size()).arg(fans.allFans.size())); + failureButton->setText(QString("故障停机 %1/%2").arg(fans.interruptedFans.size()).arg(fans.allFans.size())); + runButton->setText(QString("启动 %1/%2").arg(fans.runFans.size()).arg(fans.allFans.size())); } bool shouldDisplay(QString FanCode){ - vector displayList; - 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());} + if(isInitState()){ + return true; + } + if (std::find(displayList.begin(), displayList.end(), FanCode) != displayList.end()) { + return true; + }else{ + return false; + } + } + + bool isInitState(){ if (!interruptedButton->isChecked() && !normalButton->isChecked() && !standbyButton->isChecked() @@ -289,14 +308,22 @@ public: && !failureButton->isChecked() && !runButton->isChecked()){ return true; - } - if (std::find(displayList.begin(), displayList.end(), FanCode) != displayList.end()) { - return true; }else{ return false; } } + void updateDisplay(){ + displayList.clear(); + 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(); + } + MonitorWidget() { setupUi(this); diff --git a/Static/DamQSS.Qss b/Static/DamQSS.Qss index 2fd49ee..ccca30f 100644 --- a/Static/DamQSS.Qss +++ b/Static/DamQSS.Qss @@ -7,7 +7,7 @@ QMainWindow#MainWindow{ QWidget#MonitorTag{ - background-color: #374065; + background-color: #1D82D2; border-radius: 5px; border: 3px solid; border-color: #1E6C92; @@ -45,6 +45,11 @@ QLabel#nameLabel{ } +QLabel#infoLabel{ + + font-size: 23px; +} + QComboBox{ font-family: Microsoft YaHei; @@ -74,10 +79,10 @@ QPushButton#ClearanceButton, QPushButton#FlangeButton, QPushButton#GyroscopeButt QPushButton#monitorButton, QPushButton#flangeButton, QPushButton#clearanceButton, QPushButton#gyroscopeButton{ color: white; - background-color: rgba(16,68,105, 80%); - border-radius: 5px; - border: 3px solid; - border-color: #115C8E; + background-color: rgba(16,68,105, 0%); + /*border-radius: 5px;*/ + /*border: 3px solid;*/ + /*border-color: #115C8E;*/ height: 30px; font-family: Microsoft YaHei; font-weight: bold; @@ -88,11 +93,12 @@ QPushButton#monitorButton, QPushButton#flangeButton, QPushButton#clearanceButton QPushButton#monitorButton:checked, QPushButton#flangeButton:checked, QPushButton#clearanceButton:checked, QPushButton#gyroscopeButton:checked{ color: white; - background-color: rgba(16,68,105, 80%);; - border-radius: 5px; - border: 3px solid; - border-color: #ffffff; + background-color: rgba(16,68,105, 0%); + border-radius: 0px; + border-bottom: 3px solid; + border-color: #1D82D2; height: 30px; + width: 50px; font-family: Microsoft YaHei; font-weight: bold; font-size: 20px; @@ -101,7 +107,7 @@ QPushButton#monitorButton:checked, QPushButton#flangeButton:checked, QPushButton QPushButton#normalButton, QPushButton#standbyButton, QPushButton#hutdownButton, QPushButton#failureButton, QPushButton#runButton, QPushButton#interruptedButton{ - background-color: rgba(16,68,105, 80%); + background-color: rgba(16,68,105, 0%); color: white; height: 35px; border: none; @@ -138,6 +144,8 @@ QListView#deviceList, QListView#flangeList{ color: white; border-radius: 10px; border-color: #175E88; + font-family: Microsoft YaHei; + font-size: 20px; } diff --git a/Static/error.png b/Static/error.png new file mode 100644 index 0000000000000000000000000000000000000000..857762b54cb560b77ae254c5a68e6bd1fbd80175 GIT binary patch literal 237 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85o30K$!7fntTONu*uWKF{C2y?FB-RJF-~_c?f;J2kkyPdL|M-mqg #include +#include int main(int argc, char *argv[]) @@ -12,6 +13,7 @@ int main(int argc, char *argv[]) QFile styleFile(":/Static/DamQSS.Qss"); styleFile.open(QFile::ReadOnly); QString styleSheet = QLatin1String(styleFile.readAll()); + qDebug() << styleSheet; app.setStyleSheet(styleSheet); MainWindow w;