public static string GetMsgList_WriteMsg(WaterBaseMessage wbm, string UserDataAll, out byte[] UserDataBytesAll, out WaterBaseMessage[] MsgList)
        {
            UserDataBytesAll = HexStringUtility.HexStringToByteArray(UserDataAll);

            wbm.DataBeginChar = (byte)WaterBaseProtocol.DataBeginChar.STX;
            if (UserDataBytesAll.Length > WaterBaseProtocol.PocketSize)
            {
                wbm.TotalPackage  = (UserDataBytesAll.Length - 1) / WaterBaseProtocol.PocketSize + 1;
                wbm.DataBeginChar = (byte)WaterBaseProtocol.DataBeginChar.SYN;
            }
            else
            {
                wbm.TotalPackage = 1;
            }
            MsgList = new WaterBaseMessage[wbm.TotalPackage];

            for (int i = 0; i < wbm.TotalPackage; i++)
            {
                WaterBaseMessage bm = new WaterBaseMessage();
                bm.CenterStation  = wbm.CenterStation;
                bm.RemoteStation  = wbm.RemoteStation;
                bm.PW             = wbm.PW;
                bm.AFN            = wbm.AFN;
                bm.UpOrDown       = wbm.UpOrDown;
                bm.TotalPackage   = wbm.TotalPackage;
                bm.CurrentPackage = i + 1;
                bm.DataBeginChar  = wbm.DataBeginChar;
                byte[] bs = null;
                if (i == wbm.TotalPackage - 1)
                {
                    bs = new byte[UserDataBytesAll.Length - WaterBaseProtocol.PocketSize * i];
                    wbm.DataEndChar = (byte)WaterBaseProtocol.DataEndChar_Up.ETX;
                }
                else
                {
                    bs = new byte[WaterBaseProtocol.PocketSize];
                    wbm.DataEndChar = (byte)WaterBaseProtocol.DataEndChar_Up.ETB;
                }
                bm.DataEndChar = wbm.DataEndChar;
                Array.Copy(UserDataBytesAll, WaterBaseProtocol.PocketSize * i, bs, 0, bs.Length);
                bm.UserDataBytes = bs;

                string msg = bm.WriteMsgBase();
                if (msg == "")
                {
                    MsgList[i] = bm;
                }
                else
                {
                    MsgList = null;
                    return((i + 1) + ":" + msg);
                }
            }

            return("");
        }
        public string WriteMsg()
        {
            UserDataAll += SerialNumber.ToString("X").PadLeft(4, '0');
            UserDataAll += SendTime.ToString("yyMMddHHmmss").PadLeft(12, '0');

            UserDataBytesAll = HexStringUtility.HexStringToByteArray(UserDataAll);

            DataBeginChar = (byte)WaterBaseProtocol.DataBeginChar.STX;
            if (UserDataBytesAll.Length > WaterBaseProtocol.PocketSize)
            {
                TotalPackage  = (UserDataBytesAll.Length - 1) / WaterBaseProtocol.PocketSize + 1;
                DataBeginChar = (byte)WaterBaseProtocol.DataBeginChar.SYN;
            }
            else
            {
                TotalPackage = 1;
            }
            MsgList = new WaterBaseMessage[TotalPackage];

            for (int i = 0; i < TotalPackage; i++)
            {
                WaterBaseMessage bm = new WaterBaseMessage();
                bm.CenterStation  = this.CenterStation;
                bm.RemoteStation  = this.RemoteStation;
                bm.PW             = this.PW;
                bm.AFN            = this.AFN;
                bm.UpOrDown       = this.UpOrDown;
                bm.TotalPackage   = this.TotalPackage;
                bm.CurrentPackage = i + 1;
                bm.DataBeginChar  = this.DataBeginChar;
                byte[] bs = null;
                if (i == TotalPackage - 1)
                {
                    bs          = new byte[UserDataBytesAll.Length - WaterBaseProtocol.PocketSize * i];
                    DataEndChar = (byte)WaterBaseProtocol.DataEndChar_Up.ETX;
                }
                else
                {
                    bs          = new byte[WaterBaseProtocol.PocketSize];
                    DataEndChar = (byte)WaterBaseProtocol.DataEndChar_Up.ETB;
                }
                bm.DataEndChar = this.DataEndChar;
                Array.Copy(UserDataBytesAll, WaterBaseProtocol.PocketSize * i, bs, 0, bs.Length);
                bm.UserDataBytes = bs;
                //bm.UserData = HexStringUtility.ByteArrayToHexString(bs);

                string msg = bm.WriteMsgBase();
                if (msg == "")
                {
                    MsgList[i] = bm;
                }
                else
                {
                    MsgList = null;
                    if (ShowLog)
                    {
                        logHelper.Error((i + 1) + ":" + msg);
                    }
                    return((i + 1) + ":" + msg);
                }
            }

            return("");
        }