Esempio n. 1
0
        public string ReadMsg(string UserDataAll)
        {
            short    SerialNumberTmp;
            DateTime SendTimeTmp;
            string   msg = WaterBaseMessageService.GetSerialNumberAndSendTime(UserDataAll, out SerialNumberTmp, out SendTimeTmp);

            if (msg == "")
            {
                SerialNumber = SerialNumberTmp;
                SendTime     = SendTimeTmp;
            }
            else
            {
                if (ShowLog)
                {
                    logHelper.Error(msg);
                }
                return(msg);
            }

            try
            {
                OrderNum = Convert.ToByte(UserDataAll.Substring(16, 2), 16);
            }
            catch (Exception ex)
            {
                if (ShowLog)
                {
                    logHelper.Error(ex.Message + Environment.NewLine + "获取手机号序号出错" + " " + RawDataStr);
                }
                return("获取手机号序号出错");
            }

            try
            {
                if (UserDataAll.Length - 18 > 0)
                {
                    string str = UserDataAll.Substring(18, UserDataAll.Length - 18);
                    Phone = HexStringUtility.HexStringToStr(str);
                }
                else
                {
                    Phone = "";
                }
            }
            catch (Exception ex)
            {
                if (ShowLog)
                {
                    logHelper.Error(ex.Message + Environment.NewLine + "获取手机号出错" + " " + RawDataStr);
                }
                return("获取手机号出错");
            }

            return("");
        }
Esempio n. 2
0
 public override void SetVal(int ByteCount, int Digits, string hexStr)
 {
     try
     {
         this.SimNoTypeV = Convert.ToInt32(HexStringUtility.HexStringToStr(hexStr.Substring(0, 2)));
         this.SimNo      = HexStringUtility.HexStringToStr(hexStr.Substring(2));
     }
     catch
     {
     }
 }
Esempio n. 3
0
        public string ReadMsg(string UserDataAll)
        {
            short    SerialNumberTmp;
            DateTime SendTimeTmp;
            string   msg = WaterBaseMessageService.GetSerialNumberAndSendTime(UserDataAll, out SerialNumberTmp, out SendTimeTmp);

            if (msg == "")
            {
                SerialNumber = SerialNumberTmp;
                SendTime     = SendTimeTmp;
            }
            else
            {
                if (ShowLog)
                {
                    logHelper.Error(msg);
                }
                return(msg);
            }

            try
            {
                Iden_F1 = new Identifier_F1();
                Iden_F1.RemoteStation = UserDataAll.Substring(20, 10);
            }
            catch (Exception ex)
            {
                if (ShowLog)
                {
                    logHelper.Error(ex.Message + Environment.NewLine + "获取遥测站出错" + " " + RawDataStr);
                }
                return("获取遥测站出错");
            }

            try
            {
                VersionL = Convert.ToByte(UserDataAll.Substring(30, 2), 16);
                VersionC = HexStringUtility.HexStringToStr(UserDataAll.Substring(32, 2 * VersionL));
            }
            catch (Exception ex)
            {
                if (ShowLog)
                {
                    logHelper.Error(ex.Message + Environment.NewLine + "获取版本信息出错" + " " + RawDataStr);
                }
                return("获取版本信息出错");
            }

            return("");
        }
