using PlcSiemens.O;
using PlcSiemens.Protocol.Common;

namespace PlcSiemens.Protocol.ListBlocks
{
    public class BotItemListAll
    {
        public ResultCode Ret { get; set; }
        public byte Size { get; set; }
        public ushort Length { get; set; }
        public BotItem[] Items { get; set; }

        public void Build(ByteBuffer buffer)
        {
            Ret = (ResultCode)buffer.PopByte();
            Size = buffer.PopByte();
            Length = buffer.PopUshort();
            Items = new BotItem[Length / 4];

            for (int i = 0; i < Length / 4; i++)
            {
                var tmp = new BotItem();
                tmp.Build(buffer);
                Items[i] = tmp;
            }
        }
    }
}
