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(0xa4,"TIM")]
	public class _0xa4_SyncAssignDescriptor : TsDescriptor
	{
		public _0xa4_SyncAssignDescriptor(byte[] buffer)
		{
			MemoryStream ms = new MemoryStream(buffer, false);
			SyncAchievedTimeThreshold = ms.ReadUInt8();
			MaxSyncTries = ms.ReadUInt8();
			SyncAchievedFrequencyThreshold = ms.ReadUInt16BE();
			SyncStartSuperframe = ms.ReadUInt16BE();
			SyncFrameNumber = (ms.ReadUInt8() & 0x1f);
			SyncRepeatPeriod = ms.ReadUInt16BE();
			SyncSlotNumber = (ms.ReadUInt16BE() & 0x07ff);
			Valid = true;
		}

		public byte SyncAchievedTimeThreshold { get; }
		public byte MaxSyncTries { get; }
		public ushort SyncAchievedFrequencyThreshold { get; }
		public ushort SyncStartSuperframe { get; }
		public int SyncFrameNumber { get; }
		public ushort SyncRepeatPeriod { get; }
		public int SyncSlotNumber { get; }

		public override string ToString()
		{
			return String.Format("Sync Assign for Slot {0}", SyncSlotNumber);
		}
	}
}