Esempio n. 4
0
 public override string ToString()
 {
     try
     {
         StringBuilder sb = new StringBuilder();
         sb.Append("【" + EnumUtils.GetDescription(typeof(WaterBaseProtocol.AFN), AFN) + "】:");
         sb.Append("【流水号】:" + SerialNumber + ",");
         sb.Append("【发报时间】:" + SendTime.ToString("yyyy-MM-dd HH:mm:ss") + ",");
         if (iden_F2 != null)
         {
             sb.Append("【数据内容】:" + HexStringUtility.HexStringToStr(iden_F2.Content) + ",");
         }
         else
         {
             sb.Append("数据解析失败!");
         }
         return(sb.ToString().TrimEnd(','));
     }
     catch
     {
         return("【" + EnumUtils.GetDescription(typeof(WaterBaseProtocol.AFN), AFN) + "】:" + " ToString error");
     }
 }
        public string ReadMsg()
        {
            if (UserDataBytes == null || UserDataBytes.Length == 0)
            {
                if (ShowLog)
                {
                    logHelper.Error("无信息,无法分析!");
                }
                return("无信息,无法分析!");
            }

            UserData = HexStringUtility.ByteArrayToHexString(UserDataBytes);

            try
            {
                SerialNumber = Convert.ToInt16(UserData.Substring(0, 4), 16);
            }
            catch (Exception ex)
            {
                if (ShowLog)
                {
                    logHelper.Error(ex.Message + Environment.NewLine + "获取流水号出错" + " " + RawDataStr);
                }
                return("获取流水号出错");
            }

            try
            {
                SendTime = DateTime.ParseExact("20" + UserData.Substring(4, 12), "yyyyMMddHHmmss", CultureInfo.InvariantCulture);
            }
            catch (Exception ex)
            {
                if (ShowLog)
                {
                    logHelper.Error(ex.Message + Environment.NewLine + "获取发报时间出错" + " " + RawDataStr);
                }
                return("获取发报时间出错");
            }

            try
            {
                OrderNum = Convert.ToByte(UserData.Substring(16, 2), 16);
            }
            catch (Exception ex)
            {
                if (ShowLog)
                {
                    logHelper.Error(ex.Message + Environment.NewLine + "获取手机号序号出错" + " " + RawDataStr);
                }
                return("获取手机号序号出错");
            }

            try
            {
                if (UserDataBytes.Length * 2 - 18 > 0)
                {
                    string str = UserData.Substring(18, UserDataBytes.Length * 2 - 18);
                    Phone = HexStringUtility.HexStringToStr(str);
                }
                else
                {
                    Phone = "";
                }
            }
            catch (Exception ex)
            {
                if (ShowLog)
                {
                    logHelper.Error(ex.Message + Environment.NewLine + "获取手机号出错" + " " + RawDataStr);
                }
                return("获取手机号出错");
            }

            return("");
        }
        public string ReadMsg()
        {
            if (UserDataBytes == null || UserDataBytes.Length == 0)
            {
                if (ShowLog)
                {
                    logHelper.Error("无信息,无法分析!");
                }
                return("无信息,无法分析!");
            }

            UserData = HexStringUtility.ByteArrayToHexString(UserDataBytes);

            try
            {
                SerialNumber = Convert.ToInt16(UserData.Substring(0, 4), 16);
            }
            catch (Exception ex)
            {
                if (ShowLog)
                {
                    logHelper.Error(ex.Message + Environment.NewLine + "获取流水号出错" + " " + RawDataStr);
                }
                return("获取流水号出错");
            }

            try
            {
                SendTime = DateTime.ParseExact("20" + UserData.Substring(4, 12), "yyyyMMddHHmmss", CultureInfo.InvariantCulture);
            }
            catch (Exception ex)
            {
                if (ShowLog)
                {
                    logHelper.Error(ex.Message + Environment.NewLine + "获取发报时间出错" + " " + RawDataStr);
                }
                return("获取发报时间出错");
            }

            try
            {
                PlayCount = Convert.ToByte(UserData.Substring(16, 2), 16);
            }
            catch (Exception ex)
            {
                if (ShowLog)
                {
                    logHelper.Error(ex.Message + Environment.NewLine + "获取播报次数出错" + " " + RawDataStr);
                }
                return("获取播报次数出错");
            }

            try
            {
                PlaySpeed = Convert.ToByte(UserData.Substring(18, 1), 16);
            }
            catch (Exception ex)
            {
                if (ShowLog)
                {
                    logHelper.Error(ex.Message + Environment.NewLine + "获取播报语速出错" + " " + RawDataStr);
                }
                return("获取播报语速出错");
            }

            try
            {
                PlayRole = Convert.ToByte(UserData.Substring(19, 1), 16);
            }
            catch (Exception ex)
            {
                if (ShowLog)
                {
                    logHelper.Error(ex.Message + Environment.NewLine + "获取播报角色出错" + " " + RawDataStr);
                }
                return("获取播报角色出错");
            }

            try
            {
                PlayContext = HexStringUtility.HexStringToStr(UserData.Substring(20));
            }
            catch (Exception ex)
            {
                if (ShowLog)
                {
                    logHelper.Error(ex.Message + Environment.NewLine + "获取播报内容出错" + " " + RawDataStr);
                }
                return("获取播报内容出错");
            }

            return("");
        }