public string ReadMsg() { string UserDataAllTmp; byte[] UserDataBytesAllTmp; string msg = WaterBaseMessageService.ReadMsg(MsgList, out UserDataAllTmp, out UserDataBytesAllTmp); if (msg == "") { UserDataAll = UserDataAllTmp; UserDataBytesAll = UserDataBytesAllTmp; return(ReadMsg(UserDataAll)); } else { if (ShowLog) { logHelper.Error(msg); } return(msg); } }
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 * { * YellowLevel = Convert.ToInt16(UserData.Substring(16, 4), 16); * } * catch (Exception ex) * { * if (ShowLog) logHelper.Error(ex.Message + Environment.NewLine + "获取水位黄色预警阈值出错" + " " + RawDataStr); * return "获取水位黄色预警阈值出错"; * } * try * { * OrangeLevel = Convert.ToInt16(UserData.Substring(20, 4), 16); * } * catch (Exception ex) * { * if (ShowLog) logHelper.Error(ex.Message + Environment.NewLine + "获取水位橙色预警阈值出错" + " " + RawDataStr); * return "获取水位橙色预警阈值出错"; * } * try * { * RedLevel = Convert.ToInt16(UserData.Substring(24, 4), 16); * } * catch (Exception ex) * { * if (ShowLog) logHelper.Error(ex.Message + Environment.NewLine + "获取水位红色预警阈值出错" + " " + RawDataStr); * return "获取水位红色预警阈值出错"; * } * return "";*/ string UserDataAllTmp; byte[] UserDataBytesAllTmp; string msg = WaterBaseMessageService.ReadMsg(MsgList, out UserDataAllTmp, out UserDataBytesAllTmp); if (msg == "") { UserDataAll = UserDataAllTmp; UserDataBytesAll = UserDataBytesAllTmp; return(ReadMsg(UserDataAll)); } else { if (ShowLog) { logHelper.Error(msg); } return(msg); } }