using ProjectManagementSystem.Device.Core;
using ProjectManagementSystem.Device.Extenions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProjectManagementSystem.Device.Command
{
    public class Command1071 : IDeviceCommand
    {
        private byte[] buffer = new byte[10] { 0x10, 0x71, 0, 0, 0, 0, 0, 0, 0, 0x03 };

        public byte AgvId { get; set; }
        public byte Function { get; set; }
        public byte Operation { get; set; }
        public byte Speed { get; set; }

        public virtual byte[] Serialization()
        {
            buffer[1] = Function;
            buffer[2] = AgvId;
            if (Operation >= 0 && Operation < 8)
            {
                buffer[3] = Convert.ToByte((1 << Operation) | 0x00);
            }
            buffer[4] = Convert.ToByte(Speed);
            buffer[8] = buffer.XOR_Check(8);

            return buffer;
        }
    }
}
