/// <summary>
        /// 获取命令报文
        /// </summary>
        /// <param name="devId"></param>
        /// <param name="commandWord"></param>
        /// <param name="sendData"></param>
        /// <returns></returns>
        protected string GetWriteReport(int devId, string cmdWord, string sendData)
        {
            string strCmdData = string.Empty;

            int ctrlNo  = devId;
            int groupID = 0;

            if (devId == 0)
            {
                groupID = 0;
                ctrlNo  = 0;
            }
            else
            {
                groupID = ((ctrlNo - 1) / 0xFF) + 1;
                ctrlNo  = (ctrlNo % 0xFF);
                //解决255的倍数问题
                if (ctrlNo == 0)
                {
                    ctrlNo = 0xFF;
                }
            }

            //设备组号
            string strDevGroupID = StrUtils.IntToHex(groupID, 2);
            //设备地址
            string strDevCtrlID = StrUtils.IntToHex(ctrlNo, 2);
            //设备类型
            string strDevType = StrUtils.IntToHex((int)this.DevType, 2);
            //流水号
            string strCmdSerialNo = this.GetCmdNumber();
            //命令字
            string strCmdWord = cmdWord;

            //生成固定部分的命令报文
            strCmdData = strDevGroupID + strDevCtrlID + StrUtils.IntToHex((int)DevType, 2) + strCmdSerialNo + strCmdWord + sendData;
            // 计算校验位
            string strXorCheck = StrUtils.GetXORCheck(strCmdData);

            RunLog.Log("************CheckXor strCmdData : " + strCmdData);
            // 命令报文+校验位
            strCmdData = strCmdData + strXorCheck;

            // 格式化命令报文,如果报文中出现>= 0xF0的数据,则做特定处理
            // 特别注意:校验位也需检测

            strCmdData = CommandProcesserHelper.AddF0Escape(strCmdData);

            RunLog.Log("************ AddF0Escape strCmdData :" + strCmdData);


            // 组合报文,加上起始字和结束字
            strCmdData = CommandProcesserHelper.CMD_START_FLAG + strCmdData + CommandProcesserHelper.CMD_END_FLAG;

            IsDownLoadDevLength = strCmdData;
            RunLog.Log(strCmdData);
            return(strCmdData);
        }
        private void AnalysisDownParams(string strCmdStr)
        {
            //取返回的数据部分
            string strCmdReport = StrUtils.CopySubStr(strCmdStr, 18, strCmdStr.Length - 22);

            //判断设备Id是否正确
            int devId = CommandProcesserHelper.GetDevIDByCmdInfo(StrUtils.CopySubStr(strCmdStr, 2, 4));

            if (devId != f_CurrentLinkageCtrlInfo.DevId)
            {
                return;
            }
            //获取返回的状态
            int intStatus = StrUtils.StrToIntDef(StrUtils.CopySubStr(strCmdReport, 0, 2), -1, 16);

            switch (intStatus)
            {
            case 0x00:
            {
                this.AddOneDeviceToUI(f_CurrentLinkageCtrlInfo);
                HintProvider.ShowAutoCloseDialog(null, "参数设置成功");
            }
            break;

            case 0x01:
            {
                HintProvider.ShowAutoCloseDialog(null, "参数设置失败");
            }
            break;

            default:
            {
                HintProvider.ShowAutoCloseDialog(null, "参数设置失败,未知错误");
            }
            break;
            }

            this.IsBusy = false;
        }
        private void AnalysisSearchDevicesRecvData(string strCmdStr)
        {
            //取返回的数据部分
            string          strCmdReport    = StrUtils.CopySubStr(strCmdStr, 18, strCmdStr.Length - 22);
            LinkageCtrlInfo linkageCtrlInfo = new LinkageCtrlInfo();

            //设备ID
            linkageCtrlInfo.DevId = CommandProcesserHelper.GetDevIDByCmdInfo(StrUtils.CopySubStr(strCmdStr, 2, 4));
            //Mac地址
            linkageCtrlInfo.DevMac = CommonUtils.GetMacByHex(StrUtils.CopySubStr(strCmdReport, 2, 12));
            //设备IP
            linkageCtrlInfo.DevIp = CommonUtils.GetIPByHex(StrUtils.CopySubStr(strCmdReport, 14, 8));
            //子网掩码
            linkageCtrlInfo.SubnetMask = CommonUtils.GetIPByHex(StrUtils.CopySubStr(strCmdReport, 22, 8));
            //网关
            linkageCtrlInfo.GateWay = CommonUtils.GetIPByHex(StrUtils.CopySubStr(strCmdReport, 30, 8));
            //云电梯UDP端口
            linkageCtrlInfo.CloudUdpPort = StrUtils.StrToIntDef(StrUtils.CopySubStr(strCmdReport, 38, 4), 0, 16);
            //第三方对讲机UDP端口
            linkageCtrlInfo.ThirdUdpPort = StrUtils.StrToIntDef(StrUtils.CopySubStr(strCmdReport, 42, 4), 0, 16);
            //云电梯数量
            linkageCtrlInfo.CloudElevatorCount = StrUtils.StrToIntDef(StrUtils.CopySubStr(strCmdReport, 46, 2), 0, 16);
            //8个云电梯设备信息
            for (int i = 1; i <= AppConst.LINKAGE_CTRL_CLOUD_ELEVATOR_MAX_COUNT; i++)
            {
                if (i <= linkageCtrlInfo.CloudElevatorCount)
                {
                    linkageCtrlInfo.CloudElevatorItems[i].DevIp          = CommonUtils.GetIPByHex(StrUtils.CopySubStr(strCmdReport, 48 + (i - 1) * 10, 8));
                    linkageCtrlInfo.CloudElevatorItems[i].CtrlProporties = StrUtils.StrToIntDef(StrUtils.CopySubStr(strCmdReport, 48 + 8 + (i - 1) * 10, 2), 0, 16);
                }
                else
                {
                    linkageCtrlInfo.CloudElevatorItems[i].DevIp          = string.Empty;
                    linkageCtrlInfo.CloudElevatorItems[i].CtrlProporties = -1;
                }
            }

            this.AddOneDeviceToUI(linkageCtrlInfo);
        }
        protected override void AnalysisRecvDataEx(string strCmdStr)
        {
            //报文格式F2 XX XX ... XX XX F3
            //判断设备类型是否合法
            DeviceType devType = CommandProcesserHelper.GetDevTypeByCmdInfo(StrUtils.CopySubStr(strCmdStr, 6, 2));

            if (devType != DeviceType.LinkageCtrl)
            {
                return;
            }
            //根据命令字,解析对应命令
            string strCmdWord = StrUtils.CopySubStr(strCmdStr, 14, 4);

            if (strCmdWord == AppConst.CMD_WORD_SEARCH_DEVIDES)
            {
                //判断报文长度
                //取云电梯数量
                int cloudElevatorCount = StrUtils.StrToIntDef(StrUtils.CopySubStr(strCmdStr, 64, 2), 0, 16);
                if (strCmdStr.Length < 70 + cloudElevatorCount * 10) //35 + cloudElevatorCount 字节
                {
                    HintProvider.ShowAutoCloseDialog(null, string.Format("报文长度错误,报文:{0}", strCmdStr));
                    return;
                }
                this.AnalysisSearchDevicesRecvData(strCmdStr);
            }
            else if (strCmdWord == AppConst.CMD_WORD_SET_CLOUD_ELEVATOR_PARAMS)
            {
                //判断报文长度
                if (strCmdStr.Length < 24) //12字节
                {
                    HintProvider.ShowAutoCloseDialog(null, string.Format("报文长度错误,报文:{0}", strCmdStr));
                    return;
                }
                this.AnalysisDownParams(strCmdStr);
            }

            //this.UpdateHintInfo(strCmdStr);
        }
        private void AnalysisRecvData(string strData)
        {
            //非忙碌状态,不解析数据
            //if(!this.IsBusy)
            //{
            //    return;
            //}
            //去F0
            string strCmdStr = CommandProcesserHelper.DelF0Escape(strData);

            //判断报文长度
            if (strCmdStr.Length < 18)
            {
                RunLog.Log(string.Format("返回的报文长度错误,报文:{0}", strCmdStr));
                HintProvider.ShowAutoCloseDialog(null, string.Format("返回的报文校验错误,错误:{0}", strCmdStr), HintIconType.Err);
                return;
            }
            //判断校验码
            string requiredCheckValue = StrUtils.GetXORCheck(strCmdStr, 2, strCmdStr.Length - 6).ToUpper();
            string factCheckValue     = StrUtils.CopySubStr(strCmdStr, strCmdStr.Length - 4, 2);

            if (string.Compare(requiredCheckValue, factCheckValue, true) != 0)
            {
                RunLog.Log(string.Format("返回的报文校验错误,报文:{0}", strCmdStr));
                HintProvider.ShowAutoCloseDialog(null, string.Format("返回的报文校验错误,错误:{0}", strCmdStr), HintIconType.Err);

                return;
            }
            //判断返回的命令状态
            string strCmdStatus = StrUtils.CopySubStr(strCmdStr, 12, 2);

            //string strCmdStatus = StrUtils.CopySubStr(strCmdStr, 10, 2);
            if (StrUtils.HexStrToInt(strCmdStatus) != CommonUtils.RES_OK)
            {
                if (strCmdStatus == "7F")
                {
                    string strCmdStatus2 = StrUtils.CopySubStr(strCmdStr, 18, 2);
                    if (strCmdStatus2 == "02")
                    {
                        HintProvider.ShowAutoCloseDialog(null, string.Format("需要初始化设备,才能重新设置网络参数"));
                        return;
                    }
                }

                RunLog.Log(string.Format("命令状态错误:{0}", CommonUtils.GetErrMsgByCode(StrUtils.HexStrToInt(strCmdStatus))));

                string Error = string.Format("命令状态错误:{0}", CommonUtils.GetErrMsgByCode(StrUtils.HexStrToInt(strCmdStatus)));
                HintProvider.ShowAutoCloseDialog(null, string.Format(Error), HintIconType.Err);

                return;
            }
            else if (StrUtils.HexStrToInt(strCmdStatus) == CommonUtils.RES_OK)
            {
                string strDevID = CommandProcesserHelper.GetDevIDByCmdInfo(StrUtils.CopySubStr(strCmdStr, 2, 4)).ToString();
                if (IsDownParm || AppConst.IsDownParmCloudLinkage)
                {
                    HintProvider.ShowAutoCloseDialog(null, string.Format("下载成功"));
                    AppConst.IsDownParmCloudLinkage = false;
                    IsDownParm = false;
                }
            }

            DeviceType devType = CommandProcesserHelper.GetDevTypeByCmdInfo(StrUtils.CopySubStr(strCmdStr, 6, 2));

            if (devType == DeviceType.CloudLinkageInfoCtrl)
            {
                //云联动器
                string strCmdStatusLink = StrUtils.CopySubStr(strCmdStr, 15, 4);

                if (strCmdStatusLink == "0121" || strCmdStatusLink == "012E" || strCmdStatusLink == "0100")
                {
                    HintProvider.ShowAutoCloseDialog(null, "下载成功", HintIconType.OK);
                    Thread.Sleep(1000);
                }
            }

            //重置
            IsDownLoadDevLength = string.Empty;

            this.AnalysisRecvDataEx(strCmdStr);
        }