public string WriteMsg() { try { if (Iden_04 == null) { return("时间步长码出错"); } if (Iden == null) { return("要素标识符非法"); } UserData = ""; UserData += SerialNumber.ToString("X").PadLeft(4, '0'); UserData += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0'); UserData += StartTime.ToString("yyMMddHH").PadLeft(8, '0'); UserData += EndTime.ToString("yyMMddHH").PadLeft(8, '0'); UserData += Iden_04.GetHexStr(); UserData += Iden.GetHexStrHead(); UserDataBytes = HexStringUtility.HexStringToByteArray(UserData); return(WriteMsgBase()); } catch (Exception ex) { return(ex.Message); } }
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); }