namespace InABox.DigitalMatter
{
    public class DMDigitalDataField : DMField
    {
        public override byte Type => 0x02;

        public uint Inputs { get; set; }

        public ushort Outputs { get; set; }

        public ushort Status { get; set; }

        protected override void DoDecode()
        {
            Inputs = TakeUInt32();
            Outputs = TakeUInt16();
            Status = TakeUInt16();
        }

        protected override void DoEncode()
        {
            AddUInt32(Inputs);
            AddUInt16(Outputs);
            AddUInt16(Status);
        }

        public override string ToString()
        {
            return string.Format("In: {0:X8} Out: {1:X4} Status: {2:X4}", Inputs, Outputs, Status);
        }

        public override bool IsValid()
        {
            return Inputs != 0 || Outputs != 0 || Status != 0;
        }
    }
}