|
|
|
|
#ifndef UART_H
|
|
|
|
|
#define UART_H
|
|
|
|
|
#include<QSerialPortInfo>
|
|
|
|
|
#include<QSerialPort>
|
|
|
|
|
#include <QList>
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QObject>
|
|
|
|
|
#include <QtWidgets/QWidget>
|
|
|
|
|
#include <QApplication>
|
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
|
|
|
|
|
struct UU_data{
|
|
|
|
|
|
|
|
|
|
QByteArray wirelessTData_adress;
|
|
|
|
|
|
|
|
|
|
QByteArray wirelessTData_data;
|
|
|
|
|
|
|
|
|
|
QByteArray concentratorTData_adress;
|
|
|
|
|
|
|
|
|
|
QByteArray concentratorTData_data;
|
|
|
|
|
|
|
|
|
|
QByteArray policeData;
|
|
|
|
|
|
|
|
|
|
QByteArray TevTop;
|
|
|
|
|
|
|
|
|
|
QByteArray TevFreq;
|
|
|
|
|
|
|
|
|
|
QByteArray TevLevel;
|
|
|
|
|
|
|
|
|
|
QByteArray TevAve;
|
|
|
|
|
|
|
|
|
|
QByteArray Tevperiodicity;
|
|
|
|
|
|
|
|
|
|
QByteArray UltTop;
|
|
|
|
|
|
|
|
|
|
QByteArray UltFreq;
|
|
|
|
|
|
|
|
|
|
QByteArray UltLevel;
|
|
|
|
|
|
|
|
|
|
QByteArray UltAve;
|
|
|
|
|
|
|
|
|
|
QByteArray UltEffective;
|
|
|
|
|
|
|
|
|
|
QByteArray tevData;
|
|
|
|
|
|
|
|
|
|
QByteArray ultData;
|
|
|
|
|
|
|
|
|
|
QByteArray SecFanStartTemperature;
|
|
|
|
|
|
|
|
|
|
QByteArray SecTripTemperature;
|
|
|
|
|
|
|
|
|
|
QByteArray SecAlarmTemperature;
|
|
|
|
|
|
|
|
|
|
QByteArray SecReturnTemperature;
|
|
|
|
|
|
|
|
|
|
QByteArray SecFanStartTempeture;
|
|
|
|
|
|
|
|
|
|
QByteArray SecWheelVol;
|
|
|
|
|
|
|
|
|
|
QByteArray SecZeroSequenceVol;
|
|
|
|
|
|
|
|
|
|
QByteArray SecActivePower;
|
|
|
|
|
|
|
|
|
|
QByteArray SecActivePowerCom;
|
|
|
|
|
|
|
|
|
|
QByteArray SecReactivePower;
|
|
|
|
|
|
|
|
|
|
QByteArray SecReactivePowerCom;
|
|
|
|
|
|
|
|
|
|
QByteArray SecWheelPowerFactor;
|
|
|
|
|
|
|
|
|
|
QByteArray SecWheelPowerFactorCom;
|
|
|
|
|
|
|
|
|
|
QByteArray SecWheelFrequency;
|
|
|
|
|
|
|
|
|
|
QByteArray SecWheelTemperature;
|
|
|
|
|
|
|
|
|
|
QByteArray SecWheelPositiveElectricEnergy;
|
|
|
|
|
|
|
|
|
|
QByteArray SecWheelNegativeElectricEnergy;
|
|
|
|
|
|
|
|
|
|
QByteArray SecWheelActivePowerCom;
|
|
|
|
|
|
|
|
|
|
QByteArray SecWheelReactivePowerCom;
|
|
|
|
|
|
|
|
|
|
QByteArray SecCT;
|
|
|
|
|
|
|
|
|
|
QByteArray McuState;
|
|
|
|
|
|
|
|
|
|
QByteArray SecData;
|
|
|
|
|
|
|
|
|
|
QByteArray Incident;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
|
class UART;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class UART : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
void platform_test();
|
|
|
|
|
void happenInfoError(QByteArray data);
|
|
|
|
|
void memcpySerialData(char *data,QByteArray &A,uint16_t len);
|
|
|
|
|
explicit UART(QObject *parent = nullptr);
|
|
|
|
|
~UART();
|
|
|
|
|
void openserial(QString COM/*,QString COM2*/);
|
|
|
|
|
void setserial();
|
|
|
|
|
void ShuJu_Write(QByteArray data);
|
|
|
|
|
void serial_close();
|
|
|
|
|
void ModBusCRC16(QByteArray data);
|
|
|
|
|
void creat_file();
|
|
|
|
|
QByteArray platformdata1;
|
|
|
|
|
QByteArray platformdata2;
|
|
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
void ShuJu_Read();
|
|
|
|
|
void receverDataFromSerialPort();
|
|
|
|
|
void uart_init(QString COM,uint8_t Enable);
|
|
|
|
|
void Delay_MSec(unsigned int msec);
|
|
|
|
|
private:
|
|
|
|
|
Ui::UART *ui;
|
|
|
|
|
QThread *my_thread;
|
|
|
|
|
QThread *uart_thread;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|