using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using skyscraper5.DsmCc;
using skyscraper5.Dvb.DataBroadcasting.Biop;
using skyscraper5.Skyscraper.IO;

namespace skyscraper5.Dvb.DataBroadcasting.Dsm
{
    class ConnBinder
    {
        public ConnBinder(MemoryStream ms)
        {
            if (ms.ReadUInt32BE() != 0x49534F40)
            {
                throw new DvbException("invalid magic");
            }

            byte componentDataLength = ms.ReadUInt8();
            byte tapsCount = ms.ReadUInt8();
            OriginTap = new Tap(ms);

            BranchTaps = new Tap[tapsCount - 1];
            for (int i = 0; i < BranchTaps.Length; i++)
            {
                BranchTaps[i] = new Tap(ms);
            }

        }

        public Tap OriginTap { get; private set; }

        public Tap[] BranchTaps { get; private set; }
    }
}
