コード例 #1
0
        public string GetResultString(byte[] DataBuf)
        {
            // 命令字(1)+节点地址(6)+转发结果(1)+操作状态+场强值(1)
            if (DataBuf[0] != 0x08)
            {
                return(null);
            }
            if (DataBuf.Length <= FrmMain.AddrLength + 1 + 1 + 2)
            {
                return(null);
            }
            int    iPos    = 1 + FrmMain.AddrLength + 1;
            string strInfo = FrmMain.GetErrorInfo(DataBuf[iPos]);

            return(strInfo);
        }
コード例 #2
0
        public string GetResultString(byte[] DataBuf, byte[] TxBuf)
        {
            string strInfo = null;

            if (DataBuf[0] != 0x01)
            {
                return(null);
            }
//            D3 91 37 00 C0 02 4D FA 3F 02 00 00 00 00 60 09 19 21 68 00 30 11
            //01 10 16 10 22 14 18
            //AA 00 01 00 00 00 00 00 00 00 00 00 00 00 00 20 01 23 1B 0F 39 01 49 57 55 55 DE 16 00 03

            DataRow dr = dt.NewRow();

            dr["序号"]   = dt.Rows.Count + 1;
            dr["表具地址"] = FrmMain.GetStringAddrFromByte(DataBuf, 1);
            //dr["命令类型"] = FrmMain.GetStringFromCmd(DataBuf[0]);
            //dr["操作时间"] = DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss");
            strInfo    = FrmMain.GetErrorInfo(DataBuf[1 + FrmMain.AddrLength]);
            dr["操作结果"] = strInfo;
            //if (DataBuf.Length > FrmMain.AddrLength + 1 + 1)
            //{
            //    int iPos = 1 + FrmMain.AddrLength + 1;
            //    if (DataBuf[iPos] == 0)
            //    {
            //        dr["数据格式"] = "实时数据";
            //    }
            //    else if (DataBuf[iPos] == 1)
            //    {
            //        dr["数据格式"] = "冻结数据";
            //    }
            //    else
            //    {
            //        dr["数据格式"] = "未知格式";
            //    }
            //    iPos += 1;
            //    strInfo += "\n 数据格式:" + dr["数据格式"].ToString();
            //    string[] strResult = FrmMain.ExplainMeterData(DataBuf, iPos, DataBuf.Length - iPos);
            //    int index = 0;
            //    if (strResult.Length == 11)
            //    {   // 正转用量+反转用量
            //        dr["正转用量"] = strResult[index++];
            //        dr["反转用量"] = strResult[index++];
            //        strInfo += "\n 正转用量:" + dr["正转用量"].ToString();
            //        strInfo += "\n 反转用量:" + dr["反转用量"].ToString();
            //    }
            //    else if (strResult.Length == 15)
            //    {   // 起始序号+冻结时间+冻结方式+冻结数量+时间间隔+冻结数据
            //        dr["起始序号"] = strResult[index++];
            //        dr["冻结时间"] = strResult[index++];
            //        dr["冻结方式"] = strResult[index++];
            //        dr["冻结数量"] = strResult[index++];
            //        dr["时间间隔"] = strResult[index++];
            //        dr["冻结数据"] = strResult[index++];
            //        strInfo += "\n 起始序号:" + dr["起始序号"].ToString();
            //        strInfo += "\n 冻结时间:" + dr["冻结时间"].ToString();
            //        strInfo += "\n 冻结方式:" + dr["冻结方式"].ToString();
            //        strInfo += "\n 冻结数量:" + dr["冻结数量"].ToString();
            //        strInfo += "\n 时间间隔:" + dr["时间间隔"].ToString();
            //        strInfo += "\n 正转用量:" + dr["正转用量"].ToString();
            //        strInfo += "\n 冻结数据:" + dr["冻结数据"].ToString();
            //    }
            //    else if (strResult.Length == 12)
            //    {   // 起始序号+冻结时间+冻结数据
            //        dr["起始序号"] = strResult[index++];
            //        dr["冻结时间"] = strResult[index++];
            //        dr["冻结数据"] = strResult[index++];
            //        strInfo += "\n 起始序号:" + dr["起始序号"].ToString();
            //        strInfo += "\n 冻结时间:" + dr["冻结时间"].ToString();
            //        strInfo += "\n 冻结数据:" + dr["冻结数据"].ToString();
            //    }
            //    dr["报警信息"] = strResult[index++];
            //    dr["阀门状态"] = strResult[index++];
            //    dr["电压"] = strResult[index++];
            //    dr["温度"] = strResult[index++];
            //    dr["信噪比"] = strResult[index++];
            //    dr["信道"] = strResult[index++];
            //    dr["版本"] = strResult[index++];
            //    dr["场强↓"] = strResult[index++];
            //    dr["场强↑"] = strResult[index++];
            //    strInfo += "\n 报警信息:" + dr["报警信息"].ToString();
            //    strInfo += "\n 阀门状态:" + dr["阀门状态"].ToString();
            //    strInfo += "\n 电压:" + dr["电压"].ToString();
            //    strInfo += "\n 温度:" + dr["温度"].ToString();
            //    strInfo += "\n 信噪比:" + dr["信噪比"].ToString();
            //    strInfo += "\n 信道:" + dr["信道"].ToString();
            //    strInfo += "\n 版本:" + dr["版本"].ToString();
            //}
            dt.Rows.Add(dr);
            if (dt.Rows.Count > 2000)
            {
                dt.Rows.RemoveAt(0);
            }
            string strPath = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\DataForward";

            if (Directory.Exists(strPath) == false)
            {
                Directory.CreateDirectory(strPath);
            }
            string strFile = strPath + "\\ReadRealData.xml";

            if (File.Exists(strFile) == false)
            {
                File.Create(strFile).Close();
            }
            dt.WriteXml(strFile);
            return(strInfo);
        }
