| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- #ifndef MAINWINDOW_H
- #define MAINWINDOW_H
- #include <QMainWindow>
- #include <softkeyboard.h>
- #include <QScreen>
- #include <QGraphicsScene>
- #include <QGraphicsView>
- #include <QGraphicsProxyWidget>
- #include <QRect>
- #include <QStackedWidget>
- #include <QSerialPort>
- #include <QSerialPortInfo>
- #include <channelinfo.h>
- #include <landscape.h>
- #include <QTimer>
- #include <QThread>
- #include <QModbusDataUnit>
- #include <QModbusTcpClient>
- #include <QModbusRtuSerialMaster>
- #include <QTimeZone>
- #include <QMutex>
- #include <QMutexLocker>
- #include "portraitmode.h"
- #include "modbus/modbus.h"
- #include "readmodbus.h"
- #include "softkeyboard.h"
- #include "gpiobutten.h"
- QT_BEGIN_NAMESPACE
- namespace Ui { class MainWindow; }
- QT_END_NAMESPACE
- class ReadModbus;
- class Portraitmode;
- #define MAX_CHANNELS 14
- #define _SWITCH_T_AC_TYPE_CHN_INFO 0x1770 //获取三项类型通道
- #define _SWITCH_T_AC_IN_L1_INFO 0x1771 //三项交流输入L1
- #define _SWITCH_T_AC_IN_L2_INFO 0x1779 //三项交流输入L2
- #define _SWITCH_T_AC_IN_L3_INFO 0x1781 //三项交流输入L3
- #define _SWITCH_T_AC_CH_INFO 0x1789 //每个通道信息
- #define _SWITCH_T_AC_CH_PHASE_INFO 0x1A09 //每个通道相信息
- #define _SWITCH_T_AC_TH_INFO 0x2189 //温湿度信息
- #define _SWITCH_T_AC_CH_STATUS 0x218B //通道开关信息
- #define _SWITCH_T_AC_SENSOR_INFO 0x224B //MODBUS传感器信息
- #define _SWITCH_T_AC_SENSOR_INFO1 0x225B //干节点传感器信息
- typedef struct{
- uint16_t AllChs;
- uint8_t Type;
- float AllVoltage_L1 =0;
- float AllCurrent_L1=0;
- float AllPower_L1=0;
- float AllConsumption_L1=0;
- float AllVoltage_L2=0;
- float AllCurrent_L2=0;
- float AllPower_L2=0;
- float AllConsumption_L2=0;
- float AllVoltage_L3=0;
- float AllCurrent_L3=0;
- float AllPower_L3=0;
- float AllConsumption_L3=0;
- float Sensor_Temperature=0;
- float Sensor_Humidity=0;
- float Sensor_CO2=0;
- float Sensor_INTemperature=0;
- float Sensor_IN_Pressure = 0;
- float Sensor_OUTTemperature=0;
- float Sensor_OUT_Pressure = 0;
- bool Sensor_WaterImmersion=false;
- bool Sensor_LeakFlag=false;
- }PDUAllInfo_t;
- typedef struct
- {
- int CHNum=0;
- QString CHName=0;
- int CHPhase=0;
- float CHVoltage=0;
- float CHCurrent=0;
- float CHPower=0;
- float CHFactor=0;
- float CHConsumption=0;
- bool CHStatus=false;
- }PDUCHInfo_t;
- typedef struct
- {
- QString edit;
- QString line_send;
- QString line_recived;
- QString year;
- QString mon;
- QString day;
- QString hour;
- QString min;
- QString sec;
- QString port;
- QString addr;
- QString band;
- QString data;
- QString stop;
- QString parity;
- QString zone;
- int britnight;
- }chache_t;
- typedef struct
- {
- uint16_t slave_addr;
- char serial_name[32];
- uint32_t serial_banud;
- char serial_parity;
- uint8_t serial_data_bit;
- uint8_t serial_stop;
- }modbus_info_t;
- class MainWindow : public QMainWindow
- {
- Q_OBJECT
- public:
- MainWindow(QWidget *parent = nullptr);
- ~MainWindow();
- void test_modbus();
- void read_pdu_data();
- modbus_info_t get_modbus_info();
- int modbus_set(modbus_info_t &md_info);
- const modbus_t * get_mb() const;
- const SoftKeyBoard* get_keyboard()const;
- uint8_t get_suspend_flag();
- QTimeZone get_zone();
- void route();
- signals:
- void update_ui();
- void Notice(QString &send,QString &recived,uint8_t send_flag,uint8_t recive_flag);
- public slots:
- void opt_stop_or_start_signal(bool val);
- private:
- void modbus_init();
- public:
- ChannelInfo* get_channel_info();
- public:
- PDUAllInfo_t pdu_all_info;
- PDUCHInfo_t pdu_ch_info[15];
- uint8_t page;
- // chache_t m_che;
- int britnight;
- private:
- Ui::MainWindow *ui;
- QGraphicsScene *m_sence;
- QGraphicsView *m_view;
- QGraphicsProxyWidget *m_proxy;
- QScreen *m_screen;
- QRect screen_info;
- uint32_t m_width;
- uint32_t m_height;
- uint32_t rotation;
- modbus_info_t modbus;
- ChannelInfo *m_channel;
- SoftKeyBoard *keyboard;
- Portraitmode *port;
- Landscape *land;
- QTimer *m_timer;
- QTimeZone sysTime_zone;
- modbus_t *m_mb;
- QThread *m_thread;
- ReadModbus *m_read;
- uint8_t suspend_flag;
- GpioButten *m_key;
- };
- #endif // MAINWINDOW_H
|