#ifndef PQ_RTUHELPER_H #define PQ_RTUHELPER_H #include #include "QDebug" /*** * 通讯处理的公共函数 */ namespace PQ { class RTUHelper { public: RTUHelper(); virtual ~RTUHelper(); enum RType { SubAddress,//从站地址 GetType, //要数类型 NumLength, //需要的长度 ReadData, //需要读取数据 CRCUL, //CRC 低位 CRCUH // CRC 高位 }; inline void setCheckSubAddress(bool check){ _checkSubAddress = check; } inline void addCheckSubAddress(char ch){ _subAddress.append(ch); } void readed(const QByteArray & data); protected: virtual void doHandle(const QByteArray & data) = 0; private: QByteArray buffer; RType readType; int toReadlen; private: bool _checkSubAddress; QByteArray _subAddress; }; } #endif // RTUHELPER_H