コード例 #3
0
        // DataBuf:命令字+节点地址+转发结果+转发内容
        // TxBuf:命令字+节点地址+转发内容
        public string GetResultString(byte[] DataBuf, byte[] TxBuf)
        {
            string strInfo = null;

            if (DataBuf[0] != 0x03)
            {
                return(null);
            }
            DataRow dr = dt.NewRow();

            dr["序号"]   = dt.Rows.Count + 1;
            dr["表具地址"] = FrmMain.GetStringAddrFromByte(DataBuf, 1);
            dr["命令类型"] = FrmMain.GetStringFromCmd(DataBuf[0]);
            dr["操作时间"] = DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss");
            if (DataBuf.Length == FrmMain.AddrLength + 1 + 1)
            {
                dr["操作结果"] = FrmMain.GetErrorInfo(DataBuf[1 + FrmMain.AddrLength]);
            }
            else
            {
                if (DataBuf[1 + FrmMain.AddrLength + 1] == 0xAA)
                {
                    dr["操作结果"] = "开门成功";
                }
                else if (DataBuf[1 + FrmMain.AddrLength + 1] == 0xAB)
                {
                    dr["操作结果"] = "开门失败";
                }
            }
            if (TxBuf.Length >= 1 + FrmMain.AddrLength + 2)
            {
                //if (TxBuf[1 + FrmMain.AddrLength] == 0)
                //{
                //    dr["是否强制"] = "正常";
                //}
                //else if (TxBuf[1 + FrmMain.AddrLength] == 0x01)
                //{
                //    dr["是否强制"] = "强制";
                //}
                //if (TxBuf[2 + FrmMain.AddrLength] == 0)
                //{
                //    dr["阀门操作"] = "关阀";
                //}
                //else if (TxBuf[2 + FrmMain.AddrLength] == 0x01)
                //{
                //    dr["阀门操作"] = "开阀";
                //}
            }
            if (DataBuf.Length >= 1 + FrmMain.AddrLength + 1 + 5)
            {
                int iPos = 1 + FrmMain.AddrLength + 1 + 1;
                //string strFailReson = "";
                //if ((DataBuf[iPos] & 0x01) == 0x01)
                //{
                //    strFailReson += "电池欠压,";
                //}
                //if ((DataBuf[iPos] & 0x02) == 0x02)
                //{
                //    strFailReson += "磁干扰,";
                //}
                //if ((DataBuf[iPos] & 0x04) == 0x04)
                //{
                //    strFailReson += "ADC正在工作,";
                //}
                //if ((DataBuf[iPos] & 0x08) == 0x08)
                //{
                //    strFailReson += "阀门正在运行中,";
                //}
                //if ((DataBuf[iPos] & 0x10) == 0x10)
                //{
                //    strFailReson += "阀门故障,";
                //}
                //if ((DataBuf[iPos] & 0x20) == 0x20)
                //{
                //    strFailReson += "RF正在工作,";
                //}
                //if ((DataBuf[iPos] & 0x40) == 0x40)
                //{
                //    strFailReson += "任务申请失败,";
                //}
                //if ((DataBuf[iPos] & 0x80) == 0x80)
                //{
                //    strFailReson += "等待按键开阀,";
                //}
                //iPos += 1;
                //if ((DataBuf[iPos] & 0x01) == 0x01)
                //{
                //    strFailReson += "当前阀门已经到位,";
                //}
                //if ((DataBuf[iPos] & 0x02) == 0x02)
                //{
                //    strFailReson += "设备类型错误,";
                //}
                //if ((DataBuf[iPos] & 0x04) == 0x04)
                //{
                //    strFailReson += "time申请失败,";
                //}
                //if ((DataBuf[iPos] & 0x08) == 0x08)
                //{
                //    strFailReson += "系统欠费,";
                //}
                //dr["失败原因"] = strFailReson.TrimEnd(',');
                //iPos++;
                dr["场强↓"] = "-" + DataBuf[iPos++].ToString("D") + "dBm";
                dr["场强↑"] = "-" + DataBuf[iPos++].ToString("D") + "dBm";
            }
            else
            {
                //dr["失败原因"] = "";
                dr["场强↓"] = "";
                dr["场强↑"] = "";
            }
            if (DataBuf.Length > 1 + FrmMain.AddrLength + 1)
            {
                if (DataBuf[1 + FrmMain.AddrLength + 1] != 0xAB)
                {
                    strInfo = dr["操作结果"].ToString();
                }
            }
            dt.Rows.Add(dr);
            if (dt.Rows.Count > 2000)
            {
                dt.Rows.RemoveAt(0);
            }
            string strPath = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\DataForward";

            if (Directory.Exists(strPath) == false)
            {
                Directory.CreateDirectory(strPath);
            }
            string strFile = strPath + "\\ValveControl.xml";

            if (File.Exists(strFile) == false)
            {
                File.Create(strFile).Close();
            }
            dt.WriteXml(strFile);
            return(strInfo);
        }
