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.

76 lines
2.0 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#pragma execution_character_set("utf-8")
#pragma once
#include <QObject>
#include <QMutex>
#include "Common.h"
#include "frame/Frame.h"
class SetupService : QObject
{
Q_OBJECT
public:
static SetupService *GetInstance() {
if(!m_pInstance)
{
m_mutex.lock();
if(!m_pInstance)
{
m_pInstance = new SetupService();
}
m_mutex.unlock();
}
return m_pInstance;
}
SetupService(const SetupService&)= delete;
SetupService& operator=(const SetupService&)= delete;
void SendData(unsigned char cmd, std::string data = "", int msec=1000, unsigned char from=0);
void SendData(unsigned char cmd, Data *data, int msec=1000, unsigned char from=0);
SYS_STATUS currStatus() { return m_currStatus; }
signals:
void recv_base_setup_rsp(QString portName, unsigned char cmd, QByteArray recvData);
void recv_advance_setup_rsp(QString portName, unsigned char cmd, QByteArray recvData);
public slots:
void slot_recvData(QString portName, unsigned char cmd, QByteArray data);
void slot_recvTimeout(QString portName);
void slot_getRecordFinish(int result);
private:
SetupService() : m_currStatus(SYS_STATUS_IDLE), m_currCmd(FRAME_CMD_START), m_currCmdFrom(0) {};
private:
static SetupService *m_pInstance;
static QMutex m_mutex;
SYS_STATUS m_currStatus; // 当前状态
unsigned char m_currCmd; // 当前指令
unsigned char m_currCmdFrom; // 当前指令来源0-基础设置1-高级设置
private:
// 垃圾回收类它的唯一工作就是在析构函数中删除DeviceFactory的实例
class Garbo
{
public:
~Garbo()
{
if (SetupService::m_pInstance)
{
// 销毁设备管理单例实例
delete SetupService::m_pInstance;
}
}
};
// 定义一个静态成员,在程序结束时,系统会调用它的析构函数
static Garbo m_Garbo;
};