|
|
|
|
|
#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;//ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Դ<EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
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;//<2F><><EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD><DDB7><EFBFBD>
|
|
|
|
|
|
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;//<2F><><EFBFBD><EFBFBD>Э<EFBFBD><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD><DDB7><EFBFBD>
|
|
|
|
|
|
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;//<2F><><EFBFBD><EFBFBD> ί<><CEAF>
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // SERIALPORTTOOL_H
|