コード例 #4
0
        // DataBuf:命令字+节点地址+转发结果+转发内容
        // TxBuf:空
        public string GetResultString(byte[] DataBuf, byte[] TxBuf)
        {
            string strInfo = null;

            if (DataBuf[0] != 0x0B)
            {
                return(null);
            }
            DataRow dr = dt.NewRow();

            dr["序号"]   = dt.Rows.Count + 1;
            dr["表具地址"] = FrmMain.GetStringAddrFromByte(DataBuf, 1);
            dr["命令类型"] = FrmMain.GetStringFromCmd(DataBuf[0]);
            dr["操作时间"] = DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss");
            dr["操作结果"] = FrmMain.GetErrorInfo(DataBuf[1 + FrmMain.AddrLength]);
            if (DataBuf.Length < FrmMain.AddrLength + 1 + 1)
            {
                return(null);
            }
            if (DataBuf.Length >= FrmMain.AddrLength + 4)
            {
                int iPos = 1 + FrmMain.AddrLength + 1;
                dr["磁扰关阀"] = (DataBuf[iPos] & 0x01) == 0 ? "关闭" : "开启";
                dr["数据加密"] = (DataBuf[iPos] & 0x02) == 0 ? "关闭" : "开启";
                dr["防拆检测"] = (DataBuf[iPos] & 0x04) == 0 ? "关闭" : "开启";
                dr["垂直安装"] = (DataBuf[iPos] & 0x08) == 0 ? "关闭" : "开启";
                dr["上报功能"] = (DataBuf[iPos] & 0x10) == 0 ? "关闭" : "开启";
                dr["冻结上报"] = (DataBuf[iPos] & 0x20) == 0 ? "关闭" : "开启";
                dr["欠费关阀"] = (DataBuf[iPos] & 0x40) == 0 ? "关闭" : "开启";
                dr["预付费用"] = (DataBuf[iPos] & 0x80) == 0 ? "关闭" : "开启";
                iPos++;
                dr["阀门防锈"] = (DataBuf[iPos] & 0x02) == 0 ? "关闭" : "开启";
                dr["掉电关阀"] = (DataBuf[iPos] & 0x04) == 0 ? "关闭" : "开启";
                dr["休眠策略"] = (DataBuf[iPos] & 0x08) == 0 ? "关闭" : "开启";
                dr["自动关阀"] = (DataBuf[iPos] & 0x10) == 0 ? "关闭" : "开启";
                dr["泄露检测"] = (DataBuf[iPos] & 0x20) == 0 ? "关闭" : "开启";
                dr["流速控制"] = (DataBuf[iPos] & 0x80) == 0 ? "关闭" : "开启";
                iPos++;
                if (DataBuf.Length > FrmMain.AddrLength + 1 + 1 + 1)
                {
                    dr["场强↓"] = "-" + DataBuf[iPos++].ToString("D") + "dBm";
                    dr["场强↑"] = "-" + DataBuf[iPos++].ToString("D") + "dBm";
                }
                else
                {
                    dr["场强↓"] = "";
                    dr["场强↑"] = "";
                }

                strInfo += "\n 磁扰关阀:" + dr["磁扰关阀"];
                strInfo += "\n 数据加密:" + dr["数据加密"];
                strInfo += "\n 防拆检测:" + dr["防拆检测"];
                strInfo += "\n 垂直安装:" + dr["垂直安装"];
                strInfo += "\n 上报功能:" + dr["上报功能"];
                strInfo += "\n 冻结上报:" + dr["冻结上报"];
                strInfo += "\n 欠费关阀:" + dr["欠费关阀"];
                strInfo += "\n 预付费用:" + dr["预付费用"];
                strInfo += "\n 阀门防锈:" + dr["阀门防锈"];
                strInfo += "\n 掉电关阀:" + dr["掉电关阀"];
                strInfo += "\n 休眠策略:" + dr["休眠策略"];
                strInfo += "\n 自动关阀:" + dr["自动关阀"];
                strInfo += "\n 泄露检测:" + dr["泄露检测"];
                strInfo += "\n 流速控制:" + dr["流速控制"];
            }
            dt.Rows.Add(dr);
            if (dt.Rows.Count > 2000)
            {
                dt.Rows.RemoveAt(0);
            }
            string strPath = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\DataForward";

            if (Directory.Exists(strPath) == false)
            {
                Directory.CreateDirectory(strPath);
            }
            string strFile = strPath + "\\GetFunOption.xml";

            if (File.Exists(strFile) == false)
            {
                File.Create(strFile).Close();
            }
            dt.WriteXml(strFile);
            return(strInfo);
        }
