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); } string Remain = UserDataAll.Substring(16).ToUpper(); msg = ""; List_Identifier = Identifier.analyse(Remain, AFN, out msg); return(msg); }
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 { string Remain = UserDataAll.Substring(30); int count = Convert.ToInt32(Remain.Substring(0, 2), 16); Ps = new bool[count]; string hexStr = Remain.Substring(2, ((count - 1) / 8 + 1) * 2); string binStr = HexStringUtility.HexStringToBinString(hexStr); for (int i = 0; i < binStr.Length; i++) { if (count > binStr.Length - i - 1) { Ps[binStr.Length - i - 1] = binStr[i] == '1'; } } } catch (Exception ex) { if (ShowLog) { logHelper.Error(ex.Message + Environment.NewLine + "获取泵开关状态出错" + " " + RawDataStr); } return("获取泵开关状态出错"); } return(""); }
public string WriteMsg() { UserDataAll += SerialNumber.ToString("X").PadLeft(4, '0'); UserDataAll += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0'); if (List_Identifier != null && List_Identifier.Count > 0) { foreach (Identifier iden in List_Identifier) { UserDataAll += iden.GetHexStr(); } } byte[] UserDataBytesAllTmp; WaterBaseMessage[] MsgListTmp; string msg = WaterBaseMessageService.GetMsgList_WriteMsg(this, UserDataAll, out UserDataBytesAllTmp, out MsgListTmp); if (msg == "") { UserDataBytesAll = UserDataBytesAllTmp; MsgList = MsgListTmp; } else { if (ShowLog) { logHelper.Error(msg); } } return(msg); }
public string WriteMsg() { UserDataAll += SerialNumber.ToString("X").PadLeft(4, '0'); UserDataAll += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0'); UserDataAll += Iden_F1.GetHexStr(); UserDataAll += newPW.GetHexStr(); byte[] UserDataBytesAllTmp; WaterBaseMessage[] MsgListTmp; string msg = WaterBaseMessageService.GetMsgList_WriteMsg(this, UserDataAll, out UserDataBytesAllTmp, out MsgListTmp); if (msg == "") { UserDataBytesAll = UserDataBytesAllTmp; MsgList = MsgListTmp; } 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); short SerialNumberTmp; DateTime SendTimeTmp; string msg = WaterBaseMessageService.GetSerialNumberAndSendTime(UserData, out SerialNumberTmp, out SendTimeTmp); if (msg == "") { SerialNumber = SerialNumberTmp; SendTime = SendTimeTmp; } else { if (ShowLog) { logHelper.Error(msg); } return(msg); } return(""); }
public string WriteMsg() { UserDataAll += SerialNumber.ToString("X").PadLeft(4, '0'); UserDataAll += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0'); UserDataAll += Iden_F1.GetHexStr(); for (int i = 0; i < stateDec.Length; i++) { if (States.Count > i) { UserDataAll += States[i].ToString("X").PadLeft(4, '0'); } else { UserDataAll += "0000"; } } byte[] UserDataBytesAllTmp; WaterBaseMessage[] MsgListTmp; string msg = WaterBaseMessageService.GetMsgList_WriteMsg(this, UserDataAll, out UserDataBytesAllTmp, out MsgListTmp); if (msg == "") { UserDataBytesAll = UserDataBytesAllTmp; MsgList = MsgListTmp; } else { if (ShowLog) { logHelper.Error(msg); } } return(msg); }
public string WriteMsg() { if (Phone.Trim().Length > 11) { return("预警责任人号码读取非法!"); } if (Phone.Trim() != "" && Tools.GetTest(Phone.Trim()) != "数字") { return("预警责任人号码读取非法!"); } UserDataAll += SerialNumber.ToString("X").PadLeft(4, '0'); UserDataAll += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0'); UserDataAll += OrderNum.ToString("X").PadLeft(2, '0'); UserDataAll += HexStringUtility.StrToHexString(Phone.Trim()); byte[] UserDataBytesAllTmp; WaterBaseMessage[] MsgListTmp; string msg = WaterBaseMessageService.GetMsgList_WriteMsg(this, UserDataAll, out UserDataBytesAllTmp, out MsgListTmp); if (msg == "") { UserDataBytesAll = UserDataBytesAllTmp; MsgList = MsgListTmp; } else { if (ShowLog) { logHelper.Error(msg); } } return(msg); }
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("获取遥测站出错"); } string Remain = UserDataAll.Substring(30); msg = ""; List <Identifier> List_RTUParam = Identifier.analyse(Remain, AFN, out msg); if (msg == "") { if (List_RTUParam.Count == 1) { if (List_RTUParam[0].GetKey() == (byte)Identifier_Standard._45) { Identifier_45 iden = (Identifier_45)List_RTUParam[0]; isUsed = iden.AlarmStateV[32 - (int)AlarmState._10] == '1'; } else { msg = "数据体非法,参数关键字非法"; } } else { msg = "数据体非法,参数超过1个"; } } return(msg); }
public string WriteMsg() { UserDataAll += SerialNumber.ToString("X").PadLeft(4, '0'); UserDataAll += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0'); UserDataAll += Iden_F1.GetHexStr(); Identifier_45 iden = new Identifier_45(); iden.AlarmStateV = "0".PadLeft(32, '0'); iden.AlarmStateV = (isUsed ? "1" : "0").PadRight(10, '0').PadLeft(32, '0'); UserData += iden.GetHexStr(); byte[] UserDataBytesAllTmp; WaterBaseMessage[] MsgListTmp; string msg = WaterBaseMessageService.GetMsgList_WriteMsg(this, UserDataAll, out UserDataBytesAllTmp, out MsgListTmp); if (msg == "") { UserDataBytesAll = UserDataBytesAllTmp; MsgList = MsgListTmp; } else { if (ShowLog) { logHelper.Error(msg); } } return(msg); }
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 { Result = Convert.ToByte(UserDataAll.Substring(16, 2), 16); } catch (Exception ex) { if (ShowLog) { logHelper.Error(ex.Message + Environment.NewLine + "获取结果出错" + " " + RawDataStr); } return("获取结果出错"); } return(""); }
public string WriteMsg() { UserDataAll += SerialNumber.ToString("X").PadLeft(4, '0'); UserDataAll += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0'); UserDataAll += RType.ToString("X").PadLeft(2, '0'); UserDataAll += IsSend.ToString("X").PadLeft(2, '0'); //kqz 2016-12-31 增加 UserDataAll += NumAuthenType.ToString("X").PadLeft(2, '0'); //kqz 2016-12-31 增加 byte[] UserDataBytesAllTmp; WaterBaseMessage[] MsgListTmp; string msg = WaterBaseMessageService.GetMsgList_WriteMsg(this, UserDataAll, out UserDataBytesAllTmp, out MsgListTmp); if (msg == "") { UserDataBytesAll = UserDataBytesAllTmp; MsgList = MsgListTmp; } else { if (ShowLog) { logHelper.Error(msg); } } return(msg); }
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("获取遥测站出错"); } string Remain = UserDataAll.Substring(30).ToUpper(); msg = ""; List <RTUParam> List_RTUParam = RTUParam.analyse(Remain, AFN, out msg); if (msg == "") { if (List_RTUParam.Count == 1) { if (List_RTUParam[0].GetKey() == (byte)RTUParam.RTUParamKey._03) { newPW = (RTUParam_03)List_RTUParam[0]; } else { msg = "数据体非法,参数1关键字非法"; } } else { msg = "数据体非法,参数不为1个"; } } return(""); }
public string WriteMsg() { UserDataAll += SerialNumber.ToString("X").PadLeft(4, '0'); UserDataAll += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0'); UserDataAll += Iden_F1.GetHexStr(); VersionL = (byte)HexStringUtility.StrToByteArray(VersionC).Length; UserDataAll += VersionL.ToString("X").PadLeft(2, '0'); UserDataAll += HexStringUtility.StrToHexString(VersionC); byte[] UserDataBytesAllTmp; WaterBaseMessage[] MsgListTmp; string msg = WaterBaseMessageService.GetMsgList_WriteMsg(this, UserDataAll, out UserDataBytesAllTmp, out MsgListTmp); if (msg == "") { UserDataBytesAll = UserDataBytesAllTmp; MsgList = MsgListTmp; } else { if (ShowLog) { logHelper.Error(msg); } } return(msg); }
public string WriteMsg() { /*UserData = ""; * UserData += SerialNumber.ToString("X").PadLeft(4, '0'); * UserData += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0'); * * UserData += YellowLevel.ToString("X").PadLeft(4, '0'); * UserData += OrangeLevel.ToString("X").PadLeft(4, '0'); * UserData += RedLevel.ToString("X").PadLeft(4, '0'); * * UserDataBytes = HexStringUtility.HexStringToByteArray(UserData); * return WriteMsgBase();*/ UserDataAll += SerialNumber.ToString("X").PadLeft(4, '0'); UserDataAll += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0'); UserDataAll += YellowLevel.ToString("X").PadLeft(4, '0'); UserDataAll += OrangeLevel.ToString("X").PadLeft(4, '0'); UserDataAll += RedLevel.ToString("X").PadLeft(4, '0'); byte[] UserDataBytesAllTmp; WaterBaseMessage[] MsgListTmp; string msg = WaterBaseMessageService.GetMsgList_WriteMsg(this, UserDataAll, out UserDataBytesAllTmp, out MsgListTmp); if (msg == "") { UserDataBytesAll = UserDataBytesAllTmp; MsgList = MsgListTmp; } else { if (ShowLog) { logHelper.Error(msg); } } return(msg); }
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 { YellowLevel = Convert.ToInt16(UserDataAll.Substring(16, 4), 16); } catch (Exception ex) { if (ShowLog) { logHelper.Error(ex.Message + Environment.NewLine + "获取水位黄色预警阈值出错" + " " + RawDataStr); } return("获取水位黄色预警阈值出错"); } try { OrangeLevel = Convert.ToInt16(UserDataAll.Substring(20, 4), 16); } catch (Exception ex) { if (ShowLog) { logHelper.Error(ex.Message + Environment.NewLine + "获取水位橙色预警阈值出错" + " " + RawDataStr); } return("获取水位橙色预警阈值出错"); } try { RedLevel = Convert.ToInt16(UserDataAll.Substring(24, 4), 16); } catch (Exception ex) { if (ShowLog) { logHelper.Error(ex.Message + Environment.NewLine + "获取水位红色预警阈值出错" + " " + RawDataStr); } return("获取水位红色预警阈值出错"); } return(""); }
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(""); }
public string WriteMsg() { UserDataAll += SerialNumber.ToString("X").PadLeft(4, '0'); UserDataAll += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0'); UserDataAll += Iden_F1.GetHexStr(); int count = Ps.Length < PsOpen.Length ? Ps.Length : PsOpen.Length; UserData += count.ToString("X").PadLeft(2, '0'); string s = ""; for (int i = 0; i < count; i++) { if (Ps[i]) { s = "1" + s; } else { s = "0" + s; } } s = s.PadLeft(8 * ((count - 1) / 8 + 1), '0'); UserData += HexStringUtility.BinStringToHexString(s); for (int i = 0; i < count; i++) { if (PsOpen[i] <= 9999) { UserData += PsOpen[i].ToString().PadLeft(4, '0'); } else if (PsOpen[i] > 9999) { UserData += PsOpen[i].ToString().Substring(PsOpen[i].ToString().Length - 4); } } byte[] UserDataBytesAllTmp; WaterBaseMessage[] MsgListTmp; string msg = WaterBaseMessageService.GetMsgList_WriteMsg(this, UserDataAll, out UserDataBytesAllTmp, out MsgListTmp); if (msg == "") { UserDataBytesAll = UserDataBytesAllTmp; MsgList = MsgListTmp; } else { if (ShowLog) { logHelper.Error(msg); } } return(msg); }
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("获取遥测站出错"); } States = new List <short>(); for (int i = 0; i < stateDec.Length; i++) { if (UserDataAll.Length >= 30 + 4 * (i + 1)) { string s = UserDataAll.Substring(30 + 4 * i, 4); States.Add(Convert.ToInt16(s, 16)); } else { States.Add(0); } } return(""); }
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(""); }
public string WriteMsg() { if (Values == null || Values.Length != 12) { return("雨量预警阈值读取非法!"); } UserDataAll = ""; UserDataAll += SerialNumber.ToString("X").PadLeft(4, '0'); UserDataAll += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0'); UserDataAll += "01"; UserDataAll += Values[0].ToString("X").PadLeft(2, '0'); UserDataAll += Values[1].ToString("X").PadLeft(2, '0'); UserDataAll += Values[2].ToString("X").PadLeft(2, '0'); UserDataAll += "03"; UserDataAll += Values[3].ToString("X").PadLeft(2, '0'); UserDataAll += Values[4].ToString("X").PadLeft(2, '0'); UserDataAll += Values[5].ToString("X").PadLeft(2, '0'); UserDataAll += "06"; UserDataAll += Values[6].ToString("X").PadLeft(2, '0'); UserDataAll += Values[7].ToString("X").PadLeft(2, '0'); UserDataAll += Values[8].ToString("X").PadLeft(2, '0'); UserDataAll += "12"; UserDataAll += Values[9].ToString("X").PadLeft(2, '0'); UserDataAll += Values[10].ToString("X").PadLeft(2, '0'); UserDataAll += Values[11].ToString("X").PadLeft(2, '0'); byte[] UserDataBytesAllTmp; WaterBaseMessage[] MsgListTmp; string msg = WaterBaseMessageService.GetMsgList_WriteMsg(this, UserDataAll, out UserDataBytesAllTmp, out MsgListTmp); if (msg == "") { UserDataBytesAll = UserDataBytesAllTmp; MsgList = MsgListTmp; } else { if (ShowLog) { logHelper.Error(msg); } } return(msg); }
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); } string Remain = UserDataAll.Substring(16).ToUpper(); msg = ""; List_Identifier = Identifier.analyse(Remain, AFN, out msg); if (List_Identifier != null) { for (int i = 0; i < List_Identifier.Count; i++) { if (List_Identifier[i].GetKey() == (byte)Identifier_Standard._F3) { try { iden_F3 = (Identifier_F3)List_Identifier[i]; } catch { return("获取图片对象失败!"); } } } } return(msg); }
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("获取遥测站出错"); } string Remain = UserDataAll.Substring(30).ToUpper(); msg = ""; List_RTUParam = RTUParam.analyse(Remain, AFN, out msg); return(msg); }
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); } return(""); }
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); } }
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 { //StationType = Convert.ToByte(UserDataAll.Substring(30, 2), 16); Iden_F1 = new Identifier_F1(); Iden_F1.RemoteStation = UserDataAll.Substring(20, 10); Iden_F1.StationType = Convert.ToByte(UserDataAll.Substring(30, 2), 16); } catch (Exception ex) { if (ShowLog) { logHelper.Error(ex.Message + Environment.NewLine + "获取遥测站出错" + " " + RawDataStr); } return("获取遥测站出错"); } try { //ObsTime = DateTime.ParseExact("20" + UserDataAll.Substring(36, 10) + "00", "yyyyMMddHHmmss", CultureInfo.InvariantCulture); Iden_F0 = new Identifier_F0(); Iden_F0.ObsTime = DateTime.ParseExact("20" + UserDataAll.Substring(36, 10) + "00", "yyyyMMddHHmmss", CultureInfo.InvariantCulture); } catch (Exception ex) { if (ShowLog) { logHelper.Error(ex.Message + Environment.NewLine + "获取观测时间出错" + " " + RawDataStr); } return("获取观测时间出错"); } try { byte key_04 = Convert.ToByte(UserDataAll.Substring(46, 2), 16); if (key_04 != (int)Identifier_Standard._04) { return("获取时间步长码出错"); } string LengthStr_04 = UserDataAll.Substring(48, 2); int[] LS_04 = WaterBaseProtocol.GetLengthList(LengthStr_04); int ByteCount_04 = LS_04[0]; int Digits_04 = LS_04[1]; Iden_04 = new Identifier_04(); Iden_04.SetVal(ByteCount_04, Digits_04, UserDataAll.Substring(50, 6)); } catch (Exception ex) { if (ShowLog) { logHelper.Error(ex.Message + Environment.NewLine + "获取时间步长码出错" + " " + RawDataStr); } return("获取时间步长码出错"); } string Remain = UserDataAll.Substring(56).ToUpper(); if (Remain.Length > 4) { byte Key = Convert.ToByte(Remain.Substring(0, 2), 16); Idens = new List <Identifier>(); if (Key == (byte)Identifier_Standard._FF) { if (Remain.Length > 6) { byte KeySub = Convert.ToByte(Remain.Substring(2, 2), 16); Remain = Remain.Substring(6); if (KeySub == (byte)Identifier_Custom._03) { while (Remain.Length >= 24) { Identifier_FF_03 id = new Identifier_FF_03(); id.SetVal(0, 0, Remain.Substring(0, 24)); Idens.Add(id); Remain = Remain.Substring(24); } } else if (KeySub == (byte)Identifier_Custom._0E) { while (Remain.Length >= 36) { Identifier_FF_0E id = new Identifier_FF_0E(); id.SetVal(0, 0, Remain.Substring(0, 36)); Idens.Add(id); Remain = Remain.Substring(24); } } } } else { string LengthStr = Remain.Substring(2, 2); int[] LS = WaterBaseProtocol.GetLengthList(LengthStr); int ByteCount = LS[0]; int Digits = LS[1]; if (ByteCount > 0) { Remain = Remain.Substring(4); if (Key == (byte)Identifier_Standard._1A) { while (Remain.Length >= ByteCount * 2) { Identifier_1A id = new Identifier_1A(); id.SetVal(ByteCount, Digits, Remain.Substring(0, ByteCount * 2)); Idens.Add(id); Remain = Remain.Substring(ByteCount * 2); } } else if (Key == (byte)Identifier_Standard._1F) { while (Remain.Length >= ByteCount * 2) { Identifier_1F id = new Identifier_1F(); id.SetVal(ByteCount, Digits, Remain.Substring(0, ByteCount * 2)); Idens.Add(id); Remain = Remain.Substring(ByteCount * 2); } } else if (Key == (byte)Identifier_Standard._20) { while (Remain.Length >= ByteCount * 2) { Identifier_20 id = new Identifier_20(); id.SetVal(ByteCount, Digits, Remain.Substring(0, ByteCount * 2)); Idens.Add(id); Remain = Remain.Substring(ByteCount * 2); } } else if (Key == (byte)Identifier_Standard._26) { while (Remain.Length >= ByteCount * 2) { Identifier_26 id = new Identifier_26(); id.SetVal(ByteCount, Digits, Remain.Substring(0, ByteCount * 2)); Idens.Add(id); Remain = Remain.Substring(ByteCount * 2); } } else if (Key == (byte)Identifier_Standard._38) { while (Remain.Length >= ByteCount * 2) { Identifier_38 id = new Identifier_38(); id.SetVal(ByteCount, Digits, Remain.Substring(0, ByteCount * 2)); Idens.Add(id); Remain = Remain.Substring(ByteCount * 2); } } else if (Key == (byte)Identifier_Standard._39) { while (Remain.Length >= ByteCount * 2) { Identifier_39 id = new Identifier_39(); id.SetVal(ByteCount, Digits, Remain.Substring(0, ByteCount * 2)); Idens.Add(id); Remain = Remain.Substring(ByteCount * 2); } } else if (Key == (byte)Identifier_Standard._F4) { while (Remain.Length >= ByteCount * 2) { Identifier_F4 id = new Identifier_F4(); id.SetVal(ByteCount, Digits, Remain.Substring(0, ByteCount * 2)); Idens.Add(id); Remain = Remain.Substring(ByteCount * 2); } } else if (Key == (byte)Identifier_Standard._F5) { while (Remain.Length >= ByteCount * 2) { Identifier_F5 id = new Identifier_F5(); id.SetVal(ByteCount, Digits, Remain.Substring(0, ByteCount * 2)); Idens.Add(id); Remain = Remain.Substring(ByteCount * 2); } } } } } return(""); }
public string WriteMsg() { if (Iden_04 == null) { return("时间步长码出错"); } UserDataAll = ""; UserDataAll += SerialNumber.ToString("X").PadLeft(4, '0'); UserDataAll += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0'); /* * UserDataAll += HexStringUtility.ByteArrayToHexString(new byte[] { 0xF1, 0xF1 }); * UserDataAll += RemoteStation.PadLeft(10, '0'); * UserDataAll += StationType.ToString("X").PadLeft(2, '0'); * */ UserDataAll += Iden_F1.GetHexStr(); /* * UserDataAll += HexStringUtility.ByteArrayToHexString(new byte[] { 0xF0, 0xF0 }); * UserDataAll += ObsTime.ToString("yyMMddHHmm").PadLeft(10, '0'); * */ UserDataAll += Iden_F0.GetHexStr(); UserDataAll += Iden_04.GetHexStr(); if (Idens != null && Idens.Count > 0) { UserDataAll += Idens[0].GetHexStrHead(); if (Idens[0].GetKey() != (byte)Identifier_Standard._FF) { foreach (Identifier obj in Idens) { UserDataAll += obj.GetHexStr().Substring(4); } } else { foreach (Identifier obj in Idens) { UserDataAll += obj.GetHexStr().Substring(6); } } } else { return("无有效数据"); } byte[] UserDataBytesAllTmp; WaterBaseMessage[] MsgListTmp; string msg = WaterBaseMessageService.GetMsgList_WriteMsg(this, UserDataAll, out UserDataBytesAllTmp, out MsgListTmp); if (msg == "") { UserDataBytesAll = UserDataBytesAllTmp; MsgList = MsgListTmp; } else { if (ShowLog) { logHelper.Error(msg); } } return(msg); }
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); } Values = new byte[12]; try { Values[0] = Convert.ToByte(UserDataAll.Substring(18, 2), 16); } catch (Exception ex) { if (ShowLog) { logHelper.Error(ex.Message + Environment.NewLine + "获取1小时黄色预警值出错" + " " + RawDataStr); } return("获取1小时黄色预警值出错"); } try { Values[1] = Convert.ToByte(UserDataAll.Substring(20, 2), 16); } catch (Exception ex) { if (ShowLog) { logHelper.Error(ex.Message + Environment.NewLine + "获取1小时橙色预警值出错" + " " + RawDataStr); } return("获取1小时橙色预警值出错"); } try { Values[2] = Convert.ToByte(UserDataAll.Substring(22, 2), 16); } catch (Exception ex) { if (ShowLog) { logHelper.Error(ex.Message + Environment.NewLine + "获取1小时红色预警值出错" + " " + RawDataStr); } return("获取1小时红色预警值出错"); } try { Values[3] = Convert.ToByte(UserDataAll.Substring(26, 2), 16); } catch (Exception ex) { if (ShowLog) { logHelper.Error(ex.Message + Environment.NewLine + "获取3小时黄色预警值出错" + " " + RawDataStr); } return("获取3小时黄色预警值出错"); } try { Values[4] = Convert.ToByte(UserDataAll.Substring(28, 2), 16); } catch (Exception ex) { if (ShowLog) { logHelper.Error(ex.Message + Environment.NewLine + "获取3小时橙色预警值出错" + " " + RawDataStr); } return("获取3小时橙色预警值出错"); } try { Values[5] = Convert.ToByte(UserDataAll.Substring(30, 2), 16); } catch (Exception ex) { if (ShowLog) { logHelper.Error(ex.Message + Environment.NewLine + "获取3小时红色预警值出错" + " " + RawDataStr); } return("获取3小时红色预警值出错"); } try { Values[6] = Convert.ToByte(UserDataAll.Substring(34, 2), 16); } catch (Exception ex) { if (ShowLog) { logHelper.Error(ex.Message + Environment.NewLine + "获取6小时黄色预警值出错" + " " + RawDataStr); } return("获取6小时黄色预警值出错"); } try { Values[7] = Convert.ToByte(UserDataAll.Substring(36, 2), 16); } catch (Exception ex) { if (ShowLog) { logHelper.Error(ex.Message + Environment.NewLine + "获取6小时橙色预警值出错" + " " + RawDataStr); } return("获取6小时橙色预警值出错"); } try { Values[8] = Convert.ToByte(UserDataAll.Substring(38, 2), 16); } catch (Exception ex) { if (ShowLog) { logHelper.Error(ex.Message + Environment.NewLine + "获取6小时红色预警值出错" + " " + RawDataStr); } return("获取6小时红色预警值出错"); } try { Values[9] = Convert.ToByte(UserDataAll.Substring(42, 2), 16); } catch (Exception ex) { if (ShowLog) { logHelper.Error(ex.Message + Environment.NewLine + "获取12小时黄色预警值出错" + " " + RawDataStr); } return("获取12小时黄色预警值出错"); } try { Values[10] = Convert.ToByte(UserDataAll.Substring(44, 2), 16); } catch (Exception ex) { if (ShowLog) { logHelper.Error(ex.Message + Environment.NewLine + "获取12小时橙色预警值出错" + " " + RawDataStr); } return("获取12小时橙色预警值出错"); } try { Values[11] = Convert.ToByte(UserDataAll.Substring(46, 2), 16); } catch (Exception ex) { if (ShowLog) { logHelper.Error(ex.Message + Environment.NewLine + "获取12小时红色预警值出错" + " " + RawDataStr); } return("获取12小时红色预警值出错"); } return(""); }
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 { RType = Convert.ToByte(UserDataAll.Substring(16, 2), 16); } catch (Exception ex) { if (ShowLog) { logHelper.Error(ex.Message + Environment.NewLine + "获取遥测站类型出错" + " " + RawDataStr); } return("获取遥测站类型出错"); } try { IsSend = Convert.ToByte(UserDataAll.Substring(18, 2), 16); } catch (Exception ex) { if (ShowLog) { logHelper.Error(ex.Message + Environment.NewLine + "获取是否发送预警短信出错" + " " + RawDataStr); } return("获取是否发送预警短信出错"); } //kqz 2016-12-31 增加 try { NumAuthenType = Convert.ToByte(UserDataAll.Substring(20, 2), 16); } catch (Exception ex) { if (ShowLog) { logHelper.Error(ex.Message + Environment.NewLine + "获取电话加密方式出错" + " " + RawDataStr); } return("获取电话加密方式出错"); } //kqz 2016-12-31 增加 return(""); }