widget.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. #ifndef WIDGET_H
  2. #define WIDGET_H
  3. #include <QWidget>
  4. #include <QMenu>
  5. #include <QAction>
  6. #include <QToolButton>
  7. #include <QLabel>
  8. #include <QFont>
  9. #include <QDateTime>
  10. #include <QLinearGradient>
  11. #include <QTimer>
  12. #include <QStringList>
  13. #include <QJsonParseError>
  14. #include <QJsonDocument>
  15. #include <QJsonObject>
  16. #include <QJsonArray>
  17. #include <QJsonValue>
  18. #include <QVariant>
  19. #include <QTextCodec>
  20. #include <QGraphicsView>
  21. #include <QChart>
  22. #include <QChartView>
  23. #include <QPieSeries>
  24. #include <QPieSlice>
  25. #include <QList>
  26. #include <QStringList>
  27. #include "custqlabel.h"
  28. #include "getweather.h"
  29. #include "getfrontpage.h"
  30. #include "websocketclient.h"
  31. #include "setupform.h"
  32. #include "alarminfoform.h"
  33. #include "devdataform.h"
  34. #include "logthread.h"
  35. #include "dbthread.h"
  36. #include "speechthread.h"
  37. QT_BEGIN_NAMESPACE
  38. namespace Ui { class Widget; }
  39. QT_END_NAMESPACE
  40. using namespace QtCharts;
  41. class DevInfo {
  42. public:
  43. explicit DevInfo(QString name="", QString type="", QString level="", QString code="", QString info=""){
  44. DevName = name;
  45. DevType = type;
  46. Level = level;
  47. DevCode = code;
  48. DeviceInfo = info;
  49. DevDataInfoList = QJsonArray();
  50. }
  51. void appendData(QJsonObject data){
  52. DevDataInfoList.append(data);
  53. }
  54. QString DevName;
  55. QString DevType;
  56. QString Level;
  57. QString DevCode;
  58. QString DeviceInfo;
  59. QJsonArray DevDataInfoList;
  60. };
  61. class AlarmInfo {
  62. public:
  63. explicit AlarmInfo(QString name="", QString type="", QString info="", QString time=""){
  64. DevName = name;
  65. DevType = type;
  66. Alarminfo = info;
  67. AlarmTime = QDateTime::fromString(time,"yyyy-MM-dd HH:mm:ss");
  68. }
  69. QString DevName;
  70. QString DevType;
  71. QString Alarminfo;
  72. QDateTime AlarmTime;
  73. };
  74. class Widget : public QWidget
  75. {
  76. Q_OBJECT
  77. public:
  78. Widget(QWidget *parent = nullptr);
  79. ~Widget();
  80. void setBackground(QSize size);
  81. void setOperationBtn(QSize size);
  82. void setDateLabel(QSize size);
  83. void setTimeLabel(QSize size);
  84. void setWeatherLabel(QSize size);
  85. void setDevLabels(QSize size);
  86. void setAlarmBarLabels(QSize size);
  87. void setDevInfoLabels(QSize size);
  88. void setAlarmInfoLabels(QSize size);
  89. void setNoteLabels(QSize size);
  90. void setPieView(QSize size);
  91. void setPieVlue(QGraphicsView *view, int value);
  92. void setDevData(QString devCode, QJsonObject data);
  93. void setAlarmNote(QSize size);
  94. void setCurrentAlarmNote(AlarmInfo info);
  95. void setDevInfo();
  96. void setAlarmInfo();
  97. void setMenu();
  98. void start();
  99. void setWeatherInfo();
  100. void connectDC();
  101. bool isNewAlarm(AlarmInfo info);
  102. public slots:
  103. void setupClick();
  104. void timeout();
  105. void closeAlarmBar();
  106. 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);
  107. void getDcData(QString data);
  108. void getFrontpage(QString data);
  109. void DcSoClosed();
  110. void pageClick();
  111. void devClick();
  112. void cancel();
  113. void save(QString appid, QString key, QString name, QString pass, QString comid, QString url);
  114. void getParam(QString appid, QString key, QString name, QString pass, QString comid, QString url);
  115. private:
  116. Ui::Widget *ui;
  117. QTimer *timer, *a_timer;
  118. QToolButton *CmdBtn, *prevPageBtn, *nextPageBtn, *QuitBtn;
  119. QMenu *menu;
  120. QLabel *DateLabel;
  121. QLabel *TimeLabel;
  122. QLabel *weatherIconLabel, *weatherNowLabel, *temperatureLabel;
  123. QLabel *DevCountLabel[5], *OutCountLabel[5], *AlarmCountLabel[5];
  124. QLabel *AlarmUncomCountLabel[5], *AlarmComCountLabel[5];
  125. QLabel *AlarmUncomPLabel[5], *AlarmComPLabel[5], *AlarmPLabel[5];
  126. int DevCountLabelValue[5], OutCountLabelValue[5], AlarmCountLabelValue[5], AlarmUncomCountLabelValue[5], AlarmComCountLabelValue[5], AlarmUncomPLabelValue[5], AlarmComPLabelValue[5], AlarmPLabelValue[5];
  127. QGraphicsView *pieView[5];
  128. QPieSeries *series[5];
  129. QLabel *AlarmBarBGLabel[10], *AlarmBarValueLabel[10], *AlarmBarCoverLabel[10];
  130. CustQLabel *DevInfoLabel[39], *AlarmInfoLabel[18], *NoteBtn;
  131. QLabel *currentAlarmBG, *currentAlarmNote;
  132. QStringList CompanyName, Address, CompanyGPS, userName, Phone, CompanyCode;
  133. QLabel *NoteBgLabel, *NoteLabel;
  134. int count;
  135. int day,hour;
  136. bool firstTime;
  137. QStringList weekday;
  138. QStringList weatherstring;
  139. GetWeather *getWeather;
  140. getFrontPage *frontpage;
  141. QString dayWeather, nightWeather;
  142. QString dayWeatherCode, nightWeatherCode;
  143. QString sunBegin, sunEnd;
  144. QString dayTemperature, nightTemperature;
  145. QString TermId, TermKey;
  146. QString Loginname, Password;
  147. QString CompanyId, AppUrl;
  148. QStringList CompanyIdList;
  149. LogThread *logThread;
  150. int AlarmCount[5], AlarmConfrmCount[5];
  151. QList<DevInfo *> deviceList;
  152. QList<AlarmInfo> alarmList;
  153. int devPage;
  154. WebsocketClient *wsc;
  155. DBThread *dbThread;
  156. SpeechThread *speechThread;
  157. bool a_start;
  158. };
  159. #endif // WIDGET_H