📄 rd_adt_msgmap.h
字号:
#ifndef _USE_ADT_MSG_MAP_H_
#define _USE_ADT_MSG_MAP_H_
/***********************************************************
* 声明库说明:抽象数据类型(ADT)消息地图声明库 *
* 版本: v1.00 *
* 作者: 王卓然 *
* 创建日期: 2007年4月6日 *
* -------------------------------------------------------- *
* [支 持 库] *
* 支持库名称: *
* 需要版本: *
* 支持库名称: *
* -------------------------------------------------------- *
* [版本更新] *
* 修改: *
* 修改日期: *
* 版本: *
* -------------------------------------------------------- *
* [版本历史] *
* -------------------------------------------------------- *
* [使用说明] *
***********************************************************/
/********************
* 头 文 件 配 置 区 *
********************/
/********************
* 系 统 宏 定 义 *
********************/
/*------------------*
* 常 数 宏 定 义 *
*------------------*/
/*------------------*
* 动 作 宏 定 义 *
*------------------*/
# define START_DEFINE_MSG_MAP(Name,Count) MSG_MAP MSGMap##Name;\
MSG_MAP_ITEM MSGMap##Name##ItemArray[Count];\
void MSG_Map_##Name##_INIT(void)\
{\
uint8 n = 0;\
MSG_MAP *pMsgMap = &MSGMap##Name;\
pMsgMap->pMsgItems = MSGMap##Name##ItemArray;\
pMsgMap->cItemCount = (Count);\
for (n = 0;n < (Count);n++)\
{\
MSGMap##Name##ItemArray[n].cCMD = NULL;\
MSGMap##Name##ItemArray[n].pMsgFunc = &MSG_NULL_PROC;\
}\
n = 0;
# define ADD_NEW_MSG_MAP_ITEM(CMD,Func) if (n < pMsgMap->cItemCount)\
{\
pMsgMap->pMsgItems[n].cCMD = CMD;\
pMsgMap->pMsgItems[n].pMsgFunc = Func;\
n++;\
}
# define END_DEFINE_MSG_MAP }
# define INIT_MSG_MAP(Name) MSG_Map_##Name##_INIT();
# define MSG_MAP(Name) MSGMap##Name
# define PROCESS_MSP_MAP(Name,Msg) MsgMapProcess(&MSGMap##Name,&Msg)
/********************
* 用户变量类型定义 *
********************/
typedef struct MsgItem MSG_ITEM;
typedef struct MsgMapItem MSG_MAP_ITEM;
typedef struct MsgMap MSG_MAP;
typedef BOOL (*MSG_PROC_FUNC)(MSG_ITEM *pMsgItem);
/********************
* 结构体定义区 *
********************/
struct MsgItem
{
uint8 cCMD;
uint8 cDataLength;
uint8 *pData;
};
struct MsgMapItem
{
uint8 cCMD; //指令
MSG_PROC_FUNC pMsgFunc; //处理消息的函数指针
};
struct MsgMap
{
uint8 cItemCount; //消息地图的大小
MSG_MAP_ITEM *pMsgItems; //消息数组
};
/********************
* 函 数 引 用 区 *
********************/
extern BOOL MsgMapProcess(MSG_MAP *pMsgMap,MSG_ITEM *pMsgItem);
extern BOOL MSG_NULL_PROC(MSG_ITEM *pMsgItem);
/********************
* 全局变量引用区 *
********************/
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -