You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
228 lines
4.8 KiB
C
228 lines
4.8 KiB
C
![]()
5 months ago
|
#ifndef WIDGET_H
|
||
|
#define WIDGET_H
|
||
|
|
||
|
#include <QWidget>
|
||
|
#include <QSerialPort>
|
||
|
#include <QSettings>
|
||
|
#include <QItemDelegate>
|
||
|
#include <stdint.h>
|
||
|
#include "common.h"
|
||
|
|
||
|
namespace Ui { //新增的
|
||
|
class form;
|
||
|
}
|
||
|
|
||
|
|
||
|
#define USART_BUF_SIZE 1088
|
||
|
|
||
|
/* 设置tableview某行/列不可编辑. */
|
||
|
class ReadOnlyDelegate: public QItemDelegate
|
||
|
{
|
||
|
|
||
|
public:
|
||
|
ReadOnlyDelegate(QWidget *parent = nullptr):QItemDelegate(parent)
|
||
|
{}
|
||
|
|
||
|
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,const QModelIndex &index) const override;
|
||
|
};
|
||
|
|
||
|
class Widget : public QWidget
|
||
|
{
|
||
|
Q_OBJECT
|
||
|
|
||
|
public:
|
||
|
Widget(QWidget *parent = nullptr);
|
||
|
~Widget();
|
||
|
private slots:
|
||
|
void on_btnConn_clicked();
|
||
|
|
||
|
void on_btnReset_clicked();
|
||
|
|
||
|
void on_btnRefresh_clicked();
|
||
|
|
||
|
void on_configButton_clicked();
|
||
|
|
||
|
void on_defaultButton_clicked();
|
||
|
|
||
|
void on_fileButton_clicked();
|
||
|
|
||
|
void on_updateButton_clicked();
|
||
|
|
||
|
void on_configSetButton_clicked();
|
||
|
|
||
|
void on_configGetButton_clicked();
|
||
|
|
||
|
void on_csgConfigGetButton_clicked();
|
||
|
|
||
|
void on_csgConfigSetButton_clicked();
|
||
|
|
||
|
void on_dataRefreshButton_clicked();
|
||
|
|
||
|
void on_dataRefreshAutoButton_clicked();
|
||
|
|
||
|
void on_stateRefreshButton_clicked();
|
||
|
|
||
|
void on_freChBox_currentIndexChanged(int index);
|
||
|
|
||
|
void on_freRefreshButton_clicked();
|
||
|
|
||
|
void on_waveColButton_clicked();
|
||
|
|
||
|
void on_waveRefreshButton_clicked();
|
||
|
|
||
|
void on_waveCalButton_clicked();
|
||
|
|
||
|
void on_historyDataButton_clicked();
|
||
|
|
||
|
void on_stateLogButton_clicked();
|
||
|
|
||
|
void on_waveButton_clicked();
|
||
|
|
||
|
void on_manualRatioSetButton_clicked();
|
||
|
|
||
|
void on_manualAdjBox_activated(int index);
|
||
|
|
||
|
void on_manualAdjButton_clicked();
|
||
|
|
||
|
void on_RatioParamGetButton_clicked();
|
||
|
|
||
|
void on_RatioParamSetButton_clicked();
|
||
|
|
||
|
void on_ratioSetButton_clicked();
|
||
|
|
||
|
void on_adjButton_clicked();
|
||
|
|
||
|
void on_tabWidget_tabBarClicked(int index);
|
||
|
|
||
|
private:
|
||
|
|
||
|
QString toHexadecimal(const QByteArray &byteArray);
|
||
|
int searchUsablePort();
|
||
|
void serialErrHandle(QSerialPort::SerialPortError error);
|
||
|
void serialDisconnect();
|
||
|
int initSerial();
|
||
|
int deinitSerial();
|
||
|
int readData();
|
||
|
int writeData(char *buf, int len);
|
||
|
|
||
|
int protoHeaderInit(proto_head_t * header, uint16_t len, uint32_t id, uint8_t cmd_type, uint8_t cmd);
|
||
|
|
||
|
void buttonEnable(bool flag);
|
||
|
|
||
|
QString devStateWaveStateGet(uint8_t state);
|
||
|
|
||
|
QString devStateWlStateGet(uint8_t state);
|
||
|
void uiDevInfoRefresh();
|
||
|
void uiDevConfigRefresh();
|
||
|
void uiDevCsgConfigRefresh();
|
||
|
void uiDevRealDataRefresh();
|
||
|
|
||
|
void uiDevStateRefresh();
|
||
|
|
||
|
void uiPowerFrequencyRefresh();
|
||
|
|
||
|
void uiManualAdjustRefresh();
|
||
|
|
||
|
void uiAdjustInfoRefresh();
|
||
|
|
||
|
void protoContact(char *data);
|
||
|
|
||
|
void protoConfig(char *data);
|
||
|
|
||
|
void protoCsgConfig(char *data);
|
||
|
|
||
|
void protoRealdata(char *data);
|
||
|
|
||
|
int protoUpdateReply(char *data, int fileType);
|
||
|
|
||
|
int protoWaveDataUploadReply(char *data);
|
||
|
|
||
|
int protoPowerFrequency(char *data);
|
||
|
|
||
|
int protoState(char *data);
|
||
|
|
||
|
int protoManualAdjust(char *data);
|
||
|
|
||
|
int protoAutoAdjust(char *data);
|
||
|
|
||
|
int protoAdjustInfoGet(char *data);
|
||
|
|
||
|
int protoLog(char * data);
|
||
|
|
||
|
int protoHistoryData(char *data);
|
||
|
|
||
|
int paraseProtocols(char *data);
|
||
|
int snedMsgDeviceInfoGet();
|
||
|
int sendMsgDeviceInfoSet();
|
||
|
int sendMsgDeviceReset();
|
||
|
int sendMsgDeviceCfgDefault();
|
||
|
int sendMsgDeviceConfigSet();
|
||
|
int sendMsgDeviceConfigGet();
|
||
|
int sendMsgDeviceCsgConfigGet();
|
||
|
int sendMsgDeviceCsgConfigSet();
|
||
|
int sendMsgDeviceRealDataGet();
|
||
|
int sendMsgDeviceUpdate(int fileType);
|
||
|
int sendMsgDeviceWaveDataGet();
|
||
|
|
||
|
int sendMsgDeviceStateGet();
|
||
|
|
||
|
int sendMsgDevicePowerFrequencyGet();
|
||
|
|
||
|
int sendMsgDeviceAdjustInfoGet();
|
||
|
|
||
|
int sendMsgDeviceAdjustInfoSet();
|
||
|
|
||
|
int sendMsgDeviceAdjustMode(uint8_t cmd, adjSet *param);
|
||
|
|
||
|
int sendMsgWaveCol();
|
||
|
|
||
|
int sendMsgWaveCal();
|
||
|
|
||
|
int sendMsgLogGet();
|
||
|
|
||
|
int sendMsgHistoryDataGet();
|
||
|
|
||
|
Ui::form *ui; //新增的
|
||
|
QSerialPort *serialPort;
|
||
|
QSettings *settings;
|
||
|
QString filePath;
|
||
|
QString adjFilePath;
|
||
|
QString waveFilePath;
|
||
|
//QThread *newTask;
|
||
|
//Protocol *usartProtocol;
|
||
|
|
||
|
char rxbuf[USART_BUF_SIZE];
|
||
|
int rxbufLen;
|
||
|
|
||
|
devInfo clientDevInfo;
|
||
|
devConfig clientDevConfig;
|
||
|
csgConfig_t csgConfig;
|
||
|
realData_t clientRealData;
|
||
|
devState clientDevState;
|
||
|
dev_adj_t clientAdjInfo;
|
||
|
adjSet clientAdjSet;
|
||
|
QString energyMode[4];
|
||
|
int isConnected; // serial connect state
|
||
|
int64_t upFileSize;
|
||
|
uint32_t upFileRecvSize;
|
||
|
uint32_t upPackIndex;
|
||
|
int isDataRefresh;
|
||
|
int16_t powerFre[CFG_ADC_CH_CNT][ADC_COLLECT_CNT];
|
||
|
uint32_t freIndex;
|
||
|
uint32_t waveIndex;
|
||
|
uint16_t waveParam;
|
||
|
uint8_t is_wave_up;
|
||
|
uint8_t is_log_up;
|
||
|
uint32_t logIndex;
|
||
|
uint8_t is_data_up;
|
||
|
uint32_t dataIndex;
|
||
|
int32_t logSum;
|
||
|
int32_t historyDataSum;
|
||
|
|
||
|
|
||
|
ReadOnlyDelegate* readOnlyDelegate;
|
||
|
};
|
||
|
|
||
|
|
||
|
#endif // WIDGET_H
|