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 CommandIO : IDeviceCommand
    {
        public byte TargetID { get; set; }
        public ushort Output { get; set; }

        protected byte[] buffer = new byte[14] { 0x10, 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x03 };

        public byte[] Serialization()
        {
            var OutputBytes = BitConverter.GetBytes(Output);

            buffer[2] = TargetID;
            buffer[3] = OutputBytes[1];
            buffer[4] = OutputBytes[0];
            buffer[12] = buffer.XOR_Check(12);//异或

            return buffer;
        }
    }
}
