コード例 #1
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_04 != null)
                {
                    sb.Append(Iden_04.ToString());
                }
                else
                {
                    sb.Append("时间步长码解析出错!");
                }

                if (Idens != null && Idens.Count > 0)
                {
                    foreach (Identifier id in Idens)
                    {
                        sb.Append(id.ToString());
                    }
                }
                else
                {
                    sb.Append("数据解析失败!");
                }
                return(sb.ToString().TrimEnd(','));
            }
            catch
            {
                return("【" + EnumUtils.GetDescription(typeof(WaterBaseProtocol.AFN), AFN) + "】:" + " ToString error");
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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);
        }