From fa0abb84f2065040ec71430352f623361bcb08b9 Mon Sep 17 00:00:00 2001 From: feyris-tan <4116042+feyris-tan@users.noreply.github.com> Date: Tue, 20 Jan 2026 17:01:31 +0100 Subject: [PATCH] Refactored the Equipments. --- .../MySqlDataStorage.cs | 12 +- .../skyscraper5.Data.MySql/Skyscraper.cs | 8 +- .../BlindscanJobs.cs | 6 +- .../skyscraper5.Data.PostgreSql/UiEntities.cs | 28 ++--- .../Overrides/Form1UiJunction.cs | 2 +- .../SkyscraperHandleCollection.cs | 6 +- .../Forms/ConfigureDishTypes.cs | 13 +- .../Forms/ConfigureLnbTypes.cs | 14 ++- .../Forms/ConfigureTunersWindow.cs | 6 +- GUIs/skyscraper8.UI.ImGui/Forms/JobDisplay.cs | 2 +- .../Forms/SatellitesConfigurationWindow.cs | 15 +-- GUIs/skyscraper8.UI.ImGui/Jobs/Blindscan.cs | 14 +-- .../Jobs/CoopBlindscan.cs | 18 +-- .../Jobs/InheritedBlindscanConfigWindow.cs | 8 +- .../Jobs/InheritedBlindscanUiJunction.cs | 2 +- GUIs/skyscraper8.UI.ImGui/Program.cs | 6 +- skyscraper8.Tests/RootTests/DocsisTests.cs | 113 +++++++++++++++++- skyscraper8.sln.DotSettings.user | 23 ++-- skyscraper8/Docsis/NullDocsisEventHandler.cs | 7 ++ skyscraper8/Passing.cs | 2 +- skyscraper8/Program.cs | 2 +- .../Skyscraper/Equipment/BaseEquipment.cs | 9 ++ skyscraper8/Skyscraper/Equipment/Dish.cs | 17 +-- .../Equipment/EquipmentCollection.cs | 20 ++++ .../Equipment/EquipmentUtilities.cs | 22 ++-- skyscraper8/Skyscraper/Equipment/LNB.cs | 22 +++- .../Equipment/SatellitePositionEntity.cs | 108 +++++++++++++++++ .../BaseBlindscanJob.cs | 13 +- .../BlindscanJobConfiguration.cs | 4 +- .../FrequencyListGenerator/DbBlindscanJob.cs | 6 +- .../Scraper/ISkyscraperUiJunction.cs | 2 +- .../Skyscraper/Scraper/Storage/DataStorage.cs | 14 +-- .../Storage/Filesystem/FilesystemStorage.cs | 38 +++--- .../InMemory/InMemoryScraperStorage.cs | 32 ++--- .../Security/AccessControl/SoftcamKeyset.cs | 68 +++-------- .../AccessControl/SoftcamTestProgram.cs | 2 +- 36 files changed, 462 insertions(+), 222 deletions(-) create mode 100644 skyscraper8/Skyscraper/Equipment/EquipmentCollection.cs create mode 100644 skyscraper8/Skyscraper/Equipment/SatellitePositionEntity.cs diff --git a/DataTableStorages/skyscraper5.Data.MySql/MySqlDataStorage.cs b/DataTableStorages/skyscraper5.Data.MySql/MySqlDataStorage.cs index 004ba81..b577e08 100644 --- a/DataTableStorages/skyscraper5.Data.MySql/MySqlDataStorage.cs +++ b/DataTableStorages/skyscraper5.Data.MySql/MySqlDataStorage.cs @@ -107,12 +107,12 @@ namespace skyscraper5.Data.MySql throw new NotImplementedException(); } - public void UiSatellitesAdd(SatellitePosition newPosition) + public void UiSatellitesAdd(SatellitePositionEntity newPosition) { throw new NotImplementedException(); } - public void UiSatellitesDelete(SatellitePosition satellitePosition) + public void UiSatellitesDelete(SatellitePositionEntity satellitePosition) { throw new NotImplementedException(); } @@ -233,22 +233,22 @@ namespace skyscraper5.Data.MySql throw new NotImplementedException(); } - public List UiLnbTypesListAll() + public List UiLnbTypesListAll() { throw new NotImplementedException(); } - public void UiLnbTypesAdd(LnbType defaultLnbType) + public void UiLnbTypesAdd(LnbEntity defaultLnbType) { throw new NotImplementedException(); } - public List UiDishTypesListAll() + public List UiDishTypesListAll() { throw new NotImplementedException(); } - public void UiDishTypesAdd(DishType defaultDishType) + public void UiDishTypesAdd(DishEntity defaultDishType) { throw new NotImplementedException(); } diff --git a/DataTableStorages/skyscraper5.Data.MySql/Skyscraper.cs b/DataTableStorages/skyscraper5.Data.MySql/Skyscraper.cs index ad0cc22..3642e44 100644 --- a/DataTableStorages/skyscraper5.Data.MySql/Skyscraper.cs +++ b/DataTableStorages/skyscraper5.Data.MySql/Skyscraper.cs @@ -50,9 +50,9 @@ namespace skyscraper5.Data.MySql } - public List UiSatellitesListAll() + public List UiSatellitesListAll() { - List result = new List(); + List result = new List(); using (MySqlConnection connection = new MySqlConnection(_mcsb.ToString())) { connection.Open(); @@ -62,9 +62,9 @@ namespace skyscraper5.Data.MySql MySqlDataReader dataReader = command.ExecuteReader(); while (dataReader.Read()) { - SatellitePosition satellitePosition = new SatellitePosition(); + SatellitePositionEntity satellitePosition = new SatellitePositionEntity(); satellitePosition.angle = dataReader.GetFloat(2); - satellitePosition.cardinalDirection = dataReader.GetBoolean(3) ? 0 : 1; + //satellitePosition.cardinalDirection = dataReader.GetBoolean(3) ? 0 : 1; satellitePosition.name = dataReader.GetString(4); result.Add(satellitePosition); } diff --git a/DataTableStorages/skyscraper5.Data.PostgreSql/BlindscanJobs.cs b/DataTableStorages/skyscraper5.Data.PostgreSql/BlindscanJobs.cs index c3d986a..7860497 100644 --- a/DataTableStorages/skyscraper5.Data.PostgreSql/BlindscanJobs.cs +++ b/DataTableStorages/skyscraper5.Data.PostgreSql/BlindscanJobs.cs @@ -328,7 +328,7 @@ namespace skyscraper5.Data.PostgreSql string note = null; if (!dataReader.IsDBNull(15)) note = dataReader.GetString(15); - result = new DbBlindscanJob(uuid, tuner_mac, (STD_TYPE)tuner_std, diseqc_index, new DummyGpsReceiver(true,(float)gps_lat,(float)gps_lon), SatellitePosition.FromChecksum(sat_position)); + result = new DbBlindscanJob(uuid, tuner_mac, (STD_TYPE)tuner_std, diseqc_index, new DummyGpsReceiver(true,(float)gps_lat,(float)gps_lon), SatellitePositionEntity.FromChecksum(sat_position)); result.DateAdded = date_added; result.HorizontalHighState = (DbBlindscanJobPolarizationStatus)horizontal_high; result.HorizontalLowState = (DbBlindscanJobPolarizationStatus)horizontal_low; @@ -546,11 +546,11 @@ namespace skyscraper5.Data.PostgreSql dgr = new DummyGpsReceiver(true, gpsLat, gpsLon); } - SatellitePosition satPositionObj = null; + SatellitePositionEntity satPositionObj = null; if (!dataReader.IsDBNull("sat_position")) { int satPosition = dataReader.GetInt32("sat_position"); - satPositionObj = SatellitePosition.FromChecksum(satPosition); + satPositionObj = SatellitePositionEntity.FromChecksum(satPosition); } int diseqcIndex = dataReader.GetInt32("diseqc_index"); int version = dataReader.GetInt32("version"); diff --git a/DataTableStorages/skyscraper5.Data.PostgreSql/UiEntities.cs b/DataTableStorages/skyscraper5.Data.PostgreSql/UiEntities.cs index 21f460d..c37d273 100644 --- a/DataTableStorages/skyscraper5.Data.PostgreSql/UiEntities.cs +++ b/DataTableStorages/skyscraper5.Data.PostgreSql/UiEntities.cs @@ -19,9 +19,9 @@ namespace skyscraper5.Data.PostgreSql this.uiVersion = version; } - public List UiLnbTypesListAll() + public List UiLnbTypesListAll() { - List lnbTypes = new List(); + List lnbTypes = new List(); using (NpgsqlConnection conn = new NpgsqlConnection(connectionStringBuilder.ToString())) { conn.Open(); @@ -38,7 +38,7 @@ namespace skyscraper5.Data.PostgreSql int lofSw = dataReader.GetInt32(5); int minFreq = dataReader.GetInt32(6); int maxFreq = dataReader.GetInt32(7); - lnbTypes.Add(new LnbType(name, lof1, lof2, lofSw, minFreq, maxFreq) { DateAdded = added, Id = id }); + lnbTypes.Add(new LnbEntity("", name, lof1, lof2, lofSw, minFreq, maxFreq) { DateAdded = added, Id = id }); } dataReader.Close(); @@ -49,7 +49,7 @@ namespace skyscraper5.Data.PostgreSql return lnbTypes; } - public void UiLnbTypesAdd(LnbType defaultLnbType) + public void UiLnbTypesAdd(LnbEntity defaultLnbType) { using (NpgsqlConnection conn = new NpgsqlConnection(connectionStringBuilder.ToString())) { @@ -69,9 +69,9 @@ namespace skyscraper5.Data.PostgreSql } } - public List UiDishTypesListAll() + public List UiDishTypesListAll() { - List result = new List(); + List result = new List(); using (NpgsqlConnection conn = new NpgsqlConnection(connectionStringBuilder.ToString())) { conn.Open(); @@ -85,14 +85,14 @@ namespace skyscraper5.Data.PostgreSql string name = dataReader.GetString(2); int diameter = dataReader.GetInt32(3); DishShape shape = (DishShape)dataReader.GetInt32(4); - result.Add(new DishType(name, diameter, shape) { DateAdded = added, Id = id }); + result.Add(new DishEntity("", name, diameter, shape) { DateAdded = added, Id = id }); } } return result; } - public void UiDishTypesAdd(DishType defaultDishType) + public void UiDishTypesAdd(DishEntity defaultDishType) { using (NpgsqlConnection conn = new NpgsqlConnection(connectionStringBuilder.ToString())) { @@ -109,9 +109,9 @@ namespace skyscraper5.Data.PostgreSql } - public List UiSatellitesListAll() + public List UiSatellitesListAll() { - List positions = new List(); + List positions = new List(); using (NpgsqlConnection conn = new NpgsqlConnection(connectionStringBuilder.ToString())) { conn.Open(); @@ -123,7 +123,7 @@ namespace skyscraper5.Data.PostgreSql float angle = (float)reader.GetDouble(0); int cardinal = reader.GetInt32(1); string name = reader.GetString(2); - SatellitePosition child = new SatellitePosition(angle, cardinal, name); + SatellitePositionEntity child = new SatellitePositionEntity(angle, name); positions.Add(child); } @@ -135,7 +135,7 @@ namespace skyscraper5.Data.PostgreSql return positions; } - public void UiSatellitesAdd(SatellitePosition newPosition) + public void UiSatellitesAdd(SatellitePositionEntity newPosition) { using (NpgsqlConnection conn = new NpgsqlConnection(connectionStringBuilder.ToString())) { @@ -145,7 +145,7 @@ namespace skyscraper5.Data.PostgreSql "insert into skyscraper5_satellite_positions (angle, cardinal, name, keyversion, key) " + "values (@angle, @cardinal, @name, @keyversion, @key)"; cmd.Parameters.AddWithValue("@angle", NpgsqlDbType.Real, newPosition.angle); - cmd.Parameters.AddWithValue("@cardinal", NpgsqlDbType.Integer, newPosition.cardinalDirection); + cmd.Parameters.AddWithValue("@cardinal", NpgsqlDbType.Integer, newPosition.GetCardinalDirectionAsInt()); cmd.Parameters.AddWithValue("@name", NpgsqlDbType.Text, newPosition.name); cmd.Parameters.AddWithValue("@keyversion", NpgsqlDbType.Integer, uiVersion); cmd.Parameters.AddWithValue("@key", NpgsqlDbType.Text, newPosition.Checksum.ToString()); @@ -155,7 +155,7 @@ namespace skyscraper5.Data.PostgreSql } } - public void UiSatellitesDelete(SatellitePosition satellitePosition) + public void UiSatellitesDelete(SatellitePositionEntity satellitePosition) { using (NpgsqlConnection conn = new NpgsqlConnection(connectionStringBuilder.ToString())) { diff --git a/GUIs/skyscraper5.UI/Overrides/Form1UiJunction.cs b/GUIs/skyscraper5.UI/Overrides/Form1UiJunction.cs index ebc2abd..b429415 100644 --- a/GUIs/skyscraper5.UI/Overrides/Form1UiJunction.cs +++ b/GUIs/skyscraper5.UI/Overrides/Form1UiJunction.cs @@ -127,7 +127,7 @@ namespace skyscraper5.UI.Overrides throw new NotImplementedException(); } - public void OnBlindscanBeforeSetChannel(BlindscanSearchResult blindscanResult, LnbType lnbType) + public void OnBlindscanBeforeSetChannel(BlindscanSearchResult blindscanResult, LnbEntity lnbType) { throw new NotImplementedException(); } diff --git a/GUIs/skyscraper8.UI.ImGui.MonoGame/SkyscraperHandleCollection.cs b/GUIs/skyscraper8.UI.ImGui.MonoGame/SkyscraperHandleCollection.cs index 6c2b295..d761de5 100644 --- a/GUIs/skyscraper8.UI.ImGui.MonoGame/SkyscraperHandleCollection.cs +++ b/GUIs/skyscraper8.UI.ImGui.MonoGame/SkyscraperHandleCollection.cs @@ -21,9 +21,9 @@ namespace skyscraper8.UI.MonoGame public DataStorage DataStorage { get; set; } public ObjectStorage ObjectStorage { get; set; } public IGpsReceiver Gps { get; set; } - public List SatellitePositions { get; set; } - public List LnbTypes { get; set; } - public List DishTypes { get; set; } + public List SatellitePositions { get; set; } + public List LnbTypes { get; set; } + public List DishTypes { get; set; } public ReadOnlyCollection> AllTunerFactories { get; set; } public IStreamReader StreamReader { get; set; } public List Tuners { get; set; } diff --git a/GUIs/skyscraper8.UI.ImGui/Forms/ConfigureDishTypes.cs b/GUIs/skyscraper8.UI.ImGui/Forms/ConfigureDishTypes.cs index 36a1947..67abde9 100644 --- a/GUIs/skyscraper8.UI.ImGui/Forms/ConfigureDishTypes.cs +++ b/GUIs/skyscraper8.UI.ImGui/Forms/ConfigureDishTypes.cs @@ -14,13 +14,14 @@ namespace SDL2Demo.Forms internal class ConfigureDishTypes : IRenderable { private readonly DataStorage _scraperStroage; - private List dishTypes; + private List dishTypes; private string tableUuid; + private string manufacturer; private string name; private int diameter; private DishShape shape; - public ConfigureDishTypes(DataStorage scraperStroage, List dishTypes) + public ConfigureDishTypes(DataStorage scraperStroage, List dishTypes) { _scraperStroage = scraperStroage; this.dishTypes = dishTypes; @@ -37,12 +38,14 @@ namespace SDL2Demo.Forms if (justSaved) { name = ""; + manufacturer = ""; diameter = 0; shape = DishShape.Offset; justSaved = false; } if (ImGui.TreeNode("Add Dish Type")) { + ImGui.InputText("Manufacturer", ref manufacturer, 255); ImGui.InputText("Name", ref name, 255); ImGui.InputInt("Diameter", ref diameter, 5, 10); @@ -63,7 +66,7 @@ namespace SDL2Demo.Forms ImGui.BeginDisabled(!SaveButtonEnabled()); if (ImGui.Button("Add")) { - DishType newDish = new DishType(name, diameter, shape); + DishEntity newDish = new DishEntity(manufacturer, name, diameter, shape); dishTypes.Add(newDish); _scraperStroage.UiDishTypesAdd(newDish); justSaved = true; @@ -84,7 +87,7 @@ namespace SDL2Demo.Forms ImGui.TableSetColumnIndex(2); ImGui.Text("Type"); - foreach (DishType dishType in dishTypes) + foreach (DishEntity dishType in dishTypes) { ImGui.TableNextRow(); ImGui.TableSetColumnIndex(0); @@ -120,7 +123,7 @@ namespace SDL2Demo.Forms return false; } - foreach (DishType dishType in dishTypes) + foreach (DishEntity dishType in dishTypes) { if (dishType.Name.Equals(name)) return false; diff --git a/GUIs/skyscraper8.UI.ImGui/Forms/ConfigureLnbTypes.cs b/GUIs/skyscraper8.UI.ImGui/Forms/ConfigureLnbTypes.cs index 4a6cdcb..0503b53 100644 --- a/GUIs/skyscraper8.UI.ImGui/Forms/ConfigureLnbTypes.cs +++ b/GUIs/skyscraper8.UI.ImGui/Forms/ConfigureLnbTypes.cs @@ -16,19 +16,21 @@ namespace SDL2Demo.Forms internal class ConfigureLnbTypes : IRenderable { private readonly DataStorage _scraperStroage; - private List lnbTypes; + private List lnbTypes; private string tableUuid; private string lnbPopupUuid; + private string manufacturer; private string name; private int lof1, lof2, lofSw, minFreq, maxFreq; - public ConfigureLnbTypes(DataStorage scraperStroage, List lnbTypes) + public ConfigureLnbTypes(DataStorage scraperStroage, List lnbTypes) { _scraperStroage = scraperStroage; this.lnbTypes = lnbTypes; this.tableUuid = Guid.NewGuid().ToString(); this.name = ""; + this.manufacturer = ""; this.lnbPopupUuid = Guid.NewGuid().ToString(); } @@ -39,6 +41,8 @@ namespace SDL2Demo.Forms ImGui.Begin("Configure LNB Types", ref pOpen, windowFlags); if (ImGui.TreeNode("Add LNB Type")) { + ImGui.InputText("Manufacturer", ref this.manufacturer, 64); + ImGui.SameLine(); ImGui.InputText("Name", ref name, 255); ImGui.InputInt("LOF1", ref lof1, 50, 100); @@ -55,7 +59,7 @@ namespace SDL2Demo.Forms ImGui.BeginDisabled(!SaveButtonEnabled()); if (ImGui.Button("Add")) { - LnbType newLnb = new LnbType(name, lof1, lof2, lofSw, minFreq, maxFreq); + LnbEntity newLnb = new LnbEntity(manufacturer, name, lof1, lof2, lofSw, minFreq, maxFreq); lnbTypes.Add(newLnb); _scraperStroage.UiLnbTypesAdd(newLnb); } @@ -98,7 +102,7 @@ namespace SDL2Demo.Forms ImGui.TableSetColumnIndex(2); ImGui.Text("Frequency Range"); - foreach (LnbType lnbType in lnbTypes) + foreach (LnbEntity lnbType in lnbTypes) { ImGui.TableNextRow(); ImGui.TableSetColumnIndex(0); @@ -136,7 +140,7 @@ namespace SDL2Demo.Forms if (lof1 == 0) return false; - foreach (LnbType lnbType in lnbTypes) + foreach (LnbEntity lnbType in lnbTypes) { if (lnbType.MinimumFrequency == minFreq && lnbType.MaximumFrequency == maxFreq && diff --git a/GUIs/skyscraper8.UI.ImGui/Forms/ConfigureTunersWindow.cs b/GUIs/skyscraper8.UI.ImGui/Forms/ConfigureTunersWindow.cs index 6d934dc..b00d858 100644 --- a/GUIs/skyscraper8.UI.ImGui/Forms/ConfigureTunersWindow.cs +++ b/GUIs/skyscraper8.UI.ImGui/Forms/ConfigureTunersWindow.cs @@ -10,9 +10,9 @@ namespace SDL2Demo.Forms internal class ConfigureTunersWindow : IRenderable { private readonly DataStorage _scraperStroage; - private List satPositions; - private List lnbTypes; - private List dishTypes; + private List satPositions; + private List lnbTypes; + private List dishTypes; public ConfigureTunersWindow(List tuners, DataStorage scraperStroage) { diff --git a/GUIs/skyscraper8.UI.ImGui/Forms/JobDisplay.cs b/GUIs/skyscraper8.UI.ImGui/Forms/JobDisplay.cs index a6a4e69..654e40d 100644 --- a/GUIs/skyscraper8.UI.ImGui/Forms/JobDisplay.cs +++ b/GUIs/skyscraper8.UI.ImGui/Forms/JobDisplay.cs @@ -2102,7 +2102,7 @@ namespace SDL2Demo.Forms throw new NotImplementedException(); } - public void OnBlindscanBeforeSetChannel(BlindscanSearchResult blindscanResult,LnbType lnbType) + public void OnBlindscanBeforeSetChannel(BlindscanSearchResult blindscanResult,LnbEntity lnbType) { throw new NotImplementedException(); } diff --git a/GUIs/skyscraper8.UI.ImGui/Forms/SatellitesConfigurationWindow.cs b/GUIs/skyscraper8.UI.ImGui/Forms/SatellitesConfigurationWindow.cs index 0517f3d..bcce20d 100644 --- a/GUIs/skyscraper8.UI.ImGui/Forms/SatellitesConfigurationWindow.cs +++ b/GUIs/skyscraper8.UI.ImGui/Forms/SatellitesConfigurationWindow.cs @@ -24,7 +24,7 @@ namespace SDL2Demo.Forms private string lnbPopupUuid; private string memoryTableUuid; - private List allPositions; + private List allPositions; private readonly DataStorage _storage; @@ -50,8 +50,8 @@ namespace SDL2Demo.Forms if (allPositions.Count == 0) return true; - int currentChecksum = SatellitePosition.GetChecksum(degrees, cardinalDirection); - foreach (SatellitePosition satellitePosition in allPositions) + int currentChecksum = SatellitePositionEntity.GetChecksum(degrees); + foreach (SatellitePositionEntity satellitePosition in allPositions) { if (currentChecksum == satellitePosition.Checksum) return false; @@ -68,9 +68,6 @@ namespace SDL2Demo.Forms { ImGui.InputText("Name", ref name, 255); ImGui.InputFloat("Position", ref degrees, 0.1f); - ImGui.RadioButton("East", ref cardinalDirection, 0); - ImGui.SameLine(); - ImGui.RadioButton("West", ref cardinalDirection, 1); CheckBounds(); @@ -78,7 +75,7 @@ namespace SDL2Demo.Forms ImGui.BeginDisabled(!SaveButtonEnabled()); if (ImGui.Button("Add")) { - SatellitePosition newPosition = new SatellitePosition(degrees, cardinalDirection, name); + SatellitePositionEntity newPosition = new SatellitePositionEntity(degrees, name); allPositions.Add(newPosition); _storage.UiSatellitesAdd(newPosition); } @@ -89,13 +86,13 @@ namespace SDL2Demo.Forms ImGui.Separator(); ImGui.BeginTable(memoryTableUuid, 4); - foreach (SatellitePosition satellitePosition in allPositions) + foreach (SatellitePositionEntity satellitePosition in allPositions) { ImGui.TableNextRow(); ImGui.TableSetColumnIndex(0); ImGui.Text(satellitePosition.name); ImGui.TableSetColumnIndex(1); - ImGui.Text(String.Format("{0:0.0}° {1}", satellitePosition.angle, satellitePosition.cardinalDirection == 0 ? "E" : "W")); + ImGui.Text(String.Format("{0:0.0}° {1}", satellitePosition.angle, satellitePosition.GetCardinalDirectionAsChar())); ImGui.TableSetColumnIndex(2); ImGui.Text(""); diff --git a/GUIs/skyscraper8.UI.ImGui/Jobs/Blindscan.cs b/GUIs/skyscraper8.UI.ImGui/Jobs/Blindscan.cs index ccf215b..e192a17 100644 --- a/GUIs/skyscraper8.UI.ImGui/Jobs/Blindscan.cs +++ b/GUIs/skyscraper8.UI.ImGui/Jobs/Blindscan.cs @@ -33,7 +33,7 @@ namespace SDL2Demo.Jobs public class BlindscanTarget { public BlindscanTarget(string name, int tunerIndex, STD_TYPE tunerStandard, int diseqcType, - SatellitePosition satPosition, int satIndex, LnbType lnbType, PhysicalAddress tunerMetadataMacAddress) + SatellitePositionEntity satPosition, int satIndex, LnbEntity lnbType, PhysicalAddress tunerMetadataMacAddress) { this.name = name; this.tunerIndex = tunerIndex; @@ -50,10 +50,10 @@ namespace SDL2Demo.Jobs public int tunerIndex; public STD_TYPE tunerStandard; public int diseqcType; - public SatellitePosition satPosition; + public SatellitePositionEntity satPosition; public int satIndex; public string buttonUuid; - public LnbType lnbType; + public LnbEntity lnbType; public readonly PhysicalAddress macAddress; public bool IsTorC() @@ -84,7 +84,7 @@ namespace SDL2Demo.Jobs private DbBlindscanJob jobInDb; private IDbBlindscanJobStorage jobStorage; - public Blindscan(List tuners, List satellitePositions, List lnbTypes, DataStorage dataStorage) + public Blindscan(List tuners, List satellitePositions, List lnbTypes, DataStorage dataStorage) { this.jobStorage = dataStorage; continuationDataExists = jobStorage.TestForIncompleteJob(); @@ -98,8 +98,8 @@ namespace SDL2Demo.Jobs int numSatsFromDiseqcType = tunerMetadata.GetNumSatsFromDiseqcType(); for (int i = 0; i < numSatsFromDiseqcType; i++) { - SatellitePosition satellitePosition = satellitePositions.Find(x => x.Checksum == tunerMetadata.Satellites[i]); - LnbType lnbType = lnbTypes.Find(x => x.Id == tunerMetadata.Lnbs[i]); + SatellitePositionEntity satellitePosition = satellitePositions.Find(x => x.Checksum == tunerMetadata.Satellites[i]); + LnbEntity lnbType = lnbTypes.Find(x => x.Id == tunerMetadata.Lnbs[i]); if (satellitePosition == null) continue; if (lnbType == null) @@ -835,7 +835,7 @@ namespace SDL2Demo.Jobs now.Year, now.Month, now.Day, now.Hour, now.Minute, blindscanResult.sr1.Freq / 1000, blindscanResult.sr1.Pol == 0 ? "H" : "V", blindscanResult.sr1.SR / 1000, (int)(SelectedBlindscanTarget.satPosition.angle * 10), - SelectedBlindscanTarget.satPosition.cardinalDirection == 0 ? "E" : "W"); + SelectedBlindscanTarget.satPosition.GetCardinalDirectionAsChar()); break; case STD_TYPE.STD_DVBC: JobContext.Puppets[1].AutoMoveTo(blindscanResult.Position); diff --git a/GUIs/skyscraper8.UI.ImGui/Jobs/CoopBlindscan.cs b/GUIs/skyscraper8.UI.ImGui/Jobs/CoopBlindscan.cs index 21ec9f3..c87382c 100644 --- a/GUIs/skyscraper8.UI.ImGui/Jobs/CoopBlindscan.cs +++ b/GUIs/skyscraper8.UI.ImGui/Jobs/CoopBlindscan.cs @@ -31,10 +31,10 @@ namespace SDL2Demo.Jobs private IDbBlindscanJobStorage jobStorage; private List tunerMetadataList; private JobContext jobContext; - private List satellites; - private List lnbs; + private List satellites; + private List lnbs; - public CoopBlindscan(List tuners, List satellitePositions, List lnbTypes, IDbBlindscanJobStorage jobStorage) + public CoopBlindscan(List tuners, List satellitePositions, List lnbTypes, IDbBlindscanJobStorage jobStorage) { this.jobStorage = jobStorage; this.tunerMetadataList = tuners.Where(x => x.Type == STD_TYPE.STD_DVBS || x.Type == STD_TYPE.STD_DVBS2).ToList(); @@ -166,8 +166,8 @@ namespace SDL2Demo.Jobs { settingsWindowOpen = false; int lnbIndex = tunerMetadataList[settingsWindowTunerAselection].Lnbs[settingsWindowDiseqc - 1]; - LnbType lnb = lnbs.Find(x => x.Id == lnbIndex); - Configuration = new CoopBlindscanConfiguration(tunerMetadataList[settingsWindowTunerAselection], tunerMetadataList[settingsWindowTunerBselection], settingsWindowScanHorizontalLow, settingsWindowScanHorizontalHigh, settingsWindowScanVerticalLow, settingsWindowScanVerticalHigh, settingsWindowDiseqc, settingsWindowSatellite, SatellitePosition.FromChecksum(satellites[settingsWindowSatellite].Checksum), lnb, settingsWindowCaptureFile); + LnbEntity lnb = lnbs.Find(x => x.Id == lnbIndex); + Configuration = new CoopBlindscanConfiguration(tunerMetadataList[settingsWindowTunerAselection], tunerMetadataList[settingsWindowTunerBselection], settingsWindowScanHorizontalLow, settingsWindowScanHorizontalHigh, settingsWindowScanVerticalLow, settingsWindowScanVerticalHigh, settingsWindowDiseqc, settingsWindowSatellite, SatellitePositionEntity.FromChecksum(satellites[settingsWindowSatellite].Checksum), lnb, settingsWindowCaptureFile); } ImGui.SameLine(); @@ -185,7 +185,7 @@ namespace SDL2Demo.Jobs public class CoopBlindscanConfiguration { - public CoopBlindscanConfiguration(TunerMetadata tunerA, TunerMetadata tunerB, bool doHorizontalLow, bool doHorizontalHigh, bool doVerticalLow, bool doVerticalHigh, int diseqc, int satelliteId, SatellitePosition direction, LnbType lnbType, bool recordingEnabled) + public CoopBlindscanConfiguration(TunerMetadata tunerA, TunerMetadata tunerB, bool doHorizontalLow, bool doHorizontalHigh, bool doVerticalLow, bool doVerticalHigh, int diseqc, int satelliteId, SatellitePositionEntity direction, LnbEntity lnbType, bool recordingEnabled) { TunerA = tunerA; TunerB = tunerB; @@ -208,8 +208,8 @@ namespace SDL2Demo.Jobs public bool DoVerticalHigh { get; } public int Diseqc { get; } public int SatelliteId { get; } - public SatellitePosition Direction { get; } - public LnbType LnbType { get; } + public SatellitePositionEntity Direction { get; } + public LnbEntity LnbType { get; } public bool RecordingEnabled { get; } } #endregion @@ -689,7 +689,7 @@ namespace SDL2Demo.Jobs now.Year, now.Month, now.Day, now.Hour, now.Minute, blindscanResult.sr1.Freq / 1000, blindscanResult.sr1.Pol == 0 ? "H" : "V", blindscanResult.sr1.SR / 1000, (int)(Configuration.Direction.angle * 10), - Configuration.Direction.cardinalDirection == 0 ? "E" : "W"); + Configuration.Direction.GetCardinalDirectionAsChar()); RunSkyscraper(blindscanResult); diff --git a/GUIs/skyscraper8.UI.ImGui/Jobs/InheritedBlindscanConfigWindow.cs b/GUIs/skyscraper8.UI.ImGui/Jobs/InheritedBlindscanConfigWindow.cs index c93b104..f127de1 100644 --- a/GUIs/skyscraper8.UI.ImGui/Jobs/InheritedBlindscanConfigWindow.cs +++ b/GUIs/skyscraper8.UI.ImGui/Jobs/InheritedBlindscanConfigWindow.cs @@ -13,9 +13,9 @@ namespace SDL2Demo.Jobs { private bool windowOpen; private List tuners; - private List satellites; - private List lnbs; - private List dishes; + private List satellites; + private List lnbs; + private List dishes; private readonly TaskQueue _taskQueue; public int settingsWindowBLScanTunerSelection; @@ -52,7 +52,7 @@ namespace SDL2Demo.Jobs settingsWindowScanVerticalLow, settingsWindowScanVerticalHigh); } public InheritedBlindscanConfigWindow(List tunerMetadatas, - List satellitePositions, List lnbTypes, List dishTypes, + List satellitePositions, List lnbTypes, List dishTypes, DataStorage dataStorage, ObjectStorage objectStorage, IGpsReceiver gps, Ini ini, IStreamReader streamReader, TaskQueue taskQueue) { diff --git a/GUIs/skyscraper8.UI.ImGui/Jobs/InheritedBlindscanUiJunction.cs b/GUIs/skyscraper8.UI.ImGui/Jobs/InheritedBlindscanUiJunction.cs index 8d380cb..85a059c 100644 --- a/GUIs/skyscraper8.UI.ImGui/Jobs/InheritedBlindscanUiJunction.cs +++ b/GUIs/skyscraper8.UI.ImGui/Jobs/InheritedBlindscanUiJunction.cs @@ -1657,7 +1657,7 @@ namespace SDL2Demo.Jobs return position; } - public void OnBlindscanBeforeSetChannel(BlindscanSearchResult blindscanResult, LnbType lnb) + public void OnBlindscanBeforeSetChannel(BlindscanSearchResult blindscanResult, LnbEntity lnb) { Point point = GetFrequencyPosition(blindscanResult.SearchResult, lnb.MinimumFrequency, lnb.MaximumFrequency); jobContext.Puppets[2 + blindscanResult.SearchResult.Pol].AutoMoveTo(point); diff --git a/GUIs/skyscraper8.UI.ImGui/Program.cs b/GUIs/skyscraper8.UI.ImGui/Program.cs index e20208b..8036634 100644 --- a/GUIs/skyscraper8.UI.ImGui/Program.cs +++ b/GUIs/skyscraper8.UI.ImGui/Program.cs @@ -211,9 +211,9 @@ namespace SkyscraperUI private ConfigureDataStorageWindow configureDataStorageWindow; private ConfigureObjectStorageWindow configureObjectStorageWindow; private SatellitesConfigurationWindow satellitesConfigurationWindow; - private List satellitePositions; - private List lnbTypes; - private List dishTypes; + private List satellitePositions; + private List lnbTypes; + private List dishTypes; //private LogWindow logWindow; private ScrapeFromTcp scrapeFromTcpWindow; private JobContext jobContext; diff --git a/skyscraper8.Tests/RootTests/DocsisTests.cs b/skyscraper8.Tests/RootTests/DocsisTests.cs index e711a2b..90dca08 100644 --- a/skyscraper8.Tests/RootTests/DocsisTests.cs +++ b/skyscraper8.Tests/RootTests/DocsisTests.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.IO; +using System.Net; using System.Net.NetworkInformation; using Microsoft.VisualStudio.TestTools.UnitTesting; using skyscraper5.Docsis; @@ -998,7 +1000,7 @@ public class DocsisTests : Feyllure 9, 0, 4, 0, 0, 0, 1, 10, 0, 1, 1, - 23, 0, 5 + 5 + 5, //length fr den SA descriptor + 23, 0, 5 + 5 + 5, //length fE den SA descriptor //Hier fngt der SA descriptor an 12, 0, 2, 0, 1, @@ -1058,10 +1060,10 @@ public class DocsisTests : Feyllure { 5, 1, - 0, 7, //Lnge fr darauffolgendes + 0, 7, //Lnge fE darauffolgendes 23, - 0, 4, //Lnge fr darauffolgendes + 0, 4, //Lnge fE darauffolgendes 8, 0, 1, 1 }; AssertTargetInvocation(() => docsisEnvironment.PushMacManagementMessage(null, 1, 13, srcAddr, dstAddr, payload)); @@ -1070,13 +1072,13 @@ public class DocsisTests : Feyllure { 8, //Code 1, //Identifier - 0, 4 + 7 + 5 + 1 + 2 + 4 + 7 + 4 + 4, //Length fr alles darauf folgende + 0, 4 + 7 + 5 + 1 + 2 + 4 + 7 + 4 + 4, //Length fE alles darauf folgende 10, 0, 1, 1, 11, 0, 4, 0, 0, 0, 1, 12, 0, 2, 0, 1, 13, //TEK parameters - 0, 4 + 7 + 4 + 4, //Length fr alles darauf folgende + 0, 4 + 7 + 4 + 4, //Length fE alles darauf folgende 8, 0, 1, 1, 9, 0, 4, 0, 0, 0, 1, 10, 0, 1, 1, @@ -1209,7 +1211,108 @@ public class DocsisTests : Feyllure nullDocsisEventHandler.OnUpstreamChannel(ucd); object dequeue = nullDocsisEventHandler.GetQueue().Dequeue(); Assert.AreEqual(ucd, dequeue); + + + nullDocsisEventHandler = new NullDocsisEventHandler(); + MacDomainDescriptor.DownstreamActiveChannel dac = new MacDomainDescriptor.DownstreamActiveChannel(new byte[] {} ); + nullDocsisEventHandler.OnDownstreamChannel(dstAddr, dac); + dequeue = nullDocsisEventHandler.GetQueue().Dequeue(); + Assert.AreEqual(dac, dequeue); + nullDocsisEventHandler.OnLearnedIpFromMac(PhysicalAddress.None, IPAddress.None); + ReadOnlyDictionary readOnlyDictionary = nullDocsisEventHandler.GetKnownIps(); + Assert.AreEqual(IPAddress.None, readOnlyDictionary[PhysicalAddress.None]); + } + + [TestMethod] + public void MacDomainDescriptorTest() + { + Random rng = new Random(); + byte[] srcAddrBuffer = new byte[6]; + byte[] dstAddrBuffer = new byte[6]; + rng.NextBytes(srcAddrBuffer); + rng.NextBytes(dstAddrBuffer); + PhysicalAddress srcAddr = new PhysicalAddress(srcAddrBuffer); + PhysicalAddress dstAddr = new PhysicalAddress(dstAddrBuffer); + + byte[] testBuffer = new byte[] + { + 1,1,1,1, //Header + 1,0, //Downstream Active Channel + 2,0, //Downstream Service Group + 3,4,0,0,0,0, //DownstreamAmbiguityResolutionFrequencyList + 4,0, //ReceiveChannelProfileReportingControlObject + 5,0, //IpInitalizationParameters + 6,1,1, //EarlyAuthentication + 7,0, //ActiveUpstreamChannelList + 8,1,1, //UpstreamChannelIds + 9,1,1, //UpstreamFrequencyRange + 10,1,1, //SymbolClockLocking + 11,0, //EventControlEncoding + 12,1,1, //UpstreamTransmitPowerReporting + 15,2,255,255, //SequenceOutOfRange + 16,1,1, //ExtendedUpstreamTransmitPowerSupport + 17,0, //CmtsDocsisVersion + 18,1,1, //CmPeriodicMaintenanceTimeout + 20,4,0,0,255,255, //DownstreamOfdmProfileFailure + }; + + MacDomainDescriptor mmd = new MacDomainDescriptor(srcAddr,dstAddr,testBuffer); + Assert.AreEqual(1, mmd.ConfigurationChangeCount); + Assert.AreEqual(1, mmd.NumberOfFragments); + Assert.AreEqual(1, mmd.FragmentSequenceNumber); + Assert.AreEqual(1, mmd.CurrentChannelDcid); + Assert.IsNotNull(mmd.DownstreamServiceGroup); + Assert.HasCount(1, mmd.DownstreamAmbiguityResolutionFrequencyList); + Assert.IsNotNull(mmd.ReceiveChannelProfileReportingControl); + Assert.IsNotNull(mmd.IpInitalizationParameters); + Assert.AreEqual(1, mmd.EarlyAuthentication.Value); + Assert.HasCount(1, mmd.ActiveUpstreamChannelList); + Assert.AreEqual(1, mmd.UpstreamChannelIds[0]); + Assert.AreEqual(1, mmd.UpstreamFrequencyRange.Value); + Assert.IsTrue(mmd.SymbolClockLocking); + Assert.HasCount(1, mmd.EventControlEncoding); + Assert.AreEqual(1, mmd.UpstreamTransmitPowerReporting.Value); + Assert.IsTrue(mmd.SequenceOutOfRange); + Assert.IsTrue(mmd.CmOperatingOnBatteryBackup); + Assert.IsTrue(mmd.CmReturnedToAcPower); + Assert.IsTrue(mmd.CmMacAddressRemoval); + Assert.AreEqual(1, mmd.ExtendedUpstreamTransmitPowerSupport.Value); + Assert.IsNotNull(mmd.CmtsDocsisVersion); + Assert.AreEqual(MacDomainDescriptor.CmPeriodicMaintenanceTimeoutEnum.UseProbe, mmd.CmPeriodicMaintenanceTimeout.Value); + Assert.IsTrue(mmd.DownstreamOfdmProfileFailure); + Assert.IsTrue(mmd.PrimaryDownstreamChannelChange); + Assert.IsTrue(mmd.DpdMismatch); + Assert.IsTrue(mmd.NcpProfileFailure); + Assert.IsTrue(mmd.PlcFailure); + Assert.IsTrue(mmd.NcpProfileRecovery); + Assert.IsTrue(mmd.PlcRecovery); + Assert.IsTrue(mmd.OfdmProfileRecovery); + Assert.IsTrue(mmd.OfdmaProfileFailure); + Assert.IsTrue(mmd.MapStorageOverflowIndicator); + Assert.IsTrue(mmd.MapStorageAlmostFullIndicator); + + byte[] expTestBuffer = new byte[] + { + 1, 1, 1, 1, //Header + 254, 0 //Invalid + }; + Assert.Throws(() => new MacDomainDescriptor(srcAddr,dstAddr,expTestBuffer)); + + byte[] cdvoBuffer = new byte[] + { + 1, 1, 1, + 2, 1, 1 + }; + MacDomainDescriptor.CmtsDocsisVersionObject cdvo = new MacDomainDescriptor.CmtsDocsisVersionObject(cdvoBuffer); + Assert.AreEqual(1, cdvo.MajorVersion.Value); + Assert.AreEqual(1, cdvo.MinorVersion.Value); + + cdvoBuffer = new byte[] + { + 254, 0, + }; + Assert.Throws(() => new MacDomainDescriptor.CmtsDocsisVersionObject(cdvoBuffer)); } } diff --git a/skyscraper8.sln.DotSettings.user b/skyscraper8.sln.DotSettings.user index b1b6d7e..f9ac6e8 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 &lt;skyscraper8.Tests&gt;" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> - <And> - <Namespace>skyscraper8.Tests</Namespace> - <Project Location="\home\schiemas\RiderProjects\skyscraper8\skyscraper8.Tests" Presentation="&lt;skyscraper8.Tests&gt;" /> - </And> + <SessionState ContinuousTestingMode="0" Name="All tests from &lt;skyscraper8.Tests&gt;" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> + <And> + <Namespace>skyscraper8.Tests</Namespace> + <Project Location="\home\schiemas\RiderProjects\skyscraper8\skyscraper8.Tests" Presentation="&lt;skyscraper8.Tests&gt;" /> + </And> </SessionState> - <SessionState ContinuousTestingMode="0" IsActive="True" Name="Continuous Testing" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> - <Project Location="\home\schiemas\RiderProjects\skyscraper8\skyscraper8.Tests" Presentation="&lt;skyscraper8.Tests&gt;" /> + <SessionState ContinuousTestingMode="0" Name="Continuous Testing" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> + <Project Location="\home\schiemas\RiderProjects\skyscraper8\skyscraper8.Tests" Presentation="&lt;skyscraper8.Tests&gt;" /> </SessionState> - <SessionState ContinuousTestingMode="0" Name="All tests from &lt;skyscraper8.Tests&gt;" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> - <Project Location="\home\schiemas\RiderProjects\skyscraper8\skyscraper8.Tests" Presentation="&lt;skyscraper8.Tests&gt;" /> + <SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from &lt;skyscraper8.Tests&gt;" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> + <Solution /> </SessionState> @@ -61,4 +61,7 @@ <data><HostParameters type="LocalHostParameters" /><Argument type="StandaloneArgument"><Arguments IsNull="False"></Arguments><FileName IsNull="False"></FileName><WorkingDirectory IsNull="False"></WorkingDirectory><Scope><ProcessFilters /></Scope></Argument><Info type="TimelineInfo" /><CoreOptions type="CoreOptions"><CoreTempPath IsNull="False"></CoreTempPath><RemoteEndPoint IsNull="False"></RemoteEndPoint><AdditionalEnvironmentVariables /></CoreOptions><HostOptions type="HostOptions"><HostTempPath IsNull="False"></HostTempPath></HostOptions></data> True True - False + False + True + True + diff --git a/skyscraper8/Docsis/NullDocsisEventHandler.cs b/skyscraper8/Docsis/NullDocsisEventHandler.cs index c87e5a5..0e73cd5 100644 --- a/skyscraper8/Docsis/NullDocsisEventHandler.cs +++ b/skyscraper8/Docsis/NullDocsisEventHandler.cs @@ -1,3 +1,5 @@ +using System.Collections.Frozen; +using System.Collections.ObjectModel; using System.Net; using System.Net.NetworkInformation; using skyscraper5.Docsis.AnnexC; @@ -82,4 +84,9 @@ public class NullDocsisEventHandler : IDocsisEventHandler { return timing.Value; } + + public ReadOnlyDictionary GetKnownIps() + { + return knownIps.AsReadOnly(); + } } diff --git a/skyscraper8/Passing.cs b/skyscraper8/Passing.cs index 9792854..b3eb855 100644 --- a/skyscraper8/Passing.cs +++ b/skyscraper8/Passing.cs @@ -31,7 +31,7 @@ namespace skyscraper5 public ObjectStorage ObjectStorage { get; set; } private IStreamReader streamReader; private List tuners; - private List satellitePositions; + private List satellitePositions; private static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name); public Passing() diff --git a/skyscraper8/Program.cs b/skyscraper8/Program.cs index 85c94c7..b1f9826 100644 --- a/skyscraper8/Program.cs +++ b/skyscraper8/Program.cs @@ -88,7 +88,7 @@ namespace skyscraper5 logger.DebugFormat("I'm a {0}-bit Process.", Environment.Is64BitProcess ? 64 : 32); PluginManager.GetInstance(); - SoftcamKeyset.GetInstance().InitializeFromFile(); + SoftcamKeyset.GetInstance().AutoInitalize(); if (args.Length != 0) { diff --git a/skyscraper8/Skyscraper/Equipment/BaseEquipment.cs b/skyscraper8/Skyscraper/Equipment/BaseEquipment.cs index 0ec9dc8..566f850 100644 --- a/skyscraper8/Skyscraper/Equipment/BaseEquipment.cs +++ b/skyscraper8/Skyscraper/Equipment/BaseEquipment.cs @@ -1,11 +1,20 @@ using System; +using System.Xml.Serialization; namespace skyscraper5.Skyscraper.Equipment { public class BaseEquipment { + [XmlIgnore] public int Id { get; set; } + + [XmlAttribute] + public string Manufacturer { get; set; } + + [XmlAttribute] public string Name { get; set; } + + [XmlIgnore] public DateTime DateAdded { get; set; } } } diff --git a/skyscraper8/Skyscraper/Equipment/Dish.cs b/skyscraper8/Skyscraper/Equipment/Dish.cs index bd79724..35a558e 100644 --- a/skyscraper8/Skyscraper/Equipment/Dish.cs +++ b/skyscraper8/Skyscraper/Equipment/Dish.cs @@ -1,25 +1,29 @@ using System; +using System.Xml.Serialization; namespace skyscraper5.Skyscraper.Equipment { - public class DishType : BaseEquipment + public class DishEntity : BaseEquipment { - public DishType(string name, int diameter, DishShape shape) + public DishEntity(string manufac, string name, int diameter, DishShape shape) { + this.Manufacturer = manufac; this.Name = name; this.Diameter = diameter; this.Shape = shape; } - public DishType() + public DishEntity() { } + [XmlAttribute] public int Diameter { get; set; } + [XmlAttribute] public DishShape Shape { get; set; } - protected bool Equals(DishType other) + protected bool Equals(DishEntity other) { return Diameter == other.Diameter && Shape == other.Shape; } @@ -29,7 +33,7 @@ namespace skyscraper5.Skyscraper.Equipment if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; if (obj.GetType() != this.GetType()) return false; - return Equals((DishType)obj); + return Equals((DishEntity)obj); } public override int GetHashCode() @@ -48,7 +52,6 @@ namespace skyscraper5.Skyscraper.Equipment Offset, PrimeFocus, Mesh, - Mobisat, - Selfsat + Other } } diff --git a/skyscraper8/Skyscraper/Equipment/EquipmentCollection.cs b/skyscraper8/Skyscraper/Equipment/EquipmentCollection.cs new file mode 100644 index 0000000..01f467b --- /dev/null +++ b/skyscraper8/Skyscraper/Equipment/EquipmentCollection.cs @@ -0,0 +1,20 @@ +namespace skyscraper5.Skyscraper.Equipment; + +public class EquipmentCollection +{ + public EquipmentCollection() + { + Dishes = new List(); + LNBs = new List(); + SatellitePositions = new List(); + } + + public List Dishes { get; set; } + public List LNBs { get; set; } + public List SatellitePositions { get; set; } + + public override string ToString() + { + return String.Format("{0} dishes, {1} LNBs, {2} satellite positions", Dishes.Count, LNBs.Count, SatellitePositions.Count); + } +} diff --git a/skyscraper8/Skyscraper/Equipment/EquipmentUtilities.cs b/skyscraper8/Skyscraper/Equipment/EquipmentUtilities.cs index 69e9637..f76f107 100644 --- a/skyscraper8/Skyscraper/Equipment/EquipmentUtilities.cs +++ b/skyscraper8/Skyscraper/Equipment/EquipmentUtilities.cs @@ -9,45 +9,47 @@ namespace skyscraper5.Skyscraper.Equipment { public static void InsertDefaultLnbTypes(DataStorage storage) { - List knownLnbTypes = storage.UiLnbTypesListAll(); - foreach (LnbType defaultLnbType in GetDefaultLnbTypes()) + List knownLnbTypes = storage.UiLnbTypesListAll(); + foreach (LnbEntity defaultLnbType in GetDefaultLnbTypes()) { if (!knownLnbTypes.Contains(defaultLnbType)) storage.UiLnbTypesAdd(defaultLnbType); } } - private static IEnumerable GetDefaultLnbTypes() + private static IEnumerable GetDefaultLnbTypes() { - LnbType lnbType = new LnbType(); + LnbEntity lnbType = new LnbEntity(); lnbType.Lof1 = 9750; lnbType.Lof2 = 10600; lnbType.LofSw = 11700; lnbType.MinimumFrequency = 10700; lnbType.MaximumFrequency = 12750; - lnbType.Name = "Generic Universal LNB"; + lnbType.Manufacturer = "Generic"; + lnbType.Name = "Universal LNB"; yield return lnbType; } public static void InsertDefaultDishTypes(DataStorage storage) { - List knownDishTypes = storage.UiDishTypesListAll(); - foreach (DishType defaultDishType in GetDefaultDishTypes()) + List knownDishTypes = storage.UiDishTypesListAll(); + foreach (DishEntity defaultDishType in GetDefaultDishTypes()) { if (!knownDishTypes.Contains(defaultDishType)) storage.UiDishTypesAdd(defaultDishType); } } - private static IEnumerable GetDefaultDishTypes() + private static IEnumerable GetDefaultDishTypes() { int[] commonSizes = new int[] { 60, 80, 85, 100 }; foreach (int commonSize in commonSizes) { - DishType dishType = new DishType(); + DishEntity dishType = new DishEntity(); dishType.Diameter = commonSize; dishType.Shape = DishShape.Offset; - dishType.Name = String.Format("Generic {0} cm Offset dish antenna", commonSize); + dishType.Manufacturer = "Generic"; + dishType.Name = String.Format("{0} cm Offset dish antenna", commonSize); yield return dishType; } } diff --git a/skyscraper8/Skyscraper/Equipment/LNB.cs b/skyscraper8/Skyscraper/Equipment/LNB.cs index 322429e..9200aef 100644 --- a/skyscraper8/Skyscraper/Equipment/LNB.cs +++ b/skyscraper8/Skyscraper/Equipment/LNB.cs @@ -1,13 +1,15 @@ using System; +using System.Xml.Serialization; namespace skyscraper5.Skyscraper.Equipment { - public class LnbType : BaseEquipment + public class LnbEntity : BaseEquipment { - public LnbType() { } + public LnbEntity() { } - public LnbType(string name, int lof1, int lof2, int lofSw, int minFreq, int maxFreq) + public LnbEntity(string manufac, string name, int lof1, int lof2, int lofSw, int minFreq, int maxFreq) { + this.Manufacturer = manufac; this.Name = name; this.Lof1 = lof1; this.Lof2 = lof2; @@ -16,14 +18,22 @@ namespace skyscraper5.Skyscraper.Equipment this.MaximumFrequency = maxFreq; } + [XmlAttribute] public int Lof1 { get; set; } + + [XmlAttribute] public int Lof2 { get; set; } + + [XmlAttribute] public int LofSw { get; set; } + [XmlAttribute] public int MinimumFrequency { get; set; } + + [XmlAttribute] public int MaximumFrequency { get; set; } - protected bool Equals(LnbType other) + protected bool Equals(LnbEntity other) { return Lof1 == other.Lof1 && Lof2 == other.Lof2 && LofSw == other.LofSw && MinimumFrequency == other.MinimumFrequency && MaximumFrequency == other.MaximumFrequency; } @@ -33,7 +43,7 @@ namespace skyscraper5.Skyscraper.Equipment if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; if (obj.GetType() != this.GetType()) return false; - return Equals((LnbType)obj); + return Equals((LnbEntity)obj); } public override int GetHashCode() @@ -43,7 +53,7 @@ namespace skyscraper5.Skyscraper.Equipment public override string ToString() { - return Name; + return String.Format("{0} {1}", Manufacturer, Name); } } } diff --git a/skyscraper8/Skyscraper/Equipment/SatellitePositionEntity.cs b/skyscraper8/Skyscraper/Equipment/SatellitePositionEntity.cs new file mode 100644 index 0000000..c517183 --- /dev/null +++ b/skyscraper8/Skyscraper/Equipment/SatellitePositionEntity.cs @@ -0,0 +1,108 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace skyscraper5.Skyscraper +{ + public class SatellitePositionEntity + { + public SatellitePositionEntity() + { + } + + public SatellitePositionEntity(float angle, string name) + { + this.angle = angle; + this.name = name; + } + + public float angle; + public string name; + + public int Checksum => GetChecksum(angle); + + public static int GetChecksum(float angle) + { + int result = (int)(angle * 10.0f); + return result; + } + + public override string ToString() + { + if (angle > 0) + { + return String.Format("{0}°E {1}", angle, name); + } + else + { + float tmpAngle = angle; + tmpAngle *= -1; + return String.Format("{0}°W {1}", tmpAngle, name); + } + } + + public static SatellitePositionEntity FromChecksum(int checksum) + { + float newAngle = checksum; + newAngle /= 10.0f; + return new SatellitePositionEntity(newAngle, "???"); + } + + protected bool Equals(SatellitePositionEntity other) + { + return angle.Equals(other.angle); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((SatellitePositionEntity)obj); + } + + public override int GetHashCode() + { + return HashCode.Combine(angle); + } + + + /// + /// Returns an integer value for the cardinal direction. + /// + /// Returns 0 for east, 1 for west, 2 if satellite is at 0.0 + public int GetCardinalDirectionAsInt() + { + if (angle > 0) + return 0; + else if (angle < 0) + return 1; + else + return 2; + } + + /// + /// Get the letter matching the cardinal direction of the satellite. + /// + /// Returns either 'E' or 'W' depending on the angle. + public char GetCardinalDirectionAsChar() + { + int cardinalDirectionAsInt = GetCardinalDirectionAsInt(); + return cardinalDirectionAsInt == 0 ? 'E' : 'W'; + } + + /// + /// Get a filename-safe number of the angle. Meaning the angle stripped of its sign and decimal separator. + /// + /// For example: For 19.2°E, this will return 192, For 34.5°W, this will return 345 + public int GetCleanAngle() + { + int cleanAngle = (int)(angle * 10.0f); + if (cleanAngle < 0) + cleanAngle /= -1; + return cleanAngle; + } + } +} diff --git a/skyscraper8/Skyscraper/FrequencyListGenerator/BaseBlindscanJob.cs b/skyscraper8/Skyscraper/FrequencyListGenerator/BaseBlindscanJob.cs index f5af635..55ace83 100644 --- a/skyscraper8/Skyscraper/FrequencyListGenerator/BaseBlindscanJob.cs +++ b/skyscraper8/Skyscraper/FrequencyListGenerator/BaseBlindscanJob.cs @@ -707,12 +707,21 @@ namespace skyscraper8.Skyscraper.FrequencyListGenerator if (tsRecorder.PrepareRecording()) { DateTime now = DateTime.Now; + + int cardinalDirection = 0; + int angle = config.SatellitePosition.Checksum; + if (angle < 0) + { + angle *= -1; + cardinalDirection = 1; + } + string recordingFilename = string.Format( "skyscraper_{0:D4}{1:D2}{2:D2}_{3:D2}{4:D2}_{8:D4}{9}_{5}_{6}_{7}.ts", now.Year, now.Month, now.Day, now.Hour, now.Minute, result.GetFrequency() / 1000, result.GetPolarity(config.LnbType.LofSw), result.GetSymbolRate() / 1000, - (int)(config.SatellitePosition.angle * 10), - config.SatellitePosition.cardinalDirection == 0 ? "E" : "W"); + config.SatellitePosition.GetCleanAngle(), + config.SatellitePosition.GetCardinalDirectionAsChar()); tsRecorder.SetNextFilename(recordingFilename); tsRecorder.CreateBufferedStream(); } diff --git a/skyscraper8/Skyscraper/FrequencyListGenerator/BlindscanJobConfiguration.cs b/skyscraper8/Skyscraper/FrequencyListGenerator/BlindscanJobConfiguration.cs index 7c2af3e..0588476 100644 --- a/skyscraper8/Skyscraper/FrequencyListGenerator/BlindscanJobConfiguration.cs +++ b/skyscraper8/Skyscraper/FrequencyListGenerator/BlindscanJobConfiguration.cs @@ -18,7 +18,7 @@ namespace skyscraper8.Skyscraper.FrequencyListGenerator public TunerMetadata TunerMetadata { get; set; } public int DiseqcIndex { get; set; } public IGpsReceiver Gps { get; set; } - public SatellitePosition SatellitePosition { get; set; } + public SatellitePositionEntity SatellitePosition { get; set; } public bool DoHorizontalHigh { get; set; } public bool DoHorizontalLow { get; set; } @@ -29,7 +29,7 @@ namespace skyscraper8.Skyscraper.FrequencyListGenerator public ObjectStorage ObjectStorage { get; set; } public ISkyscraperUiJunction Ui { get; set; } public bool DoCollectRfSpectrum { get; set; } - public LnbType LnbType { get; set; } + public LnbEntity LnbType { get; set; } public bool DoCollectIqGraphs { get; set; } public bool DoRecordTs { get; set; } public Ini Ini { get; set; } diff --git a/skyscraper8/Skyscraper/FrequencyListGenerator/DbBlindscanJob.cs b/skyscraper8/Skyscraper/FrequencyListGenerator/DbBlindscanJob.cs index 611e224..26353fe 100644 --- a/skyscraper8/Skyscraper/FrequencyListGenerator/DbBlindscanJob.cs +++ b/skyscraper8/Skyscraper/FrequencyListGenerator/DbBlindscanJob.cs @@ -15,7 +15,7 @@ namespace skyscraper5.src.Skyscraper.FrequencyListGenerator public class DbBlindscanJob { public DbBlindscanJob(Guid jobGuid, PhysicalAddress tunerMac, STD_TYPE tunerStandard, int diseqCIndex, - IGpsReceiver jobContextGps, SatellitePosition satellitePosition) + IGpsReceiver jobContextGps, SatellitePositionEntity satellitePosition) { this.JobGuid = jobGuid; this.TunerMAC = tunerMac; @@ -37,7 +37,7 @@ namespace skyscraper5.src.Skyscraper.FrequencyListGenerator } - public SatellitePosition SatPosition { get; private set; } + public SatellitePositionEntity SatPosition { get; private set; } public GpsCoordinate? GpsCoordinate { get; private set; } @@ -69,7 +69,7 @@ namespace skyscraper5.src.Skyscraper.FrequencyListGenerator { case 1: if (SatPosition != null) - return String.Format("{0:0.0}° {1}", SatPosition.angle, SatPosition.cardinalDirection == 0 ? "E" : "W"); + return String.Format("{0:0.0}° {1}", SatPosition.angle, SatPosition.GetCardinalDirectionAsChar()); return TunerStandard.ToString(); case 2: return String.Format("({0}/{1}/{2}/{3})", (int)HorizontalLowState, (int)HorizontalHighState, (int)VerticalLowState, (int)VerticalHighState); diff --git a/skyscraper8/Skyscraper/Scraper/ISkyscraperUiJunction.cs b/skyscraper8/Skyscraper/Scraper/ISkyscraperUiJunction.cs index 12a20b4..5a97aa3 100644 --- a/skyscraper8/Skyscraper/Scraper/ISkyscraperUiJunction.cs +++ b/skyscraper8/Skyscraper/Scraper/ISkyscraperUiJunction.cs @@ -88,7 +88,7 @@ namespace skyscraper5.Skyscraper.Scraper /// Called before a SetChannel operation is performed. /// /// - void OnBlindscanBeforeSetChannel(BlindscanSearchResult blindscanResult, LnbType lnbType); + void OnBlindscanBeforeSetChannel(BlindscanSearchResult blindscanResult, LnbEntity lnbType); /// /// Called after a band (meaning e.g. Horizontal High) has been scraped. diff --git a/skyscraper8/Skyscraper/Scraper/Storage/DataStorage.cs b/skyscraper8/Skyscraper/Scraper/Storage/DataStorage.cs index f1be71b..eb90b9f 100644 --- a/skyscraper8/Skyscraper/Scraper/Storage/DataStorage.cs +++ b/skyscraper8/Skyscraper/Scraper/Storage/DataStorage.cs @@ -86,9 +86,9 @@ namespace skyscraper8.Skyscraper.Scraper.Storage void T2MiSetTimestamp(int currentNetworkId, int currentTransportStreamId, int pid, DateTime resolveTime); bool TestForRelatedContent(EitEvent lEvent, RctLinkInfo rctLinkInfo); void SetRelatedContent(EitEvent lEvent, RctLinkInfo rctLinkInfo); - List UiSatellitesListAll(); - void UiSatellitesAdd(SatellitePosition newPosition); - void UiSatellitesDelete(SatellitePosition satellitePosition); + List UiSatellitesListAll(); + void UiSatellitesAdd(SatellitePositionEntity newPosition); + void UiSatellitesDelete(SatellitePositionEntity satellitePosition); bool UiTunerTestFor(TunerMetadata tuner); void UiTunerUpdate(TunerMetadata tuner); void UiTunerInsert(TunerMetadata tuner); @@ -108,10 +108,10 @@ namespace skyscraper8.Skyscraper.Scraper.Storage bool T2MiTestForTransmitter(int? currentNetworkId, int? currentTransportStreamId, int relatedPid, ushort txIdentifier); void T2MiRememberTransmitter(int? currentNetworkId, int? currentTransportStreamId, int relatedPid, ushort txIdentifier); void T2MiSetTransmitterTimeOffset(int? currentNetworkId, int? currentTransportStreamId, int relatedPid, ushort txIdentifier, ushort timeOffset); - List UiLnbTypesListAll(); - void UiLnbTypesAdd(LnbType defaultLnbType); - List UiDishTypesListAll(); - void UiDishTypesAdd(DishType defaultDishType); + List UiLnbTypesListAll(); + void UiLnbTypesAdd(LnbEntity defaultLnbType); + List UiDishTypesListAll(); + void UiDishTypesAdd(DishEntity defaultDishType); IEnumerable> SelectAllPmt(); SdtService SelectSdtById(int networkId, int tsId, ushort programMappingProgramNumber); diff --git a/skyscraper8/Skyscraper/Scraper/Storage/Filesystem/FilesystemStorage.cs b/skyscraper8/Skyscraper/Scraper/Storage/Filesystem/FilesystemStorage.cs index be8e345..19e2ac7 100644 --- a/skyscraper8/Skyscraper/Scraper/Storage/Filesystem/FilesystemStorage.cs +++ b/skyscraper8/Skyscraper/Scraper/Storage/Filesystem/FilesystemStorage.cs @@ -818,30 +818,30 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.Filesystem } } - public List UiSatellitesListAll() + public List UiSatellitesListAll() { string path = Path.Combine(rootDirectory.FullName, "satellites.json"); FileInfo fi = new FileInfo(path); if (!fi.Exists) - return new List(); + return new List(); else { - return JsonConvert.DeserializeObject>(File.ReadAllText(fi.FullName)); + return JsonConvert.DeserializeObject>(File.ReadAllText(fi.FullName)); } } - public void UiSatellitesAdd(SatellitePosition newPosition) + public void UiSatellitesAdd(SatellitePositionEntity newPosition) { string path = Path.Combine(rootDirectory.FullName, "satellites.json"); FileInfo fi = new FileInfo(path); - List satellites; + List satellites; if (!fi.Exists) { - satellites = new List(); + satellites = new List(); } else { - satellites = JsonConvert.DeserializeObject>(File.ReadAllText(fi.FullName)); + satellites = JsonConvert.DeserializeObject>(File.ReadAllText(fi.FullName)); } satellites.Add(newPosition); @@ -849,11 +849,11 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.Filesystem File.WriteAllText(fi.FullName, JsonConvert.SerializeObject(satellites, Formatting.Indented)); } - public void UiSatellitesDelete(SatellitePosition satellitePosition) + 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)); + List satellites = JsonConvert.DeserializeObject>(File.ReadAllText(fi.FullName)); satellites.RemoveAll(x => x.Checksum == satellitePosition.Checksum); @@ -964,16 +964,16 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.Filesystem File.WriteAllText(path, timeOffset.ToString()); } - public List UiLnbTypesListAll() + public List UiLnbTypesListAll() { string path = Path.Combine(rootDirectory.FullName, "0-UI", "LnbTypes"); DirectoryInfo di = new DirectoryInfo(path); if (!di.Exists) { - return new List(); + return new List(); } - List result = new List(); + List result = new List(); FileInfo[] fileInfos = di.GetFiles("*.json"); foreach (FileInfo fileInfo in fileInfos) { @@ -983,7 +983,7 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.Filesystem int iid = int.Parse(fid); string json = File.ReadAllText(fileInfo.FullName); - LnbType deserializeObject = JsonConvert.DeserializeObject(json); + LnbEntity deserializeObject = JsonConvert.DeserializeObject(json); if (deserializeObject.Id != iid) continue; if (result.Contains(deserializeObject)) @@ -1017,7 +1017,7 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.Filesystem return result; } - public void UiLnbTypesAdd(LnbType defaultLnbType) + public void UiLnbTypesAdd(LnbEntity defaultLnbType) { string path = Path.Combine(rootDirectory.FullName, "0-UI", "LnbTypes"); DirectoryInfo di = new DirectoryInfo(path); @@ -1030,16 +1030,16 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.Filesystem File.WriteAllText(path, json); } - public List UiDishTypesListAll() + public List UiDishTypesListAll() { string path = Path.Combine(rootDirectory.FullName, "0-UI", "DishTypes"); DirectoryInfo di = new DirectoryInfo(path); if (!di.Exists) { - return new List(); + return new List(); } - List result = new List(); + List result = new List(); FileInfo[] fileInfos = di.GetFiles("*.json"); foreach (FileInfo fileInfo in fileInfos) { @@ -1049,7 +1049,7 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.Filesystem int iid = int.Parse(fid); string json = File.ReadAllText(fileInfo.FullName); - DishType deserializeObject = JsonConvert.DeserializeObject(json); + DishEntity deserializeObject = JsonConvert.DeserializeObject(json); if (deserializeObject.Id != iid) continue; if (result.Contains(deserializeObject)) @@ -1060,7 +1060,7 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.Filesystem return result; } - public void UiDishTypesAdd(DishType defaultDishType) + public void UiDishTypesAdd(DishEntity defaultDishType) { string path = Path.Combine(rootDirectory.FullName, "0-UI", "DishTypes"); DirectoryInfo di = new DirectoryInfo(path); diff --git a/skyscraper8/Skyscraper/Scraper/Storage/InMemory/InMemoryScraperStorage.cs b/skyscraper8/Skyscraper/Scraper/Storage/InMemory/InMemoryScraperStorage.cs index 9fa0d43..6e8de88 100644 --- a/skyscraper8/Skyscraper/Scraper/Storage/InMemory/InMemoryScraperStorage.cs +++ b/skyscraper8/Skyscraper/Scraper/Storage/InMemory/InMemoryScraperStorage.cs @@ -771,23 +771,23 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory throw new NotImplementedException(); } - private List satellitePositions; + private List satellitePositions; - public List UiSatellitesListAll() + public List UiSatellitesListAll() { if (satellitePositions == null) - satellitePositions = new List(); + satellitePositions = new List(); return satellitePositions.ToList(); } - public void UiSatellitesAdd(SatellitePosition newPosition) + public void UiSatellitesAdd(SatellitePositionEntity newPosition) { if (satellitePositions == null) - satellitePositions = new List(); + satellitePositions = new List(); satellitePositions.Add(newPosition); } - public void UiSatellitesDelete(SatellitePosition satellitePosition) + public void UiSatellitesDelete(SatellitePositionEntity satellitePosition) { satellitePositions.RemoveAll(x => x.Checksum == satellitePosition.Checksum); } @@ -905,37 +905,37 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory t2miTransmitters[t2miTransmitterId].TimeOffset = timeOffset; } - private List _lnbTypes; + private List _lnbTypes; - public List UiLnbTypesListAll() + public List UiLnbTypesListAll() { if (_lnbTypes == null) - _lnbTypes = new List(); + _lnbTypes = new List(); return _lnbTypes; } - public void UiLnbTypesAdd(LnbType defaultLnbType) + public void UiLnbTypesAdd(LnbEntity defaultLnbType) { if (_lnbTypes == null) - _lnbTypes = new List(); + _lnbTypes = new List(); if (!_lnbTypes.Contains(defaultLnbType)) _lnbTypes.Add(defaultLnbType); } - private List _dishTypes; + private List _dishTypes; - public List UiDishTypesListAll() + public List UiDishTypesListAll() { if (_dishTypes == null) - _dishTypes = new List(); + _dishTypes = new List(); return _dishTypes; } - public void UiDishTypesAdd(DishType defaultDishType) + public void UiDishTypesAdd(DishEntity defaultDishType) { if (_dishTypes == null) - _dishTypes = new List(); + _dishTypes = new List(); if (!_dishTypes.Contains(defaultDishType)) _dishTypes.Add(defaultDishType); } diff --git a/skyscraper8/Skyscraper/Security/AccessControl/SoftcamKeyset.cs b/skyscraper8/Skyscraper/Security/AccessControl/SoftcamKeyset.cs index c140168..662e8e3 100644 --- a/skyscraper8/Skyscraper/Security/AccessControl/SoftcamKeyset.cs +++ b/skyscraper8/Skyscraper/Security/AccessControl/SoftcamKeyset.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using skyscraper5.Skyscraper; +using skyscraper5.Skyscraper.Plugins; namespace skyscraper8.Skyscraper.Security.AccessControl { @@ -21,45 +22,24 @@ namespace skyscraper8.Skyscraper.Security.AccessControl return _singleton; } - private FileInfo TryFindSoftcamKey() + public bool AutoInitalize() { - foreach (FileInfo fi in GetPossibleLocations()) - { - if (fi.Exists) - { - return fi; - } - } + PluginManager pluginManager = PluginManager.GetInstance(); + Ini ini = pluginManager.Ini; + bool softcamEnabled = ini.ReadValue("softcam", "enable", false); + if (!softcamEnabled) + return false; - return null; + string softcamKeyPath = ini.ReadValue("softcam", "path", FILE_NAME); + FileInfo softcamKeyFileInfo = new FileInfo(softcamKeyPath); + if (!softcamKeyFileInfo.Exists) + return false; + + int result = LoadSoftcamKey(softcamKeyFileInfo); + return result > 0; } - + private const string FILE_NAME = "SoftCam.Key"; - private IEnumerable GetPossibleLocations() - { - FileInfo self = new FileInfo(FILE_NAME); - yield return self; - - string assemblyLocation = this.GetType().Assembly.Location; - FileInfo assemblyLocationFileInfo = new FileInfo(assemblyLocation); - DirectoryInfo assemblyLocationDirectory = assemblyLocationFileInfo.Directory; - string assemblyLocationKeyfileName = Path.Combine(assemblyLocationDirectory.FullName, FILE_NAME); - yield return new FileInfo(assemblyLocationKeyfileName); - - DirectoryInfo rootDirectory = self.Directory.Root; - DirectoryInfo selfDirectory = self.Directory; - do - { - selfDirectory = selfDirectory.Parent; - if (selfDirectory == null) - break; - string possibleName = Path.Combine(selfDirectory.FullName, FILE_NAME); - yield return new FileInfo(possibleName); - } while (!selfDirectory.Equals(rootDirectory)); - - yield return new FileInfo("C:\\FT\\SoftCam_Emu\\SoftCam.Key"); - } - private int LoadSoftcamKey(FileInfo fi) { int result = 0; @@ -181,24 +161,6 @@ namespace skyscraper8.Skyscraper.Security.AccessControl return result; } - private bool doneFileInitalization; - public void InitializeFromFile() - { - if (doneFileInitalization) - { - throw new AccessControlException("Softcam.key Keyset already initalized."); - } - - doneFileInitalization = true; - FileInfo keyLocation = TryFindSoftcamKey(); - if (keyLocation != null) - { - logger.InfoFormat("Loading keys from: {0}", keyLocation.FullName); - int numKeysLoaded = LoadSoftcamKey(keyLocation); - logger.InfoFormat("I suppose you are legally entitled to use those {0} keys I just loaded, You are, right?",numKeysLoaded); - } - } - private List _viaccessKeys; public IReadOnlyList ViaccessKeys => _viaccessKeys; diff --git a/skyscraper8/Skyscraper/Security/AccessControl/SoftcamTestProgram.cs b/skyscraper8/Skyscraper/Security/AccessControl/SoftcamTestProgram.cs index af9294c..69ab46c 100644 --- a/skyscraper8/Skyscraper/Security/AccessControl/SoftcamTestProgram.cs +++ b/skyscraper8/Skyscraper/Security/AccessControl/SoftcamTestProgram.cs @@ -14,7 +14,7 @@ namespace skyscraper8.Skyscraper.Security.AccessControl public void Run() { SoftcamKeyset softcamKeyset = SoftcamKeyset.GetInstance(); - softcamKeyset.InitializeFromFile(); + softcamKeyset.AutoInitalize(); byte[] bissKey = softcamKeyset.FindBissKey(2, 85); BissDescrambleFilter descrambler = new BissDescrambleFilter(bissKey);