diff --git a/skyscraper8.sln.DotSettings.user b/skyscraper8.sln.DotSettings.user
index f9ac6e8..7f44235 100644
--- a/skyscraper8.sln.DotSettings.user
+++ b/skyscraper8.sln.DotSettings.user
@@ -40,17 +40,17 @@
<Assembly Path="/home/schiemas/.nuget/packages/allure.net.commons/2.14.1/lib/netstandard2.0/Allure.Net.Commons.dll" />
</AssemblyExplorer>
/home/schiemas/.cache/JetBrains/Rider2025.1/resharper-host/temp/Rider/vAny/CoverageData/_skyscraper8.1808907683/Snapshot/snapshot.utdcvr
- <SessionState ContinuousTestingMode="0" Name="All tests from <skyscraper8.Tests>" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
- <And>
- <Namespace>skyscraper8.Tests</Namespace>
- <Project Location="\home\schiemas\RiderProjects\skyscraper8\skyscraper8.Tests" Presentation="<skyscraper8.Tests>" />
- </And>
+ <SessionState ContinuousTestingMode="0" Name="All tests from <skyscraper8.Tests>" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
+ <And>
+ <Namespace>skyscraper8.Tests</Namespace>
+ <Project Location="\home\schiemas\RiderProjects\skyscraper8\skyscraper8.Tests" Presentation="<skyscraper8.Tests>" />
+ </And>
</SessionState>
- <SessionState ContinuousTestingMode="0" Name="Continuous Testing" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
- <Project Location="\home\schiemas\RiderProjects\skyscraper8\skyscraper8.Tests" Presentation="<skyscraper8.Tests>" />
+ <SessionState ContinuousTestingMode="0" Name="Continuous Testing" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
+ <Project Location="\home\schiemas\RiderProjects\skyscraper8\skyscraper8.Tests" Presentation="<skyscraper8.Tests>" />
</SessionState>
- <SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from <skyscraper8.Tests>" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
- <Solution />
+ <SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from <skyscraper8.Tests>" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
+ <Solution />
</SessionState>
diff --git a/skyscraper8/Experimentals/NdsSsu/NdsSsuParser.cs b/skyscraper8/Experimentals/NdsSsu/NdsSsuParser.cs
index 6a95467..a82d939 100644
--- a/skyscraper8/Experimentals/NdsSsu/NdsSsuParser.cs
+++ b/skyscraper8/Experimentals/NdsSsu/NdsSsuParser.cs
@@ -286,6 +286,14 @@ namespace skyscraper8.Experimentals.NdsSsu
}
}
+ public byte[] WriteToByteArray()
+ {
+ byte[] buffer = new byte[CalculateLength()];
+ MemoryStream ms = new MemoryStream(buffer);
+ WriteToStream(ms);
+ return ms.GetBuffer();
+ }
+
public void Dispose()
{
for (int x = 0; x < superblocks.Length; x++)
diff --git a/skyscraper8/Skyscraper/Drawing/IqChartData.cs b/skyscraper8/Skyscraper/Drawing/IqChartData.cs
index 61ab365..515cec5 100644
--- a/skyscraper8/Skyscraper/Drawing/IqChartData.cs
+++ b/skyscraper8/Skyscraper/Drawing/IqChartData.cs
@@ -101,6 +101,13 @@ namespace skyscraper8.Skyscraper.Drawing
}
}
+ public byte[] SaveToBytes()
+ {
+ MemoryStream ms = new MemoryStream();
+ SaveTo(ms);
+ return ms.GetBuffer();
+ }
+
private bool scaled;
public void AutoScale()
{
diff --git a/skyscraper8/Skyscraper/Drawing/RfFrequencyChartData.cs b/skyscraper8/Skyscraper/Drawing/RfFrequencyChartData.cs
index 2aa4c07..3884e2d 100644
--- a/skyscraper8/Skyscraper/Drawing/RfFrequencyChartData.cs
+++ b/skyscraper8/Skyscraper/Drawing/RfFrequencyChartData.cs
@@ -53,6 +53,13 @@ namespace skyscraper8.Skyscraper.Drawing
stream.WriteUInt8(0x4f);
}
+
+ public byte[] SaveToBytes()
+ {
+ MemoryStream ms = new MemoryStream();
+ SaveTo(ms);
+ return ms.GetBuffer();
+ }
}
public class RfSpectrumDataBlock
diff --git a/skyscraper8/Skyscraper/Scraper/Storage/Filesystem/FilesystemStorage.cs b/skyscraper8/Skyscraper/Scraper/Storage/Filesystem/FilesystemStorage.cs
index 19e2ac7..d1e9995 100644
--- a/skyscraper8/Skyscraper/Scraper/Storage/Filesystem/FilesystemStorage.cs
+++ b/skyscraper8/Skyscraper/Scraper/Storage/Filesystem/FilesystemStorage.cs
@@ -1,1984 +1,1984 @@
-using Newtonsoft.Json;
-using skyscraper5.Docsis.MacManagement;
-using skyscraper5.DsmCc.Descriptors;
-using skyscraper5.Dvb.DataBroadcasting.IntModel;
-using skyscraper5.Dvb.DataBroadcasting.SkyscraperVfs;
-using skyscraper5.Dvb.Descriptors;
-using skyscraper5.Dvb.Psi.Model;
-using skyscraper5.Dvb.SystemSoftwareUpdate.Model;
-using skyscraper5.Dvb.TvAnytime;
-using skyscraper5.Mhp.Si;
-using skyscraper5.Mhp.Si.Model;
-using skyscraper5.Mpeg2.Descriptors;
-using skyscraper5.Mpeg2.Psi.Model;
-using skyscraper5.Rds.Messages;
-using skyscraper5.Scte35;
-using skyscraper5.Skyscraper.Equipment;
-using skyscraper5.Skyscraper.Gps;
-using skyscraper5.Skyscraper.Headless;
-using skyscraper5.Skyscraper.IO;
-using skyscraper5.Skyscraper.IO.CrazycatStreamReader;
-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;
-using skyscraper5.Teletext;
-using skyscraper8.DvbI;
-using skyscraper8.DvbNip;
-using skyscraper8.Experimentals.NdsSsu;
-using skyscraper8.Ietf.FLUTE;
-using skyscraper8.InteractionChannel.Model;
-using skyscraper8.InteractionChannel.Model2;
-using skyscraper8.InteractionChannel.Model2.Descriptors;
-using skyscraper8.Ses;
-using skyscraper8.SimpleServiceDiscoveryProtocol;
-using skyscraper8.Skyscraper.Drawing;
-using skyscraper8.Skyscraper.Scraper.Storage;
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.IO;
-using System.Linq;
-using System.Net;
-using System.Net.NetworkInformation;
-using System.Text;
-using System.Text.RegularExpressions;
-using Platform = skyscraper5.Dvb.SystemSoftwareUpdate.Model.Platform;
-
-namespace skyscraper5.Skyscraper.Scraper.Storage.Filesystem
-{
- internal class FilesystemStorage : DataStorage, ObjectStorage
- {
- private readonly DirectoryInfo rootDirectory;
- private readonly string importFilesKnownFilename;
- private readonly JsonSerializerSettings jsonSerializerSettings;
-
- public FilesystemStorage(DirectoryInfo rootDirectory)
- {
- EnsureDirectoryExists(rootDirectory);
- this.rootDirectory = rootDirectory;
- this.importFilesKnownFilename = Path.Combine(rootDirectory.FullName, "import_files_known.json");
- this.jsonSerializerSettings = new JsonSerializerSettings()
- {
- NullValueHandling = NullValueHandling.Ignore,
- Formatting = Formatting.Indented
- };
- }
-
- public bool TestForNitNetwork(NitNetwork nitNetwork)
- {
- string combine = Path.Combine(rootDirectory.FullName, "NIT", nitNetwork.NetworkId.ToString(), "info.json");
- return File.Exists(combine);
- }
-
- public void StoreNitNetwork(NitNetwork nitNetwork)
- {
- string combine = Path.Combine(rootDirectory.FullName, "NIT", nitNetwork.NetworkId.ToString(), "info.json");
- FileInfo fi = new FileInfo(combine);
- EnsureDirectoryExists(fi.Directory);
- File.WriteAllText(fi.FullName, JsonConvert.SerializeObject(nitNetwork, Formatting.Indented, jsonSerializerSettings));
- }
-
- public bool UpdateNitNetwork(NitNetwork nitNetwork)
- {
- string combine = Path.Combine(rootDirectory.FullName, "NIT", nitNetwork.NetworkId.ToString(), "info.json");
- FileInfo fi = new FileInfo(combine);
- NitNetwork stored = JsonConvert.DeserializeObject(File.ReadAllText(fi.FullName));
- bool needsUpdate = stored.NeedsUpdate(nitNetwork);
- if (needsUpdate)
- StoreNitNetwork(nitNetwork);
- return needsUpdate;
- }
-
- public bool TestForNitTransportStream(ushort networkId, NitTransportStream transportStream)
- {
- string combine = Path.Combine(rootDirectory.FullName, "NIT", networkId.ToString(), String.Format("{0}.json", transportStream.TransportStreamId));
- return File.Exists(combine);
- }
-
- public void StoreNitTransportStream(ushort networkId, NitTransportStream transportStream)
- {
- string combine = Path.Combine(rootDirectory.FullName, "NIT", networkId.ToString(), String.Format("{0}.json", transportStream.TransportStreamId));
- FileInfo fi = new FileInfo(combine);
- EnsureDirectoryExists(fi.Directory);
- File.WriteAllText(fi.FullName, JsonConvert.SerializeObject(transportStream, Formatting.Indented, jsonSerializerSettings));
- }
-
- public bool UpdateNitTransportStream(ushort networkId, NitTransportStream transportStream)
- {
- string combine = Path.Combine(rootDirectory.FullName, "NIT", networkId.ToString(), String.Format("{0}.json", transportStream.TransportStreamId));
- FileInfo fi = new FileInfo(combine);
- NitTransportStream nitTransportStream = JsonConvert.DeserializeObject(File.ReadAllText(combine));
- if (nitTransportStream.NeedUpdate(nitTransportStream))
- {
- StoreNitTransportStream(networkId, transportStream);
- return true;
- }
- return false;
- }
-
- public bool StorePatEntry(int currentNetworkId, int currentTransportStreamId, int pmtPid, ushort programId)
- {
- string combine = Path.Combine(rootDirectory.FullName, "PAT", currentNetworkId.ToString(), currentTransportStreamId.ToString(), String.Format("{0}.n", programId));
- FileInfo fi = new FileInfo(combine);
- if (fi.Exists)
- return false;
- EnsureDirectoryExists(fi.Directory);
- File.WriteAllText(fi.FullName, pmtPid.ToString());
- return true;
- }
-
- public bool TestForPmtEvent(int currentNetworkId, int currentTransportStreamId, ProgramMapping result)
- {
- string combine = Path.Combine(rootDirectory.FullName, "PMT", currentNetworkId.ToString(),
- currentTransportStreamId.ToString(), String.Format("{0}.json", result.ProgramNumber));
- return File.Exists(combine);
- }
-
- public bool StorePmtEvent(int currentNetworkId, int currentTransportStreamId, ProgramMapping mapping)
- {
- string combine = Path.Combine(rootDirectory.FullName, "PMT", currentNetworkId.ToString(),
- currentTransportStreamId.ToString(), String.Format("{0}.json", mapping.ProgramNumber));
- FileInfo fi = new FileInfo(combine);
- if (fi.Exists)
- return false;
- EnsureDirectoryExists(fi.Directory);
- File.WriteAllText(fi.FullName, JsonConvert.SerializeObject(mapping, Formatting.Indented, jsonSerializerSettings));
- return true;
- }
-
- public bool StoreTeletextPage(int networkId, int transportStreamId, ushort programNumber, TeletextMagazine magazine, DateTime timestamp)
- {
- ushort pageNo = magazine.HumanReadablePageNumber;
- if (pageNo > 999)
- return false;
-
- string combine = Path.Combine(rootDirectory.FullName, "Teletext", timestamp.Year.ToString(), timestamp.Month.ToString(), timestamp.Day.ToString(), timestamp.Hour.ToString(), networkId.ToString(), transportStreamId.ToString(), programNumber.ToString(), String.Format("{0}.txt",pageNo));
- FileInfo fi = new FileInfo(combine);
- if (fi.Exists)
- return false;
- EnsureDirectoryExists(fi.Directory);
- FileStream fileStream = fi.OpenWrite();
- magazine.WriteOut(fileStream);
- fileStream.Flush();
- fileStream.Close();
- return true;
- }
-
- public bool TestForSdtService(ushort transportStreamId, ushort originalNetworkId, SdtService sdtService)
- {
- string combine = Path.Combine(rootDirectory.FullName, "SDT", originalNetworkId.ToString(), transportStreamId.ToString(), String.Format("{0}.json", sdtService.ServiceId.ToString()));
- return File.Exists(combine);
- }
-
- public bool TestForTeletextPage(int networkId, int transportStreamId, ushort programNumber, TeletextMagazine magazine,
- DateTime timestamp)
- {
- ushort pageNo = magazine.HumanReadablePageNumber;
- if (pageNo > 999)
- return false;
-
- string combine = Path.Combine(rootDirectory.FullName, "Teletext", timestamp.Year.ToString(), timestamp.Month.ToString(), timestamp.Day.ToString(), timestamp.Hour.ToString(), networkId.ToString(), transportStreamId.ToString(), programNumber.ToString(), String.Format("{0}.txt", pageNo));
- return File.Exists(combine);
- }
-
- public void MarkTeletextPageAsKnown(int networkId, int transportStreamId, ushort programNumber, TeletextMagazine magazine,
- DateTime timestamp)
- {
- StoreTeletextPage(networkId, transportStreamId, programNumber, magazine, timestamp);
- }
-
- public bool UpdateSdtService(ushort transportStreamId, ushort originalNetworkId, SdtService sdtService)
- {
- string combine = Path.Combine(rootDirectory.FullName, "SDT", originalNetworkId.ToString(), transportStreamId.ToString(), String.Format("{0}.json", sdtService.ServiceId.ToString()));
- SdtService stored = JsonConvert.DeserializeObject(File.ReadAllText(combine));
- if (stored.NeedsUpdate(sdtService))
- {
- StoreSdtService(transportStreamId, originalNetworkId, sdtService);
- return true;
- }
- return false;
- }
-
- public void StoreSdtService(ushort transportStreamId, ushort originalNetworkId, SdtService sdtService)
- {
- string combine = Path.Combine(rootDirectory.FullName, "SDT", originalNetworkId.ToString(), transportStreamId.ToString(), String.Format("{0}.json", sdtService.ServiceId.ToString()));
- FileInfo fi = new FileInfo(combine);
- EnsureDirectoryExists(fi.Directory);
- File.WriteAllText(combine,JsonConvert.SerializeObject(sdtService, Formatting.Indented, jsonSerializerSettings));
- }
-
- public bool TestForBatBouquet(BatBouquet batBouquet)
- {
- string combine = Path.Combine(rootDirectory.FullName, "BAT", batBouquet.BouquetId.ToString(), "info.json");
- return File.Exists(combine);
- }
-
- public bool UpdateBatBouquet(BatBouquet batBouquet)
- {
- if (!TestForBatBouquet(batBouquet))
- {
- StoreBatBouquet(batBouquet);
- return true;
- }
- string combine = Path.Combine(rootDirectory.FullName, "BAT", batBouquet.BouquetId.ToString(), "info.json");
- BatBouquet stored = JsonConvert.DeserializeObject(File.ReadAllText(combine));
- if (stored.NeedUpdate(batBouquet))
- {
- StoreBatBouquet(batBouquet);
- return true;
- }
- return false;
- }
-
- public void StoreBatBouquet(BatBouquet batBouquet)
- {
- string combine = Path.Combine(rootDirectory.FullName, "BAT", batBouquet.BouquetId.ToString(), "info.json");
- FileInfo fi = new FileInfo(combine);
- EnsureDirectoryExists(fi.Directory);
- File.WriteAllText(fi.FullName, JsonConvert.SerializeObject(batBouquet, Formatting.Indented, jsonSerializerSettings));
- }
-
- public bool TestForBatTransportStream(ushort batBouquetBouquetId, BatTransportStream child)
- {
- string combine = Path.Combine(rootDirectory.FullName, "BAT", batBouquetBouquetId.ToString(), child.OriginalNetworkId.ToString(), String.Format("{0}.json", child.TransportStreamId));
- return File.Exists(combine);
- }
-
- public bool UpdateBatTransportStream(ushort batBouquetBouquetId, BatTransportStream child)
- {
- string combine = Path.Combine(rootDirectory.FullName, "BAT", batBouquetBouquetId.ToString(), child.OriginalNetworkId.ToString(), String.Format("{0}.json", child.TransportStreamId));
- FileInfo fi = new FileInfo(combine);
- if (!fi.Exists)
- {
- StoreBatTransportStream(batBouquetBouquetId, child);
- return true;
- }
- BatTransportStream stored = JsonConvert.DeserializeObject(File.ReadAllText(combine));
- if (stored.NeedsUpdate(child))
- {
- StoreBatTransportStream(batBouquetBouquetId, child);
- return true;
- }
- return false;
- }
-
- public void StoreBatTransportStream(ushort batBouquetBouquetId, BatTransportStream child)
- {
- string combine = Path.Combine(rootDirectory.FullName, "BAT", batBouquetBouquetId.ToString(), child.OriginalNetworkId.ToString(), String.Format("{0}.json", child.TransportStreamId));
- FileInfo fi = new FileInfo(combine);
- EnsureDirectoryExists(fi.Directory);
- File.WriteAllText(fi.FullName, JsonConvert.SerializeObject(child, Formatting.Indented, jsonSerializerSettings));
- }
-
- public bool UpdateTimeOffsetTable(int currentNetworkId, int currentTransportStreamId, DateTime utcTime,
- LocalTimeOffsetDescriptor ltod)
- {
- string combine = Path.Combine(rootDirectory.FullName, "TOT", currentNetworkId.ToString(), String.Format("{0}.n", currentTransportStreamId));
- FileInfo fi = new FileInfo(combine);
- if (fi.Exists)
- {
- long l = long.Parse(File.ReadAllText(fi.FullName));
- DateTime savedDate = new DateTime(l);
- if (utcTime > savedDate)
- {
- File.WriteAllText(fi.FullName, utcTime.Ticks.ToString());
- return true;
- }
- }
- else
- {
- EnsureDirectoryExists(fi.Directory);
- File.WriteAllText(fi.FullName, utcTime.Ticks.ToString());
- combine = Path.Combine(rootDirectory.FullName, "TOT", currentNetworkId.ToString(), String.Format("{0}.json", currentTransportStreamId));
- File.WriteAllText(combine, JsonConvert.SerializeObject(ltod, Formatting.Indented, jsonSerializerSettings));
- return true;
- }
- return false;
- }
-
- public bool UpdateTimeAndDate(int currentNetworkId, int currentTransportStreamId, DateTime utcTime)
- {
- string combine = Path.Combine(rootDirectory.FullName, "TDT", currentNetworkId.ToString(), String.Format("{0}.n", currentTransportStreamId));
- FileInfo fi = new FileInfo(combine);
- if (fi.Exists)
- {
- long l = long.Parse(File.ReadAllText(fi.FullName));
- DateTime savedDate = new DateTime(l);
- if (utcTime > savedDate)
- {
- File.WriteAllText(fi.FullName, utcTime.Ticks.ToString());
- return true;
- }
- }
- else
- {
- EnsureDirectoryExists(fi.Directory);
- File.WriteAllText(fi.FullName, utcTime.Ticks.ToString());
- return true;
- }
- return false;
- }
-
- private void EnsureDirectoryExists(DirectoryInfo di)
- {
- if (di.Exists)
- return;
- EnsureDirectoryExists(di.Parent);
- di.Create();
- di.Refresh();
- }
-
- public bool StoreEitEvent(EitEvent eitEvent)
- {
- string path = Path.Combine(rootDirectory.FullName, "EIT", eitEvent.StartTime.Year.ToString(),
- eitEvent.StartTime.Month.ToString(), eitEvent.StartTime.Day.ToString(),
- eitEvent.OriginalNetworkId.ToString(), eitEvent.TransportStreamId.ToString(),
- eitEvent.ServiceId.ToString(), String.Format("{0}.json", eitEvent.EventId));
- FileInfo outFileInfo = new FileInfo(path);
- if (outFileInfo.Exists)
- return false;
- EnsureDirectoryExists(outFileInfo.Directory);
- File.WriteAllText(outFileInfo.FullName, JsonConvert.SerializeObject(eitEvent, Formatting.Indented, jsonSerializerSettings));
- return true;
- }
-
- public bool TestForAitApplication(ApplicationIdentifier aitApplicationApplicationIdentifier)
- {
- string combine = Path.Combine(rootDirectory.FullName, "AIT", aitApplicationApplicationIdentifier.OrganisationId.ToString(), String.Format("{0}.json",aitApplicationApplicationIdentifier.ApplicationId.ToString()));
- return File.Exists(combine);
- }
-
- public void StoreAitApplication(AitApplication aitApplication)
- {
- string combine = Path.Combine(rootDirectory.FullName, "AIT", aitApplication.ApplicationIdentifier.OrganisationId.ToString(), String.Format("{0}.json", aitApplication.ApplicationIdentifier.ApplicationId));
- FileInfo fi = new FileInfo(combine);
- EnsureDirectoryExists(fi.Directory);
- File.WriteAllText(fi.FullName, JsonConvert.SerializeObject(aitApplication, Formatting.Indented, jsonSerializerSettings));
- }
-
- public bool ObjectCarouselFileArrival(VfsFile vfsFile, int transportStreamId, int networkId)
- {
- string combine = Path.Combine(rootDirectory.FullName, "DSM-CC_Objects", networkId.ToString(), transportStreamId.ToString(), vfsFile.SourcePid.ToString(), vfsFile.ToString().Substring(1));
- FileInfo fi = new FileInfo(combine);
- if (fi.Exists)
- return false;
- EnsureDirectoryExists(fi.Directory);
- File.WriteAllBytes(fi.FullName,vfsFile.FileContent);
- return true;
- }
-
- public bool TestForCaSystem(int currentNetworkId, int currentTransportStreamId, int caDescriptorCaPid)
- {
- string combine = Path.Combine(rootDirectory.FullName, "CAT", currentNetworkId.ToString(), currentTransportStreamId.ToString(), String.Format("{0}.json", caDescriptorCaPid));
- return File.Exists(combine);
- }
-
- public void StoreCaSystem(int currentNetworkId, int currentTransportStreamId, CaDescriptor caDescriptor)
- {
- string combine = Path.Combine(rootDirectory.FullName, "CAT", currentNetworkId.ToString(), currentTransportStreamId.ToString(), String.Format("{0}.json", caDescriptor.CaPid));
- FileInfo fi = new FileInfo(combine);
- EnsureDirectoryExists(fi.Directory);
- File.WriteAllText(fi.FullName, JsonConvert.SerializeObject(caDescriptor, Formatting.Indented, jsonSerializerSettings));
- }
-
- public bool TestForUpdateNotification(int hashCode, UpdateNotificationGroup common)
- {
- string combine = Path.Combine(rootDirectory.FullName, "UNT", common.Oui, "index.json");
- return File.Exists(combine);
- }
-
- public void StoreUpdateNotification(int hashCode, UpdateNotificationGroup common, Compatibility compatibility, Platform platform)
- {
- string combine = Path.Combine(rootDirectory.FullName, "UNT", common.Oui, compatibility.Version.ToString(), String.Format("{0}.json", platform.ToString()));
- FileInfo platformFi = new FileInfo(combine);
- EnsureDirectoryExists(platformFi.Directory);
- if (!platformFi.Exists)
- File.WriteAllText(platformFi.FullName, JsonConvert.SerializeObject(platform, Formatting.Indented, jsonSerializerSettings));
- else
- return;
-
- combine = Path.Combine(rootDirectory.FullName, "UNT", common.Oui, compatibility.Version.ToString(), "index.json");
- FileInfo compatFi = new FileInfo(combine);
- if (!compatFi.Exists)
- File.WriteAllText(compatFi.FullName, JsonConvert.SerializeObject(compatibility, Formatting.Indented, jsonSerializerSettings));
- else
- return;
-
- combine = Path.Combine(rootDirectory.FullName, "UNT", common.Oui, "index.json");
- FileInfo commonFi = new FileInfo(combine);
- if (!commonFi.Exists)
- File.WriteAllText(commonFi.FullName, JsonConvert.SerializeObject(common, Formatting.Indented, jsonSerializerSettings));
- }
-
- public void DataCarouselModuleArrival(int currentNetworkId, int currentTransportStreamId, int elementaryPid, ushort moduleId, byte moduleVersion, Stream result)
- {
- string combine = Path.Combine(rootDirectory.FullName, "DSM-CC_Data", currentNetworkId.ToString(), currentTransportStreamId.ToString(), elementaryPid.ToString(), String.Format("{0}_V{1}.bin", moduleId, moduleVersion));
- FileInfo fi = new FileInfo(combine);
- if (!fi.Exists)
- {
- EnsureDirectoryExists(fi.Directory);
- FileStream outputStream = fi.OpenWrite();
- result.CopyTo(outputStream);
- outputStream.Close();
- outputStream.Dispose();
- }
- }
-
- public bool TestForKnownRdsData(int currentNetworkId, int currentTransportStreamId, int programNumber)
- {
- string combine = Path.Combine(rootDirectory.FullName, "RDS", currentNetworkId.ToString(), currentTransportStreamId.ToString(), programNumber.ToString(), "marker.bin");
- return File.Exists(combine);
- }
-
- public void EnableRdsCollection(int currentNetworkId, int currentTransportStreamId, int programNumber)
- {
- string combine = Path.Combine(rootDirectory.FullName, "RDS", currentNetworkId.ToString(), currentTransportStreamId.ToString(), programNumber.ToString(), "marker.bin");
- FileInfo fi = new FileInfo(combine);
- if (!fi.Exists)
- {
- EnsureDirectoryExists(fi.Directory);
- FileStream fileStream = fi.Open(FileMode.CreateNew);
- fileStream.Flush(true);
- fileStream.Close();
- }
- }
-
- public bool UpdateRdsProgrammeServiceName(int currentNetworkId, int currentTransportStreamId, int programNumber,
- string programmeService2)
- {
- string combine = Path.Combine(rootDirectory.FullName, "RDS", currentNetworkId.ToString(), currentTransportStreamId.ToString(), programNumber.ToString(), "ps.txt");
- FileInfo fi = new FileInfo(combine);
- string alreadyKnown = "";
- if (fi.Exists)
- {
- alreadyKnown = File.ReadAllText(combine);
- }
-
- if (!alreadyKnown.Equals(programmeService2))
- {
- File.WriteAllText(combine, programmeService2);
- return true;
- }
- return false;
- }
-
- public bool UpdateRdsRadioText(int currentNetworkId, int currentTransportStreamId, int programNumber, string text)
- {
- string combine = Path.Combine(rootDirectory.FullName, "RDS", currentNetworkId.ToString(), currentTransportStreamId.ToString(), programNumber.ToString(), "rt.txt");
- FileInfo fi = new FileInfo(combine);
- string alreadyKnown = "";
- if (fi.Exists)
- {
- alreadyKnown = File.ReadAllText(combine);
- }
-
- if (!alreadyKnown.Equals(text))
- {
- File.WriteAllText(combine, text);
- return true;
- }
- return false;
- }
-
- public bool UpdateRdsPty(int currentNetworkId, int currentTransportStreamId, int programNumber, PTY.ProgrammeTypeCodes pty)
- {
- string combine = Path.Combine(rootDirectory.FullName, "RDS", currentNetworkId.ToString(), currentTransportStreamId.ToString(), programNumber.ToString(), "pty.bin");
- FileInfo fi = new FileInfo(combine);
- if (fi.Exists)
- {
- byte[] readAllBytes = File.ReadAllBytes(combine);
- if (readAllBytes[0] != (byte)pty)
- {
- byte[] tmp = new byte[] { (byte)pty };
- File.WriteAllBytes(combine, tmp);
- return true;
- }
- return false;
- }
- else
- {
- byte[] tmp = new byte[] { (byte)pty };
- File.WriteAllBytes(combine, tmp);
- return true;
- }
- }
-
- public bool MarkAsRdsTrafficInformationProgramme(int currentNetworkId, int currentTransportStreamId, int programNumber)
- {
- string combine = Path.Combine(rootDirectory.FullName, "RDS", currentNetworkId.ToString(), currentTransportStreamId.ToString(), programNumber.ToString(), "ti.bin");
- FileInfo fi = new FileInfo(combine);
- if (!fi.Exists)
- {
- FileStream fileStream = fi.OpenWrite();
- fileStream.Flush(true);
- fileStream.Close();
- return true;
- }
- return false;
- }
-
- public bool TestForScte35SpliceInsert(int currentNetworkId, int currentTransportStreamId, ushort programNumber, SpliceInsert spliceInsert)
- {
- string path = Path.Combine(rootDirectory.FullName, "SCTE-35",currentNetworkId.ToString(), currentTransportStreamId.ToString(), programNumber.ToString(), String.Format("{0}.json", spliceInsert.SpliceEventId));
- return File.Exists(path);
- }
-
- public void StoreScte35SpliceInsert(int currentNetworkId, int currentTransportStreamId, ushort programNumber, SpliceInsert spliceInsert)
- {
- string path = Path.Combine(rootDirectory.FullName, "SCTE-35", currentNetworkId.ToString(), currentTransportStreamId.ToString(), programNumber.ToString(), String.Format("{0}.json", spliceInsert.SpliceEventId));
- FileInfo fi = new FileInfo(path);
- if (!fi.Exists)
- {
- EnsureDirectoryExists(fi.Directory);
- File.WriteAllText(fi.FullName, JsonConvert.SerializeObject(spliceInsert, Formatting.Indented, jsonSerializerSettings));
- }
- }
-
- public bool IsCompliant(int currentNetworkId, int currentTransportStreamId, string compliance)
- {
- string path = Path.Combine(rootDirectory.FullName, "TSDT", currentNetworkId.ToString(), currentTransportStreamId.ToString(), String.Format("{0}.5ds",compliance));
- return File.Exists(path);
- }
-
- public void MarkAsCompliant(int currentNetworkId, int currentTransportStreamId, string compliance)
- {
- string path = Path.Combine(rootDirectory.FullName, "TSDT", currentNetworkId.ToString(), currentTransportStreamId.ToString(), String.Format("{0}.5ds", compliance));
- FileInfo fi = new FileInfo(path);
- if (!fi.Exists)
- {
- EnsureDirectoryExists(fi.Directory);
- fi.Create().Close();
- }
- }
-
- public bool SetStationIdentification(int currentNetworkId, int currentTransportStreamId, string stationIdentification)
- {
- string path = Path.Combine(rootDirectory.FullName, "TSDT", currentNetworkId.ToString(), String.Format("{0}.999", currentTransportStreamId));
- FileInfo fi = new FileInfo(path);
- if (fi.Exists)
- {
- string text = File.ReadAllText(fi.FullName);
- if (text.Equals(stationIdentification))
- return false;
- }
- else
- {
- EnsureDirectoryExists(fi.Directory);
- }
-
- File.WriteAllText(fi.FullName, stationIdentification);
- return true;
- }
-
-
- public bool IsDsmCcModuleWanted(int currentNetworkId, int currentTransportStreamId, int elementaryPid, ushort moduleId,
- byte moduleVersion)
- {
- string combine = Path.Combine(rootDirectory.FullName, "DSM-CC_Data", currentNetworkId.ToString(), currentTransportStreamId.ToString(), elementaryPid.ToString(), String.Format("{0}_V{1}.bin", moduleId, moduleVersion));
- return !File.Exists(combine);
- }
-
- public void StoreDsmCcDoItNowEvent(DateTime timestamp, int currentNetworkId, int currentTransportStreamId, int programNumber, StreamEventDescriptor descriptorListStreamEventDescriptor, int pid)
- {
- string combine = Path.Combine(rootDirectory.FullName, "DSM-CC_Events", currentNetworkId.ToString(), currentTransportStreamId.ToString(), pid.ToString(), String.Format("event{0}_{1}.bin", descriptorListStreamEventDescriptor.EventId, timestamp.ToUnixTime()));
- FileInfo fi = new FileInfo(combine);
- if (!fi.Exists)
- {
- EnsureDirectoryExists(fi.Directory);
- File.WriteAllBytes(combine, descriptorListStreamEventDescriptor.PrivateData);
- }
- }
-
- public bool StoreRunningStatus(uint transportStreamId, uint originalNetworkId, uint serviceId, uint eventId,
- RunningStatus runningStatus, DateTime currentTime)
- {
- string combine = Path.Combine(rootDirectory.FullName, "RST", originalNetworkId.ToString(), transportStreamId.ToString(), serviceId.ToString(), eventId.ToString(), String.Format("{0}.999", runningStatus.ToString()));
- FileInfo fi = new FileInfo(combine);
- if (fi.Exists)
- return false;
-
- EnsureDirectoryExists(fi.Directory);
- File.WriteAllText(fi.FullName, currentTime.ToUnixTime().ToString());
- return true;
- }
-
-
-
- public void SetScte35TimeSignal(int currentNetworkId, int currentTransportStreamId, DateTime currentTime, ushort programNumber, TimeSignal timeSignal)
- {
- string path = Path.Combine(rootDirectory.FullName, "SCTE-35", currentNetworkId.ToString(), currentTransportStreamId.ToString(), programNumber.ToString(), String.Format("TimeSignal_{0}.json", currentTime.ToUnixTime()));
- FileInfo fi = new FileInfo(path);
- if (fi.Exists)
- return;
- fi.Directory.EnsureExists();
- File.WriteAllText(fi.FullName, JsonConvert.SerializeObject(timeSignal, Formatting.Indented, jsonSerializerSettings));
- }
-
- public bool TestForFramegrab(int currentNetworkId, int transportStreamId, ushort mappingProgramNumber, int mappingStreamElementaryPid)
- {
- string path = Path.Combine(rootDirectory.FullName, "0-Framegrabs", currentNetworkId.ToString(), transportStreamId.ToString(), String.Format("{0}.jpg", mappingProgramNumber));
- return File.Exists(path);
- }
-
-
- public void StoreFramegrab(int currentNetworkId, int transportStreamId, ushort mappingProgramNumber, ushort pid, byte[] imageData)
- {
- string path = Path.Combine(rootDirectory.FullName, "0-Framegrabs", currentNetworkId.ToString(), transportStreamId.ToString(), String.Format("{0}.jpg", mappingProgramNumber));
- FileInfo fi = new FileInfo(path);
- fi.Directory.EnsureExists();
- File.WriteAllBytes(path, imageData);
- }
-
- public bool TestForDocsisUpstreamChannel(PhysicalAddress mmmSource, uint mmmFrequency, int locationId)
- {
- string path = Path.Combine(rootDirectory.FullName, "DOCSIS", "UpstreamChannels", String.Format("Location_{0}", locationId), mmmSource.ToString(), mmmFrequency.ToString() + ".json");
- return File.Exists(path);
- }
-
- public void StoreDocsisUpstreamChannel(UpstreamChannelDescriptor mmm, int locationId)
- {
- string fname = Path.Combine(rootDirectory.FullName, "DOCSIS", "UpstreamChannels", String.Format("Location_{0}", locationId), mmm.Source.ToString(), mmm.Frequency.ToString() + ".json");
- FileInfo fi = new FileInfo(fname);
- fi.Directory.EnsureExists();
- File.WriteAllText(fi.FullName, JsonConvert.SerializeObject(mmm, Formatting.Indented, jsonSerializerSettings));
- }
-
- public bool TestForDocsisDownstreamChannel(PhysicalAddress physicalAddress, MacDomainDescriptor.DownstreamActiveChannel downstreamActiveChannel, int locationId)
- {
- string fname = Path.Combine(rootDirectory.FullName, "DOCSIS", "DownstreamChannels", String.Format("Location_{0}", locationId), physicalAddress.ToString(), downstreamActiveChannel.Frequency.Value.ToString() + ".json");
- return File.Exists(fname);
- }
-
- public void StoreDocsisDownstreamChannel(PhysicalAddress physicalAddress, MacDomainDescriptor.DownstreamActiveChannel downstreamActiveChannel, int locationId)
- {
- string fname = Path.Combine(rootDirectory.FullName, "DOCSIS", "DownstreamChannels", String.Format("Location_{0}",locationId), physicalAddress.ToString(), downstreamActiveChannel.Frequency.Value.ToString() + ".json");
- FileInfo fi = new FileInfo(fname);
- fi.Directory.EnsureExists();
- File.WriteAllText(fi.FullName, JsonConvert.SerializeObject(downstreamActiveChannel, Formatting.Indented, jsonSerializerSettings));
- }
-
- public bool SetCmtsIp(PhysicalAddress physicalAddress, IPAddress ip)
- {
- string fname = Path.Combine(rootDirectory.FullName, "DOCSIS", "CMTS_IP", physicalAddress.ToString() + ".txt");
- FileInfo fi = new FileInfo(fname);
- IPAddress ondisk = IPAddress.None;
- if (fi.Exists)
- {
- ondisk = new IPAddress(File.ReadAllBytes(fname));
- }
-
- if (!ondisk.Equals(ip))
- {
- fi.Directory.EnsureExists();
- File.WriteAllBytes(fi.FullName, ip.GetAddressBytes());
- return true;
- }
-
- return false;
- }
-
- private DsmCcModuleBlacklist dsmCcBlacklist;
- public bool IsDsmCcModuleBlacklisted(int currentNetworkId, int currentTransportStreamId, int elementaryPid, ushort moduleId, byte moduleVersion)
- {
- if (dsmCcBlacklist == null)
- {
- string fname = Path.Combine(rootDirectory.FullName, "dsmcc_blacklist.csv");
- FileInfo fi = new FileInfo(fname);
- dsmCcBlacklist = new DsmCcModuleBlacklist(fi);
- }
-
- return dsmCcBlacklist.IsBlacklisted(currentNetworkId, currentTransportStreamId, elementaryPid, moduleId, moduleVersion);
- }
-
- public int? GetCurrentLocationId()
- {
- string fname = Path.Combine(rootDirectory.FullName, "docsis_location.txt");
- FileInfo fi = new FileInfo(fname);
- if (fi.Exists)
- {
- string readAllText = File.ReadAllText(fi.FullName);
- return Int32.Parse(readAllText);
- }
-
- return null;
- }
-
- public void StoreDocsisParticipant(PhysicalAddress pa, int currentLocation)
- {
- string fname = Path.Combine(rootDirectory.FullName, "DOCSIS", "Participants", String.Format("Location_{0}", currentLocation), pa.ToString() + ".tmp");
- FileInfo fi = new FileInfo(fname);
- if (!fi.Exists)
- {
- EnsureDirectoryExists(fi.Directory);
- fi.Create().Close();
- }
- }
-
- public bool TestForIpMacNotification(IpMacNotification notification)
- {
- string path = Path.Combine(rootDirectory.FullName, "INT", String.Format("{0}.json", notification.PlatformId));
- return File.Exists(path);
- }
-
- public void StoreIpMacNotification(IpMacNotification notification)
- {
- string path = Path.Combine(rootDirectory.FullName, "INT", String.Format("{0}.json", notification.PlatformId));
- FileInfo fi = new FileInfo(path);
- EnsureDirectoryExists(fi.Directory);
- File.WriteAllText(fi.FullName, JsonConvert.SerializeObject(notification, Formatting.Indented, jsonSerializerSettings));
- }
-
- private KnownTsMemory knownTss;
- private List importFilesKnown;
-
- public bool ImportFileKnown(FileInfo fi)
- {
- if (knownTss == null)
- knownTss = new KnownTsMemory(importFilesKnownFilename);
- return knownTss.ImportFileKnown(fi);
- }
-
- public void ImportMarkFileAsKnown(FileInfo fi, TimeSpan ts, int tstype)
- {
- if (knownTss == null)
- knownTss = new KnownTsMemory(importFilesKnownFilename);
- knownTss.ImportMarkFileAsKnown(fi, ts, tstype);
- }
-
- public DateTime T2MiGetTimestamp(int currentNetworkId, int currentTransportStreamId, int pid)
- {
- string path = Path.Combine(rootDirectory.FullName, "T2-MI", currentNetworkId.ToString(), currentTransportStreamId.ToString(),String.Format("{0}.timestamp", pid));
- if (!File.Exists(path))
- {
- return DateTime.MinValue;
- }
-
- string readAllText = File.ReadAllText(path);
- long l = long.Parse(readAllText);
- DateTime result = new DateTime(l);
- return result;
- }
-
- public void T2MiSetTimestamp(int currentNetworkId, int currentTransportStreamId, int pid, DateTime resolveTime)
- {
- string path = Path.Combine(rootDirectory.FullName, "T2-MI", currentNetworkId.ToString(), currentTransportStreamId.ToString(), String.Format("{0}.timestamp", pid));
- FileInfo fi = new FileInfo(path);
- EnsureDirectoryExists(fi.Directory);
- File.WriteAllText(fi.FullName, resolveTime.Ticks.ToString());
- }
-
- private string BuildRctIdentifier(RctLinkInfo rctLinkInfo)
- {
- char[] invalidFileNameChars = Path.GetInvalidFileNameChars();
- StringBuilder sb = new StringBuilder();
- if (rctLinkInfo.LinkType == RctLinkInfo.LinkTypeValue.Uri)
- {
- sb.Append("A_");
- char[] charArray = rctLinkInfo.MediaUri.ToCharArray();
- foreach (char c in charArray)
- {
- if (!invalidFileNameChars.Contains(c))
- sb.Append(c);
- else
- sb.Append('_');
- }
- }
- else
- {
- throw new NotImplementedException(rctLinkInfo.LinkType.ToString());
- }
-
- sb.Append(".json");
- return sb.ToString();
- }
-
- public bool TestForRelatedContent(EitEvent lEvent, RctLinkInfo rctLinkInfo)
- {
- string path = Path.Combine(rootDirectory.FullName, "RCT", lEvent.StartTime.Year.ToString(), lEvent.StartTime.Month.ToString(),
- lEvent.StartTime.Day.ToString(), lEvent.OriginalNetworkId.ToString(), lEvent.TransportStreamId.ToString(), lEvent.ServiceId.ToString(),
- lEvent.EventId.ToString(), BuildRctIdentifier(rctLinkInfo));
- return File.Exists(path);
- }
-
- public void SetRelatedContent(EitEvent lEvent, RctLinkInfo rctLinkInfo)
- {
- string path = Path.Combine(rootDirectory.FullName, "RCT", lEvent.StartTime.Year.ToString(), lEvent.StartTime.Month.ToString(),
- lEvent.StartTime.Day.ToString(), lEvent.OriginalNetworkId.ToString(), lEvent.TransportStreamId.ToString(), lEvent.ServiceId.ToString(),
- lEvent.EventId.ToString(), BuildRctIdentifier(rctLinkInfo));
- FileInfo fi = new FileInfo(path);
- if (!fi.Exists)
- {
- EnsureDirectoryExists(fi.Directory);
- File.WriteAllText(fi.FullName, JsonConvert.SerializeObject(rctLinkInfo, Formatting.Indented));
- }
- }
-
- public List UiSatellitesListAll()
- {
- string path = Path.Combine(rootDirectory.FullName, "satellites.json");
- FileInfo fi = new FileInfo(path);
- if (!fi.Exists)
- return new List();
- else
- {
- return JsonConvert.DeserializeObject>(File.ReadAllText(fi.FullName));
- }
- }
-
- public void UiSatellitesAdd(SatellitePositionEntity newPosition)
- {
- string path = Path.Combine(rootDirectory.FullName, "satellites.json");
- FileInfo fi = new FileInfo(path);
- List satellites;
- if (!fi.Exists)
- {
- satellites = new List();
- }
- else
- {
- satellites = JsonConvert.DeserializeObject>(File.ReadAllText(fi.FullName));
- }
-
- satellites.Add(newPosition);
- EnsureDirectoryExists(fi.Directory);
- File.WriteAllText(fi.FullName, JsonConvert.SerializeObject(satellites, Formatting.Indented));
- }
-
- public void UiSatellitesDelete(SatellitePositionEntity satellitePosition)
- {
- string path = Path.Combine(rootDirectory.FullName, "satellites.json");
- FileInfo fi = new FileInfo(path);
- List satellites = JsonConvert.DeserializeObject>(File.ReadAllText(fi.FullName));
-
- satellites.RemoveAll(x => x.Checksum == satellitePosition.Checksum);
-
- File.WriteAllText(fi.FullName, JsonConvert.SerializeObject(satellites, Formatting.Indented));
- }
-
- public bool UiTunerTestFor(TunerMetadata tuner)
- {
- string fname = BitConverter.ToString(tuner.MacAddress.GetAddressBytes());
- string path = Path.Combine(rootDirectory.FullName, "0-UI", "Tuners", fname + ".json");
- return File.Exists(path);
- }
-
- public void UiTunerUpdate(TunerMetadata tuner)
- {
- string fname = BitConverter.ToString(tuner.MacAddress.GetAddressBytes());
- string path = Path.Combine(rootDirectory.FullName, "0-UI", "Tuners", fname + ".json");
- File.WriteAllText(path, JsonConvert.SerializeObject(tuner, Formatting.Indented));
- }
-
- public void UiTunerInsert(TunerMetadata tuner)
- {
- string fname = BitConverter.ToString(tuner.MacAddress.GetAddressBytes());
- string path = Path.Combine(rootDirectory.FullName, "0-UI", "Tuners", fname + ".json");
- FileInfo fi = new FileInfo(path);
- EnsureDirectoryExists(fi.Directory);
- File.WriteAllText(fi.FullName, JsonConvert.SerializeObject(tuner, Formatting.Indented));
- }
-
- public void UiTunerGetConfiguration(TunerMetadata foundTuner)
- {
- string fname = BitConverter.ToString(foundTuner.MacAddress.GetAddressBytes());
- string path = Path.Combine(rootDirectory.FullName, "0-UI", "Tuners", fname + ".json");
- TunerMetadata copy = JsonConvert.DeserializeObject(File.ReadAllText(path));
- foundTuner.DiseqcType = copy.DiseqcType;
- foundTuner.Satellites = new int[4];
- foundTuner.Satellites[0] = copy.Satellites[0];
- foundTuner.Satellites[1] = copy.Satellites[1];
- foundTuner.Satellites[2] = copy.Satellites[2];
- foundTuner.Satellites[3] = copy.Satellites[3];
- foundTuner.Lnbs = new int[4];
- foundTuner.Lnbs[0] = copy.Lnbs[0];
- foundTuner.Lnbs[1] = copy.Lnbs[1];
- foundTuner.Lnbs[2] = copy.Lnbs[2];
- foundTuner.Lnbs[3] = copy.Lnbs[3];
- }
-
- public HeadlessJob GetQueuedJob()
- {
- throw new NotImplementedException();
- }
-
- public void SetQueuedJobComplete(HeadlessJob headlessJob)
- {
- throw new NotImplementedException();
- }
-
- public void WaitForCompletion()
- {
- }
-
- private int uiVersion;
- public void UiSetVersion(int version)
- {
- this.uiVersion = version;
- }
-
- public bool T2MiTestForTransmitter(int? currentNetworkId, int? currentTransportStreamId, int relatedPid, ushort txIdentifier)
- {
- if (!currentNetworkId.HasValue)
- return true;
- if (!currentTransportStreamId.HasValue)
- return true;
-
- string txName = String.Format("{0}_TX{1}", relatedPid, txIdentifier);
-
- string path = Path.Combine(rootDirectory.FullName, "T2-MI", currentNetworkId.ToString(), currentTransportStreamId.ToString(), txName, "test.bin");
- return File.Exists(path);
- }
-
- public void T2MiRememberTransmitter(int? currentNetworkId, int? currentTransportStreamId, int relatedPid, ushort txIdentifier)
- {
- if (!currentNetworkId.HasValue)
- return;
- if (!currentTransportStreamId.HasValue)
- return;
-
- string txName = String.Format("{0}_TX{1}", relatedPid, txIdentifier);
-
- string path = Path.Combine(rootDirectory.FullName, "T2-MI", currentNetworkId.ToString(), currentTransportStreamId.ToString(), txName, "test.bin");
- FileInfo fi = new FileInfo(path);
- EnsureDirectoryExists(fi.Directory);
- fi.OpenWrite().Close();
- }
-
- public void T2MiSetTransmitterTimeOffset(int? currentNetworkId, int? currentTransportStreamId, int relatedPid, ushort txIdentifier, ushort timeOffset)
- {
- if (!currentNetworkId.HasValue)
- return;
- if (!currentTransportStreamId.HasValue)
- return;
-
- string txName = String.Format("{0}_TX{1}", relatedPid, txIdentifier);
-
- string path = Path.Combine(rootDirectory.FullName, "T2-MI", currentNetworkId.ToString(), currentTransportStreamId.ToString(), txName, "timeoff.set");
- FileInfo fi = new FileInfo(path);
- EnsureDirectoryExists(fi.Directory);
- File.WriteAllText(path, timeOffset.ToString());
- }
-
- public List UiLnbTypesListAll()
- {
- string path = Path.Combine(rootDirectory.FullName, "0-UI", "LnbTypes");
- DirectoryInfo di = new DirectoryInfo(path);
- if (!di.Exists)
- {
- return new List();
- }
-
- List result = new List();
- FileInfo[] fileInfos = di.GetFiles("*.json");
- foreach (FileInfo fileInfo in fileInfos)
- {
- string fid = Path.GetFileNameWithoutExtension(fileInfo.Name);
- if (!fid.IsNaturalNumeric())
- continue;
- int iid = int.Parse(fid);
-
- string json = File.ReadAllText(fileInfo.FullName);
- LnbEntity deserializeObject = JsonConvert.DeserializeObject(json);
- if (deserializeObject.Id != iid)
- continue;
- if (result.Contains(deserializeObject))
- continue;
- result.Add(deserializeObject);
- }
-
- return result;
- }
-
- private int GetNextJsonFileNumber(DirectoryInfo di)
- {
- if (!di.Exists)
- {
- EnsureDirectoryExists(di);
- return 1;
- }
-
- int result = 0;
- foreach (FileInfo fileInfo in di.GetFiles("*.json"))
- {
- string fname = Path.GetFileNameWithoutExtension(fileInfo.Name);
- if (!fname.IsNaturalNumeric())
- continue;
- int iname = Int32.Parse(fname);
- if (iname > result)
- result = iname;
- }
-
- result++;
- return result;
- }
-
- public void UiLnbTypesAdd(LnbEntity defaultLnbType)
- {
- string path = Path.Combine(rootDirectory.FullName, "0-UI", "LnbTypes");
- DirectoryInfo di = new DirectoryInfo(path);
- int fileId = GetNextJsonFileNumber(di);
- defaultLnbType.Id = fileId;
- defaultLnbType.DateAdded = DateTime.Now;
-
- path = Path.Combine(rootDirectory.FullName, "0-UI", "LnbTypes", fileId.ToString() + ".json");
- string json = JsonConvert.SerializeObject(defaultLnbType, jsonSerializerSettings);
- File.WriteAllText(path, json);
- }
-
- public List UiDishTypesListAll()
- {
- string path = Path.Combine(rootDirectory.FullName, "0-UI", "DishTypes");
- DirectoryInfo di = new DirectoryInfo(path);
- if (!di.Exists)
- {
- return new List();
- }
-
- List result = new List();
- FileInfo[] fileInfos = di.GetFiles("*.json");
- foreach (FileInfo fileInfo in fileInfos)
- {
- string fid = Path.GetFileNameWithoutExtension(fileInfo.Name);
- if (!fid.IsNaturalNumeric())
- continue;
- int iid = int.Parse(fid);
-
- string json = File.ReadAllText(fileInfo.FullName);
- DishEntity deserializeObject = JsonConvert.DeserializeObject(json);
- if (deserializeObject.Id != iid)
- continue;
- if (result.Contains(deserializeObject))
- continue;
- result.Add(deserializeObject);
- }
-
- return result;
- }
-
- public void UiDishTypesAdd(DishEntity defaultDishType)
- {
- string path = Path.Combine(rootDirectory.FullName, "0-UI", "DishTypes");
- DirectoryInfo di = new DirectoryInfo(path);
- int fileId = GetNextJsonFileNumber(di);
- defaultDishType.Id = fileId;
- defaultDishType.DateAdded = DateTime.Now;
-
- path = Path.Combine(rootDirectory.FullName, "0-UI", "DishTypes", fileId.ToString() + ".json");
- string json = JsonConvert.SerializeObject(defaultDishType, jsonSerializerSettings);
- File.WriteAllText(path, json);
- }
-
- public object[] GetPluginConnector()
- {
- return new object[] { rootDirectory };
- }
-
- private bool pinged;
- public void Ping()
- {
- //Test if we can read
- string path = Path.Combine(rootDirectory.FullName, "test_write.bin");
- FileInfo testWriteFileInfo = new FileInfo(path);
- if (!testWriteFileInfo.Exists)
- {
- byte[] randomBuffer = new byte[4096];
- new Random().NextBytes(randomBuffer);
- File.WriteAllBytes(testWriteFileInfo.FullName, randomBuffer);
- }
-
- //Test if we can write
- byte[] readBack = File.ReadAllBytes(path);
-
- //Touch the ping file
- if (!pinged)
- {
- path = Path.Combine(rootDirectory.FullName, "ping.bin");
- FileStream fileStream = File.OpenWrite(path);
- BinaryWriter bw = new BinaryWriter(fileStream);
- bw.Write(Guid.NewGuid().ToByteArray());
- bw.Write(Environment.MachineName);
- bw.Write(Environment.UserName);
- bw.Write(DateTime.Now.ToUnixTime());
-
- NetworkInterface[] allNetworkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
- bw.Write(allNetworkInterfaces.Length);
- foreach (NetworkInterface allNetworkInterface in allNetworkInterfaces)
- {
- byte[] macBytes = allNetworkInterface.GetPhysicalAddress().GetAddressBytes();
- int macLength = macBytes.Length;
- if (macLength > Byte.MaxValue)
- macLength = 0;
-
- bw.Write((uint)1213222739);
- bw.Write((byte)macLength);
- bw.Write(macBytes, 0, macLength);
- }
- bw.Flush();
- fileStream.Close();
- pinged = true;
- }
- }
-
- public IEnumerable> GetBlindscanResultFrequencies(Guid selectedGuid)
- {
- throw new NotImplementedException();
- }
-
- public void InsertUiBlindscanSettingHistory(int settingsWindowBlScanTunerSelection,
- int multitunerMode, 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[] data = new object[]
- {
- DateTime.Now,
- settingsWindowBlScanTunerSelection, multitunerMode,
- settingsWindowSetFilterTunerSelection, settingsWindowDiseqc, settingsWindowCollectIqGraphs,
- settingsWindowCollectRfSpectrum, settingsWindowCaptureFile, settingsWindowSatellite, settingsWindowLnb,
- dish, settingsWindowScanHorizontalLow, settingsWindowScanHorizontalHigh,
- settingsWindowScanVerticalLow, settingsWindowScanVerticalHigh
- };
- string path = Path.Combine(rootDirectory.FullName, "last_blindscan_settings.json");
- File.WriteAllText(path, JsonConvert.SerializeObject(data));
- }
-
- public object[] GetLastUiBlindscanSettings()
- {
- string path = Path.Combine(rootDirectory.FullName, "last_blindscan_settings.json");
- if (File.Exists(path))
- {
- object[] result = JsonConvert.DeserializeObject