コード例 #1
0
        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);
        }
コード例 #2
0
        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 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);
        }