123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- #ifndef __SERIALINTERFACE_BY_ZEROT_
- #define __SERIALINTERFACE_BY_ZEROT_
- #ifdef SERIAL_IMPL
- #define SERIALDLLEXPORT _declspec(dllexport)
- #else
- #define SERIALDLLEXPORT _declspec(dllimport)
- #endif
- // 接口纯虚类,实现多态;
- class SERIALDLLEXPORT CSerialInterface
- {
-
- // [in]:
- public:
- // 打开串口;
- virtual BOOL OpenSerialPort(
- const int &iCommPort,
- const int &iRate,
- const int &iDataBit,
- const int &iStopBit,
- const int &iParity,
- const int &iReqTime,
- const int &iInterval ) = 0;
- // 关闭串口;
- virtual BOOL CloseSerialPort( const int &iCommPort ) = 0;
- // 自动采集;
- virtual int AutoCollect(const int &iCommPort) = 0;
- // 停止自动采集;
- virtual void StopCollect(const int &iCommPort) = 0;
- // 自动接收;
- virtual void AutoScatter(const int &iCommPort) = 0;
- // 停止自动接收;
- virtual void StopScatter(const int &iCommPort) = 0;
- // 发送读请求命令;
- // iRequestType : 命令的类型 , == 0 是设置, == 1 是读取;
- virtual void SendRequest( const int &iCommPort, const int &iAddr, BYTE *szCmd,const int &iLen, const int &iRequestType ) = 0;
- // 读取请求回复数据;
- virtual void ReadRespone( const int &iCommPort, const int &iAddr ) = 0;
- // 添加读请求命令(其中:szMark,只为多命令设备使用,如果设备只有一个命令,szMark可以省略不写);
- virtual void InserCommand(
- const int &iCommPort,
- const int &iAddr,
- BYTE *szCommand,
- const int &iLen,
- char *szMark,
- bool bRecv = true,
- const int &iSNum = -1) = 0;
- // 删除读请求命令;
- virtual void DeleteRequestCommannd( const int &iCommPort,const int &iAddr, BYTE *szCommand, const int &iLen ) = 0;
- // [out]
- public:
- // 获取变量的值;
- // iCommPort: 串口号;
- // iAddr: 地址;
- // szMark: 命令特征码;
- // iIndex: 返回数据索引;(0开始)
- // iCutLen: 从索引开始截取的长度;
- // iSBit: 起始位;(默认 -1,表示不取位) // 纠正:不用设置默认值,如果是取位,iConvertType 就能表示数据转换类型是不是取位;
- // iEBit: 终止位;(默认 -1,表示不取位)
- // szValue: 返回的值(经数据处理);
- // iConvertType:数据转换处理类型;
- virtual void GetAnalogValue(
- const int &iCommPort,
- const int &iAddr,
- char *szMark,
- const int &iIndex,
- const int &iCutLen,
- const int &iSBit,
- const int &iEBit,
- char *szValue,
- const int &iConvertType) = 0;
- // 获取变量的值;
- // iCommPort: 串口号;
- // iAddr: 地址;
- // szMark: 命令特征码;
- // iIndex: 返回数据索引;(0开始)
- // iCutLen: 从索引开始截取的长度;
- // iSBit: 起始位;(默认 -1,表示不取位) // 纠正:不用设置默认值,如果是取位,iConvertType 就能表示数据转换类型是不是取位;
- // iEBit: 终止位;(默认 -1,表示不取位)
- // szValue: 要设置的值(经数据处理);
- // iConvertType:设置值的数据转换处理类型;
- virtual void SetAnalogValue(
- const int &iCommPort,
- const int &iAddr,
- char *szMark,
- const int &iIndex,
- const int &iCutLen,
- const int &iSBit,
- const int &iEbit,
- char *szSetValue,
- const int &iCovertType) = 0;
- };
- #endif
|