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.
51 lines
1.4 KiB
C++
51 lines
1.4 KiB
C++
#ifndef SERIALPORTTOOL_H
|
|
#define SERIALPORTTOOL_H
|
|
#include <QObject>
|
|
#include <QByteArray>
|
|
#include "FastDelegate.h"
|
|
#include "ctransform.h"
|
|
using namespace fastdelegate;
|
|
class ISerialPortTool : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
ISerialPortTool(){};
|
|
~ISerialPortTool(){};
|
|
virtual void CloseCom() = 0;
|
|
virtual bool OpenCom(const QString &m_Comname, const QString &BaudRate = "38400") = 0;
|
|
virtual bool getComState(void) = 0;
|
|
virtual int getRxDataSize(void) = 0;
|
|
virtual QByteArray getRxBufData(void) = 0;
|
|
virtual bool takeData(QByteArray &data, int nLen /*= 1*/) = 0;//取出数据 自带删除功能
|
|
virtual bool takeData(quint8 &data, int nLen /*= 1*/) = 0;
|
|
virtual bool cleanRxDataBuf(void) = 0;
|
|
virtual bool init(void) = 0;
|
|
virtual bool pullData2Tx(const QByteArray &data) = 0;//裸数据发送
|
|
virtual bool pullData2Tx(int size, quint8 *data) = 0;
|
|
|
|
|
|
virtual bool SwapFrame(SComFrame &frame) = 0;
|
|
virtual bool SwapData(quint16 &tmp) = 0;
|
|
virtual bool enquequeData(SComFrame &frame) = 0;//带有协议的数据发送
|
|
template <typename T, typename MemFnPtr>
|
|
bool loadAnalysefunc(T *obj, MemFnPtr fuc)
|
|
{
|
|
_analysiseFun.bind(obj, fuc);
|
|
return true;
|
|
};
|
|
|
|
signals :
|
|
void comRecive();
|
|
void recvData(int size);
|
|
void sendData(int size);
|
|
void sendNum(int num);
|
|
void recvNum(int num);
|
|
void sendShowData(QByteArray m_data);
|
|
void CallBackPullData(QByteArray m_data);
|
|
|
|
protected:
|
|
FastDelegate1<SComFrame > _analysiseFun;//解析 委托
|
|
};
|
|
|
|
#endif // SERIALPORTTOOL_H
|