diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index b7675b2..0dc3454 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -24,21 +24,3 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} path-to-lcov: src/BaseStationReader.Tests/coverage/coverage.info - - name: Cache SonarCloud packages - uses: actions/cache@v1 - with: - path: ~/sonar/cache - key: ${{ runner.os }}-sonar - restore-keys: ${{ runner.os }}-sonar - - name: Install SonarCloud scanners - run: | - dotnet tool install --global dotnet-sonarscanner - - name: Build and analyze - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: | - dotnet-sonarscanner begin /k:"davewalker5_ADS-B-BaseStationReader" /o:"davewalker5" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" - dotnet build --configuration Release src/BaseStationReader.sln - dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" - diff --git a/src/BaseStationReader.Data/BaseStationReader.Data.csproj b/src/BaseStationReader.Data/BaseStationReader.Data.csproj index d5d44a6..68c2317 100644 --- a/src/BaseStationReader.Data/BaseStationReader.Data.csproj +++ b/src/BaseStationReader.Data/BaseStationReader.Data.csproj @@ -5,7 +5,7 @@ enable enable BaseStationReader.Data - 1.30.0.0 + 1.31.0.0 Dave Walker Copyright (c) Dave Walker 2023 Dave Walker @@ -17,7 +17,7 @@ https://github.com/davewalker5/ADS-B-BaseStationReader MIT false - 1.30.0.0 + 1.31.0.0 diff --git a/src/BaseStationReader.Entities/BaseStationReader.Entities.csproj b/src/BaseStationReader.Entities/BaseStationReader.Entities.csproj index 0dde3c5..aaf843a 100644 --- a/src/BaseStationReader.Entities/BaseStationReader.Entities.csproj +++ b/src/BaseStationReader.Entities/BaseStationReader.Entities.csproj @@ -5,7 +5,7 @@ enable enable BaseStationReader.Entities - 1.30.0.0 + 1.31.0.0 Dave Walker Copyright (c) Dave Walker 2023 Dave Walker @@ -17,7 +17,7 @@ https://github.com/davewalker5/ADS-B-BaseStationReader MIT false - 1.30.0.0 + 1.31.0.0 diff --git a/src/BaseStationReader.Entities/Config/CommandLineOptionType.cs b/src/BaseStationReader.Entities/Config/CommandLineOptionType.cs index b4d96e4..b5a6ec1 100644 --- a/src/BaseStationReader.Entities/Config/CommandLineOptionType.cs +++ b/src/BaseStationReader.Entities/Config/CommandLineOptionType.cs @@ -7,6 +7,7 @@ public enum CommandLineOptionType Port, SocketReadTimeout, ApplicationTimeout, + RestartOnTimeout, TimeToRecent, TimeToStale, TimeToRemoval, diff --git a/src/BaseStationReader.Entities/Config/TrackerApplicationSettings.cs b/src/BaseStationReader.Entities/Config/TrackerApplicationSettings.cs index 515f0c1..ff329aa 100644 --- a/src/BaseStationReader.Entities/Config/TrackerApplicationSettings.cs +++ b/src/BaseStationReader.Entities/Config/TrackerApplicationSettings.cs @@ -11,6 +11,7 @@ public class TrackerApplicationSettings public int Port { get; set; } public int SocketReadTimeout { get; set; } public int ApplicationTimeout { get; set; } + public bool RestartOnTimeout { get; set; } public int TimeToRecent { get; set; } public int TimeToStale { get; set; } public int TimeToRemoval { get; set; } diff --git a/src/BaseStationReader.Logic/BaseStationReader.Logic.csproj b/src/BaseStationReader.Logic/BaseStationReader.Logic.csproj index b736375..21186fc 100644 --- a/src/BaseStationReader.Logic/BaseStationReader.Logic.csproj +++ b/src/BaseStationReader.Logic/BaseStationReader.Logic.csproj @@ -5,7 +5,7 @@ enable enable BaseStationReader.Logic - 1.30.0.0 + 1.31.0.0 Dave Walker Copyright (c) Dave Walker 2023 Dave Walker @@ -17,7 +17,7 @@ https://github.com/davewalker5/ADS-B-BaseStationReader MIT false - 1.30.0.0 + 1.31.0.0 diff --git a/src/BaseStationReader.Logic/Configuration/TrackerSettingsBuilder.cs b/src/BaseStationReader.Logic/Configuration/TrackerSettingsBuilder.cs index b0c6146..51c240e 100644 --- a/src/BaseStationReader.Logic/Configuration/TrackerSettingsBuilder.cs +++ b/src/BaseStationReader.Logic/Configuration/TrackerSettingsBuilder.cs @@ -24,6 +24,7 @@ public class TrackerSettingsBuilder : ITrackerSettingsBuilder parser.Add(CommandLineOptionType.Port, false, "--port", "-p", "Port to connect to for data stream", 1, 1); parser.Add(CommandLineOptionType.SocketReadTimeout, false, "--read-timeout", "-t", "Timeout (ms) for socket read operations", 1, 1); parser.Add(CommandLineOptionType.ApplicationTimeout, false, "--app-timeout", "-a", "Timeout (ms) after which the application will quit of no messages are recieved", 1, 1); + parser.Add(CommandLineOptionType.RestartOnTimeout, false, "--auto-restart", "-ar", "Automatically restart the tracker after a timeout", 1, 1); parser.Add(CommandLineOptionType.TimeToRecent, false, "--recent", "-r", "Time (ms) to 'recent' staleness", 1, 1); parser.Add(CommandLineOptionType.TimeToStale, false, "--stale", "-s", "Time (ms) to 'stale' staleness", 1, 1); parser.Add(CommandLineOptionType.TimeToRemoval, false, "--remove", "-x", "Time (ms) to removal of stale records", 1, 1); @@ -52,6 +53,9 @@ public class TrackerSettingsBuilder : ITrackerSettingsBuilder values = parser.GetValues(CommandLineOptionType.ApplicationTimeout); if (values != null) settings!.ApplicationTimeout = int.Parse(values[0]); + values = parser.GetValues(CommandLineOptionType.RestartOnTimeout); + if (values != null) settings!.RestartOnTimeout = bool.Parse(values[0]); + values = parser.GetValues(CommandLineOptionType.TimeToRecent); if (values != null) settings!.TimeToRecent = int.Parse(values[0]); diff --git a/src/BaseStationReader.Simulator/BaseStationReader.Simulator.csproj b/src/BaseStationReader.Simulator/BaseStationReader.Simulator.csproj index bd1db7a..4780025 100644 --- a/src/BaseStationReader.Simulator/BaseStationReader.Simulator.csproj +++ b/src/BaseStationReader.Simulator/BaseStationReader.Simulator.csproj @@ -3,9 +3,9 @@ Exe net7.0 - 1.30.0.0 - 1.30.0.0 - 1.30.0 + 1.31.0.0 + 1.31.0.0 + 1.31.0 enable enable diff --git a/src/BaseStationReader.Terminal/BaseStationReader.Terminal.csproj b/src/BaseStationReader.Terminal/BaseStationReader.Terminal.csproj index 4faac9a..3ec1847 100644 --- a/src/BaseStationReader.Terminal/BaseStationReader.Terminal.csproj +++ b/src/BaseStationReader.Terminal/BaseStationReader.Terminal.csproj @@ -3,9 +3,9 @@ Exe net7.0 - 1.30.0.0 - 1.30.0.0 - 1.30.0 + 1.31.0.0 + 1.31.0.0 + 1.31.0 enable enable diff --git a/src/BaseStationReader.Terminal/Program.cs b/src/BaseStationReader.Terminal/Program.cs index 704a751..c610a3e 100644 --- a/src/BaseStationReader.Terminal/Program.cs +++ b/src/BaseStationReader.Terminal/Program.cs @@ -50,20 +50,24 @@ public static async Task Main(string[] args) _wrapper.AircraftUpdated += OnAircraftUpdated; _wrapper.AircraftRemoved += OnAircraftRemoved; - // Configure the table - var trackerIndexManager = new TrackerIndexManager(); - _tableManager = new TrackerTableManager(trackerIndexManager, _settings!.Columns, _settings!.MaximumRows); - _tableManager.CreateTable(title); - - // Construct the live view - await AnsiConsole.Live(_tableManager.Table!) - .AutoClear(true) - .Overflow(VerticalOverflow.Ellipsis) - .Cropping(VerticalOverflowCropping.Bottom) - .StartAsync(async ctx => - { - await ShowTrackingTable(ctx); - }); + do + { + // Configure the table + var trackerIndexManager = new TrackerIndexManager(); + _tableManager = new TrackerTableManager(trackerIndexManager, _settings!.Columns, _settings!.MaximumRows); + _tableManager.CreateTable(title); + + // Construct the live view + await AnsiConsole.Live(_tableManager.Table!) + .AutoClear(true) + .Overflow(VerticalOverflow.Ellipsis) + .Cropping(VerticalOverflowCropping.Bottom) + .StartAsync(async ctx => + { + await ShowTrackingTable(ctx); + }); + } + while (_settings!.RestartOnTimeout); } /// @@ -73,8 +77,11 @@ await AnsiConsole.Live(_tableManager.Table!) /// private static async Task ShowTrackingTable(LiveDisplayContext ctx) { - // Continously update the table + // Reset the elapsed time since the last update int elapsed = 0; + _lastUpdate = DateTime.Now; + + // Start the wrapper and continuously update the table _wrapper!.Start(); while (elapsed <= _settings!.ApplicationTimeout) { @@ -87,6 +94,9 @@ private static async Task ShowTrackingTable(LiveDisplayContext ctx) elapsed = (int)(DateTime.Now - _lastUpdate).TotalMilliseconds; #pragma warning restore S6561 } + + // Stop the wrapper + _wrapper.Stop(); } /// diff --git a/src/BaseStationReader.Terminal/appsettings.json b/src/BaseStationReader.Terminal/appsettings.json index d4559c5..188ec35 100644 --- a/src/BaseStationReader.Terminal/appsettings.json +++ b/src/BaseStationReader.Terminal/appsettings.json @@ -4,6 +4,7 @@ "Port": 30003, "SocketReadTimeout": 60000, "ApplicationTimeout": 600000, + "RestartOnTimeout": true, "TimeToRecent": 60000, "TimeToStale": 120000, "TimeToRemoval": 180000, diff --git a/src/BaseStationReader.Tests/TrackerSettingsBuilderTest.cs b/src/BaseStationReader.Tests/TrackerSettingsBuilderTest.cs index 8516ec9..06d0ae3 100644 --- a/src/BaseStationReader.Tests/TrackerSettingsBuilderTest.cs +++ b/src/BaseStationReader.Tests/TrackerSettingsBuilderTest.cs @@ -15,6 +15,7 @@ public void DefaultConfigTest() Assert.AreEqual(30003, settings?.Port); Assert.AreEqual(60000, settings?.SocketReadTimeout); Assert.AreEqual(600000, settings?.ApplicationTimeout); + Assert.IsTrue(settings?.RestartOnTimeout); Assert.AreEqual(60000, settings?.TimeToRecent); Assert.AreEqual(120000, settings?.TimeToStale); Assert.AreEqual(180000, settings?.TimeToRemoval); @@ -68,6 +69,14 @@ public void OverrideApplicationTimeoutTest() Assert.AreEqual(45198, settings?.ApplicationTimeout); } + [TestMethod] + public void OverrideRestartOnTimeoutTest() + { + var args = new string[] { "--auto-restart", "false" }; + var settings = new TrackerSettingsBuilder().BuildSettings(args, "trackersettings.json"); + Assert.IsFalse(settings?.RestartOnTimeout); + } + [TestMethod] public void OverrideTimeToRecentTest() { diff --git a/src/BaseStationReader.Tests/trackersettings.json b/src/BaseStationReader.Tests/trackersettings.json index 39dcc5b..23e872e 100644 --- a/src/BaseStationReader.Tests/trackersettings.json +++ b/src/BaseStationReader.Tests/trackersettings.json @@ -4,6 +4,7 @@ "Port": 30003, "SocketReadTimeout": 60000, "ApplicationTimeout": 600000, + "RestartOnTimeout": true, "TimeToRecent": 60000, "TimeToStale": 120000, "TimeToRemoval": 180000, diff --git a/src/BaseStationReader.UI/BaseStationReader.UI.csproj b/src/BaseStationReader.UI/BaseStationReader.UI.csproj index 479c04f..909306b 100644 --- a/src/BaseStationReader.UI/BaseStationReader.UI.csproj +++ b/src/BaseStationReader.UI/BaseStationReader.UI.csproj @@ -2,9 +2,9 @@ WinExe net7.0 - 1.30.0.0 - 1.30.0.0 - 1.30.0 + 1.31.0.0 + 1.31.0.0 + 1.31.0 enable true app.manifest