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

namespace skyscraper5.src.InteractionChannel.Model.Descriptors
{
	[SkyscraperPlugin]
	[TsDescriptor(0xa3,"TIM")]
	internal class _0xa3_AcqAssignDescriptor : TsDescriptor
	{
		public _0xa3_AcqAssignDescriptor(byte[] buffer)
		{
			MemoryStream ms = new MemoryStream(buffer, false);
			AchievedTimeThreshold = ms.ReadUInt8();
			AchievedFrequencyThreshold = ms.ReadUInt16BE();
			Repeats = ms.ReadUInt8() & 0x3f;
			StartSuperframe = ms.ReadUInt16BE();
			FrameNumber = ms.ReadUInt8() & 0x1f;
			RepeatPeriod = ms.ReadUInt8() & 0x3f;
			SlotNumber = ms.ReadUInt16BE() & 0x07ff;
			Valid = true;
		}

		public byte AchievedTimeThreshold { get; }
		public ushort AchievedFrequencyThreshold { get; }
		public int Repeats { get; }
		public ushort StartSuperframe { get; }
		public int FrameNumber { get; }
		public int RepeatPeriod { get; }
		public int SlotNumber { get; }

		public override string ToString()
		{
			return String.Format("ACQ Assign Slot {0}", SlotNumber);
		}
	}
}
