| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- #ifndef WIDGET_H
- #define WIDGET_H
- #include <QWidget>
- #include <QMenu>
- #include <QAction>
- #include <QToolButton>
- #include <QLabel>
- #include <QFont>
- #include <QDateTime>
- #include <QLinearGradient>
- #include <QTimer>
- #include <QStringList>
- #include <QJsonParseError>
- #include <QJsonDocument>
- #include <QJsonObject>
- #include <QJsonArray>
- #include <QJsonValue>
- #include <QVariant>
- #include <QTextCodec>
- #include <QGraphicsView>
- #include <QChart>
- #include <QChartView>
- #include <QPieSeries>
- #include <QPieSlice>
- #include <QList>
- #include <QStringList>
- #include "custqlabel.h"
- #include "getweather.h"
- #include "getfrontpage.h"
- #include "websocketclient.h"
- #include "setupform.h"
- #include "alarminfoform.h"
- #include "devdataform.h"
- #include "logthread.h"
- #include "dbthread.h"
- #include "speechthread.h"
- QT_BEGIN_NAMESPACE
- namespace Ui { class Widget; }
- QT_END_NAMESPACE
- using namespace QtCharts;
- class DevInfo {
- public:
- explicit DevInfo(QString name="", QString type="", QString level="", QString code="", QString info=""){
- DevName = name;
- DevType = type;
- Level = level;
- DevCode = code;
- DeviceInfo = info;
- DevDataInfoList = QJsonArray();
- }
- void appendData(QJsonObject data){
- DevDataInfoList.append(data);
- }
- QString DevName;
- QString DevType;
- QString Level;
- QString DevCode;
- QString DeviceInfo;
- QJsonArray DevDataInfoList;
- };
- class AlarmInfo {
- public:
- explicit AlarmInfo(QString name="", QString type="", QString info="", QString time=""){
- DevName = name;
- DevType = type;
- Alarminfo = info;
- AlarmTime = QDateTime::fromString(time,"yyyy-MM-dd HH:mm:ss");
- }
- QString DevName;
- QString DevType;
- QString Alarminfo;
- QDateTime AlarmTime;
- };
- class Widget : public QWidget
- {
- Q_OBJECT
- public:
- Widget(QWidget *parent = nullptr);
- ~Widget();
- void setBackground(QSize size);
- void setOperationBtn(QSize size);
- void setDateLabel(QSize size);
- void setTimeLabel(QSize size);
- void setWeatherLabel(QSize size);
- void setDevLabels(QSize size);
- void setAlarmBarLabels(QSize size);
- void setDevInfoLabels(QSize size);
- void setAlarmInfoLabels(QSize size);
- void setNoteLabels(QSize size);
- void setPieView(QSize size);
- void setPieVlue(QGraphicsView *view, int value);
- void setDevData(QString devCode, QJsonObject data);
- void setAlarmNote(QSize size);
- void setCurrentAlarmNote(AlarmInfo info);
- void setDevInfo();
- void setAlarmInfo();
- void setMenu();
- void start();
- void setWeatherInfo();
- void connectDC();
- bool isNewAlarm(AlarmInfo info);
- public slots:
- void setupClick();
- void timeout();
- void closeAlarmBar();
- void get_weather(QString day_weather, QString day_weather_code, QString night_weather, QString night_weather_code, QString sun_begin, QString sun_end, QString day_air_temperature, QString night_air_temperature);
- void getDcData(QString data);
- void getFrontpage(QString data);
- void DcSoClosed();
- void pageClick();
- void devClick();
- void cancel();
- void save(QString appid, QString key, QString name, QString pass, QString comid, QString url);
- void getParam(QString appid, QString key, QString name, QString pass, QString comid, QString url);
- private:
- Ui::Widget *ui;
- QTimer *timer, *a_timer;
- QToolButton *CmdBtn, *prevPageBtn, *nextPageBtn, *QuitBtn;
- QMenu *menu;
- QLabel *DateLabel;
- QLabel *TimeLabel;
- QLabel *weatherIconLabel, *weatherNowLabel, *temperatureLabel;
- QLabel *DevCountLabel[5], *OutCountLabel[5], *AlarmCountLabel[5];
- QLabel *AlarmUncomCountLabel[5], *AlarmComCountLabel[5];
- QLabel *AlarmUncomPLabel[5], *AlarmComPLabel[5], *AlarmPLabel[5];
- int DevCountLabelValue[5], OutCountLabelValue[5], AlarmCountLabelValue[5], AlarmUncomCountLabelValue[5], AlarmComCountLabelValue[5], AlarmUncomPLabelValue[5], AlarmComPLabelValue[5], AlarmPLabelValue[5];
- QGraphicsView *pieView[5];
- QPieSeries *series[5];
- QLabel *AlarmBarBGLabel[10], *AlarmBarValueLabel[10], *AlarmBarCoverLabel[10];
- CustQLabel *DevInfoLabel[39], *AlarmInfoLabel[18], *NoteBtn;
- QLabel *currentAlarmBG, *currentAlarmNote;
- QStringList CompanyName, Address, CompanyGPS, userName, Phone, CompanyCode;
- QLabel *NoteBgLabel, *NoteLabel;
- int count;
- int day,hour;
- bool firstTime;
- QStringList weekday;
- QStringList weatherstring;
- GetWeather *getWeather;
- getFrontPage *frontpage;
- QString dayWeather, nightWeather;
- QString dayWeatherCode, nightWeatherCode;
- QString sunBegin, sunEnd;
- QString dayTemperature, nightTemperature;
- QString TermId, TermKey;
- QString Loginname, Password;
- QString CompanyId, AppUrl;
- QStringList CompanyIdList;
- LogThread *logThread;
- int AlarmCount[5], AlarmConfrmCount[5];
- QList<DevInfo *> deviceList;
- QList<AlarmInfo> alarmList;
- int devPage;
- WebsocketClient *wsc;
- DBThread *dbThread;
- SpeechThread *speechThread;
- bool a_start;
- };
- #endif // WIDGET_H
|