PathDataRtnPkg.cs 1.5 KB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mushiny.Model
{
    /// <summary>
    /// 路径应答包:主要用于路径包的应答
    /// AGV->RCS
    /// </summary>
    internal class PathDataRtnPkg : PkgData
    {
        public PathDataRtnPkg() : base()
        {
        }

        public bool IsOK()
        {
            if (CmdWord == 0xa0)
                return false;
            else if (CmdWord == 0xa1)
                return true;
            return false;
        }
        /// <summary>
        /// 保留
        /// </summary>
        public byte Reserved { get; set; }
        /// <summary>
        /// 路径的时间戳
        /// </summary>
        public uint PathTimeStamp { get; set; }
        public override bool Parse(byte[] bytes)
        {
            bool result = false;
            try
            {
                if (base.Parse(bytes))
                {
                    if (bytes.Length < 19)
                    {
                        return false;
                    }
                    Reserved = Common.GetSubBytes(bytes, 12, 1)[0];
                    PathTimeStamp = Common.ConvertToUInt(Common.GetSubBytes(bytes, 13, 4));
                    result = true;
                }
                else
                {
                    result = false;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return result;
        }
    }
}