From d69c4cda684ece8f2858f181c599aac06ad75d2d Mon Sep 17 00:00:00 2001 From: feyris-tan <4116042+feyris-tan@users.noreply.github.com> Date: Sat, 18 Oct 2025 00:06:38 +0200 Subject: [PATCH] Implemented FCT2 and TBTP2. --- .../InteractionChannelHandler.cs | 4 +- .../InteractionChannelPsiGatherer.cs | 4 +- skyscraper8/InteractionChannel/Model2/Fct2.cs | 59 ++++++++++++++++++- .../InteractionChannel/Model2/Tbtp2.cs | 2 +- .../NullInteractionChannelHandler.cs | 28 ++++----- skyscraper8/Properties/launchSettings.json | 2 +- .../Skyscraper/Scraper/SkyscraperContext.cs | 19 ++++++ .../Scraper/SkyscraperContextEvent.cs | 3 +- .../Skyscraper/Scraper/Storage/DataStorage.cs | 3 + .../Storage/Filesystem/FilesystemStorage.cs | 11 ++++ .../InMemory/InMemoryScraperStorage.cs | 20 +++++++ .../InteractionChannelContestant.cs | 11 +++- 12 files changed, 144 insertions(+), 22 deletions(-) diff --git a/skyscraper8/InteractionChannel/InteractionChannelHandler.cs b/skyscraper8/InteractionChannel/InteractionChannelHandler.cs index e189686..2a34fa4 100644 --- a/skyscraper8/InteractionChannel/InteractionChannelHandler.cs +++ b/skyscraper8/InteractionChannel/InteractionChannelHandler.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Net.NetworkInformation; using System.Text; using System.Threading.Tasks; +using skyscraper5.src.InteractionChannel.Model2; namespace skyscraper5.src.InteractionChannel { @@ -28,5 +29,6 @@ namespace skyscraper5.src.InteractionChannel int GetRmtTransmissionStandard(ushort networkId); void OnReturnTransmissionMOdes(PhysicalAddress macAddress, _0xb2_ReturnTransmissionModesDescriptor descriptor); void OnConnectionControl(PhysicalAddress macAddress, _0xaf_ConnectionControlDescriptor descriptor); - } + void OnTerminalBurstTimePlan2(ushort interactiveNetworkId, Tbtp2 tbtp2); + } } diff --git a/skyscraper8/InteractionChannel/InteractionChannelPsiGatherer.cs b/skyscraper8/InteractionChannel/InteractionChannelPsiGatherer.cs index 761c9bc..1c84f37 100644 --- a/skyscraper8/InteractionChannel/InteractionChannelPsiGatherer.cs +++ b/skyscraper8/InteractionChannel/InteractionChannelPsiGatherer.cs @@ -222,7 +222,9 @@ namespace skyscraper5.src.InteractionChannel _handler.OnInteractionChannelError(InteractionChannelErrorState.Tbtp2Invalid); return; } - throw new NotImplementedException("TBTP2"); + + _handler.OnTerminalBurstTimePlan2(tbtp2Header.InteractiveNetworkId, tbtp2); + break; case 0xAE: //TMST2 InteractionChannelSiSectionHeader tmst2Header = new InteractionChannelSiSectionHeader(ms); if (!tmst2Header.Valid) diff --git a/skyscraper8/InteractionChannel/Model2/Fct2.cs b/skyscraper8/InteractionChannel/Model2/Fct2.cs index d1879f6..4f38348 100644 --- a/skyscraper8/InteractionChannel/Model2/Fct2.cs +++ b/skyscraper8/InteractionChannel/Model2/Fct2.cs @@ -5,6 +5,7 @@ using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; +using skyscraper5.Skyscraper.IO; namespace skyscraper5.src.InteractionChannel.Model2 { @@ -12,7 +13,63 @@ namespace skyscraper5.src.InteractionChannel.Model2 { public Fct2(MemoryStream ms) { - throw new NotImplementedException(); + byte frameTypeLoopCount = ms.ReadUInt8(); + FrameTypes = new Frame[frameTypeLoopCount]; + for (int i = 0; i < frameTypeLoopCount; i++) + { + FrameTypes[i] = new Frame(); + FrameTypes[i].FrameType = ms.ReadUInt8(); + FrameTypes[i].FrameDuration = ms.ReadUInt32BE(); + FrameTypes[i].TxFormatClass = ms.ReadUInt8(); + FrameTypes[i].BtuDuration = ms.ReadUInt24BE(); + FrameTypes[i].BtuCarrierBw = ms.ReadUInt24BE(); + FrameTypes[i].BtuSymbolRate = ms.ReadUInt24BE(); + FrameTypes[i].TimeUnitCount = ms.ReadUInt16BE(); + + byte gridRepeatCount = ms.ReadUInt8(); + FrameTypes[i].GridFrequencyOffset = new uint[gridRepeatCount]; + for (int j = 0; j < gridRepeatCount; j++) + { + if (ms.GetAvailableBytes() < 2) + { + Valid = false; + return; + } + FrameTypes[i].GridFrequencyOffset[j] = ms.ReadUInt24BE(); + } + + byte sectionLoopCount = ms.ReadUInt8(); + FrameTypes[i].SectionLoop = new SectionLoop[sectionLoopCount]; + for (int j = 0; j < sectionLoopCount; j++) + { + FrameTypes[i].SectionLoop[j].DefaultTxType = ms.ReadUInt8(); + FrameTypes[i].SectionLoop[j].FixedAccessMethod = (ms.ReadUInt8() & 0x0f); + FrameTypes[i].SectionLoop[j].RepeatCount = ms.ReadUInt16BE(); + } + } + + Valid = true; + } + + public Frame[] FrameTypes { get; private set; } + public class Frame + { + public byte FrameType { get; set; } + public uint FrameDuration { get; set; } + public byte TxFormatClass { get; set; } + public uint BtuDuration { get; set; } + public uint BtuCarrierBw { get; set; } + public uint BtuSymbolRate { get; set; } + public ushort TimeUnitCount { get; set; } + public uint[] GridFrequencyOffset { get; set; } + public SectionLoop[] SectionLoop { get; set; } + } + + public class SectionLoop + { + public byte DefaultTxType { get; set; } + public int FixedAccessMethod { get; set; } + public ushort RepeatCount { get; set; } } } } diff --git a/skyscraper8/InteractionChannel/Model2/Tbtp2.cs b/skyscraper8/InteractionChannel/Model2/Tbtp2.cs index 54b8c0b..ce9c0fd 100644 --- a/skyscraper8/InteractionChannel/Model2/Tbtp2.cs +++ b/skyscraper8/InteractionChannel/Model2/Tbtp2.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; namespace skyscraper5.src.InteractionChannel.Model2 { - internal class Tbtp2 : Validatable + public class Tbtp2 : Validatable { public Tbtp2(MemoryStream ms) { diff --git a/skyscraper8/InteractionChannel/NullInteractionChannelHandler.cs b/skyscraper8/InteractionChannel/NullInteractionChannelHandler.cs index 836625c..ea1b879 100644 --- a/skyscraper8/InteractionChannel/NullInteractionChannelHandler.cs +++ b/skyscraper8/InteractionChannel/NullInteractionChannelHandler.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Net.NetworkInformation; using System.Text; using System.Threading.Tasks; +using skyscraper5.src.InteractionChannel.Model2; namespace skyscraper5.src.InteractionChannel { @@ -21,6 +22,11 @@ namespace skyscraper5.src.InteractionChannel { } + public void OnTerminalBurstTimePlan2(ushort interactiveNetworkId, Tbtp2 tbtp2) + { + + } + public void OnContentionControl(PhysicalAddress macAddress, _0xab_ContentionControlDescriptor ccd) { } @@ -29,6 +35,11 @@ namespace skyscraper5.src.InteractionChannel { } + public void OnNetworkLayerInfo(PhysicalAddress macAddress, _0xa0_NetworkLayerInfoDescriptor descriptor) + { + + } + public void OnCorrectionMessage(ushort interactiveNetworkId, Cmt cmt) { } @@ -44,16 +55,7 @@ namespace skyscraper5.src.InteractionChannel public void OnInteractionChannelError(InteractionChannelErrorState unexpectedTable) { } - - public void OnNetworkLayerInfo(PhysicalAddress macAddress, TsDescriptor descriptor) - { - } - - public void OnNetworkLayerInfo(PhysicalAddress macAddress, _0xa0_NetworkLayerInfoDescriptor descriptor) - { - throw new NotImplementedException(); - } - + public void OnRcsMap(Rmt rmt) { } @@ -73,11 +75,7 @@ namespace skyscraper5.src.InteractionChannel public void OnTerminalBurstTimePlan(ushort interactiveNetworkId, Tbtp tbtp) { } - - public void OnTerminalInformation(PhysicalAddress macAddress, Tim tim) - { - } - + public void OnTimeslotComposition(ushort interactiveNetworkId, Tct tct) { } diff --git a/skyscraper8/Properties/launchSettings.json b/skyscraper8/Properties/launchSettings.json index d2912aa..6e6d2e0 100644 --- a/skyscraper8/Properties/launchSettings.json +++ b/skyscraper8/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "skyscraper8": { "commandName": "Project", - "commandLineArgs": "C:\\devel\\skyscraper8\\skyscraper8\\bin\\Debug\\net8.0\\11049v.ts", + "commandLineArgs": "C:\\devel\\skyscraper8\\skyscraper8\\bin\\Debug\\net8.0\\638963394655023111.ts", "remoteDebugEnabled": false }, "Container (Dockerfile)": { diff --git a/skyscraper8/Skyscraper/Scraper/SkyscraperContext.cs b/skyscraper8/Skyscraper/Scraper/SkyscraperContext.cs index e85b738..36e2d3d 100644 --- a/skyscraper8/Skyscraper/Scraper/SkyscraperContext.cs +++ b/skyscraper8/Skyscraper/Scraper/SkyscraperContext.cs @@ -76,6 +76,7 @@ using System.Net; using System.Net.NetworkInformation; using System.Security.Policy; using System.Text; +using skyscraper5.src.InteractionChannel.Model2; using skyscraper8.Experimentals.NdsSsu; using skyscraper8.Experimentals.OtvSsu; using skyscraper8.GSE; @@ -2396,6 +2397,22 @@ namespace skyscraper5.Skyscraper.Scraper } } + public void OnTerminalBurstTimePlan2(ushort interactiveNetworkId, Tbtp2 tbtp2) + { + foreach (Tbtp2.Frame frame in tbtp2.Frames) + { + for (int assignmentOrdinal = 0; assignmentOrdinal < frame.Assignments.Length; assignmentOrdinal++) + { + Tbtp2.Assignment assignment = frame.Assignments[assignmentOrdinal]; + if (!DataStorage.TestForTerminalBurstTimePlan2(interactiveNetworkId, tbtp2.GroupId, frame.FrameNumber)) + { + LogEvent(SkyscraperContextEvent.TerminalBurstTimePlan2, String.Format("Network ID = {0}, Group ID = {1}, Frame Number = {2}",interactiveNetworkId,tbtp2.GroupId,frame.FrameNumber)); + DataStorage.StoreTerminalBurstTimePlan2(interactiveNetworkId, tbtp2.GroupId, frame); + } + } + } + } + void InteractionChannelHandler.OnTimeslotComposition(ushort interactiveNetworkId, Tct tct) { throw new NotImplementedException(); @@ -3009,5 +3026,7 @@ namespace skyscraper5.Skyscraper.Scraper { //TODO: Implement this. } + + } } diff --git a/skyscraper8/Skyscraper/Scraper/SkyscraperContextEvent.cs b/skyscraper8/Skyscraper/Scraper/SkyscraperContextEvent.cs index f3869a7..d0b6f3c 100644 --- a/skyscraper8/Skyscraper/Scraper/SkyscraperContextEvent.cs +++ b/skyscraper8/Skyscraper/Scraper/SkyscraperContextEvent.cs @@ -85,6 +85,7 @@ OtvSsuFileDetected, OtvSsuComplete, NdsSsuFileAnnounced, - NdsSsuProgress + NdsSsuProgress, + TerminalBurstTimePlan2 } } diff --git a/skyscraper8/Skyscraper/Scraper/Storage/DataStorage.cs b/skyscraper8/Skyscraper/Scraper/Storage/DataStorage.cs index 169f456..28e5ddb 100644 --- a/skyscraper8/Skyscraper/Scraper/Storage/DataStorage.cs +++ b/skyscraper8/Skyscraper/Scraper/Storage/DataStorage.cs @@ -27,6 +27,7 @@ using skyscraper8.DvbNip; using skyscraper8.Ses; using System.Net; using System.Net.NetworkInformation; +using skyscraper5.src.InteractionChannel.Model2; using Platform = skyscraper5.Dvb.SystemSoftwareUpdate.Model.Platform; namespace skyscraper8.Skyscraper.Scraper.Storage @@ -193,5 +194,7 @@ namespace skyscraper8.Skyscraper.Scraper.Storage IEnumerable> GetBlindscanResultFrequencies(Guid selectedGuid); void InsertUiBlindscanSettingHistory(int settingsWindowBlScanTunerSelection, int settingsWindowUseDifferentTunerForSetFilter, int settingsWindowSetFilterTunerSelection, int settingsWindowDiseqc, bool settingsWindowCollectIqGraphs, bool settingsWindowCollectRfSpectrum, bool settingsWindowCaptureFile, int settingsWindowSatellite, int settingsWindowLnb, int dish, bool settingsWindowScanHorizontalLow, bool settingsWindowScanHorizontalHigh, bool settingsWindowScanVerticalLow, bool settingsWindowScanVerticalHigh); object[] GetLastUiBlindscanSettings(); + bool TestForTerminalBurstTimePlan2(ushort interactiveNetworkId, byte tbtp2GroupId, byte frameFrameNumber); + void StoreTerminalBurstTimePlan2(ushort interactiveNetworkId, byte tbtp2GroupId, Tbtp2.Frame frame); } } diff --git a/skyscraper8/Skyscraper/Scraper/Storage/Filesystem/FilesystemStorage.cs b/skyscraper8/Skyscraper/Scraper/Storage/Filesystem/FilesystemStorage.cs index bba180d..becfd08 100644 --- a/skyscraper8/Skyscraper/Scraper/Storage/Filesystem/FilesystemStorage.cs +++ b/skyscraper8/Skyscraper/Scraper/Storage/Filesystem/FilesystemStorage.cs @@ -29,6 +29,7 @@ using skyscraper5.Skyscraper.Scraper.Storage.InMemory.Model; using skyscraper5.Skyscraper.Scraper.Storage.Utilities; using skyscraper5.src.InteractionChannel.Model; using skyscraper5.src.InteractionChannel.Model.Descriptors; +using skyscraper5.src.InteractionChannel.Model2; using skyscraper5.src.Skyscraper.FrequencyListGenerator; using skyscraper5.src.Skyscraper.Scraper.Dns; using skyscraper5.src.Skyscraper.Scraper.Storage.InMemory; @@ -1155,6 +1156,16 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.Filesystem return null; } + public bool TestForTerminalBurstTimePlan2(ushort interactiveNetworkId, byte tbtp2GroupId, byte frameFrameNumber) + { + throw new NotImplementedException(); + } + + public void StoreTerminalBurstTimePlan2(ushort interactiveNetworkId, byte tbtp2GroupId, Tbtp2.Frame frame) + { + throw new NotImplementedException(); + } + public IEnumerable> SelectAllPmt() { throw new NotImplementedException(); diff --git a/skyscraper8/Skyscraper/Scraper/Storage/InMemory/InMemoryScraperStorage.cs b/skyscraper8/Skyscraper/Scraper/Storage/InMemory/InMemoryScraperStorage.cs index 9441e6a..bc4d6db 100644 --- a/skyscraper8/Skyscraper/Scraper/Storage/InMemory/InMemoryScraperStorage.cs +++ b/skyscraper8/Skyscraper/Scraper/Storage/InMemory/InMemoryScraperStorage.cs @@ -36,6 +36,7 @@ using System.IO; using System.Linq; using System.Net; using System.Net.NetworkInformation; +using skyscraper5.src.InteractionChannel.Model2; using skyscraper8.Ietf.FLUTE; using skyscraper8.Skyscraper.Scraper.Storage; using skyscraper8.Skyscraper.Scraper.Storage.Utilities; @@ -966,6 +967,25 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory throw new NotImplementedException(); } + private Dictionary, Tbtp2.Frame> _tbtp2; + public bool TestForTerminalBurstTimePlan2(ushort interactiveNetworkId, byte tbtp2GroupId, byte frameFrameNumber) + { + if (_tbtp2 == null) + return false; + + Tuple key = new Tuple(interactiveNetworkId, tbtp2GroupId, frameFrameNumber); + return _tbtp2.ContainsKey(key); + } + + public void StoreTerminalBurstTimePlan2(ushort interactiveNetworkId, byte tbtp2GroupId, Tbtp2.Frame frame) + { + if (_tbtp2 == null) + _tbtp2 = new Dictionary, Tbtp2.Frame>(); + + Tuple key = new Tuple(interactiveNetworkId, tbtp2GroupId, frame.FrameNumber); + _tbtp2.Add(key, frame); + } + public IEnumerable> SelectAllPmt() { for (int x = 0; x < pmtEntries.Length; x++) diff --git a/skyscraper8/Skyscraper/Scraper/StreamAutodetection/Contestants/InteractionChannelContestant.cs b/skyscraper8/Skyscraper/Scraper/StreamAutodetection/Contestants/InteractionChannelContestant.cs index f2b2b06..bfd8d19 100644 --- a/skyscraper8/Skyscraper/Scraper/StreamAutodetection/Contestants/InteractionChannelContestant.cs +++ b/skyscraper8/Skyscraper/Scraper/StreamAutodetection/Contestants/InteractionChannelContestant.cs @@ -11,6 +11,7 @@ using System.Linq; using System.Net.NetworkInformation; using System.Text; using System.Threading.Tasks; +using skyscraper5.src.InteractionChannel.Model2; namespace skyscraper5.src.Skyscraper.Scraper.StreamAutodetection.Contestants { @@ -183,5 +184,13 @@ namespace skyscraper5.src.Skyscraper.Scraper.StreamAutodetection.Contestants { Score++; } - } + + public void OnTerminalBurstTimePlan2(ushort interactiveNetworkId, Tbtp2 tbtp2) + { + if (tbtp2.Frames.Length > 0) + { + Score++; + } + } + } }