From b75bd3c4dd47afe9a1d2aaa14f0c3da9c0715ff0 Mon Sep 17 00:00:00 2001 From: Fey Date: Sun, 10 May 2026 12:23:41 +0200 Subject: [PATCH] Refactored FFTScan in the StreamReader interface. --- .../Drawing/RfFrequencyChartData.cs | 5 ++- .../CoopBlindscanStreamReaderProxy.cs | 3 +- .../SatIpWithStreamReaderProxy.cs | 9 ++-- skyscraper8/Skyscraper/IO/IStreamReader.cs | 17 ++++++- .../RemoteStreamReaderClient.cs | 45 +++++++++++++++++-- .../RemoteStreamReaderConstants.cs | 6 ++- .../IO/TunerInterface/NullTunerFactory.cs | 3 +- .../Storage/Filesystem/FilesystemStorage.cs | 7 ++- 8 files changed, 77 insertions(+), 18 deletions(-) diff --git a/skyscraper8/Skyscraper/Drawing/RfFrequencyChartData.cs b/skyscraper8/Skyscraper/Drawing/RfFrequencyChartData.cs index 2a13e01..4e0f001 100644 --- a/skyscraper8/Skyscraper/Drawing/RfFrequencyChartData.cs +++ b/skyscraper8/Skyscraper/Drawing/RfFrequencyChartData.cs @@ -119,11 +119,14 @@ namespace skyscraper8.Skyscraper.Drawing public double[] Data { get; private set; } - public void Push(int i, double rf) + public bool Push(int i, double rf) { i -= MinimumFrequency; i /= Step; + if (i >= Data.Length) + return false; Data[i] = rf; + return true; } } } diff --git a/skyscraper8/Skyscraper/FrequencyListGenerator/CoopBlindscanStreamReaderProxy.cs b/skyscraper8/Skyscraper/FrequencyListGenerator/CoopBlindscanStreamReaderProxy.cs index 394d2b0..1ebba15 100644 --- a/skyscraper8/Skyscraper/FrequencyListGenerator/CoopBlindscanStreamReaderProxy.cs +++ b/skyscraper8/Skyscraper/FrequencyListGenerator/CoopBlindscanStreamReaderProxy.cs @@ -250,8 +250,7 @@ namespace skyscraper8.Skyscraper.FrequencyListGenerator throw new NotImplementedException(); } - public bool FFTScan(int freq, int pol, int lof1, int lof2, int lofsw, uint range, byte mode, byte nb_acc, nint pTab, - nint pBegin, nint pNum) + public bool FFTScan(int freq, int pol, int lof1, int lof2, int lofsw, uint range, byte mode, byte nb_acc, uint[] pTab, ref uint pBegin, ref uint pNum) { throw new NotImplementedException(); } diff --git a/skyscraper8/Skyscraper/FrequencyListGenerator/SatIpWithStreamReaderProxy.cs b/skyscraper8/Skyscraper/FrequencyListGenerator/SatIpWithStreamReaderProxy.cs index f0b167c..04a19df 100644 --- a/skyscraper8/Skyscraper/FrequencyListGenerator/SatIpWithStreamReaderProxy.cs +++ b/skyscraper8/Skyscraper/FrequencyListGenerator/SatIpWithStreamReaderProxy.cs @@ -322,11 +322,10 @@ namespace skyscraper8.Skyscraper.FrequencyListGenerator public bool FFTInit() { throw new NotImplementedException(); - } - - public bool FFTScan(int freq, int pol, int lof1, int lof2, int lofsw, uint range, byte mode, byte nb_acc, nint pTab, - nint pBegin, nint pNum) - { + } + + public bool FFTScan(int freq, int pol, int lof1, int lof2, int lofsw, uint range, byte mode, byte nb_acc, uint[] pTab, ref uint pBegin, ref uint pNum) + { throw new NotImplementedException(); } diff --git a/skyscraper8/Skyscraper/IO/IStreamReader.cs b/skyscraper8/Skyscraper/IO/IStreamReader.cs index f7e6fe9..cf31871 100644 --- a/skyscraper8/Skyscraper/IO/IStreamReader.cs +++ b/skyscraper8/Skyscraper/IO/IStreamReader.cs @@ -236,7 +236,22 @@ namespace skyscraper5.Skyscraper.IO bool FFTInit(); - bool FFTScan(int freq, int pol, int lof1, int lof2, int lofsw, uint range, byte mode, byte nb_acc, IntPtr pTab, IntPtr pBegin, IntPtr pNum); + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// Set this to 5. This is a value known to work. + /// Set this to 255. This is a value known to work. + /// + /// + /// + /// + bool FFTScan(int freq, int pol, int lof1, int lof2, int lofsw, uint range, byte mode, byte nb_acc, uint[] pTab, ref uint pBegin, ref uint pNum); /// /// Given an approximate satellite frequency, tune to the nearest channel. diff --git a/skyscraper8/Skyscraper/IO/RemoteStreamReader/RemoteStreamReaderClient.cs b/skyscraper8/Skyscraper/IO/RemoteStreamReader/RemoteStreamReaderClient.cs index c234777..61f01df 100644 --- a/skyscraper8/Skyscraper/IO/RemoteStreamReader/RemoteStreamReaderClient.cs +++ b/skyscraper8/Skyscraper/IO/RemoteStreamReader/RemoteStreamReaderClient.cs @@ -524,13 +524,50 @@ namespace skyscraper5.Skyscraper.IO.RemoteStreamReader public bool FFTInit() { - throw new NotImplementedException(); + TcpStream.WriteUInt32BE((uint)RemoteStreamReaderConstants.REQUEST_FFT_INIT); + + RemoteStreamReaderConstants result = (RemoteStreamReaderConstants)(TcpStream.ReadUInt32BE()); + switch(result) + { + case RemoteStreamReaderConstants.COMMAND_SUCCESSFUL: + return true; + case RemoteStreamReaderConstants.COMMAND_FAILED: + return false; + default: + throw new NotImplementedException(result.ToString()); + } } - public bool FFTScan(int freq, int pol, int lof1, int lof2, int lofsw, uint range, byte mode, byte nb_acc, IntPtr pTab, - IntPtr pBegin, IntPtr pNum) + public bool FFTScan(int freq, int pol, int lof1, int lof2, int lofsw, uint range, byte mode, byte nb_acc, uint[] pTab, ref uint pBegin, ref uint pNum) { - throw new NotImplementedException(); + TcpStream.WriteUInt32BE((uint)RemoteStreamReaderConstants.REQUEST_FFT_SCAN); + TcpStream.WriteInt32BE(freq); + TcpStream.WriteInt32BE(pol); + TcpStream.WriteInt32BE(lof1); + TcpStream.WriteInt32BE(lof2); + TcpStream.WriteInt32BE(lofsw); + TcpStream.WriteUInt32BE(range); + TcpStream.WriteUInt8(mode); + TcpStream.WriteUInt8(nb_acc); + TcpStream.WriteInt32BE(pTab.Length); + + RemoteStreamReaderConstants result = (RemoteStreamReaderConstants)(TcpStream.ReadUInt32BE()); + switch (result) + { + case RemoteStreamReaderConstants.COMMAND_SUCCESSFUL: + pBegin = TcpStream.ReadUInt32BE(); + pNum = TcpStream.ReadUInt32BE(); + for (uint i = pBegin; i < pNum; i++) + { + pTab[i] = TcpStream.ReadUInt32BE(); + } + + return true; + case RemoteStreamReaderConstants.COMMAND_FAILED: + return false; + default: + throw new NotImplementedException(); + } } public bool BLScan(int freq, int freq_range, int pol, int lof1, int lof2, int lofsw, int minsr, diff --git a/skyscraper8/Skyscraper/IO/RemoteStreamReader/RemoteStreamReaderConstants.cs b/skyscraper8/Skyscraper/IO/RemoteStreamReader/RemoteStreamReaderConstants.cs index 73f52a6..7c4a498 100644 --- a/skyscraper8/Skyscraper/IO/RemoteStreamReader/RemoteStreamReaderConstants.cs +++ b/skyscraper8/Skyscraper/IO/RemoteStreamReader/RemoteStreamReaderConstants.cs @@ -42,6 +42,8 @@ REQUEST_SKYSCRAPER_ENGINE_NAME, REQUEST_SKYSCRAPER_ENGINE_VERSION, REQUEST_RF_SCAN_2, - REQUEST_FFT_TERM - } + REQUEST_FFT_TERM, + REQUEST_FFT_INIT, + REQUEST_FFT_SCAN + } } diff --git a/skyscraper8/Skyscraper/IO/TunerInterface/NullTunerFactory.cs b/skyscraper8/Skyscraper/IO/TunerInterface/NullTunerFactory.cs index c244cc4..e88a579 100644 --- a/skyscraper8/Skyscraper/IO/TunerInterface/NullTunerFactory.cs +++ b/skyscraper8/Skyscraper/IO/TunerInterface/NullTunerFactory.cs @@ -157,8 +157,7 @@ namespace skyscraper5.Skyscraper.IO.TunerInterface throw new NotImplementedException(); } - public bool FFTScan(int freq, int pol, int lof1, int lof2, int lofsw, uint range, byte mode, byte nb_acc, IntPtr pTab, - IntPtr pBegin, IntPtr pNum) + public bool FFTScan(int freq, int pol, int lof1, int lof2, int lofsw, uint range, byte mode, byte nb_acc, uint[] pTab, ref uint pBegin, ref uint pNum) { throw new NotImplementedException(); } diff --git a/skyscraper8/Skyscraper/Scraper/Storage/Filesystem/FilesystemStorage.cs b/skyscraper8/Skyscraper/Scraper/Storage/Filesystem/FilesystemStorage.cs index 50dafb0..7b8c393 100644 --- a/skyscraper8/Skyscraper/Scraper/Storage/Filesystem/FilesystemStorage.cs +++ b/skyscraper8/Skyscraper/Scraper/Storage/Filesystem/FilesystemStorage.cs @@ -1396,7 +1396,12 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.Filesystem public void DeleteRfSpectrum(Guid selectedGuid) { - throw new NotImplementedException(); + string filename = Path.Combine(rootDirectory.FullName, "rf", selectedGuid.ToString() + ".rf"); + FileInfo fi = new FileInfo(filename); + if (fi.Exists) + { + fi.Delete(); + } } public bool OtvSsuTestFile(int? currentNetworkId, int? currentTransportStreamId, int sourcePid, ushort tableIdExtension,