using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using skyscraper5.Skyscraper;
using skyscraper5.Skyscraper.IO;

namespace skyscraper8.InteractionChannel.Model2
{
	/// <summary>
	/// Broadcast Configuration Table as found on ETSI EN 301 545-2 V1.4.1, page 59
	/// </summary>
	public class Bct : Validatable
	{
		public Bct(MemoryStream ms)
		{
			byte loopCount = ms.ReadUInt8();
			TxTypes = new BroadcastConfiguration[loopCount];
			for (int i = 0; i < loopCount; i++)
			{
				TxTypes[i] = new BroadcastConfiguration();
				TxTypes[i].TxType = ms.ReadUInt8();
				TxTypes[i].TxContentType = ms.ReadUInt8();
				TxTypes[i].TxFormatClass = ms.ReadUInt8();
				byte txFormatDataLengnth = ms.ReadUInt8();
				TxTypes[i].TxFormatData = ms.ReadBytes(txFormatDataLengnth);
			}

			Valid = true;
		}

		public BroadcastConfiguration[] TxTypes { get; private set; }

		public class BroadcastConfiguration
		{
			public byte TxType { get; set; }
			public byte TxContentType { get; set; }
			public byte TxFormatClass { get; set; }
			public byte[] TxFormatData { get; set; }
		}
	}
}
