📄 commproc.h
字号:
// CommProc.h: interface for the CCommProc class.
// CommProc.h: interface for the CCommProc class.
/******************************
//***公共函数接口程序文件: CommProc.h
//***功能:定义公共类:Define a commonality Class
//***公共函数定义
//***调用该对象方法:CCommProc* pCommProc;
//***引用该类方法或函数如:byHC = pCommProc.strHexToByte(strHC)
//***主要函数和变量列表:Function List:
1. byte strBinToByte(CString strBin); //二进制的字符串转换位byte型(16进制):strBinToByte()
2. byte strDecTobyte(CString strDec); //整型值的字符串转换位byte型():strDecTobyte()
3. byte strHexToByte(CString strHex); //将十六进制表示的字符串(如"0x01")转换为byte型的数据(0x01):strHexToByte()
4. CString ByteToStrBin(byte* bySource,int iCount,int iStart=0); //将byte型转换为Bin(二进制):ByteToStrBin()
5. CString ByteToStrDec(byte* bySource,int iCount,int iStart=0);//将byte型转换为Dec(八进制):ByteToStrDec()
6. CString ByteToStrHex(byte* bySource,int iCount,int iStart=0);//将byte型转换为Hex(十六进制):ByteToStrHex()
7. CString ByteToStrChar(byte* bySource,int iCount,int iStart=0);//将byte型转换为char(字符):ByteToStrChar()
////数据位移函数FMoveBit():配置帧头的x10命令,解析后,按每个字节长度保存到byte数组中
8. BOOL FMoveBit(const byte btSource1,int iToFirst1,int iLast1,const byte bySource2,int iToFirst2,byte &byDest);
9. byte GetSum(const byte *AddData,int iCount); //计算校验和GetSum()
10.byte HexChartobyte(unsigned char cHexChar); //HexChartobyte:将无符号的字符char转换成byte
//***
//***Author:wan
//***date: 03-23-2005
******************************/
//
//////////////////////////////////////////////////////////////////////
#ifndef __COMMPROC_H__
#define __COMMPROC_H__
class CCommProc
{
public:
CCommProc();
virtual ~CCommProc();
public:
byte strBinToByte(CString strBin); //二进制的字符串转换位byte型(16进制)
byte strDecTobyte(CString strDec);
byte strHexToByte(CString strHex); //将十六进制表示的字符串(如"0x01")转换为byte型的数据(0x01)
//Byte 值类型表示值介于 0 和 255 之间的无符号整数,表示一个 8 位无符号整数(占一个字节)
int strHexToInt(CString strHex); //输入如("3FFF")十六进制表示的字符串,转化为int
CString ByteToStrBin(byte* bySource,int iCount,int iStart=0);//将byte型转换为Bin(二进制)
CString ByteToStrDec(byte* bySource,int iCount,int iStart=0);//将byte型转换为Dec(八进制)
CString ByteToStrHex(byte* bySource,int iCount,int iStart=0);//将byte型转换为Hex(十六进制)
CString ByteToStrChar(byte* bySource,int iCount,int iStart=0);//将byte型转换为char(字符)
CString ByteToStrHexNew(byte* bySource,int iCount,int iStart); //将byte型转换为HEX(十六进制)
//CString CCommProc::ByteToStrBin(byte* bySource,int iCount,int iStart=0) //将byte型转换为Bin(二进制)
//x10命令帧组合FMoveBit()
BOOL FMoveBit(const byte btSource1,int iToFirst1,int iLast1,const byte bySource2,int iToFirst2,byte &byDest);
byte GetSum(const byte *AddData,int iCount); //计算校验和GetSum()
BOOL Get485Data(byte byHC,byte byDC,byte *pby485Data,byte by485DataLen,byte *pbyX10Frame,int &iLen);
BOOL Set485FrameHead(byte byHC,byte byDC,byte *pby485Data,byte by485DataLen,byte *pbyX10Frame,int &iLen); //配置485帧头的x10命令解析保存到byte数组中
BOOL Set485Frame(byte byHC,byte byDC,byte Byte1,byte Byte2,byte *pbyX10Frame,int &iLen); ////配置485帧的起始位置和长度的x10命令解析保存到byte数组中
BOOL Get485State(byte byHC,byte byDC,byte *pbyX10Frame,int &iLen);
BOOL Set485Baud(byte byHC,byte byDC,byte byBaud,byte *pbyX10Frame,int &iLen); //////配置485的波特率的x10命令解析保存到byte数组中
BOOL mRelease(byte *pSource,byte *pDest,int &iRet); //还原发送的数据
BOOL GetReleaseByte(const byte btSource1,int iToFront1,int iToBack1,
const byte btSource2,int iToFront2,int iToBack2,byte &byDest); //解析x10数据
void WriteString(CString strContent,CEdit *pViewText, CString strSeparate); //写CEdit
byte HexChartobyte(unsigned char cHexChar); //函数HexChartobyte:将无符号的字符char转换成byte
};
#endif __COMMPROC_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -