ActionFinishRtnPkg.cs 1.3 KB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mushiny.Model
{
    /// <summary>
    /// 动作完成 应答包:主要用于状态完成包的应答
    /// </summary>
    internal class ActionFinishRtnPkg:PkgData
    {
        /// <summary>
        /// 状态完成包的应答
        /// </summary>
        /// <param name="ok"></param>
        public ActionFinishRtnPkg(bool ok=true) : base() 
        {
            FrameHead = 0xbb;
            if(ok)
            {
                CmdWord = 0XA1;
            }
            else
            {
                CmdWord = 0xa0;
            }
        }
        /// <summary>
        /// 应答命令
        /// </summary>
        public byte ResponseCmd { get; set; }
        /// <summary>
        /// 保留
        /// </summary>
        public byte[] Reserved { get; set; }=new byte[4];
        public override byte[] ToBytes()
        {
            List<byte> bytes = new List<byte>(base.ToBytes())
            {
            };
            bytes.Add(ResponseCmd);
            bytes.AddRange(Reserved);
            calSendCrc(bytes);
            bytes.Add(CRC16Low);
            bytes.Add(CRC16Upper);
            return bytes.ToArray();
        }
    }
}