PrtModbus.h
上传用户:asikq0571
上传日期:2014-07-12
资源大小:528k
文件大小:2k
- // PrtModbus.h: interface for the CPrtModbus class.
- //
- //////////////////////////////////////////////////////////////////////
- #if !defined(AFX_PRTMODBUS_H__4F9A6C80_2319_4E42_AB70_A41AB536D794__INCLUDED_)
- #define AFX_PRTMODBUS_H__4F9A6C80_2319_4E42_AB70_A41AB536D794__INCLUDED_
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- #include "PrtObj.h"
- class CPrtModbus : public CPrtObj
- {
- public:
- CPrtModbus();
- virtual ~CPrtModbus();
- public: //虚函数,各规约函数使用时覆盖,实现各自功能
- virtual void SlaveSend(); //从站发送
- virtual void SlaveRec(BYTE recByte); //从站接收
- virtual void MasterRec(BYTE recByte); //主站接收
- virtual void MasterSend(UINT nIDEvent); //主站发送
- virtual void CloseTimer(); //关闭定时召唤流程
- virtual void StartTimer(); //启动定时召唤流程
- virtual void InitPrt();
- public: //规约解包/打包函数
- void MPackYC();
- void MPackYX();
- void MasterUnPack();
- void MUnPackYC();
- void MUnPackYX();
- void SPackYC();
- void SPackYX();
- public:
- char m_Addr;
- char m_YXFunc;
- char m_YCFunc;
- char m_YCSize;
- int m_CallIntv;
- int m_CallTimerID;
- BOOL m_bIsTimerStar;
- BOOL m_CallYXFlag;
- BYTE m_CallYXByte[8]; //主站召唤遥信报文
- BYTE m_CallYCByte[8]; //主站召唤遥测报文
- BYTE m_MRecByte[260]; //主站接收包含信息体的报文 最大字节数为260 (3+255+2)
- BYTE m_SSendByte[260]; //子站发送包含信息体的报文 最大字节数为260 (3+255+2)
- BYTE m_SRecByte[8]; //子站接收主站召唤的报文
- enum MasterReading {AddrCode,FuncCode,NumCode,InfoCode,CRCHiCode,CRCLoCode,Finished} m_MReadState;
- enum SlaveReading {AddrByte,FuncByte,AddrHiByte,AddrLoByte,NumHiByte,NumLoByte,CRCHiByte,CRCLoByte} m_SReadState;
- int m_MInfoIndex; //主站读信息体索引
-
- };
- #endif // !defined(AFX_PRTMODBUS_H__4F9A6C80_2319_4E42_AB70_A41AB536D794__INCLUDED_)