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.
115 lines
3.5 KiB
C++
115 lines
3.5 KiB
C++
#ifndef BASESETUPWIDGET_H
|
|
#define BASESETUPWIDGET_H
|
|
|
|
#include <QWidget>
|
|
#include <QTimer>
|
|
#include "Common.h"
|
|
#include "data/Data.h"
|
|
#include <Qtxlsx>
|
|
|
|
namespace Ui {
|
|
class BaseSetupWidget;
|
|
}
|
|
|
|
// 记录文件相关定义
|
|
typedef enum
|
|
{
|
|
FIELD_TYPE_STRING = 0,
|
|
FIELD_TYPE_UCHAR = 1,
|
|
FIELD_TYPE_USHORT = 2,
|
|
FIELD_TYPE_UINT = 4,
|
|
FIELD_TYPE_DATETIME = 7
|
|
} enumFieldType;
|
|
|
|
typedef struct
|
|
{
|
|
QString fieldName; // 字段名
|
|
unsigned char fieldType; // 字段类型, 0 - string, 1 - unsigned char, 2 - unsigned short, 4 - unsigned int,
|
|
unsigned char fieldLen; // 字段长度
|
|
}tagRecordFile;
|
|
|
|
class BaseSetupWidget : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit BaseSetupWidget(QWidget *parent = nullptr);
|
|
~BaseSetupWidget();
|
|
|
|
// 初始化
|
|
void init();
|
|
|
|
// 定时器
|
|
void initTimer0();
|
|
void clearTimer0();
|
|
|
|
void processSetTimeRsp(QString portName, QByteArray data);
|
|
void processGetTimeRsp(QString portName, QByteArray data);
|
|
void processSetSerialNumberRsp(QString portName, QByteArray data);
|
|
void processGetSerialNumberRsp(QString portName, QByteArray data);
|
|
void processSetDeviceNameRsp(QString portName, QByteArray data);
|
|
void processGetDeviceNameRsp(QString portName, QByteArray data);
|
|
void processSetDeviceNumberRsp(QString portName, QByteArray data);
|
|
void processGetDeviceNumberRsp(QString portName, QByteArray data);
|
|
void processSetOperatorRsp(QString portName, QByteArray data);
|
|
void processGetOperatorRsp(QString portName, QByteArray data);
|
|
|
|
void processGetRecordRsp(QString portName, QByteArray data);
|
|
void processClsRecordRsp(QString portName, QByteArray data);
|
|
void processSetLockStatusRsp(QString portName, QByteArray data);
|
|
void saveRecordToFile();
|
|
void saveToXlsx();
|
|
void saveToCsv();
|
|
|
|
void initRecordTimer();
|
|
void startRecordTimer(unsigned int msec);
|
|
void stopRecordTimer();
|
|
|
|
signals:
|
|
//void get_record_timeout();
|
|
void get_record_finish(int result); // result: -1 失败返回; 0 成功返回; 1 超时返回
|
|
|
|
private slots:
|
|
// 时间定时器
|
|
void slot_timer0_task();
|
|
|
|
// 接收文件定时器槽
|
|
void slot_recordTimeout();
|
|
|
|
void slot_pushButtonToolsUnlock_clicked();
|
|
void slot_pushButtonToolsSerialNumber_clicked();
|
|
void slot_pushButtonTimeSetting_clicked();
|
|
void slot_pushButtonUserEquitmentItem_clicked();
|
|
void slot_pushButtonUserEquitmentNo_clicked();
|
|
void slot_pushButtonOperatorSettings_clicked();
|
|
void slot_pushButtonGetRecords_clicked();
|
|
void slot_pushButtonDeleteRecordedData_clicked();
|
|
|
|
void slot_recvData(QString portName, unsigned char cmd, QByteArray recvData);
|
|
|
|
private:
|
|
Ui::BaseSetupWidget *ui;
|
|
|
|
// 时间定时器
|
|
QTimer m_timer0;
|
|
|
|
//SYS_STATUS m_sysStatus; // 系统状态
|
|
unsigned char m_currCmd; // 当前执行的指令
|
|
unsigned char m_bSucc; // 当前指令执行状态
|
|
|
|
//QAxObject *m_excelObject;
|
|
|
|
// 获取文件记录操作相关变量
|
|
bool m_recordFlag; // 文件记录标记
|
|
unsigned short m_recordAllCount; // 文件总记录数
|
|
unsigned short m_recordCurrCount; // 当前文件记录数
|
|
QList<QString> m_recordData; // 文件内容
|
|
QTimer m_recordTimer; // 获取记录定时器
|
|
QString m_recordFilePath; // 文件保存路径
|
|
// unsigned int m_recordElapsedTime; // 定时器剩余时间
|
|
// QTime m_recordTime;
|
|
|
|
};
|
|
|
|
#endif // BASESETUPWIDGET_H
|