mainwidget.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #ifndef MAINWIDGET_H
  2. #define MAINWIDGET_H
  3. #include <QLabel>
  4. #include <QWidget>
  5. #include <QTimer>
  6. #include "USB485_Ctrl.h"
  7. #include "widget.h"
  8. #include <QJniObject>
  9. QT_BEGIN_NAMESPACE
  10. namespace Ui { class MainWidget; }
  11. QT_END_NAMESPACE
  12. //==========================PDU数据结构=======================
  13. struct PDUAllInfo
  14. {
  15. float AllVoltage_L1 =0;
  16. float AllCurrent_L1=0;
  17. float AllPower_L1=0;
  18. float AllConsumption_L1=0;
  19. float AllVoltage_L2=0;
  20. float AllCurrent_L2=0;
  21. float AllPower_L2=0;
  22. float AllConsumption_L2=0;
  23. float AllVoltage_L3=0;
  24. float AllCurrent_L3=0;
  25. float AllPower_L3=0;
  26. float AllConsumption_L3=0;
  27. float Sensor_Temperature=0;
  28. float Sensor_Humidity=0;
  29. bool Sensor_WaterImmersion=true;
  30. float Sensor_INTemperature=0;
  31. float Sensor_OUTTemperature=0;
  32. };
  33. struct PDUCHInfo
  34. {
  35. int CHNum=0;
  36. QString CHName=0;
  37. int CHPhase=0;
  38. float CHVoltage=0;
  39. float CHCurrent=0;
  40. float CHPower=0;
  41. float CHFactor=0;
  42. float CHConsumption=0;
  43. bool CHStatus=false;
  44. };
  45. class MainWidget : public QWidget
  46. {
  47. Q_OBJECT
  48. public:
  49. MainWidget(QWidget *parent = nullptr);
  50. ~MainWidget();
  51. void InitUI();
  52. void InitConnect();
  53. bool InitSerial();
  54. private slots:
  55. /*手动连接槽函数*/
  56. void manual_serialPortReadyRead();
  57. /*以下为mainwindow.ui文件中点击“转到槽”自动生成的函数*/
  58. void on_Button_openserial_clicked();
  59. void on_Button_tx_clicked();
  60. void on_Button_clearrecive_clicked();
  61. void on_Button_cleartx_clicked();
  62. void on_check_autosend_stateChanged(int arg1);
  63. void on_Button_checkserial_clicked();
  64. void slot_changeDebugMode();
  65. void UpdateStatusInfo();
  66. private:
  67. void setNumOnLabel(QLabel *lbl, QString strS, long num);
  68. private:
  69. Ui::MainWidget *ui;
  70. // 发送、接收字节计数
  71. long sendNum, recvNum;
  72. QLabel *lblSendNum;
  73. QLabel *lblRecvNum;
  74. QLabel *lblPortState;
  75. // 定时发送-定时器
  76. QTimer *timSend;
  77. QTimer *_timer_update_info = NULL;
  78. Usb485_Ctrl m_USBCtrl;
  79. int m_TotalCHNum;
  80. PDUAllInfo m_PDUAllInfo;
  81. PDUCHInfo m_PDUCHInfo[64];
  82. Widget m_chWidget[64];
  83. };
  84. #endif // MAINWIDGET_H