コード例 #5
0
        // DataBuf:命令字+节点地址+转发结果+转发内容
        // TxBuf:命令字+节点地址+转发内容
        public string GetResultString(byte[] DataBuf, byte[] TxBuf)
        {
            string strInfo = null;

            string[] strState = new string[3] {
                "关闭", "开启", "不处理"
            };
            if (DataBuf[0] != 0x08)
            {
                return(null);
            }
            DataRow dr = dt.NewRow();

            dr["序号"]   = dt.Rows.Count + 1;
            dr["表具地址"] = FrmMain.GetStringAddrFromByte(DataBuf, 1);
            dr["命令类型"] = FrmMain.GetStringFromCmd(DataBuf[0]);
            dr["操作时间"] = DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss");
            if (DataBuf.Length < FrmMain.AddrLength + 1 + 1)
            {
                return(null);
            }
            if (TxBuf.Length >= 1 + FrmMain.AddrLength + 16)
            {
                if (DataBuf.Length >= FrmMain.AddrLength + 1 + 1 + 1)
                {
                    strInfo    = FrmMain.GetErrorInfo(DataBuf[1 + FrmMain.AddrLength + 1]);
                    dr["操作结果"] = strInfo;
                }
                else
                {
                    dr["操作结果"] = FrmMain.GetErrorInfo(DataBuf[1 + FrmMain.AddrLength]);;
                }
                int iPos = 1 + FrmMain.AddrLength;
                dr["磁扰关阀"] = strState[TxBuf[iPos++]];
                dr["数据加密"] = strState[TxBuf[iPos++]];
                dr["防拆检测"] = strState[TxBuf[iPos++]];
                dr["垂直安装"] = strState[TxBuf[iPos++]];
                dr["上报功能"] = strState[TxBuf[iPos++]];
                dr["冻结上报"] = strState[TxBuf[iPos++]];
                dr["欠费关阀"] = strState[TxBuf[iPos++]];
                dr["预付费用"] = strState[TxBuf[iPos++]];
                iPos++;
                dr["阀门防锈"] = strState[TxBuf[iPos++]];
                dr["掉电关阀"] = strState[TxBuf[iPos++]];
                dr["休眠策略"] = strState[TxBuf[iPos++]];
                dr["自动关阀"] = strState[TxBuf[iPos++]];
                dr["泄露检测"] = strState[TxBuf[iPos++]];
                iPos++;
                dr["流速控制"] = strState[TxBuf[iPos++]];
                if (DataBuf.Length >= FrmMain.AddrLength + 1 + 1 + 1)
                {
                    dr["场强↓"] = "-" + DataBuf[1 + FrmMain.AddrLength + 1 + 1].ToString("D") + "dBm";
                    dr["场强↑"] = "-" + DataBuf[1 + FrmMain.AddrLength + 1 + 2].ToString("D") + "dBm";
                }
                else
                {
                    dr["场强↓"] = "";
                    dr["场强↑"] = "";
                }
            }
            dt.Rows.Add(dr);
            if (dt.Rows.Count > 2000)
            {
                dt.Rows.RemoveAt(0);
            }
            string strPath = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\DataForward";

            if (Directory.Exists(strPath) == false)
            {
                Directory.CreateDirectory(strPath);
            }
            string strFile = strPath + "\\SetFunOption.xml";

            if (File.Exists(strFile) == false)
            {
                File.Create(strFile).Close();
            }
            dt.WriteXml(strFile);
            return(strInfo);
        }