/// <summary> /// 使用 2007-12-10 第 1 版协议解析数据 /// </summary> private static MemDataAnalyz AnalysisPolling_20071210_1(byte[] cmdRight, MemDataAnalyz memDataAnalyz) { int iCmdLength = cmdRight[3] + cmdRight[4] * 256; // 命令长度 memDataAnalyz.IsEnable = true; memDataAnalyz.CmdLength = iCmdLength; int iCmdLoc = 5; ArrayList arrayList = new ArrayList(); while (iCmdLoc < iCmdLength + 5) { MemHead memHead = new MemHead(); #region [ 检测探头数据时间和状态 ] memHead.IsBreak = false; // 探头是否故障 int iSHead = cmdRight[iCmdLoc]; // 探头号 int iSecond = cmdRight[iCmdLoc + 4]; // 秒,其中最高位 1 时表示探头故障 memHead.HeadAddress = iSHead; DateTime dtTime = DateTime.Now; int iPerCount = 0; int iPerLength = 0; //Czlt-2011-11-17--交直流供电 if (iSHead == 7) { //if (iSecond >= 128) // iSecond = iSecond - 128; if (cmdRight[iCmdLoc + 1] != 0) { // 接收到数据的时间 dtTime = BuildDateTime(cmdRight[iCmdLoc + 1], cmdRight[iCmdLoc + 2], cmdRight[iCmdLoc + 3], iSecond); memHead.Time = dtTime; } iPerCount = cmdRight[iCmdLoc + 5]; // 人数 iPerLength = cmdRight[iCmdLoc + 5] * 2; // 长度 memHead.CodeCount = iPerCount; // 探头检测到的人数 } else { if (iSecond >= 128) { // 秒最高位为 1 时探头故障 iSecond = iSecond - 128; if (cmdRight[iCmdLoc + 1] != 0) { // 接收到数据的时间 dtTime = BuildDateTime(cmdRight[iCmdLoc + 1], cmdRight[iCmdLoc + 2], cmdRight[iCmdLoc + 3], iSecond); memHead.Time = dtTime; } memHead.IsBreak = true; // 该探头故障 } else { if (cmdRight[iCmdLoc + 1] != 0) { dtTime = BuildDateTime(cmdRight[iCmdLoc + 1], cmdRight[iCmdLoc + 2], cmdRight[iCmdLoc + 3], iSecond); memHead.Time = dtTime; } iPerCount = cmdRight[iCmdLoc + 5]; // 人数 iPerLength = cmdRight[iCmdLoc + 5] * 2; // 长度 memHead.CodeCount = iPerCount; // 探头检测到的人数 } } #endregion #region [ 探头接收到的卡号 ] StringBuilder sbHeadA = new StringBuilder(); // 探头 A 接收到的发码器 StringBuilder sbHeadB = new StringBuilder(); // 探头 B 接收到的发码器 StringBuilder sbHeadC = new StringBuilder(); // 探头 接收到全为 0 的发码器 出 StringBuilder sbHeadD = new StringBuilder(); // 探头 接收到全为 1 的发码器 求救 StringBuilder sbHeadE = new StringBuilder(); // 低电量 探头 A 接收到的发码器 StringBuilder sbHeadF = new StringBuilder(); // 低电量 探头 B 接收到的发码器 StringBuilder sbHeadG = new StringBuilder(); // 低电量 探头 接收到全为 0 的发码器 出 StringBuilder sbHeadH = new StringBuilder(); // 低电量 探头 接收到全为 1 的发码器 求救 //Czlt-2011-11-17-添加交直流的判断 StringBuilder dyHead = new StringBuilder(); int i; for (i = iCmdLoc + 6; i < iCmdLoc + 6 + iPerLength; i += 2) { int iCard = cmdRight[i] + cmdRight[i + 1] * 256; #region 【Czlt-2011-11-17 交直流供电】 //Czlt -2011-11-17 -交直流供电 if (iCard == 24486) //交流 { dyHead.Append("3."); } else if (iCard == 24487) //直流 { dyHead.Append("2."); } #endregion if (iCard > 49152)//求救 { iCard = iCard - 49152; if (iCard > 8192) { iCard = iCard - 8192; sbHeadH.Append(iCard + ","); } else { sbHeadD.Append(iCard + ","); } } else if (iCard >= 32768)//A天线 { iCard = iCard - 32768; if (iCard > 8192) { iCard = iCard - 8192; sbHeadE.Append(iCard + ","); } else { sbHeadA.Append(iCard + ","); } } else if (iCard >= 16384)//B天线 { iCard = iCard - 16384; if (iCard > 8192) { iCard = iCard - 8192; sbHeadF.Append(iCard + ","); } else { sbHeadB.Append(iCard + ","); } } else//出 { if (iCard > 8192) { iCard = iCard - 8192; sbHeadG.Append(iCard + ","); } else { sbHeadC.Append(iCard + ","); } } } memHead.CodesA = sbHeadA.ToString(); memHead.CodesB = sbHeadB.ToString(); memHead.CodesC = sbHeadC.ToString(); memHead.CodesD = sbHeadD.ToString(); memHead.CodesE = sbHeadE.ToString(); memHead.CodesF = sbHeadF.ToString(); memHead.CodesG = sbHeadG.ToString(); memHead.CodesH = sbHeadH.ToString(); //Czlt-2011-11-17 交直流电源 memHead.CodesDY = dyHead.ToString(); if (memHead.IsBreak) { iCmdLoc = i - 1; } else { iCmdLoc = i; } // 显示探头出检测出多少张卡 if (iPerCount > 0) { // RTxtMsgc.WriteTxt(strMsg.ToString(), " RX", true); //return strMsg.ToString(); } #endregion arrayList.Add(memHead); #region [ 检测标记位是否存在 ] if (cmdRight[iCmdLoc++] != 255) { break; } #endregion } // 初始化探头 memDataAnalyz.memHead= new MemHead[arrayList.Count]; // 循环添加探头 for (int i = 0; i < arrayList.Count;i++ ) { memDataAnalyz.memHead[i] = (MemHead)arrayList[i]; } return memDataAnalyz; }
/// <summary> /// 使用 2007-12-10 第 1 版协议解析数据 /// </summary> private static MemDataAnalyz AnalysisPolling_20060610_1(byte[] cmdRight, MemDataAnalyz memDataAnalyz) { int iCmdLength = cmdRight[2] + cmdRight[3] * 256; // 命令长度 memDataAnalyz.IsEnable = true; memDataAnalyz.CmdLength = iCmdLength; ArrayList arrayList = new ArrayList(); // 人数 int iPerCount = cmdRight[4] + cmdRight[5] * 256; //获取数据的时间 DateTime dtTime = BuildDateTime(cmdRight[6], cmdRight[7], cmdRight[8]); MemHead memHead = new MemHead(); memHead.Time = dtTime; memHead.CodeCount = iPerCount; // 探头检测到的人数 memHead.HeadAddress = 0; memHead.IsBreak = true; #region [ 分站接收到的卡号 ] StringBuilder sbHeadA = new StringBuilder(); // 分站 接收到最高位为 1 的发码器 出分站 StringBuilder sbHeadC = new StringBuilder(); // 分站 第一位和第二位为0 的发码器 进分站 StringBuilder sbHeadD = new StringBuilder(); // 分站 接收到全为 1 的发码器 即求救 StringBuilder sbHeadE = new StringBuilder(); // 低电量 分站 接收到最高位为 1 的发码器 出分站 StringBuilder sbHeadG = new StringBuilder(); // 低电量 分站 第一位和第二位为0 的发码器 进分站 StringBuilder sbHeadH = new StringBuilder(); // 低电量 分站 接收到全为 1 的发码器 即求救 for (int i = 0; i < iPerCount; i++) { int iCard; iCard = (int)cmdRight[9 + 2 * i] + (int)cmdRight[10 + 2 * i] * 256; if (iCard != 29998 && iCard != 62766 && iCard !=29999) { if (iCard > 49152)//求救 { iCard = iCard - 49152; if (iCard > 8192) { iCard = iCard - 8192; sbHeadH.Append(iCard + ","); } sbHeadD.Append(iCard + ","); } else if (iCard >= 32768)//出分站 { iCard = iCard - 32768; if (iCard > 8192) { iCard = iCard - 8192; sbHeadE.Append(iCard + ","); } sbHeadA.Append(iCard + ","); } else if (iCard >= 16384)//B天线 { //iCard = iCard - 16384; //if (iCard > 8192) //{ // iCard = iCard - 8192; // sbHeadF.Append(iCard + ","); //} //sbHeadB.Append(iCard + ","); } else//进分站 { if (iCard > 8192) { iCard = iCard - 8192; sbHeadG.Append(iCard + ","); } sbHeadC.Append(iCard + ","); } } } #endregion memHead.CodesA = sbHeadA.ToString(); memHead.CodesC = sbHeadC.ToString(); memHead.CodesD = sbHeadD.ToString(); memHead.CodesE = sbHeadE.ToString(); memHead.CodesG = sbHeadG.ToString(); memHead.CodesH = sbHeadH.ToString(); arrayList.Add(memHead); // 初始化探头 memDataAnalyz.memHead = new MemHead[arrayList.Count]; // 循环添加探头 for (int i = 0; i < arrayList.Count; i++) { memDataAnalyz.memHead[i] = (MemHead)arrayList[i]; } return memDataAnalyz; }