写入部分:
pObj->Point = DelRecord[del_num].Point;//2015.4.3 xp
pPointer = (char *)PtrShareMemOutData + pObj->Point;
//共享内存地址头+模块在共享内存中的位置
//模块名称(对于CString的操作方式)
memcpy(pPointer,pObj->Module_Name,MAX_STRINGLENGTH);
pPointer += MAX_STRINGLENGTH;
//模块序号(对于定长类型的操作方式)
*((unsigned int*)pPointer) = pObj->Module_Count;
pPointer += sizeof(unsigned int);
//模块所占长度
*((unsigned int*)pPointer) = pObj->Module_Length;
pPointer += sizeof(unsigned int);
读出部分:
t_Point = (char *)PtrShareMemOutData + pObj->m_InPoint[i]; //获取输入变量所在的指针
t_Point = (char *)PtrShareMemOutData
+ pObj->Point
+ MAX_STRINGLENGTH + INT_LENGTH + INT_LENGTH
+ (MAX_STRINGLENGTH + CHAR_LENGTH + DOUBLE_LENGTH)*i
+ MAX_STRINGLENGTH +1;
//移动指针位置读取,此处用宏定义不易出错
每一个模块的写入顺序为:
名称->序号->长度->输入->常数->输出
其中后三者挨个是根据“名称->状态->值”去写入的
对于成组输入也是如此