From 27a4659cc9c85bf7f442a3fc383c16c6b782e146 Mon Sep 17 00:00:00 2001 From: "sushi.at" Date: Mon, 31 Jan 2022 11:41:52 +0000 Subject: [PATCH 1/9] First commit of isolating simulator Can of worms opened :) --- .editorconfig | 2 +- Installer/Product.wxs | 28 +- .../Enums/ClientEvents.cs | 2 +- .../Enums/CrashSequence.cs | 4 +- .../Enums/TimeOfDay.cs | 2 +- .../Helpers/ProcessLandingAnalysis.cs | 2 +- .../Helpers/ProcessPrimaryTracking.cs | 2 +- .../Helpers/ProcessSecondaryTracking.cs | 2 +- .../Models/AircraftTrailLocation.cs | 4 +- .../Models/FlightLoadingTempStructs.cs | 9 +- .../OpenSky.Agent.SimConnectMSFS.csproj | 129 +++++ ...ky.Agent.SimConnectMSFS.csproj.DotSettings | 2 + .../Properties/AssemblyInfo.cs | 21 + .../SimConnect.Flight.cs | 5 +- .../SimConnect.GroundHandling.cs | 3 +- .../SimConnect.Process.ChangeOverTime.cs | 2 +- .../SimConnect.Process.FlightPhases.cs | 3 +- .../SimConnect.Process.Landing.cs | 3 +- .../SimConnect.Process.Lights.cs | 2 +- .../SimConnect.Process.PositionReports.cs | 4 +- .../SimConnect.Process.Systems.cs | 5 +- .../SimConnect.Process.cs | 4 +- .../SimConnect.SaveLoadXML.cs | 5 +- .../SimConnect.Simbrief.cs | 3 +- .../SimConnect.cs | 10 +- .../Structs/FuelTanks.cs | 230 +++++++++ .../Structs/LandingAnalysis.cs | 20 +- .../Structs/PayloadStations.cs | 62 +-- .../Structs/PlaneIdentity.cs | 27 +- .../Structs/PlaneRegistry.cs | 2 +- .../Structs/PrimaryTracking.cs | 33 +- .../Structs/SecondaryTracking.cs | 42 +- .../Structs/SlewPlaneIntoPosition.cs | 21 +- .../Structs/WeightAndBalance.cs | 126 +++++ OpenSky.Agent.SimConnectMSFS/packages.config | 10 + .../Enums/FuelTank.cs | 6 +- .../Enums/Pushback.cs | 4 +- .../Enums/Requests.cs | 4 +- .../Models/AircraftIdentity.cs | 70 +++ .../Models}/FuelTanks.cs | 208 +++----- .../Models/LandingAnalysis.cs | 126 +++++ .../Models/MapPositionUpdate.cs | 2 +- .../Models/PayloadStations.cs | 379 ++++++++++++++ .../Models/PrimaryTracking.cs | 170 +++++++ .../Models/SecondaryTracking.cs | 247 +++++++++ .../Models/TrackingConditions.cs | 2 +- .../Models/TrackingStatus.cs | 2 +- .../Models/VerticalProfile.cs | 2 +- .../Models}/WeightAndBalance.cs | 111 ++-- .../OpenAPIs/ModelExtensions/AircraftType.cs | 24 +- .../OpenAPIs/ModelExtensions/Airport.cs | 2 +- .../OpenAPIs/ModelExtensions/Flight.cs | 2 +- .../OpenAPIs/OpenSkyService.cs | 33 +- .../OpenAPIs/OpenSkyServiceBase.cs | 315 ++++++------ .../OpenAPIs/ValidationProblemDetails.cs | 2 +- .../OpenAPIs/swagger.cs | 472 +++++++++++++++++- .../OpenAPIs/swagger.json | 429 +++++++++++++++- .../OpenSky.Agent.Simulator.csproj | 120 +++++ ...OpenSky.Agent.Simulator.csproj.DotSettings | 2 + .../Properties/AssemblyInfo.cs | 21 + OpenSky.Agent.Simulator/Simulator.cs | 93 ++++ .../Tools/StringValueAttribute.cs | 52 ++ OpenSky.Agent.Simulator/packages.config | 10 + OpenSky.AgentMSFS.sln => OpenSky.Agent.sln | 22 +- ...tSettings => OpenSky.Agent.sln.DotSettings | 1 + .../App.config.debug | 0 .../App.config.release | 0 {OpenSky.AgentMSFS => OpenSky.Agent}/App.xaml | 2 +- .../App.xaml.cs | 4 +- .../Controls/FuelTankControl.xaml | 2 +- .../Controls/FuelTankControl.xaml.cs | 2 +- .../Controls/Models/ErrorDetails.cs | 2 +- .../Models/ExtendedMessageBoxImage.cs | 2 +- .../Models/ExtendedMessageBoxResult.cs | 2 +- .../Controls/OpenSkyMessageBox.xaml | 2 +- .../Controls/OpenSkyMessageBox.xaml.cs | 2 +- .../Controls/OpenSkyNotification.xaml | 2 +- .../Controls/OpenSkyNotification.xaml.cs | 2 +- .../Controls/OpenSkyWindow.cs | 2 +- .../Controls/PayloadStationControl.xaml | 2 +- .../Controls/PayloadStationControl.xaml.cs | 2 +- .../Controls/ScrollingListBox.cs | 2 +- .../AircraftTypeEngineInfoConverter.cs | 2 +- .../AircraftTypeForeignKeyConverter.cs | 2 +- .../Converters/BooleanVisibilityConverter.cs | 2 +- .../CanSetWeightAndBalancesConverter.cs | 2 +- .../Converters/CgColorConverter.cs | 4 +- .../Converters/CgLateralColorConverter.cs | 2 +- .../FuelTankCapacityVisibilityConverter.cs | 2 +- .../InvertedBooleanVisibilityConverter.cs | 2 +- .../Converters/IsPausedButtonConverter.cs | 2 +- .../MapZoomLevelFontSizeConverter.cs | 2 +- .../MapZoomLevelVisibilityConverter.cs | 2 +- .../NullItemToVisibilityConverter.cs | 2 +- .../PayloadStationsVisibilityConverter.cs | 2 +- .../Converters/PoundsKilogramsConverter.cs | 2 +- .../Converters/WeightsColorConverter.cs | 4 +- .../Fonts/Montserrat-Black.ttf | Bin .../Fonts/Montserrat-BlackItalic.ttf | Bin .../Fonts/Montserrat-Bold.ttf | Bin .../Fonts/Montserrat-BoldItalic.ttf | Bin .../Fonts/Montserrat-ExtraBold.ttf | Bin .../Fonts/Montserrat-ExtraBoldItalic.ttf | Bin .../Fonts/Montserrat-ExtraLight.ttf | Bin .../Fonts/Montserrat-ExtraLightItalic.ttf | Bin .../Fonts/Montserrat-Italic.ttf | Bin .../Fonts/Montserrat-Light.ttf | Bin .../Fonts/Montserrat-LightItalic.ttf | Bin .../Fonts/Montserrat-Medium.ttf | Bin .../Fonts/Montserrat-MediumItalic.ttf | Bin .../Fonts/Montserrat-Regular.ttf | Bin .../Fonts/Montserrat-SemiBold.ttf | Bin .../Fonts/Montserrat-SemiBoldItalic.ttf | Bin .../Fonts/Montserrat-Thin.ttf | Bin .../Fonts/Montserrat-ThinItalic.ttf | Bin .../MVVM/AsynchronousCommand.cs | 2 +- .../MVVM/CancelCommandEventArgs.cs | 2 +- .../MVVM/Command.cs | 2 +- .../MVVM/CommandEventArgs.cs | 2 +- .../MVVM/NotifyingProperty.cs | 2 +- .../MVVM/ViewModel.cs | 2 +- .../Models/LandingReportNotification.cs | 2 +- .../Models/SimbriefWaypointMarker.cs | 2 +- .../Models/TrackingCondition.cs | 2 +- .../Models/TrackingEventLogEntry.cs | 3 +- .../Models/TrackingEventMarker.cs | 4 +- .../Native/Mouse.cs | 2 +- .../Native/PInvoke/Enums/ABE.cs | 2 +- .../Native/PInvoke/Enums/ABM.cs | 2 +- .../Native/PInvoke/Enums/ABS.cs | 2 +- .../Native/PInvoke/Enums/TaskbarPosition.cs | 2 +- .../Native/PInvoke/Gdi32.cs | 2 +- .../Native/PInvoke/Shell32.cs | 2 +- .../Native/PInvoke/Structs/AppBarData.cs | 2 +- .../Native/PInvoke/Structs/Point.cs | 2 +- .../Native/PInvoke/Structs/Rect.cs | 2 +- .../Native/PInvoke/User32.cs | 2 +- .../Native/Taskbar.cs | 2 +- .../OpenSky.Agent.csproj | 72 +-- .../OpenSky.Agent.csproj.DotSettings | 2 + .../OpenSkyColors.cs | 2 +- .../OpenSkyStyles.xaml | 0 .../Properties/AssemblyInfo.cs | 12 +- .../Properties/DesignTimeResources.xaml | 0 .../Properties/Resources.Designer.cs | 0 .../Properties/Resources.resx | 0 .../Properties/Settings.Designer.cs | 0 .../Properties/Settings.settings | 0 .../Resources/OSannouncement.wav | Bin .../Resources/OSbeepbeepstart.wav | Bin .../Resources/OSdingdong.wav | Bin .../Resources/OSnegative.wav | Bin .../Resources/opensky.ico | Bin .../Resources/opensky_grey16.ico | Bin .../Resources/opensky_pause16.ico | Bin .../Resources/opensky_red16.ico | Bin .../Resources/profile200.png | Bin .../SpeechSoundPacks.cs | 2 +- .../SyncfusionLicenseRegister.bat | 0 .../Tools/AssemblyVersionExtension.cs | 2 +- .../Tools/ColorExtensions.cs | 2 +- .../Tools/DateTimeTextWriterTraceListener.cs | 2 +- .../Tools/ExceptionExtensions.cs | 3 +- .../Tools/MultiSelectExtension.cs | 2 +- .../Tools/SleepScheduler.cs | 2 +- .../Tools/StringEnumExtension.cs | 2 +- .../Tools/StringValueAttribute.cs | 2 +- .../Tools/UpdateGUIDelegate.cs | 2 +- .../Tools/VisibilityAnimation.cs | 2 +- .../Tools/WindowExtensions.cs | 2 +- .../UserSessionService.cs | 6 +- .../VectorGraphics.xaml | 0 .../Views/AircraftTypes.xaml | 2 +- .../Views/AircraftTypes.xaml.cs | 3 +- .../Views/AutoUpdate.xaml | 2 +- .../Views/AutoUpdate.xaml.cs | 2 +- .../Views/FlightTracking.xaml | 2 +- .../Views/FlightTracking.xaml.cs | 5 +- .../Views/LandingReport.xaml | 2 +- .../Views/LandingReport.xaml.cs | 2 +- .../Views/LoginNotification.xaml | 2 +- .../Views/LoginNotification.xaml.cs | 2 +- .../Views/Models/AircraftTypesViewModel.cs | 5 +- .../Views/Models/AutoUpdateViewModel.cs | 2 +- .../FlightTrackingViewModel.FuelTanks.cs | 4 +- .../Models/FlightTrackingViewModel.Graphs.cs | 2 +- .../Models/FlightTrackingViewModel.Map.cs | 3 +- ...FlightTrackingViewModel.PayloadStations.cs | 4 +- .../Views/Models/FlightTrackingViewModel.cs | 4 +- .../Views/Models/LandingReportViewModel.cs | 2 +- .../Models/LoginNotificationViewModel.cs | 3 +- .../Models/NewFlightNotificationViewModel.cs | 2 +- .../Views/Models/SettingsViewModel.cs | 3 +- .../Views/Models/SoundPackTesterViewModel.cs | 2 +- .../Views/Models/StartupViewModel.cs | 3 +- .../Views/Models/TrackingDebugViewModel.cs | 8 +- .../Views/NewFlightNotification.xaml | 2 +- .../Views/NewFlightNotification.xaml.cs | 2 +- .../Views/Settings.xaml | 2 +- .../Views/Settings.xaml.cs | 2 +- .../Views/SoundPackTester.xaml | 2 +- .../Views/SoundPackTester.xaml.cs | 2 +- .../Views/Startup.xaml | 4 +- .../Views/Startup.xaml.cs | 2 +- .../Views/TrackingDebug.xaml | 298 +++++------ .../Views/TrackingDebug.xaml.cs | 2 +- OpenSky.Agent/app.config | 67 +++ .../pre-build.bat | 0 README.md | 4 +- 209 files changed, 3451 insertions(+), 1007 deletions(-) rename {OpenSky.AgentMSFS/SimConnect => OpenSky.Agent.SimConnectMSFS}/Enums/ClientEvents.cs (98%) rename {OpenSky.AgentMSFS/SimConnect => OpenSky.Agent.SimConnectMSFS}/Enums/CrashSequence.cs (95%) rename {OpenSky.AgentMSFS/SimConnect => OpenSky.Agent.SimConnectMSFS}/Enums/TimeOfDay.cs (97%) rename {OpenSky.AgentMSFS/SimConnect => OpenSky.Agent.SimConnectMSFS}/Helpers/ProcessLandingAnalysis.cs (98%) rename {OpenSky.AgentMSFS/SimConnect => OpenSky.Agent.SimConnectMSFS}/Helpers/ProcessPrimaryTracking.cs (98%) rename {OpenSky.AgentMSFS/SimConnect => OpenSky.Agent.SimConnectMSFS}/Helpers/ProcessSecondaryTracking.cs (98%) rename {OpenSky.AgentMSFS => OpenSky.Agent.SimConnectMSFS}/Models/AircraftTrailLocation.cs (98%) rename {OpenSky.AgentMSFS => OpenSky.Agent.SimConnectMSFS}/Models/FlightLoadingTempStructs.cs (85%) create mode 100644 OpenSky.Agent.SimConnectMSFS/OpenSky.Agent.SimConnectMSFS.csproj create mode 100644 OpenSky.Agent.SimConnectMSFS/OpenSky.Agent.SimConnectMSFS.csproj.DotSettings create mode 100644 OpenSky.Agent.SimConnectMSFS/Properties/AssemblyInfo.cs rename {OpenSky.AgentMSFS/SimConnect => OpenSky.Agent.SimConnectMSFS}/SimConnect.Flight.cs (99%) rename {OpenSky.AgentMSFS/SimConnect => OpenSky.Agent.SimConnectMSFS}/SimConnect.GroundHandling.cs (99%) rename {OpenSky.AgentMSFS/SimConnect => OpenSky.Agent.SimConnectMSFS}/SimConnect.Process.ChangeOverTime.cs (99%) rename {OpenSky.AgentMSFS/SimConnect => OpenSky.Agent.SimConnectMSFS}/SimConnect.Process.FlightPhases.cs (99%) rename {OpenSky.AgentMSFS/SimConnect => OpenSky.Agent.SimConnectMSFS}/SimConnect.Process.Landing.cs (98%) rename {OpenSky.AgentMSFS/SimConnect => OpenSky.Agent.SimConnectMSFS}/SimConnect.Process.Lights.cs (99%) rename {OpenSky.AgentMSFS/SimConnect => OpenSky.Agent.SimConnectMSFS}/SimConnect.Process.PositionReports.cs (99%) rename {OpenSky.AgentMSFS/SimConnect => OpenSky.Agent.SimConnectMSFS}/SimConnect.Process.Systems.cs (99%) rename {OpenSky.AgentMSFS/SimConnect => OpenSky.Agent.SimConnectMSFS}/SimConnect.Process.cs (99%) rename {OpenSky.AgentMSFS/SimConnect => OpenSky.Agent.SimConnectMSFS}/SimConnect.SaveLoadXML.cs (99%) rename {OpenSky.AgentMSFS/SimConnect => OpenSky.Agent.SimConnectMSFS}/SimConnect.Simbrief.cs (99%) rename {OpenSky.AgentMSFS/SimConnect => OpenSky.Agent.SimConnectMSFS}/SimConnect.cs (99%) create mode 100644 OpenSky.Agent.SimConnectMSFS/Structs/FuelTanks.cs rename {OpenSky.AgentMSFS/SimConnect => OpenSky.Agent.SimConnectMSFS}/Structs/LandingAnalysis.cs (87%) rename {OpenSky.AgentMSFS/SimConnect => OpenSky.Agent.SimConnectMSFS}/Structs/PayloadStations.cs (87%) rename {OpenSky.AgentMSFS/SimConnect => OpenSky.Agent.SimConnectMSFS}/Structs/PlaneIdentity.cs (77%) rename {OpenSky.AgentMSFS/SimConnect => OpenSky.Agent.SimConnectMSFS}/Structs/PlaneRegistry.cs (98%) rename {OpenSky.AgentMSFS/SimConnect => OpenSky.Agent.SimConnectMSFS}/Structs/PrimaryTracking.cs (84%) rename {OpenSky.AgentMSFS/SimConnect => OpenSky.Agent.SimConnectMSFS}/Structs/SecondaryTracking.cs (90%) rename {OpenSky.AgentMSFS/SimConnect => OpenSky.Agent.SimConnectMSFS}/Structs/SlewPlaneIntoPosition.cs (93%) create mode 100644 OpenSky.Agent.SimConnectMSFS/Structs/WeightAndBalance.cs create mode 100644 OpenSky.Agent.SimConnectMSFS/packages.config rename {OpenSky.AgentMSFS/SimConnect => OpenSky.Agent.Simulator}/Enums/FuelTank.cs (95%) rename {OpenSky.AgentMSFS/SimConnect => OpenSky.Agent.Simulator}/Enums/Pushback.cs (94%) rename {OpenSky.AgentMSFS/SimConnect => OpenSky.Agent.Simulator}/Enums/Requests.cs (96%) create mode 100644 OpenSky.Agent.Simulator/Models/AircraftIdentity.cs rename {OpenSky.AgentMSFS/SimConnect/Structs => OpenSky.Agent.Simulator/Models}/FuelTanks.cs (78%) create mode 100644 OpenSky.Agent.Simulator/Models/LandingAnalysis.cs rename {OpenSky.AgentMSFS => OpenSky.Agent.Simulator}/Models/MapPositionUpdate.cs (98%) create mode 100644 OpenSky.Agent.Simulator/Models/PayloadStations.cs create mode 100644 OpenSky.Agent.Simulator/Models/PrimaryTracking.cs create mode 100644 OpenSky.Agent.Simulator/Models/SecondaryTracking.cs rename {OpenSky.AgentMSFS => OpenSky.Agent.Simulator}/Models/TrackingConditions.cs (97%) rename {OpenSky.AgentMSFS => OpenSky.Agent.Simulator}/Models/TrackingStatus.cs (98%) rename {OpenSky.AgentMSFS => OpenSky.Agent.Simulator}/Models/VerticalProfile.cs (97%) rename {OpenSky.AgentMSFS/SimConnect/Structs => OpenSky.Agent.Simulator/Models}/WeightAndBalance.cs (73%) rename {OpenSky.AgentMSFS => OpenSky.Agent.Simulator}/OpenAPIs/ModelExtensions/AircraftType.cs (85%) rename {OpenSky.AgentMSFS => OpenSky.Agent.Simulator}/OpenAPIs/ModelExtensions/Airport.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent.Simulator}/OpenAPIs/ModelExtensions/Flight.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent.Simulator}/OpenAPIs/OpenSkyService.cs (57%) rename {OpenSky.AgentMSFS => OpenSky.Agent.Simulator}/OpenAPIs/OpenSkyServiceBase.cs (60%) rename {OpenSky.AgentMSFS => OpenSky.Agent.Simulator}/OpenAPIs/ValidationProblemDetails.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent.Simulator}/OpenAPIs/swagger.cs (95%) rename {OpenSky.AgentMSFS => OpenSky.Agent.Simulator}/OpenAPIs/swagger.json (94%) create mode 100644 OpenSky.Agent.Simulator/OpenSky.Agent.Simulator.csproj create mode 100644 OpenSky.Agent.Simulator/OpenSky.Agent.Simulator.csproj.DotSettings create mode 100644 OpenSky.Agent.Simulator/Properties/AssemblyInfo.cs create mode 100644 OpenSky.Agent.Simulator/Simulator.cs create mode 100644 OpenSky.Agent.Simulator/Tools/StringValueAttribute.cs create mode 100644 OpenSky.Agent.Simulator/packages.config rename OpenSky.AgentMSFS.sln => OpenSky.Agent.sln (56%) rename OpenSky.AgentMSFS.sln.DotSettings => OpenSky.Agent.sln.DotSettings (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/App.config.debug (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/App.config.release (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/App.xaml (98%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/App.xaml.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Controls/FuelTankControl.xaml (98%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Controls/FuelTankControl.xaml.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Controls/Models/ErrorDetails.cs (98%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Controls/Models/ExtendedMessageBoxImage.cs (98%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Controls/Models/ExtendedMessageBoxResult.cs (97%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Controls/OpenSkyMessageBox.xaml (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Controls/OpenSkyMessageBox.xaml.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Controls/OpenSkyNotification.xaml (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Controls/OpenSkyNotification.xaml.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Controls/OpenSkyWindow.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Controls/PayloadStationControl.xaml (98%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Controls/PayloadStationControl.xaml.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Controls/ScrollingListBox.cs (98%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Converters/AircraftTypeEngineInfoConverter.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Converters/AircraftTypeForeignKeyConverter.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Converters/BooleanVisibilityConverter.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Converters/CanSetWeightAndBalancesConverter.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Converters/CgColorConverter.cs (98%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Converters/CgLateralColorConverter.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Converters/FuelTankCapacityVisibilityConverter.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Converters/InvertedBooleanVisibilityConverter.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Converters/IsPausedButtonConverter.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Converters/MapZoomLevelFontSizeConverter.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Converters/MapZoomLevelVisibilityConverter.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Converters/NullItemToVisibilityConverter.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Converters/PayloadStationsVisibilityConverter.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Converters/PoundsKilogramsConverter.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Converters/WeightsColorConverter.cs (98%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Fonts/Montserrat-Black.ttf (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Fonts/Montserrat-BlackItalic.ttf (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Fonts/Montserrat-Bold.ttf (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Fonts/Montserrat-BoldItalic.ttf (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Fonts/Montserrat-ExtraBold.ttf (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Fonts/Montserrat-ExtraBoldItalic.ttf (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Fonts/Montserrat-ExtraLight.ttf (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Fonts/Montserrat-ExtraLightItalic.ttf (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Fonts/Montserrat-Italic.ttf (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Fonts/Montserrat-Light.ttf (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Fonts/Montserrat-LightItalic.ttf (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Fonts/Montserrat-Medium.ttf (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Fonts/Montserrat-MediumItalic.ttf (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Fonts/Montserrat-Regular.ttf (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Fonts/Montserrat-SemiBold.ttf (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Fonts/Montserrat-SemiBoldItalic.ttf (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Fonts/Montserrat-Thin.ttf (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Fonts/Montserrat-ThinItalic.ttf (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/MVVM/AsynchronousCommand.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/MVVM/CancelCommandEventArgs.cs (98%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/MVVM/Command.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/MVVM/CommandEventArgs.cs (97%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/MVVM/NotifyingProperty.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/MVVM/ViewModel.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Models/LandingReportNotification.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Models/SimbriefWaypointMarker.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Models/TrackingCondition.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Models/TrackingEventLogEntry.cs (98%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Models/TrackingEventMarker.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Native/Mouse.cs (98%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Native/PInvoke/Enums/ABE.cs (97%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Native/PInvoke/Enums/ABM.cs (98%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Native/PInvoke/Enums/ABS.cs (97%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Native/PInvoke/Enums/TaskbarPosition.cs (97%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Native/PInvoke/Gdi32.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Native/PInvoke/Shell32.cs (98%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Native/PInvoke/Structs/AppBarData.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Native/PInvoke/Structs/Point.cs (98%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Native/PInvoke/Structs/Rect.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Native/PInvoke/User32.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Native/Taskbar.cs (99%) rename OpenSky.AgentMSFS/OpenSky.AgentMSFS.csproj => OpenSky.Agent/OpenSky.Agent.csproj (86%) create mode 100644 OpenSky.Agent/OpenSky.Agent.csproj.DotSettings rename {OpenSky.AgentMSFS => OpenSky.Agent}/OpenSkyColors.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/OpenSkyStyles.xaml (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Properties/AssemblyInfo.cs (75%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Properties/DesignTimeResources.xaml (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Properties/Resources.Designer.cs (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Properties/Resources.resx (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Properties/Settings.Designer.cs (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Properties/Settings.settings (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Resources/OSannouncement.wav (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Resources/OSbeepbeepstart.wav (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Resources/OSdingdong.wav (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Resources/OSnegative.wav (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Resources/opensky.ico (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Resources/opensky_grey16.ico (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Resources/opensky_pause16.ico (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Resources/opensky_red16.ico (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Resources/profile200.png (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/SpeechSoundPacks.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/SyncfusionLicenseRegister.bat (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Tools/AssemblyVersionExtension.cs (98%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Tools/ColorExtensions.cs (98%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Tools/DateTimeTextWriterTraceListener.cs (98%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Tools/ExceptionExtensions.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Tools/MultiSelectExtension.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Tools/SleepScheduler.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Tools/StringEnumExtension.cs (98%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Tools/StringValueAttribute.cs (98%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Tools/UpdateGUIDelegate.cs (96%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Tools/VisibilityAnimation.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Tools/WindowExtensions.cs (98%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/UserSessionService.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/VectorGraphics.xaml (100%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/AircraftTypes.xaml (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/AircraftTypes.xaml.cs (98%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/AutoUpdate.xaml (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/AutoUpdate.xaml.cs (98%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/FlightTracking.xaml (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/FlightTracking.xaml.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/LandingReport.xaml (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/LandingReport.xaml.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/LoginNotification.xaml (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/LoginNotification.xaml.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/Models/AircraftTypesViewModel.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/Models/AutoUpdateViewModel.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/Models/FlightTrackingViewModel.FuelTanks.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/Models/FlightTrackingViewModel.Graphs.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/Models/FlightTrackingViewModel.Map.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/Models/FlightTrackingViewModel.PayloadStations.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/Models/FlightTrackingViewModel.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/Models/LandingReportViewModel.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/Models/LoginNotificationViewModel.cs (98%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/Models/NewFlightNotificationViewModel.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/Models/SettingsViewModel.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/Models/SoundPackTesterViewModel.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/Models/StartupViewModel.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/Models/TrackingDebugViewModel.cs (87%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/NewFlightNotification.xaml (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/NewFlightNotification.xaml.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/Settings.xaml (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/Settings.xaml.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/SoundPackTester.xaml (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/SoundPackTester.xaml.cs (99%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/Startup.xaml (97%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/Startup.xaml.cs (98%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/TrackingDebug.xaml (63%) rename {OpenSky.AgentMSFS => OpenSky.Agent}/Views/TrackingDebug.xaml.cs (98%) create mode 100644 OpenSky.Agent/app.config rename {OpenSky.AgentMSFS => OpenSky.Agent}/pre-build.bat (100%) diff --git a/.editorconfig b/.editorconfig index e0a8988..81a6f6b 100644 --- a/.editorconfig +++ b/.editorconfig @@ -18,7 +18,7 @@ insert_final_newline = false # Organize usings dotnet_separate_import_directive_groups = true -file_header_template = --------------------------------------------------------------------------------------------------------------------\n\nOpenSky project 2021\n\n-------------------------------------------------------------------------------------------------------------------- +file_header_template = --------------------------------------------------------------------------------------------------------------------\n\nOpenSky project 2021-2022\n\n-------------------------------------------------------------------------------------------------------------------- # this. and Me. preferences dotnet_style_qualification_for_event = true:suggestion diff --git a/Installer/Product.wxs b/Installer/Product.wxs index ffdf22d..2e40533 100644 --- a/Installer/Product.wxs +++ b/Installer/Product.wxs @@ -2,9 +2,9 @@ - + - + @@ -15,20 +15,20 @@ - - - + + + - + - + @@ -39,14 +39,14 @@ - + - - - + + + - - + + @@ -55,7 +55,7 @@ - + diff --git a/OpenSky.AgentMSFS/SimConnect/Enums/ClientEvents.cs b/OpenSky.Agent.SimConnectMSFS/Enums/ClientEvents.cs similarity index 98% rename from OpenSky.AgentMSFS/SimConnect/Enums/ClientEvents.cs rename to OpenSky.Agent.SimConnectMSFS/Enums/ClientEvents.cs index fa14fd1..c505315 100644 --- a/OpenSky.AgentMSFS/SimConnect/Enums/ClientEvents.cs +++ b/OpenSky.Agent.SimConnectMSFS/Enums/ClientEvents.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- diff --git a/OpenSky.AgentMSFS/SimConnect/Enums/CrashSequence.cs b/OpenSky.Agent.SimConnectMSFS/Enums/CrashSequence.cs similarity index 95% rename from OpenSky.AgentMSFS/SimConnect/Enums/CrashSequence.cs rename to OpenSky.Agent.SimConnectMSFS/Enums/CrashSequence.cs index 4cdfa19..65187e0 100644 --- a/OpenSky.AgentMSFS/SimConnect/Enums/CrashSequence.cs +++ b/OpenSky.Agent.SimConnectMSFS/Enums/CrashSequence.cs @@ -1,10 +1,10 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- -namespace OpenSky.AgentMSFS.SimConnect.Enums +namespace OpenSky.Agent.Simulator.Enums { /// ------------------------------------------------------------------------------------------------- /// diff --git a/OpenSky.AgentMSFS/SimConnect/Enums/TimeOfDay.cs b/OpenSky.Agent.SimConnectMSFS/Enums/TimeOfDay.cs similarity index 97% rename from OpenSky.AgentMSFS/SimConnect/Enums/TimeOfDay.cs rename to OpenSky.Agent.SimConnectMSFS/Enums/TimeOfDay.cs index 2e76092..70708d8 100644 --- a/OpenSky.AgentMSFS/SimConnect/Enums/TimeOfDay.cs +++ b/OpenSky.Agent.SimConnectMSFS/Enums/TimeOfDay.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- diff --git a/OpenSky.AgentMSFS/SimConnect/Helpers/ProcessLandingAnalysis.cs b/OpenSky.Agent.SimConnectMSFS/Helpers/ProcessLandingAnalysis.cs similarity index 98% rename from OpenSky.AgentMSFS/SimConnect/Helpers/ProcessLandingAnalysis.cs rename to OpenSky.Agent.SimConnectMSFS/Helpers/ProcessLandingAnalysis.cs index 09bccbd..314f228 100644 --- a/OpenSky.AgentMSFS/SimConnect/Helpers/ProcessLandingAnalysis.cs +++ b/OpenSky.Agent.SimConnectMSFS/Helpers/ProcessLandingAnalysis.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- diff --git a/OpenSky.AgentMSFS/SimConnect/Helpers/ProcessPrimaryTracking.cs b/OpenSky.Agent.SimConnectMSFS/Helpers/ProcessPrimaryTracking.cs similarity index 98% rename from OpenSky.AgentMSFS/SimConnect/Helpers/ProcessPrimaryTracking.cs rename to OpenSky.Agent.SimConnectMSFS/Helpers/ProcessPrimaryTracking.cs index 6f1367b..ac026af 100644 --- a/OpenSky.AgentMSFS/SimConnect/Helpers/ProcessPrimaryTracking.cs +++ b/OpenSky.Agent.SimConnectMSFS/Helpers/ProcessPrimaryTracking.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- diff --git a/OpenSky.AgentMSFS/SimConnect/Helpers/ProcessSecondaryTracking.cs b/OpenSky.Agent.SimConnectMSFS/Helpers/ProcessSecondaryTracking.cs similarity index 98% rename from OpenSky.AgentMSFS/SimConnect/Helpers/ProcessSecondaryTracking.cs rename to OpenSky.Agent.SimConnectMSFS/Helpers/ProcessSecondaryTracking.cs index 96c4891..5f14a9c 100644 --- a/OpenSky.AgentMSFS/SimConnect/Helpers/ProcessSecondaryTracking.cs +++ b/OpenSky.Agent.SimConnectMSFS/Helpers/ProcessSecondaryTracking.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- diff --git a/OpenSky.AgentMSFS/Models/AircraftTrailLocation.cs b/OpenSky.Agent.SimConnectMSFS/Models/AircraftTrailLocation.cs similarity index 98% rename from OpenSky.AgentMSFS/Models/AircraftTrailLocation.cs rename to OpenSky.Agent.SimConnectMSFS/Models/AircraftTrailLocation.cs index 27fd805..9169208 100644 --- a/OpenSky.AgentMSFS/Models/AircraftTrailLocation.cs +++ b/OpenSky.Agent.SimConnectMSFS/Models/AircraftTrailLocation.cs @@ -1,10 +1,10 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- -namespace OpenSky.AgentMSFS.Models +namespace OpenSky.Agent.Simulator.Models { using System; diff --git a/OpenSky.AgentMSFS/Models/FlightLoadingTempStructs.cs b/OpenSky.Agent.SimConnectMSFS/Models/FlightLoadingTempStructs.cs similarity index 85% rename from OpenSky.AgentMSFS/Models/FlightLoadingTempStructs.cs rename to OpenSky.Agent.SimConnectMSFS/Models/FlightLoadingTempStructs.cs index 20c2b3e..a5bc903 100644 --- a/OpenSky.AgentMSFS/Models/FlightLoadingTempStructs.cs +++ b/OpenSky.Agent.SimConnectMSFS/Models/FlightLoadingTempStructs.cs @@ -1,12 +1,11 @@ -// -------------------------------------------------------------------------------------------------------------------- -// -// OpenSky project 2021 +// +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- -namespace OpenSky.AgentMSFS.Models +namespace OpenSky.Agent.Simulator.Models { - using OpenSky.AgentMSFS.SimConnect.Structs; + using OpenSky.Agent.Simulator.Structs; /// ------------------------------------------------------------------------------------------------- /// diff --git a/OpenSky.Agent.SimConnectMSFS/OpenSky.Agent.SimConnectMSFS.csproj b/OpenSky.Agent.SimConnectMSFS/OpenSky.Agent.SimConnectMSFS.csproj new file mode 100644 index 0000000..1a1b732 --- /dev/null +++ b/OpenSky.Agent.SimConnectMSFS/OpenSky.Agent.SimConnectMSFS.csproj @@ -0,0 +1,129 @@ + + + + + + Debug + AnyCPU + {1F9CBEDE-669D-4510-BCA2-E6AD29D6A498} + Library + Properties + OpenSky.Agent.SimConnectMSFS + OpenSky.Agent.SimConnectMSFS + v4.8 + 512 + true + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + bin\Debug\OpenSky.Agent.SimConnectMSFS.xml + latest + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + bin\Release\OpenSky.Agent.SimConnectMSFS.xml + latest + + + + ..\packages\CTrue.FsConnect.1.3.3\lib\net45\CTrue.FsConnect.dll + + + ..\packages\JetBrains.Annotations.2021.3.0\lib\net20\JetBrains.Annotations.dll + + + ..\packages\CTrue.FsConnect.1.3.3\lib\net45\Microsoft.FlightSimulator.SimConnect.dll + + + ..\packages\Microsoft.Maps.MapControl.WPF.1.0.0.3\lib\net40-Client\Microsoft.Maps.MapControl.WPF.dll + + + ..\packages\OpenSky.FlightLogXML.0.1.4\lib\net48\OpenSky.FlightLogXML.dll + + + ..\packages\MSFT.ParallelExtensionsExtras.1.2.0\lib\ParallelExtensionsExtras.dll + + + ..\packages\Serilog.2.10.0\lib\net46\Serilog.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {30c467e8-2eee-41e5-be01-0142a61ba171} + OpenSky.Agent.Simulator + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + \ No newline at end of file diff --git a/OpenSky.Agent.SimConnectMSFS/OpenSky.Agent.SimConnectMSFS.csproj.DotSettings b/OpenSky.Agent.SimConnectMSFS/OpenSky.Agent.SimConnectMSFS.csproj.DotSettings new file mode 100644 index 0000000..4887f94 --- /dev/null +++ b/OpenSky.Agent.SimConnectMSFS/OpenSky.Agent.SimConnectMSFS.csproj.DotSettings @@ -0,0 +1,2 @@ + + CSharp100 \ No newline at end of file diff --git a/OpenSky.Agent.SimConnectMSFS/Properties/AssemblyInfo.cs b/OpenSky.Agent.SimConnectMSFS/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..dfcb19a --- /dev/null +++ b/OpenSky.Agent.SimConnectMSFS/Properties/AssemblyInfo.cs @@ -0,0 +1,21 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// OpenSky project 2021-2022 +// +// -------------------------------------------------------------------------------------------------------------------- + +using System.Reflection; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("OpenSky.Agent.SimConnectMSFS")] +[assembly: AssemblyDescription("OpenSky Agent SimConnect Library for MSFS 2020")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("OpenSky")] +[assembly: AssemblyProduct("OpenSky")] +[assembly: AssemblyCopyright("OpenSky project 2021-2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: ComVisible(false)] +[assembly: Guid("1f9cbede-669d-4510-bca2-e6ad29d6a498")] +[assembly: AssemblyVersion("0.4.0")] +[assembly: AssemblyFileVersion("0.4.0")] \ No newline at end of file diff --git a/OpenSky.AgentMSFS/SimConnect/SimConnect.Flight.cs b/OpenSky.Agent.SimConnectMSFS/SimConnect.Flight.cs similarity index 99% rename from OpenSky.AgentMSFS/SimConnect/SimConnect.Flight.cs rename to OpenSky.Agent.SimConnectMSFS/SimConnect.Flight.cs index e8ac7d9..0bdc25b 100644 --- a/OpenSky.AgentMSFS/SimConnect/SimConnect.Flight.cs +++ b/OpenSky.Agent.SimConnectMSFS/SimConnect.Flight.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- @@ -21,11 +21,12 @@ namespace OpenSky.AgentMSFS.SimConnect using Microsoft.Maps.MapControl.WPF; + using OpenSky.Agent.Simulator.Enums; + using OpenSky.Agent.Simulator.Models; using OpenSky.AgentMSFS.Models; using OpenSky.AgentMSFS.SimConnect.Enums; using OpenSky.AgentMSFS.SimConnect.Helpers; using OpenSky.AgentMSFS.SimConnect.Structs; - using OpenSky.AgentMSFS.Tools; using OpenSky.FlightLogXML; using OpenSkyApi; diff --git a/OpenSky.AgentMSFS/SimConnect/SimConnect.GroundHandling.cs b/OpenSky.Agent.SimConnectMSFS/SimConnect.GroundHandling.cs similarity index 99% rename from OpenSky.AgentMSFS/SimConnect/SimConnect.GroundHandling.cs rename to OpenSky.Agent.SimConnectMSFS/SimConnect.GroundHandling.cs index e4ca16f..0e01db2 100644 --- a/OpenSky.AgentMSFS/SimConnect/SimConnect.GroundHandling.cs +++ b/OpenSky.Agent.SimConnectMSFS/SimConnect.GroundHandling.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- @@ -11,7 +11,6 @@ namespace OpenSky.AgentMSFS.SimConnect using System.Threading; using OpenSky.AgentMSFS.Models; - using OpenSky.AgentMSFS.Tools; using OpenSky.FlightLogXML; using TomsToolbox.Essentials; diff --git a/OpenSky.AgentMSFS/SimConnect/SimConnect.Process.ChangeOverTime.cs b/OpenSky.Agent.SimConnectMSFS/SimConnect.Process.ChangeOverTime.cs similarity index 99% rename from OpenSky.AgentMSFS/SimConnect/SimConnect.Process.ChangeOverTime.cs rename to OpenSky.Agent.SimConnectMSFS/SimConnect.Process.ChangeOverTime.cs index 4399575..2dbf1df 100644 --- a/OpenSky.AgentMSFS/SimConnect/SimConnect.Process.ChangeOverTime.cs +++ b/OpenSky.Agent.SimConnectMSFS/SimConnect.Process.ChangeOverTime.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- diff --git a/OpenSky.AgentMSFS/SimConnect/SimConnect.Process.FlightPhases.cs b/OpenSky.Agent.SimConnectMSFS/SimConnect.Process.FlightPhases.cs similarity index 99% rename from OpenSky.AgentMSFS/SimConnect/SimConnect.Process.FlightPhases.cs rename to OpenSky.Agent.SimConnectMSFS/SimConnect.Process.FlightPhases.cs index e2ad08c..2bdd55c 100644 --- a/OpenSky.AgentMSFS/SimConnect/SimConnect.Process.FlightPhases.cs +++ b/OpenSky.Agent.SimConnectMSFS/SimConnect.Process.FlightPhases.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- @@ -12,6 +12,7 @@ namespace OpenSky.AgentMSFS.SimConnect using System.Media; using System.Reflection; + using OpenSky.Agent.Simulator.Enums; using OpenSky.AgentMSFS.Models; using OpenSky.AgentMSFS.SimConnect.Enums; using OpenSky.FlightLogXML; diff --git a/OpenSky.AgentMSFS/SimConnect/SimConnect.Process.Landing.cs b/OpenSky.Agent.SimConnectMSFS/SimConnect.Process.Landing.cs similarity index 98% rename from OpenSky.AgentMSFS/SimConnect/SimConnect.Process.Landing.cs rename to OpenSky.Agent.SimConnectMSFS/SimConnect.Process.Landing.cs index a1abbe1..f69aa42 100644 --- a/OpenSky.AgentMSFS/SimConnect/SimConnect.Process.Landing.cs +++ b/OpenSky.Agent.SimConnectMSFS/SimConnect.Process.Landing.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- @@ -15,7 +15,6 @@ namespace OpenSky.AgentMSFS.SimConnect using OpenSky.AgentMSFS.Models; using OpenSky.AgentMSFS.SimConnect.Helpers; - using OpenSky.AgentMSFS.Tools; using OpenSky.FlightLogXML; /// ------------------------------------------------------------------------------------------------- diff --git a/OpenSky.AgentMSFS/SimConnect/SimConnect.Process.Lights.cs b/OpenSky.Agent.SimConnectMSFS/SimConnect.Process.Lights.cs similarity index 99% rename from OpenSky.AgentMSFS/SimConnect/SimConnect.Process.Lights.cs rename to OpenSky.Agent.SimConnectMSFS/SimConnect.Process.Lights.cs index 1754d1a..92937fc 100644 --- a/OpenSky.AgentMSFS/SimConnect/SimConnect.Process.Lights.cs +++ b/OpenSky.Agent.SimConnectMSFS/SimConnect.Process.Lights.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- diff --git a/OpenSky.AgentMSFS/SimConnect/SimConnect.Process.PositionReports.cs b/OpenSky.Agent.SimConnectMSFS/SimConnect.Process.PositionReports.cs similarity index 99% rename from OpenSky.AgentMSFS/SimConnect/SimConnect.Process.PositionReports.cs rename to OpenSky.Agent.SimConnectMSFS/SimConnect.Process.PositionReports.cs index 84d9fc8..b85222c 100644 --- a/OpenSky.AgentMSFS/SimConnect/SimConnect.Process.PositionReports.cs +++ b/OpenSky.Agent.SimConnectMSFS/SimConnect.Process.PositionReports.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- @@ -14,9 +14,9 @@ namespace OpenSky.AgentMSFS.SimConnect using Microsoft.Maps.MapControl.WPF; + using OpenSky.Agent.Simulator.Models; using OpenSky.AgentMSFS.Models; using OpenSky.AgentMSFS.SimConnect.Structs; - using OpenSky.AgentMSFS.Tools; using OpenSkyApi; diff --git a/OpenSky.AgentMSFS/SimConnect/SimConnect.Process.Systems.cs b/OpenSky.Agent.SimConnectMSFS/SimConnect.Process.Systems.cs similarity index 99% rename from OpenSky.AgentMSFS/SimConnect/SimConnect.Process.Systems.cs rename to OpenSky.Agent.SimConnectMSFS/SimConnect.Process.Systems.cs index e1e3d4e..1617734 100644 --- a/OpenSky.AgentMSFS/SimConnect/SimConnect.Process.Systems.cs +++ b/OpenSky.Agent.SimConnectMSFS/SimConnect.Process.Systems.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- @@ -12,12 +12,13 @@ namespace OpenSky.AgentMSFS.SimConnect using System.Reflection; using System.Windows; + using OpenSky.Agent.Simulator.Enums; + using OpenSky.Agent.Simulator.Models; using OpenSky.AgentMSFS.Properties; using OpenSky.AgentMSFS.Models; using OpenSky.AgentMSFS.SimConnect.Enums; using OpenSky.AgentMSFS.SimConnect.Helpers; - using OpenSky.AgentMSFS.Tools; using OpenSky.FlightLogXML; using TrackingEventMarker = Models.TrackingEventMarker; diff --git a/OpenSky.AgentMSFS/SimConnect/SimConnect.Process.cs b/OpenSky.Agent.SimConnectMSFS/SimConnect.Process.cs similarity index 99% rename from OpenSky.AgentMSFS/SimConnect/SimConnect.Process.cs rename to OpenSky.Agent.SimConnectMSFS/SimConnect.Process.cs index 4bb979c..22b0e14 100644 --- a/OpenSky.AgentMSFS/SimConnect/SimConnect.Process.cs +++ b/OpenSky.Agent.SimConnectMSFS/SimConnect.Process.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- @@ -22,11 +22,11 @@ namespace OpenSky.AgentMSFS.SimConnect using Microsoft.Maps.MapControl.WPF; + using OpenSky.Agent.Simulator.Enums; using OpenSky.AgentMSFS.Models; using OpenSky.AgentMSFS.SimConnect.Enums; using OpenSky.AgentMSFS.SimConnect.Helpers; using OpenSky.AgentMSFS.SimConnect.Structs; - using OpenSky.AgentMSFS.Tools; using OpenSky.FlightLogXML; using TrackingEventLogEntry = Models.TrackingEventLogEntry; diff --git a/OpenSky.AgentMSFS/SimConnect/SimConnect.SaveLoadXML.cs b/OpenSky.Agent.SimConnectMSFS/SimConnect.SaveLoadXML.cs similarity index 99% rename from OpenSky.AgentMSFS/SimConnect/SimConnect.SaveLoadXML.cs rename to OpenSky.Agent.SimConnectMSFS/SimConnect.SaveLoadXML.cs index a1eb3e2..7804571 100644 --- a/OpenSky.AgentMSFS/SimConnect/SimConnect.SaveLoadXML.cs +++ b/OpenSky.Agent.SimConnectMSFS/SimConnect.SaveLoadXML.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- @@ -17,8 +17,9 @@ namespace OpenSky.AgentMSFS.SimConnect using Microsoft.Maps.MapControl.WPF; + using OpenSky.Agent.Simulator; + using OpenSky.Agent.Simulator.Models; using OpenSky.AgentMSFS.Models; - using OpenSky.AgentMSFS.Tools; using OpenSky.FlightLogXML; using OpenSkyApi; diff --git a/OpenSky.AgentMSFS/SimConnect/SimConnect.Simbrief.cs b/OpenSky.Agent.SimConnectMSFS/SimConnect.Simbrief.cs similarity index 99% rename from OpenSky.AgentMSFS/SimConnect/SimConnect.Simbrief.cs rename to OpenSky.Agent.SimConnectMSFS/SimConnect.Simbrief.cs index c88ad2f..a81b364 100644 --- a/OpenSky.AgentMSFS/SimConnect/SimConnect.Simbrief.cs +++ b/OpenSky.Agent.SimConnectMSFS/SimConnect.Simbrief.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- @@ -16,7 +16,6 @@ namespace OpenSky.AgentMSFS.SimConnect using Microsoft.Maps.MapControl.WPF; using OpenSky.AgentMSFS.Models; - using OpenSky.AgentMSFS.Tools; /// ------------------------------------------------------------------------------------------------- /// diff --git a/OpenSky.AgentMSFS/SimConnect/SimConnect.cs b/OpenSky.Agent.SimConnectMSFS/SimConnect.cs similarity index 99% rename from OpenSky.AgentMSFS/SimConnect/SimConnect.cs rename to OpenSky.Agent.SimConnectMSFS/SimConnect.cs index 9354903..da502fe 100644 --- a/OpenSky.AgentMSFS/SimConnect/SimConnect.cs +++ b/OpenSky.Agent.SimConnectMSFS/SimConnect.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- @@ -19,8 +19,6 @@ namespace OpenSky.AgentMSFS.SimConnect using CTrue.FsConnect; - using OpenSky.AgentMSFS.Properties; - using JetBrains.Annotations; using Microsoft.Maps.MapControl.WPF; @@ -29,10 +27,10 @@ namespace OpenSky.AgentMSFS.SimConnect using OpenSky.AgentMSFS.SimConnect.Enums; using OpenSky.AgentMSFS.SimConnect.Helpers; using OpenSky.AgentMSFS.SimConnect.Structs; - using OpenSky.AgentMSFS.Tools; using OpenSky.FlightLogXML; - using TrackingEventLogEntry = Models.TrackingEventLogEntry; + using OpenSky.Agent.Simulator; + using OpenSky.Agent.Simulator.Enums; /// ------------------------------------------------------------------------------------------------- /// @@ -42,7 +40,7 @@ namespace OpenSky.AgentMSFS.SimConnect /// sushi.at, 13/03/2021. /// /// ------------------------------------------------------------------------------------------------- - public partial class SimConnect : INotifyPropertyChanged + public partial class SimConnect : Simulator, INotifyPropertyChanged { /// ------------------------------------------------------------------------------------------------- /// diff --git a/OpenSky.Agent.SimConnectMSFS/Structs/FuelTanks.cs b/OpenSky.Agent.SimConnectMSFS/Structs/FuelTanks.cs new file mode 100644 index 0000000..2ccc884 --- /dev/null +++ b/OpenSky.Agent.SimConnectMSFS/Structs/FuelTanks.cs @@ -0,0 +1,230 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// OpenSky project 2021-2022 +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace OpenSky.AgentMSFS.SimConnect.Structs +{ + using System.Collections.Generic; + using System.Runtime.InteropServices; + + using CTrue.FsConnect; + + using Microsoft.FlightSimulator.SimConnect; + + using OpenSky.Agent.Simulator.Enums; + using OpenSky.AgentMSFS.SimConnect.Enums; + + + /// ------------------------------------------------------------------------------------------------- + /// + /// Fuel tanks struct. + /// + /// + /// sushi.at, 17/03/2021. + /// + /// ------------------------------------------------------------------------------------------------- + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)] + public struct FuelTanks + { + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets or sets the fuel tank center capacity. + /// + /// ------------------------------------------------------------------------------------------------- + public double FuelTankCenterCapacity { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets or sets the fuel tank center 2 capacity. + /// + /// ------------------------------------------------------------------------------------------------- + public double FuelTankCenter2Capacity { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets or sets the fuel tank center 3 capacity. + /// + /// ------------------------------------------------------------------------------------------------- + public double FuelTankCenter3Capacity { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets or sets the fuel tank left main capacity. + /// + /// ------------------------------------------------------------------------------------------------- + public double FuelTankLeftMainCapacity { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets or sets the fuel tank left auxiliary capacity. + /// + /// ------------------------------------------------------------------------------------------------- + public double FuelTankLeftAuxCapacity { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets or sets the fuel tank left tip capacity. + /// + /// ------------------------------------------------------------------------------------------------- + public double FuelTankLeftTipCapacity { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets or sets the fuel tank right main capacity. + /// + /// ------------------------------------------------------------------------------------------------- + public double FuelTankRightMainCapacity { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets or sets the fuel tank right auxiliary capacity. + /// + /// ------------------------------------------------------------------------------------------------- + public double FuelTankRightAuxCapacity { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets or sets the fuel tank right tip capacity. + /// + /// ------------------------------------------------------------------------------------------------- + public double FuelTankRightTipCapacity { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets or sets the fuel tank external 1 capacity. + /// + /// ------------------------------------------------------------------------------------------------- + public double FuelTankExternal1Capacity { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets or sets the fuel tank external 2 capacity. + /// + /// ------------------------------------------------------------------------------------------------- + public double FuelTankExternal2Capacity { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets or sets the fuel tank center quantity. + /// + /// ------------------------------------------------------------------------------------------------- + public double FuelTankCenterQuantity { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets or sets the fuel tank center 2 quantity. + /// + /// ------------------------------------------------------------------------------------------------- + public double FuelTankCenter2Quantity { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets or sets the fuel tank center 3 quantity. + /// + /// ------------------------------------------------------------------------------------------------- + public double FuelTankCenter3Quantity { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets or sets the fuel tank left main quantity. + /// + /// ------------------------------------------------------------------------------------------------- + public double FuelTankLeftMainQuantity { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets or sets the fuel tank left auxiliary quantity. + /// + /// ------------------------------------------------------------------------------------------------- + public double FuelTankLeftAuxQuantity { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets or sets the fuel tank left tip quantity. + /// + /// ------------------------------------------------------------------------------------------------- + public double FuelTankLeftTipQuantity { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets or sets the fuel tank right main quantity. + /// + /// ------------------------------------------------------------------------------------------------- + public double FuelTankRightMainQuantity { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets or sets the fuel tank right auxiliary quantity. + /// + /// ------------------------------------------------------------------------------------------------- + public double FuelTankRightAuxQuantity { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets or sets the fuel tank right tip quantity. + /// + /// ------------------------------------------------------------------------------------------------- + public double FuelTankRightTipQuantity { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets or sets the fuel tank external 1 quantity. + /// + /// ------------------------------------------------------------------------------------------------- + public double FuelTankExternal1Quantity { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets or sets the fuel tank external 2 quantity. + /// + /// ------------------------------------------------------------------------------------------------- + public double FuelTankExternal2Quantity { get; set; } + } + + + /// ------------------------------------------------------------------------------------------------- + /// + /// The fuel tanks struct SimConnect properties definition. + /// + /// + /// sushi.at, 18/03/2021. + /// + /// ------------------------------------------------------------------------------------------------- + public static class FuelTanksDefinition + { + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets the definition list of sim properties. + /// + /// ------------------------------------------------------------------------------------------------- + public static List Definition => + new() + { + new SimVar("FUEL TANK CENTER CAPACITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), + new SimVar("FUEL TANK CENTER2 CAPACITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), + new SimVar("FUEL TANK CENTER3 CAPACITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), + new SimVar("FUEL TANK LEFT MAIN CAPACITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), + new SimVar("FUEL TANK LEFT AUX CAPACITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), + new SimVar("FUEL TANK LEFT TIP CAPACITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), + new SimVar("FUEL TANK RIGHT MAIN CAPACITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), + new SimVar("FUEL TANK RIGHT AUX CAPACITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), + new SimVar("FUEL TANK RIGHT TIP CAPACITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), + new SimVar("FUEL TANK EXTERNAL1 CAPACITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), + new SimVar("FUEL TANK EXTERNAL2 CAPACITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), + + new SimVar("FUEL TANK CENTER QUANTITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), + new SimVar("FUEL TANK CENTER2 QUANTITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), + new SimVar("FUEL TANK CENTER3 QUANTITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), + new SimVar("FUEL TANK LEFT MAIN QUANTITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), + new SimVar("FUEL TANK LEFT AUX QUANTITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), + new SimVar("FUEL TANK LEFT TIP QUANTITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), + new SimVar("FUEL TANK RIGHT MAIN QUANTITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), + new SimVar("FUEL TANK RIGHT AUX QUANTITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), + new SimVar("FUEL TANK RIGHT TIP QUANTITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), + new SimVar("FUEL TANK EXTERNAL1 QUANTITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), + new SimVar("FUEL TANK EXTERNAL2 QUANTITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), + }; + } +} \ No newline at end of file diff --git a/OpenSky.AgentMSFS/SimConnect/Structs/LandingAnalysis.cs b/OpenSky.Agent.SimConnectMSFS/Structs/LandingAnalysis.cs similarity index 87% rename from OpenSky.AgentMSFS/SimConnect/Structs/LandingAnalysis.cs rename to OpenSky.Agent.SimConnectMSFS/Structs/LandingAnalysis.cs index ba1dd72..0f33c14 100644 --- a/OpenSky.AgentMSFS/SimConnect/Structs/LandingAnalysis.cs +++ b/OpenSky.Agent.SimConnectMSFS/Structs/LandingAnalysis.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- @@ -115,24 +115,6 @@ public struct LandingAnalysis /// /// ------------------------------------------------------------------------------------------------- public double BankAngle { get; set; } - - // ================================================================================================== - // END OF STRUCT PROPERTIES - BELOW ARE GET-ONLY COMPUTED PROPERTIES FOR OPENSKY - // ================================================================================================== - - /// ------------------------------------------------------------------------------------------------- - /// - /// The landing rate in feet per minute. - /// - /// ------------------------------------------------------------------------------------------------- - public double LandingRate => this.LandingRateSeconds * 60; - - /// ------------------------------------------------------------------------------------------------- - /// - /// The current map location. - /// - /// ------------------------------------------------------------------------------------------------- - public Location Location => new(this.Latitude, this.Longitude, this.Altitude); } /// ------------------------------------------------------------------------------------------------- diff --git a/OpenSky.AgentMSFS/SimConnect/Structs/PayloadStations.cs b/OpenSky.Agent.SimConnectMSFS/Structs/PayloadStations.cs similarity index 87% rename from OpenSky.AgentMSFS/SimConnect/Structs/PayloadStations.cs rename to OpenSky.Agent.SimConnectMSFS/Structs/PayloadStations.cs index 7ae060c..0462de9 100644 --- a/OpenSky.AgentMSFS/SimConnect/Structs/PayloadStations.cs +++ b/OpenSky.Agent.SimConnectMSFS/Structs/PayloadStations.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- @@ -14,6 +14,11 @@ namespace OpenSky.AgentMSFS.SimConnect.Structs using Microsoft.FlightSimulator.SimConnect; + + using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; + using System.Runtime.InteropServices; + /// ------------------------------------------------------------------------------------------------- /// /// Payload stations struct. @@ -333,62 +338,9 @@ public struct PayloadStations /// ------------------------------------------------------------------------------------------------- public double Weight20 { get; set; } - // ================================================================================================== - // END OF STRUCT PROPERTIES - BELOW ARE GET-ONLY COMPUTED PROPERTIES FOR OPENSKY - // ================================================================================================== - /// ------------------------------------------------------------------------------------------------- - /// - /// Gets the payload stations names list. - /// - /// ------------------------------------------------------------------------------------------------- - public List Names => - new() - { - this.Name1?.Replace("TT:MENU.PAYLOAD.", string.Empty), - this.Name2?.Replace("TT:MENU.PAYLOAD.", string.Empty), - this.Name3?.Replace("TT:MENU.PAYLOAD.", string.Empty), - this.Name4?.Replace("TT:MENU.PAYLOAD.", string.Empty), - this.Name5?.Replace("TT:MENU.PAYLOAD.", string.Empty), - this.Name6?.Replace("TT:MENU.PAYLOAD.", string.Empty), - this.Name7?.Replace("TT:MENU.PAYLOAD.", string.Empty), - this.Name8?.Replace("TT:MENU.PAYLOAD.", string.Empty), - this.Name9?.Replace("TT:MENU.PAYLOAD.", string.Empty), - this.Name10?.Replace("TT:MENU.PAYLOAD.", string.Empty), - this.Name11?.Replace("TT:MENU.PAYLOAD.", string.Empty), - this.Name12?.Replace("TT:MENU.PAYLOAD.", string.Empty), - this.Name13?.Replace("TT:MENU.PAYLOAD.", string.Empty), - this.Name14?.Replace("TT:MENU.PAYLOAD.", string.Empty), - this.Name15?.Replace("TT:MENU.PAYLOAD.", string.Empty), - this.Name16?.Replace("TT:MENU.PAYLOAD.", string.Empty), - this.Name17?.Replace("TT:MENU.PAYLOAD.", string.Empty), - this.Name18?.Replace("TT:MENU.PAYLOAD.", string.Empty), - this.Name19?.Replace("TT:MENU.PAYLOAD.", string.Empty), - this.Name20?.Replace("TT:MENU.PAYLOAD.", string.Empty), - }; + - /// ------------------------------------------------------------------------------------------------- - /// - /// Gets the total payload weight across all stations. - /// - /// ------------------------------------------------------------------------------------------------- - public double TotalWeight - { - get - { - var total = 0.0; - for (var i = 1; i < this.Count + 1; i++) - { - var propInfo = this.GetType().GetProperty($"Weight{i}"); - if (propInfo != null) - { - total += (double)propInfo.GetValue(this); - } - } - - return total; - } - } } /// ------------------------------------------------------------------------------------------------- diff --git a/OpenSky.AgentMSFS/SimConnect/Structs/PlaneIdentity.cs b/OpenSky.Agent.SimConnectMSFS/Structs/PlaneIdentity.cs similarity index 77% rename from OpenSky.AgentMSFS/SimConnect/Structs/PlaneIdentity.cs rename to OpenSky.Agent.SimConnectMSFS/Structs/PlaneIdentity.cs index 7eb7d06..edc2b6e 100644 --- a/OpenSky.AgentMSFS/SimConnect/Structs/PlaneIdentity.cs +++ b/OpenSky.Agent.SimConnectMSFS/Structs/PlaneIdentity.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- @@ -79,31 +79,6 @@ public struct PlaneIdentity /// /// ------------------------------------------------------------------------------------------------- public bool GearRetractable { get; set; } - - // ================================================================================================== - // END OF STRUCT PROPERTIES - BELOW ARE GET-ONLY COMPUTED PROPERTIES FOR OPENSKY - // ================================================================================================== - - /// ------------------------------------------------------------------------------------------------- - /// - /// The plane type as property (for gui bindings). - /// - /// ------------------------------------------------------------------------------------------------- - public string TypeProperty => this.Type; - - /// ------------------------------------------------------------------------------------------------- - /// - /// The ATC plane type as property (for gui bindings). - /// - /// ------------------------------------------------------------------------------------------------- - public string AtcTypeProperty => this.AtcType; - - /// ------------------------------------------------------------------------------------------------- - /// - /// The ATC plane model as property (for gui bindings). - /// - /// ------------------------------------------------------------------------------------------------- - public string AtcModelProperty => this.AtcModel; } /// ------------------------------------------------------------------------------------------------- diff --git a/OpenSky.AgentMSFS/SimConnect/Structs/PlaneRegistry.cs b/OpenSky.Agent.SimConnectMSFS/Structs/PlaneRegistry.cs similarity index 98% rename from OpenSky.AgentMSFS/SimConnect/Structs/PlaneRegistry.cs rename to OpenSky.Agent.SimConnectMSFS/Structs/PlaneRegistry.cs index 68b0f86..8f12378 100644 --- a/OpenSky.AgentMSFS/SimConnect/Structs/PlaneRegistry.cs +++ b/OpenSky.Agent.SimConnectMSFS/Structs/PlaneRegistry.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- diff --git a/OpenSky.AgentMSFS/SimConnect/Structs/PrimaryTracking.cs b/OpenSky.Agent.SimConnectMSFS/Structs/PrimaryTracking.cs similarity index 84% rename from OpenSky.AgentMSFS/SimConnect/Structs/PrimaryTracking.cs rename to OpenSky.Agent.SimConnectMSFS/Structs/PrimaryTracking.cs index 47e387f..acafe27 100644 --- a/OpenSky.AgentMSFS/SimConnect/Structs/PrimaryTracking.cs +++ b/OpenSky.Agent.SimConnectMSFS/Structs/PrimaryTracking.cs @@ -1,21 +1,19 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- namespace OpenSky.AgentMSFS.SimConnect.Structs { using System.Collections.Generic; - using System.Device.Location; using System.Runtime.InteropServices; using CTrue.FsConnect; using Microsoft.FlightSimulator.SimConnect; - using Microsoft.Maps.MapControl.WPF; - using OpenSky.AgentMSFS.SimConnect.Enums; + using OpenSky.Agent.Simulator.Enums; /// ------------------------------------------------------------------------------------------------- /// @@ -153,33 +151,6 @@ public struct PrimaryTracking /// /// ------------------------------------------------------------------------------------------------- public CrashSequence CrashSequence { get; set; } - - // todo Maybe add "AMBIENT IN CLOUD Bool", so we further refine lights on requirements (say no ldg lights below 10000 if in the clouds?) - - // ================================================================================================== - // END OF STRUCT PROPERTIES - BELOW ARE GET-ONLY COMPUTED PROPERTIES FOR OPENSKY - // ================================================================================================== - - /// ------------------------------------------------------------------------------------------------- - /// - /// The vertical speed in feet per minute. - /// - /// ------------------------------------------------------------------------------------------------- - public double VerticalSpeed => this.VerticalSpeedSeconds * 60; - - /// ------------------------------------------------------------------------------------------------- - /// - /// The current map location. - /// - /// ------------------------------------------------------------------------------------------------- - public Location MapLocation => new(this.Latitude, this.Longitude, this.Altitude); - - /// ------------------------------------------------------------------------------------------------- - /// - /// Gets the geo coordinate. - /// - /// ------------------------------------------------------------------------------------------------- - public GeoCoordinate GeoCoordinate => new(this.Latitude, this.Longitude, this.Altitude); } /// ------------------------------------------------------------------------------------------------- diff --git a/OpenSky.AgentMSFS/SimConnect/Structs/SecondaryTracking.cs b/OpenSky.Agent.SimConnectMSFS/Structs/SecondaryTracking.cs similarity index 90% rename from OpenSky.AgentMSFS/SimConnect/Structs/SecondaryTracking.cs rename to OpenSky.Agent.SimConnectMSFS/Structs/SecondaryTracking.cs index 03761d1..cb3464a 100644 --- a/OpenSky.AgentMSFS/SimConnect/Structs/SecondaryTracking.cs +++ b/OpenSky.Agent.SimConnectMSFS/Structs/SecondaryTracking.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- @@ -16,6 +16,14 @@ namespace OpenSky.AgentMSFS.SimConnect.Structs using OpenSky.AgentMSFS.SimConnect.Enums; + using System; + using System.Runtime.InteropServices; + + using OpenSky.Agent.Simulator.Enums; + using OpenSky.FlightLogXML; + + using TimeOfDay = OpenSky.AgentMSFS.SimConnect.Enums.TimeOfDay; + /// ------------------------------------------------------------------------------------------------- /// /// Secondary flight tracking struct. @@ -222,38 +230,6 @@ public struct SecondaryTracking /// /// ------------------------------------------------------------------------------------------------- public bool NoSmokingSign { get; set; } - - - // ================================================================================================== - // END OF STRUCT PROPERTIES - BELOW ARE GET-ONLY COMPUTED PROPERTIES FOR OPENSKY - // ================================================================================================== - - /// ------------------------------------------------------------------------------------------------- - /// - /// The UTC date/time. - /// - /// ------------------------------------------------------------------------------------------------- - public DateTime UtcDateTime - { - get - { - try - { - return new DateTime(this.UtcYear, this.UtcMonth, this.UtcDay).AddSeconds(this.UtcTime); - } - catch - { - return DateTime.MinValue; - } - } - } - - /// ------------------------------------------------------------------------------------------------- - /// - /// Is there a running engine? - /// - /// ------------------------------------------------------------------------------------------------- - public bool EngineRunning => this.EngineCombustion1 || this.EngineCombustion2 || this.EngineCombustion3 || this.EngineCombustion4; } /// ------------------------------------------------------------------------------------------------- diff --git a/OpenSky.AgentMSFS/SimConnect/Structs/SlewPlaneIntoPosition.cs b/OpenSky.Agent.SimConnectMSFS/Structs/SlewPlaneIntoPosition.cs similarity index 93% rename from OpenSky.AgentMSFS/SimConnect/Structs/SlewPlaneIntoPosition.cs rename to OpenSky.Agent.SimConnectMSFS/Structs/SlewPlaneIntoPosition.cs index c526180..3aa2741 100644 --- a/OpenSky.AgentMSFS/SimConnect/Structs/SlewPlaneIntoPosition.cs +++ b/OpenSky.Agent.SimConnectMSFS/Structs/SlewPlaneIntoPosition.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- @@ -14,6 +14,9 @@ namespace OpenSky.AgentMSFS.SimConnect.Structs using Microsoft.FlightSimulator.SimConnect; + using System.Device.Location; + using System.Runtime.InteropServices; + /// ------------------------------------------------------------------------------------------------- /// /// Slew plane into position struct. @@ -132,14 +135,14 @@ public static SlewPlaneIntoPosition FromPrimaryTracking(PrimaryTracking primary) } /// ------------------------------------------------------------------------------------------------- - /// - /// The slew plane into position struct SimConnect properties definition. - /// - /// - /// sushi.at, 13/03/2021. - /// - /// ------------------------------------------------------------------------------------------------- - public static class SlewPlaneIntoPositionDefinition + /// + /// The slew plane into position struct SimConnect properties definition. + /// + /// + /// sushi.at, 13/03/2021. + /// + /// ------------------------------------------------------------------------------------------------- + public static class SlewPlaneIntoPositionDefinition { /// ------------------------------------------------------------------------------------------------- /// diff --git a/OpenSky.Agent.SimConnectMSFS/Structs/WeightAndBalance.cs b/OpenSky.Agent.SimConnectMSFS/Structs/WeightAndBalance.cs new file mode 100644 index 0000000..bb933aa --- /dev/null +++ b/OpenSky.Agent.SimConnectMSFS/Structs/WeightAndBalance.cs @@ -0,0 +1,126 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// OpenSky project 2021-2022 +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace OpenSky.AgentMSFS.SimConnect.Structs +{ + using System.Collections.Generic; + + using CTrue.FsConnect; + + using Microsoft.FlightSimulator.SimConnect; + + /// ------------------------------------------------------------------------------------------------- + /// + /// The weight and balance struct. + /// + /// + /// sushi.at, 20/03/2021. + /// + /// ------------------------------------------------------------------------------------------------- + public struct WeightAndBalance + { + /// ------------------------------------------------------------------------------------------------- + /// + /// Empty weight in pounds. + /// + /// ------------------------------------------------------------------------------------------------- + public double EmptyWeight { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Total weight in pounds. + /// + /// ------------------------------------------------------------------------------------------------- + public double TotalWeight { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Max gross weight in pounds. + /// + /// ------------------------------------------------------------------------------------------------- + public double MaxGrossWeight { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Fuel total capacity in gallons. + /// + /// ------------------------------------------------------------------------------------------------- + public double FuelTotalCapacity { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Fuel total quantity on board in gallons. + /// + /// ------------------------------------------------------------------------------------------------- + public double FuelTotalQuantity { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Fuel weight (pounds/gallon). + /// + /// ------------------------------------------------------------------------------------------------- + public double FuelWeightPerGallon { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The center of gravity aft limit. + /// + /// ------------------------------------------------------------------------------------------------- + public double CgAftLimit { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The center of gravity forward limit. + /// + /// ------------------------------------------------------------------------------------------------- + public double CgFwdLimit { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The center of gravity (longitudinal) + /// + /// ------------------------------------------------------------------------------------------------- + public double CgPercent { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The center of gravity (lateral) + /// + /// ------------------------------------------------------------------------------------------------- + public double CgPercentLateral { get; set; } + } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The weight and balance struct SimConnect properties definition. + /// + /// + /// sushi.at, 20/03/2021. + /// + /// ------------------------------------------------------------------------------------------------- + public static class WeightAndBalanceDefinition + { + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets the definition list of sim properties. + /// + /// ------------------------------------------------------------------------------------------------- + public static List Definition => + new() + { + new SimVar("EMPTY WEIGHT", "Pounds", SIMCONNECT_DATATYPE.FLOAT64), + new SimVar("TOTAL WEIGHT", "Pounds", SIMCONNECT_DATATYPE.FLOAT64), + new SimVar("MAX GROSS WEIGHT", "Pounds", SIMCONNECT_DATATYPE.FLOAT64), + new SimVar("FUEL TOTAL CAPACITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), + new SimVar("FUEL TOTAL QUANTITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), + new SimVar("FUEL WEIGHT PER GALLON", "Pounds", SIMCONNECT_DATATYPE.FLOAT64), + new SimVar("CG AFT LIMIT", "Percent over 100", SIMCONNECT_DATATYPE.FLOAT64), + new SimVar("CG FWD LIMIT", "Percent over 100", SIMCONNECT_DATATYPE.FLOAT64), + new SimVar("CG PERCENT", "Percent over 100", SIMCONNECT_DATATYPE.FLOAT64), + new SimVar("CG PERCENT LATERAL", "Percent over 100", SIMCONNECT_DATATYPE.FLOAT64), + }; + } +} \ No newline at end of file diff --git a/OpenSky.Agent.SimConnectMSFS/packages.config b/OpenSky.Agent.SimConnectMSFS/packages.config new file mode 100644 index 0000000..b130324 --- /dev/null +++ b/OpenSky.Agent.SimConnectMSFS/packages.config @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/OpenSky.AgentMSFS/SimConnect/Enums/FuelTank.cs b/OpenSky.Agent.Simulator/Enums/FuelTank.cs similarity index 95% rename from OpenSky.AgentMSFS/SimConnect/Enums/FuelTank.cs rename to OpenSky.Agent.Simulator/Enums/FuelTank.cs index 9b67ea4..d199f26 100644 --- a/OpenSky.AgentMSFS/SimConnect/Enums/FuelTank.cs +++ b/OpenSky.Agent.Simulator/Enums/FuelTank.cs @@ -1,12 +1,12 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- -namespace OpenSky.AgentMSFS.SimConnect.Enums +namespace OpenSky.Agent.Simulator.Enums { - using OpenSky.AgentMSFS.Tools; + using OpenSky.Agent.Simulator.Tools; /// ------------------------------------------------------------------------------------------------- /// diff --git a/OpenSky.AgentMSFS/SimConnect/Enums/Pushback.cs b/OpenSky.Agent.Simulator/Enums/Pushback.cs similarity index 94% rename from OpenSky.AgentMSFS/SimConnect/Enums/Pushback.cs rename to OpenSky.Agent.Simulator/Enums/Pushback.cs index 045a52b..fb17c34 100644 --- a/OpenSky.AgentMSFS/SimConnect/Enums/Pushback.cs +++ b/OpenSky.Agent.Simulator/Enums/Pushback.cs @@ -1,10 +1,10 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- -namespace OpenSky.AgentMSFS.SimConnect.Enums +namespace OpenSky.Agent.Simulator.Enums { /// ------------------------------------------------------------------------------------------------- /// diff --git a/OpenSky.AgentMSFS/SimConnect/Enums/Requests.cs b/OpenSky.Agent.Simulator/Enums/Requests.cs similarity index 96% rename from OpenSky.AgentMSFS/SimConnect/Enums/Requests.cs rename to OpenSky.Agent.Simulator/Enums/Requests.cs index ecb8140..ed82159 100644 --- a/OpenSky.AgentMSFS/SimConnect/Enums/Requests.cs +++ b/OpenSky.Agent.Simulator/Enums/Requests.cs @@ -1,10 +1,10 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- -namespace OpenSky.AgentMSFS.SimConnect.Enums +namespace OpenSky.Agent.Simulator.Enums { /// ------------------------------------------------------------------------------------------------- /// diff --git a/OpenSky.Agent.Simulator/Models/AircraftIdentity.cs b/OpenSky.Agent.Simulator/Models/AircraftIdentity.cs new file mode 100644 index 0000000..96a3d82 --- /dev/null +++ b/OpenSky.Agent.Simulator/Models/AircraftIdentity.cs @@ -0,0 +1,70 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// OpenSky project 2021-2022 +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace OpenSky.Agent.Simulator.Models +{ + using OpenSkyApi; + + /// ------------------------------------------------------------------------------------------------- + /// + /// Aircraft identity model. + /// + /// + /// sushi.at, 31/01/2022. + /// + /// ------------------------------------------------------------------------------------------------- + public class AircraftIdentity + { + /// ------------------------------------------------------------------------------------------------- + /// + /// The ATC plane model string. + /// + /// ------------------------------------------------------------------------------------------------- + public string AtcModel { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The ATC plane type string. + /// + /// ------------------------------------------------------------------------------------------------- + public string AtcType { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The engine count. + /// + /// ------------------------------------------------------------------------------------------------- + public int EngineCount { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Engine type. + /// + /// ------------------------------------------------------------------------------------------------- + public EngineType EngineType { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Does the plane have flaps? + /// + /// ------------------------------------------------------------------------------------------------- + public bool FlapsAvailable { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Is the landing gear retractable? + /// + /// ------------------------------------------------------------------------------------------------- + public bool GearRetractable { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets or sets the plane type. + /// + /// ------------------------------------------------------------------------------------------------- + public string Type { get; set; } + } +} \ No newline at end of file diff --git a/OpenSky.AgentMSFS/SimConnect/Structs/FuelTanks.cs b/OpenSky.Agent.Simulator/Models/FuelTanks.cs similarity index 78% rename from OpenSky.AgentMSFS/SimConnect/Structs/FuelTanks.cs rename to OpenSky.Agent.Simulator/Models/FuelTanks.cs index a1f6feb..2b75fde 100644 --- a/OpenSky.AgentMSFS/SimConnect/Structs/FuelTanks.cs +++ b/OpenSky.Agent.Simulator/Models/FuelTanks.cs @@ -1,37 +1,45 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- -namespace OpenSky.AgentMSFS.SimConnect.Structs +namespace OpenSky.Agent.Simulator.Models { using System.Collections.Generic; - using System.Runtime.InteropServices; - using CTrue.FsConnect; - - using Microsoft.FlightSimulator.SimConnect; - - using OpenSky.AgentMSFS.SimConnect.Enums; + using OpenSky.Agent.Simulator.Enums; /// ------------------------------------------------------------------------------------------------- /// - /// Fuel tanks struct. + /// Fuel tanks model. /// /// - /// sushi.at, 17/03/2021. + /// sushi.at, 31/01/2022. /// /// ------------------------------------------------------------------------------------------------- - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)] - public struct FuelTanks + public class FuelTanks { /// ------------------------------------------------------------------------------------------------- /// - /// Gets or sets the fuel tank center capacity. + /// Gets the fuel tank capacities dictionary. /// /// ------------------------------------------------------------------------------------------------- - public double FuelTankCenterCapacity { get; set; } + public Dictionary Capacities => + new() + { + { FuelTank.Center, this.FuelTankCenterCapacity }, + { FuelTank.Center2, this.FuelTankCenter2Capacity }, + { FuelTank.Center3, this.FuelTankCenter3Capacity }, + { FuelTank.LeftMain, this.FuelTankLeftMainCapacity }, + { FuelTank.LeftAux, this.FuelTankLeftAuxCapacity }, + { FuelTank.LeftTip, this.FuelTankLeftTipCapacity }, + { FuelTank.RightMain, this.FuelTankRightMainCapacity }, + { FuelTank.RightAux, this.FuelTankRightAuxCapacity }, + { FuelTank.RightTip, this.FuelTankRightTipCapacity }, + { FuelTank.External1, this.FuelTankExternal1Capacity }, + { FuelTank.External2, this.FuelTankExternal2Capacity } + }; /// ------------------------------------------------------------------------------------------------- /// @@ -42,87 +50,87 @@ public struct FuelTanks /// ------------------------------------------------------------------------------------------------- /// - /// Gets or sets the fuel tank center 3 capacity. + /// Gets or sets the fuel tank center 2 quantity. /// /// ------------------------------------------------------------------------------------------------- - public double FuelTankCenter3Capacity { get; set; } + public double FuelTankCenter2Quantity { get; set; } /// ------------------------------------------------------------------------------------------------- /// - /// Gets or sets the fuel tank left main capacity. + /// Gets or sets the fuel tank center 3 capacity. /// /// ------------------------------------------------------------------------------------------------- - public double FuelTankLeftMainCapacity { get; set; } + public double FuelTankCenter3Capacity { get; set; } /// ------------------------------------------------------------------------------------------------- /// - /// Gets or sets the fuel tank left auxiliary capacity. + /// Gets or sets the fuel tank center 3 quantity. /// /// ------------------------------------------------------------------------------------------------- - public double FuelTankLeftAuxCapacity { get; set; } + public double FuelTankCenter3Quantity { get; set; } /// ------------------------------------------------------------------------------------------------- /// - /// Gets or sets the fuel tank left tip capacity. + /// Gets or sets the fuel tank center capacity. /// /// ------------------------------------------------------------------------------------------------- - public double FuelTankLeftTipCapacity { get; set; } + public double FuelTankCenterCapacity { get; set; } /// ------------------------------------------------------------------------------------------------- /// - /// Gets or sets the fuel tank right main capacity. + /// Gets or sets the fuel tank center quantity. /// /// ------------------------------------------------------------------------------------------------- - public double FuelTankRightMainCapacity { get; set; } + public double FuelTankCenterQuantity { get; set; } /// ------------------------------------------------------------------------------------------------- /// - /// Gets or sets the fuel tank right auxiliary capacity. + /// Gets or sets the fuel tank external 1 capacity. /// /// ------------------------------------------------------------------------------------------------- - public double FuelTankRightAuxCapacity { get; set; } + public double FuelTankExternal1Capacity { get; set; } /// ------------------------------------------------------------------------------------------------- /// - /// Gets or sets the fuel tank right tip capacity. + /// Gets or sets the fuel tank external 1 quantity. /// /// ------------------------------------------------------------------------------------------------- - public double FuelTankRightTipCapacity { get; set; } + public double FuelTankExternal1Quantity { get; set; } /// ------------------------------------------------------------------------------------------------- /// - /// Gets or sets the fuel tank external 1 capacity. + /// Gets or sets the fuel tank external 2 capacity. /// /// ------------------------------------------------------------------------------------------------- - public double FuelTankExternal1Capacity { get; set; } + public double FuelTankExternal2Capacity { get; set; } /// ------------------------------------------------------------------------------------------------- /// - /// Gets or sets the fuel tank external 2 capacity. + /// Gets or sets the fuel tank external 2 quantity. /// /// ------------------------------------------------------------------------------------------------- - public double FuelTankExternal2Capacity { get; set; } + public double FuelTankExternal2Quantity { get; set; } /// ------------------------------------------------------------------------------------------------- /// - /// Gets or sets the fuel tank center quantity. + /// Gets or sets the fuel tank left auxiliary capacity. /// /// ------------------------------------------------------------------------------------------------- - public double FuelTankCenterQuantity { get; set; } + public double FuelTankLeftAuxCapacity { get; set; } /// ------------------------------------------------------------------------------------------------- /// - /// Gets or sets the fuel tank center 2 quantity. + /// Gets or sets the fuel tank left auxiliary quantity. /// /// ------------------------------------------------------------------------------------------------- - public double FuelTankCenter2Quantity { get; set; } + public double FuelTankLeftAuxQuantity { get; set; } /// ------------------------------------------------------------------------------------------------- /// - /// Gets or sets the fuel tank center 3 quantity. + /// Gets or sets the fuel tank left main capacity. /// /// ------------------------------------------------------------------------------------------------- - public double FuelTankCenter3Quantity { get; set; } + public double FuelTankLeftMainCapacity { get; set; } /// ------------------------------------------------------------------------------------------------- /// @@ -133,10 +141,10 @@ public struct FuelTanks /// ------------------------------------------------------------------------------------------------- /// - /// Gets or sets the fuel tank left auxiliary quantity. + /// Gets or sets the fuel tank left tip capacity. /// /// ------------------------------------------------------------------------------------------------- - public double FuelTankLeftAuxQuantity { get; set; } + public double FuelTankLeftTipCapacity { get; set; } /// ------------------------------------------------------------------------------------------------- /// @@ -147,10 +155,10 @@ public struct FuelTanks /// ------------------------------------------------------------------------------------------------- /// - /// Gets or sets the fuel tank right main quantity. + /// Gets or sets the fuel tank right auxiliary capacity. /// /// ------------------------------------------------------------------------------------------------- - public double FuelTankRightMainQuantity { get; set; } + public double FuelTankRightAuxCapacity { get; set; } /// ------------------------------------------------------------------------------------------------- /// @@ -161,68 +169,31 @@ public struct FuelTanks /// ------------------------------------------------------------------------------------------------- /// - /// Gets or sets the fuel tank right tip quantity. - /// - /// ------------------------------------------------------------------------------------------------- - public double FuelTankRightTipQuantity { get; set; } - - /// ------------------------------------------------------------------------------------------------- - /// - /// Gets or sets the fuel tank external 1 quantity. + /// Gets or sets the fuel tank right main capacity. /// /// ------------------------------------------------------------------------------------------------- - public double FuelTankExternal1Quantity { get; set; } + public double FuelTankRightMainCapacity { get; set; } /// ------------------------------------------------------------------------------------------------- /// - /// Gets or sets the fuel tank external 2 quantity. + /// Gets or sets the fuel tank right main quantity. /// /// ------------------------------------------------------------------------------------------------- - public double FuelTankExternal2Quantity { get; set; } - - // ================================================================================================== - // END OF STRUCT PROPERTIES - BELOW ARE GET-ONLY COMPUTED PROPERTIES FOR OPENSKY - // ================================================================================================== + public double FuelTankRightMainQuantity { get; set; } /// ------------------------------------------------------------------------------------------------- /// - /// Gets the total quantity of fuel in all tanks. + /// Gets or sets the fuel tank right tip capacity. /// /// ------------------------------------------------------------------------------------------------- - public double TotalQuantity - { - get - { - var total = 0.0; - foreach (var quantity in Quantities) - { - total += quantity.Value; - } - - return total; - } - } + public double FuelTankRightTipCapacity { get; set; } /// ------------------------------------------------------------------------------------------------- /// - /// Gets the fuel tank capacities dictionary. + /// Gets or sets the fuel tank right tip quantity. /// /// ------------------------------------------------------------------------------------------------- - public Dictionary Capacities => - new() - { - { FuelTank.Center, this.FuelTankCenterCapacity }, - { FuelTank.Center2, this.FuelTankCenter2Capacity }, - { FuelTank.Center3, this.FuelTankCenter3Capacity }, - { FuelTank.LeftMain, this.FuelTankLeftMainCapacity }, - { FuelTank.LeftAux, this.FuelTankLeftAuxCapacity }, - { FuelTank.LeftTip, this.FuelTankLeftTipCapacity }, - { FuelTank.RightMain, this.FuelTankRightMainCapacity }, - { FuelTank.RightAux, this.FuelTankRightAuxCapacity }, - { FuelTank.RightTip, this.FuelTankRightTipCapacity }, - { FuelTank.External1, this.FuelTankExternal1Capacity }, - { FuelTank.External2, this.FuelTankExternal2Capacity } - }; + public double FuelTankRightTipQuantity { get; set; } /// ------------------------------------------------------------------------------------------------- /// @@ -245,6 +216,25 @@ public double TotalQuantity { FuelTank.External2, this.FuelTankExternal2Quantity } }; + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets the total quantity of fuel in all tanks. + /// + /// ------------------------------------------------------------------------------------------------- + public double TotalQuantity + { + get + { + var total = 0.0; + foreach (var quantity in this.Quantities) + { + total += quantity.Value; + } + + return total; + } + } + /// ------------------------------------------------------------------------------------------------- /// /// Updates the quantities from a modified dictionary. @@ -271,48 +261,4 @@ public void UpdateQuantitiesFromDictionary(Dictionary modified this.FuelTankExternal2Quantity = modifiedDictionary[FuelTank.External2]; } } - - /// ------------------------------------------------------------------------------------------------- - /// - /// The fuel tanks struct SimConnect properties definition. - /// - /// - /// sushi.at, 18/03/2021. - /// - /// ------------------------------------------------------------------------------------------------- - public static class FuelTanksDefinition - { - /// ------------------------------------------------------------------------------------------------- - /// - /// Gets the definition list of sim properties. - /// - /// ------------------------------------------------------------------------------------------------- - public static List Definition => - new() - { - new SimVar("FUEL TANK CENTER CAPACITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), - new SimVar("FUEL TANK CENTER2 CAPACITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), - new SimVar("FUEL TANK CENTER3 CAPACITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), - new SimVar("FUEL TANK LEFT MAIN CAPACITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), - new SimVar("FUEL TANK LEFT AUX CAPACITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), - new SimVar("FUEL TANK LEFT TIP CAPACITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), - new SimVar("FUEL TANK RIGHT MAIN CAPACITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), - new SimVar("FUEL TANK RIGHT AUX CAPACITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), - new SimVar("FUEL TANK RIGHT TIP CAPACITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), - new SimVar("FUEL TANK EXTERNAL1 CAPACITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), - new SimVar("FUEL TANK EXTERNAL2 CAPACITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), - - new SimVar("FUEL TANK CENTER QUANTITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), - new SimVar("FUEL TANK CENTER2 QUANTITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), - new SimVar("FUEL TANK CENTER3 QUANTITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), - new SimVar("FUEL TANK LEFT MAIN QUANTITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), - new SimVar("FUEL TANK LEFT AUX QUANTITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), - new SimVar("FUEL TANK LEFT TIP QUANTITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), - new SimVar("FUEL TANK RIGHT MAIN QUANTITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), - new SimVar("FUEL TANK RIGHT AUX QUANTITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), - new SimVar("FUEL TANK RIGHT TIP QUANTITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), - new SimVar("FUEL TANK EXTERNAL1 QUANTITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), - new SimVar("FUEL TANK EXTERNAL2 QUANTITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), - }; - } } \ No newline at end of file diff --git a/OpenSky.Agent.Simulator/Models/LandingAnalysis.cs b/OpenSky.Agent.Simulator/Models/LandingAnalysis.cs new file mode 100644 index 0000000..88c7054 --- /dev/null +++ b/OpenSky.Agent.Simulator/Models/LandingAnalysis.cs @@ -0,0 +1,126 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// OpenSky project 2021-2022 +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace OpenSky.Agent.Simulator.Models +{ + using Microsoft.Maps.MapControl.WPF; + + /// ------------------------------------------------------------------------------------------------- + /// + /// Landing analysis model. + /// + /// + /// sushi.at, 31/01/2022. + /// + /// ------------------------------------------------------------------------------------------------- + public class LandingAnalysis + { + /// ------------------------------------------------------------------------------------------------- + /// + /// The true airspeed. + /// + /// ------------------------------------------------------------------------------------------------- + public double AirspeedTrue { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The altitude in feet. + /// + /// ------------------------------------------------------------------------------------------------- + public double Altitude { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The bank angle in degrees. + /// + /// ------------------------------------------------------------------------------------------------- + public double BankAngle { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The g-force. + /// + /// ------------------------------------------------------------------------------------------------- + public double Gforce { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The ground speed. + /// + /// ------------------------------------------------------------------------------------------------- + public double GroundSpeed { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The landing rate in feet per minute. + /// + /// ------------------------------------------------------------------------------------------------- + public double LandingRate => this.LandingRateSeconds * 60; + + /// ------------------------------------------------------------------------------------------------- + /// + /// The vertical speed during touchdown (feet/s). + /// + /// ------------------------------------------------------------------------------------------------- + public double LandingRateSeconds { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The latitude in degrees. + /// + /// ------------------------------------------------------------------------------------------------- + public double Latitude { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The current map location. + /// + /// ------------------------------------------------------------------------------------------------- + public Location Location => new(this.Latitude, this.Longitude, this.Altitude); + + /// ------------------------------------------------------------------------------------------------- + /// + /// The longitude in degrees. + /// + /// ------------------------------------------------------------------------------------------------- + public double Longitude { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Is the plane on the ground? + /// + /// ------------------------------------------------------------------------------------------------- + public bool OnGround { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The sidewards speed of the plane (feet/s). + /// + /// ------------------------------------------------------------------------------------------------- + public double SpeedLat { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The forward speed of the plane (feet/s). + /// + /// ------------------------------------------------------------------------------------------------- + public double SpeedLong { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The cross wind (knots). + /// + /// ------------------------------------------------------------------------------------------------- + public double WindLat { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The headwind/tailwind (knots). + /// + /// ------------------------------------------------------------------------------------------------- + public double WindLong { get; set; } + } +} \ No newline at end of file diff --git a/OpenSky.AgentMSFS/Models/MapPositionUpdate.cs b/OpenSky.Agent.Simulator/Models/MapPositionUpdate.cs similarity index 98% rename from OpenSky.AgentMSFS/Models/MapPositionUpdate.cs rename to OpenSky.Agent.Simulator/Models/MapPositionUpdate.cs index 79f21f8..be803cb 100644 --- a/OpenSky.AgentMSFS/Models/MapPositionUpdate.cs +++ b/OpenSky.Agent.Simulator/Models/MapPositionUpdate.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- diff --git a/OpenSky.Agent.Simulator/Models/PayloadStations.cs b/OpenSky.Agent.Simulator/Models/PayloadStations.cs new file mode 100644 index 0000000..5f6a58d --- /dev/null +++ b/OpenSky.Agent.Simulator/Models/PayloadStations.cs @@ -0,0 +1,379 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// OpenSky project 2021-2022 +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace OpenSky.Agent.Simulator.Models +{ + using System.Collections.Generic; + + /// ------------------------------------------------------------------------------------------------- + /// + /// Payload stations model. + /// + /// + /// sushi.at, 31/01/2022. + /// + /// ------------------------------------------------------------------------------------------------- + public class PayloadStations + { + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets or sets the number of payload stations. + /// + /// ------------------------------------------------------------------------------------------------- + public int Count { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station name 1. + /// + /// ------------------------------------------------------------------------------------------------- + public string Name1 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station name 10. + /// + /// ------------------------------------------------------------------------------------------------- + + public string Name10 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station name 11. + /// + /// ------------------------------------------------------------------------------------------------- + + public string Name11 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station name 12. + /// + /// ------------------------------------------------------------------------------------------------- + + public string Name12 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station name 13. + /// + /// ------------------------------------------------------------------------------------------------- + + public string Name13 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station name 14. + /// + /// ------------------------------------------------------------------------------------------------- + + public string Name14 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station name 15. + /// + /// ------------------------------------------------------------------------------------------------- + + public string Name15 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station name 16. + /// + /// ------------------------------------------------------------------------------------------------- + + public string Name16 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station name 17. + /// + /// ------------------------------------------------------------------------------------------------- + + public string Name17 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station name 18. + /// + /// ------------------------------------------------------------------------------------------------- + + public string Name18 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station name 19. + /// + /// ------------------------------------------------------------------------------------------------- + + public string Name19 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station name 2. + /// + /// ------------------------------------------------------------------------------------------------- + public string Name2 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station name 20. + /// + /// ------------------------------------------------------------------------------------------------- + + public string Name20 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station name 3. + /// + /// ------------------------------------------------------------------------------------------------- + + public string Name3 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station name 4. + /// + /// ------------------------------------------------------------------------------------------------- + + public string Name4 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station name 5. + /// + /// ------------------------------------------------------------------------------------------------- + + public string Name5 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station name 6. + /// + /// ------------------------------------------------------------------------------------------------- + + public string Name6 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station name 7. + /// + /// ------------------------------------------------------------------------------------------------- + + public string Name7 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station name 8. + /// + /// ------------------------------------------------------------------------------------------------- + + public string Name8 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station name 9. + /// + /// ------------------------------------------------------------------------------------------------- + + public string Name9 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets the payload stations names list. + /// + /// ------------------------------------------------------------------------------------------------- + public List Names => + new() + { + this.Name1?.Replace("TT:MENU.PAYLOAD.", string.Empty), + this.Name2?.Replace("TT:MENU.PAYLOAD.", string.Empty), + this.Name3?.Replace("TT:MENU.PAYLOAD.", string.Empty), + this.Name4?.Replace("TT:MENU.PAYLOAD.", string.Empty), + this.Name5?.Replace("TT:MENU.PAYLOAD.", string.Empty), + this.Name6?.Replace("TT:MENU.PAYLOAD.", string.Empty), + this.Name7?.Replace("TT:MENU.PAYLOAD.", string.Empty), + this.Name8?.Replace("TT:MENU.PAYLOAD.", string.Empty), + this.Name9?.Replace("TT:MENU.PAYLOAD.", string.Empty), + this.Name10?.Replace("TT:MENU.PAYLOAD.", string.Empty), + this.Name11?.Replace("TT:MENU.PAYLOAD.", string.Empty), + this.Name12?.Replace("TT:MENU.PAYLOAD.", string.Empty), + this.Name13?.Replace("TT:MENU.PAYLOAD.", string.Empty), + this.Name14?.Replace("TT:MENU.PAYLOAD.", string.Empty), + this.Name15?.Replace("TT:MENU.PAYLOAD.", string.Empty), + this.Name16?.Replace("TT:MENU.PAYLOAD.", string.Empty), + this.Name17?.Replace("TT:MENU.PAYLOAD.", string.Empty), + this.Name18?.Replace("TT:MENU.PAYLOAD.", string.Empty), + this.Name19?.Replace("TT:MENU.PAYLOAD.", string.Empty), + this.Name20?.Replace("TT:MENU.PAYLOAD.", string.Empty), + }; + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets the total payload weight across all stations. + /// + /// ------------------------------------------------------------------------------------------------- + public double TotalWeight + { + get + { + var total = 0.0; + for (var i = 1; i < this.Count + 1; i++) + { + var propInfo = this.GetType().GetProperty($"Weight{i}"); + if (propInfo != null) + { + total += (double)propInfo.GetValue(this); + } + } + + return total; + } + } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station weight 1. + /// + /// ------------------------------------------------------------------------------------------------- + public double Weight1 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station weight 10. + /// + /// ------------------------------------------------------------------------------------------------- + public double Weight10 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station weight 11. + /// + /// ------------------------------------------------------------------------------------------------- + public double Weight11 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station weight 12. + /// + /// ------------------------------------------------------------------------------------------------- + public double Weight12 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station weight 13. + /// + /// ------------------------------------------------------------------------------------------------- + public double Weight13 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station weight 14. + /// + /// ------------------------------------------------------------------------------------------------- + public double Weight14 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station weight 15. + /// + /// ------------------------------------------------------------------------------------------------- + public double Weight15 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station weight 16. + /// + /// ------------------------------------------------------------------------------------------------- + public double Weight16 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station weight 17. + /// + /// ------------------------------------------------------------------------------------------------- + public double Weight17 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station weight 18. + /// + /// ------------------------------------------------------------------------------------------------- + public double Weight18 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station weight 19. + /// + /// ------------------------------------------------------------------------------------------------- + public double Weight19 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station weight 2. + /// + /// ------------------------------------------------------------------------------------------------- + public double Weight2 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station weight 20. + /// + /// ------------------------------------------------------------------------------------------------- + public double Weight20 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station weight 3. + /// + /// ------------------------------------------------------------------------------------------------- + public double Weight3 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station weight 4. + /// + /// ------------------------------------------------------------------------------------------------- + public double Weight4 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station weight 5. + /// + /// ------------------------------------------------------------------------------------------------- + public double Weight5 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station weight 6. + /// + /// ------------------------------------------------------------------------------------------------- + public double Weight6 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station weight 7. + /// + /// ------------------------------------------------------------------------------------------------- + public double Weight7 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station weight 8. + /// + /// ------------------------------------------------------------------------------------------------- + public double Weight8 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The payload station weight 9. + /// + /// ------------------------------------------------------------------------------------------------- + public double Weight9 { get; set; } + } +} \ No newline at end of file diff --git a/OpenSky.Agent.Simulator/Models/PrimaryTracking.cs b/OpenSky.Agent.Simulator/Models/PrimaryTracking.cs new file mode 100644 index 0000000..7237dc8 --- /dev/null +++ b/OpenSky.Agent.Simulator/Models/PrimaryTracking.cs @@ -0,0 +1,170 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// OpenSky project 2021-2022 +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace OpenSky.Agent.Simulator.Models +{ + using System.Device.Location; + + using Microsoft.Maps.MapControl.WPF; + + /// ------------------------------------------------------------------------------------------------- + /// + /// Primary flight tracking model (checked often). + /// + /// + /// sushi.at, 31/01/2022. + /// + /// ------------------------------------------------------------------------------------------------- + public class PrimaryTracking + { + /// ------------------------------------------------------------------------------------------------- + /// + /// True airspeed in knots. + /// + /// ------------------------------------------------------------------------------------------------- + public double AirspeedTrue { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The altitude in feet. + /// + /// ------------------------------------------------------------------------------------------------- + public double Altitude { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The bank angle in degrees. + /// + /// ------------------------------------------------------------------------------------------------- + public double BankAngle { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets or sets a value indicating whether the aircraft crashed. + /// + /// ------------------------------------------------------------------------------------------------- + public bool Crash { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets the geo coordinate. + /// + /// ------------------------------------------------------------------------------------------------- + public GeoCoordinate GeoCoordinate => new(this.Latitude, this.Longitude, this.Altitude); + + /// ------------------------------------------------------------------------------------------------- + /// + /// The g-force. + /// + /// ------------------------------------------------------------------------------------------------- + public double GForce { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Ground speed in knots. + /// + /// ------------------------------------------------------------------------------------------------- + public double GroundSpeed { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The magnetic heading. + /// + /// ------------------------------------------------------------------------------------------------- + public double Heading { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The indicated altitude in feet. + /// + /// ------------------------------------------------------------------------------------------------- + public double IndicatedAltitude { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The latitude in degrees. + /// + /// ------------------------------------------------------------------------------------------------- + public double Latitude { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The longitude in degrees. + /// + /// ------------------------------------------------------------------------------------------------- + public double Longitude { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The current map location. + /// + /// ------------------------------------------------------------------------------------------------- + public Location MapLocation => new(this.Latitude, this.Longitude, this.Altitude); + + /// ------------------------------------------------------------------------------------------------- + /// + /// Is the plane on the ground? + /// + /// ------------------------------------------------------------------------------------------------- + public bool OnGround { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The over-speed warning. + /// + /// ------------------------------------------------------------------------------------------------- + public bool OverspeedWarning { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The pitch angle in degrees. + /// + /// ------------------------------------------------------------------------------------------------- + public double PitchAngle { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The radio height in feet. + /// + /// ------------------------------------------------------------------------------------------------- + public double RadioHeight { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The simulation rate. + /// + /// ------------------------------------------------------------------------------------------------- + public double SimulationRate { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Is slew mode active? + /// + /// ------------------------------------------------------------------------------------------------- + public bool SlewActive { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The stall warning. + /// + /// ------------------------------------------------------------------------------------------------- + public bool StallWarning { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The vertical speed in feet per minute. + /// + /// ------------------------------------------------------------------------------------------------- + public double VerticalSpeed => this.VerticalSpeedSeconds * 60; + + /// ------------------------------------------------------------------------------------------------- + /// + /// The vertical speed in feet per second. + /// + /// ------------------------------------------------------------------------------------------------- + public double VerticalSpeedSeconds { get; set; } + } +} \ No newline at end of file diff --git a/OpenSky.Agent.Simulator/Models/SecondaryTracking.cs b/OpenSky.Agent.Simulator/Models/SecondaryTracking.cs new file mode 100644 index 0000000..3e8b25f --- /dev/null +++ b/OpenSky.Agent.Simulator/Models/SecondaryTracking.cs @@ -0,0 +1,247 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// OpenSky project 2021-2022 +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace OpenSky.Agent.Simulator.Models +{ + using System; + + using OpenSky.Agent.Simulator.Enums; + using OpenSky.FlightLogXML; + + /// ------------------------------------------------------------------------------------------------- + /// + /// Secondary flight tracking model (checked less often). + /// + /// + /// sushi.at, 31/01/2022. + /// + /// ------------------------------------------------------------------------------------------------- + public class SecondaryTracking + { + /// ------------------------------------------------------------------------------------------------- + /// + /// Is the APU running? + /// + /// ------------------------------------------------------------------------------------------------- + public bool ApuGenerator { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Is the auto pilot engaged? + /// + /// ------------------------------------------------------------------------------------------------- + public bool AutoPilot { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Is crash detection turned on? + /// + /// ------------------------------------------------------------------------------------------------- + public bool CrashDetection { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Is the electrical master battery turned on? + /// + /// ------------------------------------------------------------------------------------------------- + public bool ElectricalMasterBattery { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The engine1 combustion flag. + /// + /// ------------------------------------------------------------------------------------------------- + public bool EngineCombustion1 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The engine1 combustion flag. + /// + /// ------------------------------------------------------------------------------------------------- + public bool EngineCombustion2 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The engine1 combustion flag. + /// + /// ------------------------------------------------------------------------------------------------- + public bool EngineCombustion3 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The engine1 combustion flag. + /// + /// ------------------------------------------------------------------------------------------------- + public bool EngineCombustion4 { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Is there a running engine? + /// + /// ------------------------------------------------------------------------------------------------- + public bool EngineRunning => this.EngineCombustion1 || this.EngineCombustion2 || this.EngineCombustion3 || this.EngineCombustion4; + + /// ------------------------------------------------------------------------------------------------- + /// + /// Flaps handle percentage. + /// + /// ------------------------------------------------------------------------------------------------- + public double FlapsHandle { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Flaps (trailing) percentage. + /// + /// ------------------------------------------------------------------------------------------------- + public double FlapsPercentage { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gear handle in down position? + /// + /// ------------------------------------------------------------------------------------------------- + public bool GearHandle { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gear extended percentage. + /// + /// ------------------------------------------------------------------------------------------------- + public double GearPercentage { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Are the beacon lights on? + /// + /// ------------------------------------------------------------------------------------------------- + public bool LightBeacon { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Are the landing lights on? + /// + /// ------------------------------------------------------------------------------------------------- + public bool LightLanding { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Are the nav lights on? + /// + /// ------------------------------------------------------------------------------------------------- + public bool LightNav { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Are the strobe lights on? + /// + /// ------------------------------------------------------------------------------------------------- + public bool LightStrobe { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Are the taxi lights on? + /// + /// ------------------------------------------------------------------------------------------------- + public bool LightTaxi { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// No smoking sign on? + /// + /// ------------------------------------------------------------------------------------------------- + public bool NoSmokingSign { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Is the parking brake set? + /// + /// ------------------------------------------------------------------------------------------------- + public bool ParkingBrake { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Pushback status. + /// + /// ------------------------------------------------------------------------------------------------- + public Pushback Pushback { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Seat belt sign on? + /// + /// ------------------------------------------------------------------------------------------------- + public bool SeatBeltSign { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Are the spoilers armed? + /// + /// ------------------------------------------------------------------------------------------------- + public bool SpoilersArmed { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The time of day. + /// + /// ------------------------------------------------------------------------------------------------- + public TimeOfDay TimeOfDay { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Is unlimited fuel turned on? + /// + /// ------------------------------------------------------------------------------------------------- + public bool UnlimitedFuel { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The UTC date/time. + /// + /// ------------------------------------------------------------------------------------------------- + public DateTime UtcDateTime + { + get + { + try + { + return new DateTime(this.UtcYear, this.UtcMonth, this.UtcDay).AddSeconds(this.UtcTime); + } + catch + { + return DateTime.MinValue; + } + } + } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The UTC day of the month. + /// + /// ------------------------------------------------------------------------------------------------- + public int UtcDay { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The UTC month of the year. + /// + /// ------------------------------------------------------------------------------------------------- + public int UtcMonth { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The UTC time in seconds since midnight. + /// + /// ------------------------------------------------------------------------------------------------- + public double UtcTime { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// The UTC year. + /// + /// ------------------------------------------------------------------------------------------------- + public int UtcYear { get; set; } + } +} \ No newline at end of file diff --git a/OpenSky.AgentMSFS/Models/TrackingConditions.cs b/OpenSky.Agent.Simulator/Models/TrackingConditions.cs similarity index 97% rename from OpenSky.AgentMSFS/Models/TrackingConditions.cs rename to OpenSky.Agent.Simulator/Models/TrackingConditions.cs index 1219d55..c66b6fb 100644 --- a/OpenSky.AgentMSFS/Models/TrackingConditions.cs +++ b/OpenSky.Agent.Simulator/Models/TrackingConditions.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- diff --git a/OpenSky.AgentMSFS/Models/TrackingStatus.cs b/OpenSky.Agent.Simulator/Models/TrackingStatus.cs similarity index 98% rename from OpenSky.AgentMSFS/Models/TrackingStatus.cs rename to OpenSky.Agent.Simulator/Models/TrackingStatus.cs index 426bd2e..30255cf 100644 --- a/OpenSky.AgentMSFS/Models/TrackingStatus.cs +++ b/OpenSky.Agent.Simulator/Models/TrackingStatus.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- diff --git a/OpenSky.AgentMSFS/Models/VerticalProfile.cs b/OpenSky.Agent.Simulator/Models/VerticalProfile.cs similarity index 97% rename from OpenSky.AgentMSFS/Models/VerticalProfile.cs rename to OpenSky.Agent.Simulator/Models/VerticalProfile.cs index e094ee3..558ccc2 100644 --- a/OpenSky.AgentMSFS/Models/VerticalProfile.cs +++ b/OpenSky.Agent.Simulator/Models/VerticalProfile.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- diff --git a/OpenSky.AgentMSFS/SimConnect/Structs/WeightAndBalance.cs b/OpenSky.Agent.Simulator/Models/WeightAndBalance.cs similarity index 73% rename from OpenSky.AgentMSFS/SimConnect/Structs/WeightAndBalance.cs rename to OpenSky.Agent.Simulator/Models/WeightAndBalance.cs index f879b51..38492c3 100644 --- a/OpenSky.AgentMSFS/SimConnect/Structs/WeightAndBalance.cs +++ b/OpenSky.Agent.Simulator/Models/WeightAndBalance.cs @@ -1,135 +1,125 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- -namespace OpenSky.AgentMSFS.SimConnect.Structs +namespace OpenSky.Agent.Simulator.Models { - using System.Collections.Generic; - - using CTrue.FsConnect; - - using Microsoft.FlightSimulator.SimConnect; - /// ------------------------------------------------------------------------------------------------- /// - /// The weight and balance struct. + /// Weight and balance model. /// /// - /// sushi.at, 20/03/2021. + /// sushi.at, 31/01/2022. /// /// ------------------------------------------------------------------------------------------------- - public struct WeightAndBalance + public class WeightAndBalance { /// ------------------------------------------------------------------------------------------------- /// - /// Empty weight in pounds. + /// The center of gravity aft limit. /// /// ------------------------------------------------------------------------------------------------- - public double EmptyWeight { get; set; } + public double CgAftLimit { get; set; } /// ------------------------------------------------------------------------------------------------- /// - /// Total weight in pounds. + /// The center of gravity forward limit. /// /// ------------------------------------------------------------------------------------------------- - public double TotalWeight { get; set; } + public double CgFwdLimit { get; set; } /// ------------------------------------------------------------------------------------------------- /// - /// Max gross weight in pounds. + /// The center of gravity (longitudinal) /// /// ------------------------------------------------------------------------------------------------- - public double MaxGrossWeight { get; set; } + public double CgPercent { get; set; } /// ------------------------------------------------------------------------------------------------- /// - /// Fuel total capacity in gallons. + /// The center of gravity (lateral) /// /// ------------------------------------------------------------------------------------------------- - public double FuelTotalCapacity { get; set; } + public double CgPercentLateral { get; set; } /// ------------------------------------------------------------------------------------------------- /// - /// Fuel total quantity on board in gallons. + /// Empty weight in pounds. /// /// ------------------------------------------------------------------------------------------------- - public double FuelTotalQuantity { get; set; } + public double EmptyWeight { get; set; } /// ------------------------------------------------------------------------------------------------- /// - /// Fuel weight (pounds/gallon). + /// Fuel total capacity in gallons. /// /// ------------------------------------------------------------------------------------------------- - public double FuelWeightPerGallon { get; set; } + public double FuelTotalCapacity { get; set; } /// ------------------------------------------------------------------------------------------------- /// - /// The center of gravity aft limit. + /// Fuel total quantity on board in gallons. /// /// ------------------------------------------------------------------------------------------------- - public double CgAftLimit { get; set; } + public double FuelTotalQuantity { get; set; } /// ------------------------------------------------------------------------------------------------- /// - /// The center of gravity forward limit. + /// The fuel weight in pounds. /// /// ------------------------------------------------------------------------------------------------- - public double CgFwdLimit { get; set; } + public double FuelWeight => this.FuelTotalQuantity * this.FuelWeightPerGallon; /// ------------------------------------------------------------------------------------------------- /// - /// The center of gravity (longitudinal) + /// Fuel weight (pounds/gallon). /// /// ------------------------------------------------------------------------------------------------- - public double CgPercent { get; set; } + public double FuelWeightPerGallon { get; set; } /// ------------------------------------------------------------------------------------------------- /// - /// The center of gravity (lateral) + /// The maximum fuel weight in pounds. /// /// ------------------------------------------------------------------------------------------------- - public double CgPercentLateral { get; set; } - - // ================================================================================================== - // END OF STRUCT PROPERTIES - BELOW ARE GET-ONLY COMPUTED PROPERTIES FOR OPENSKY - // ================================================================================================== + public double MaxFuelWeight => this.FuelTotalCapacity * this.FuelWeightPerGallon; /// ------------------------------------------------------------------------------------------------- /// - /// The fuel weight in pounds. + /// Max gross weight in pounds. /// /// ------------------------------------------------------------------------------------------------- - public double FuelWeight => this.FuelTotalQuantity * this.FuelWeightPerGallon; + public double MaxGrossWeight { get; set; } /// ------------------------------------------------------------------------------------------------- /// - /// The maximum fuel weight in pounds. + /// The maximum payload weight in pounds. /// /// ------------------------------------------------------------------------------------------------- - public double MaxFuelWeight => this.FuelTotalCapacity * this.FuelWeightPerGallon; + public double MaxPayloadWeight => this.MaxGrossWeight - this.EmptyWeight - this.FuelWeight; /// ------------------------------------------------------------------------------------------------- /// - /// The payload weight in pounds. + /// Gets the payload percentage out of maximum allowed. /// /// ------------------------------------------------------------------------------------------------- - public double PayloadWeight => this.TotalWeight - this.EmptyWeight - this.FuelWeight; + public double PayloadPercentOfMax => this.MaxPayloadWeight != 0 ? this.PayloadWeight / this.MaxPayloadWeight : 0; /// ------------------------------------------------------------------------------------------------- /// - /// The maximum payload weight in pounds. + /// The payload weight in pounds. /// /// ------------------------------------------------------------------------------------------------- - public double MaxPayloadWeight => this.MaxGrossWeight - this.EmptyWeight - this.FuelWeight; + public double PayloadWeight => this.TotalWeight - this.EmptyWeight - this.FuelWeight; /// ------------------------------------------------------------------------------------------------- /// - /// Gets the payload percentage out of maximum allowed. + /// Total weight in pounds. /// /// ------------------------------------------------------------------------------------------------- - public double PayloadPercentOfMax => this.MaxPayloadWeight != 0 ? this.PayloadWeight / this.MaxPayloadWeight : 0; + public double TotalWeight { get; set; } /// ------------------------------------------------------------------------------------------------- /// @@ -138,35 +128,4 @@ public struct WeightAndBalance /// ------------------------------------------------------------------------------------------------- public double TotalWeightPercentOfMax => this.MaxGrossWeight != 0 ? this.TotalWeight / this.MaxGrossWeight : 0; } - - /// ------------------------------------------------------------------------------------------------- - /// - /// The weight and balance struct SimConnect properties definition. - /// - /// - /// sushi.at, 20/03/2021. - /// - /// ------------------------------------------------------------------------------------------------- - public static class WeightAndBalanceDefinition - { - /// ------------------------------------------------------------------------------------------------- - /// - /// Gets the definition list of sim properties. - /// - /// ------------------------------------------------------------------------------------------------- - public static List Definition => - new() - { - new SimVar("EMPTY WEIGHT", "Pounds", SIMCONNECT_DATATYPE.FLOAT64), - new SimVar("TOTAL WEIGHT", "Pounds", SIMCONNECT_DATATYPE.FLOAT64), - new SimVar("MAX GROSS WEIGHT", "Pounds", SIMCONNECT_DATATYPE.FLOAT64), - new SimVar("FUEL TOTAL CAPACITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), - new SimVar("FUEL TOTAL QUANTITY", "Gallons", SIMCONNECT_DATATYPE.FLOAT64), - new SimVar("FUEL WEIGHT PER GALLON", "Pounds", SIMCONNECT_DATATYPE.FLOAT64), - new SimVar("CG AFT LIMIT", "Percent over 100", SIMCONNECT_DATATYPE.FLOAT64), - new SimVar("CG FWD LIMIT", "Percent over 100", SIMCONNECT_DATATYPE.FLOAT64), - new SimVar("CG PERCENT", "Percent over 100", SIMCONNECT_DATATYPE.FLOAT64), - new SimVar("CG PERCENT LATERAL", "Percent over 100", SIMCONNECT_DATATYPE.FLOAT64), - }; - } } \ No newline at end of file diff --git a/OpenSky.AgentMSFS/OpenAPIs/ModelExtensions/AircraftType.cs b/OpenSky.Agent.Simulator/OpenAPIs/ModelExtensions/AircraftType.cs similarity index 85% rename from OpenSky.AgentMSFS/OpenAPIs/ModelExtensions/AircraftType.cs rename to OpenSky.Agent.Simulator/OpenAPIs/ModelExtensions/AircraftType.cs index 72eb7f0..32c0d2a 100644 --- a/OpenSky.AgentMSFS/OpenAPIs/ModelExtensions/AircraftType.cs +++ b/OpenSky.Agent.Simulator/OpenAPIs/ModelExtensions/AircraftType.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- @@ -10,8 +10,6 @@ namespace OpenSkyApi { using System; - using OpenSky.AgentMSFS.SimConnect; - /// ------------------------------------------------------------------------------------------------- /// /// Aircraft type model - local extensions. @@ -152,34 +150,34 @@ public override int GetHashCode() /// ------------------------------------------------------------------------------------------------- public bool MatchesAircraftInSimulator() { - if (SimConnect.Instance.Connected) + if (OpenSky.Agent.Simulator.Simulator.Instance.Connected) { - if (!string.Equals(!string.IsNullOrEmpty(SimConnect.Instance.PlaneIdentity.AtcTypeProperty) ? SimConnect.Instance.PlaneIdentity.AtcTypeProperty : "MISSING", this.AtcType, StringComparison.InvariantCultureIgnoreCase)) + if (!string.Equals(!string.IsNullOrEmpty(OpenSky.Agent.Simulator.Simulator.Instance.AircraftIdentity.AtcType) ? OpenSky.Agent.Simulator.Simulator.Instance.AircraftIdentity.AtcType : "MISSING", this.AtcType, StringComparison.InvariantCultureIgnoreCase)) { return false; } - if (!string.Equals(!string.IsNullOrEmpty(SimConnect.Instance.PlaneIdentity.AtcModelProperty) ? SimConnect.Instance.PlaneIdentity.AtcModelProperty : "MISSING", this.AtcModel, StringComparison.InvariantCultureIgnoreCase)) + if (!string.Equals(!string.IsNullOrEmpty(OpenSky.Agent.Simulator.Simulator.Instance.AircraftIdentity.AtcModel) ? OpenSky.Agent.Simulator.Simulator.Instance.AircraftIdentity.AtcModel : "MISSING", this.AtcModel, StringComparison.InvariantCultureIgnoreCase)) { return false; } - if (SimConnect.Instance.PlaneIdentity.EngineType != this.EngineType) + if (OpenSky.Agent.Simulator.Simulator.Instance.AircraftIdentity.EngineType != this.EngineType) { return false; } - if (SimConnect.Instance.PlaneIdentity.EngineCount != this.EngineCount) + if (OpenSky.Agent.Simulator.Simulator.Instance.AircraftIdentity.EngineCount != this.EngineCount) { return false; } - if (SimConnect.Instance.PlaneIdentity.FlapsAvailable != this.FlapsAvailable) + if (OpenSky.Agent.Simulator.Simulator.Instance.AircraftIdentity.FlapsAvailable != this.FlapsAvailable) { return false; } - if (SimConnect.Instance.PlaneIdentity.GearRetractable != this.IsGearRetractable) + if (OpenSky.Agent.Simulator.Simulator.Instance.AircraftIdentity.GearRetractable != this.IsGearRetractable) { return false; } @@ -187,17 +185,17 @@ public bool MatchesAircraftInSimulator() // Skip these checks if detailed checks are TEMPORARILY disabled if (!this.DetailedChecksDisabled) { - if (Math.Abs(SimConnect.Instance.WeightAndBalance.EmptyWeight - this.EmptyWeight) > 0.5) + if (Math.Abs(OpenSky.Agent.Simulator.Simulator.Instance.WeightAndBalance.EmptyWeight - this.EmptyWeight) > 0.5) { return false; } - if (Math.Abs(SimConnect.Instance.WeightAndBalance.FuelTotalCapacity - this.FuelTotalCapacity) > 0.5) + if (Math.Abs(OpenSky.Agent.Simulator.Simulator.Instance.WeightAndBalance.FuelTotalCapacity - this.FuelTotalCapacity) > 0.5) { return false; } - if (Math.Abs(SimConnect.Instance.WeightAndBalance.MaxGrossWeight - this.MaxGrossWeight) > 0.5) + if (Math.Abs(OpenSky.Agent.Simulator.Simulator.Instance.WeightAndBalance.MaxGrossWeight - this.MaxGrossWeight) > 0.5) { return false; } diff --git a/OpenSky.AgentMSFS/OpenAPIs/ModelExtensions/Airport.cs b/OpenSky.Agent.Simulator/OpenAPIs/ModelExtensions/Airport.cs similarity index 99% rename from OpenSky.AgentMSFS/OpenAPIs/ModelExtensions/Airport.cs rename to OpenSky.Agent.Simulator/OpenAPIs/ModelExtensions/Airport.cs index 60ee8a7..b74959c 100644 --- a/OpenSky.AgentMSFS/OpenAPIs/ModelExtensions/Airport.cs +++ b/OpenSky.Agent.Simulator/OpenAPIs/ModelExtensions/Airport.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- diff --git a/OpenSky.AgentMSFS/OpenAPIs/ModelExtensions/Flight.cs b/OpenSky.Agent.Simulator/OpenAPIs/ModelExtensions/Flight.cs similarity index 99% rename from OpenSky.AgentMSFS/OpenAPIs/ModelExtensions/Flight.cs rename to OpenSky.Agent.Simulator/OpenAPIs/ModelExtensions/Flight.cs index b1324e7..bebb8a1 100644 --- a/OpenSky.AgentMSFS/OpenAPIs/ModelExtensions/Flight.cs +++ b/OpenSky.Agent.Simulator/OpenAPIs/ModelExtensions/Flight.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- diff --git a/OpenSky.AgentMSFS/OpenAPIs/OpenSkyService.cs b/OpenSky.Agent.Simulator/OpenAPIs/OpenSkyService.cs similarity index 57% rename from OpenSky.AgentMSFS/OpenAPIs/OpenSkyService.cs rename to OpenSky.Agent.Simulator/OpenAPIs/OpenSkyService.cs index f3d4477..bf4c3df 100644 --- a/OpenSky.AgentMSFS/OpenAPIs/OpenSkyService.cs +++ b/OpenSky.Agent.Simulator/OpenAPIs/OpenSkyService.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- @@ -10,8 +10,6 @@ namespace OpenSkyApi { using System.Net.Http; - using OpenSky.AgentMSFS.Properties; - /// ------------------------------------------------------------------------------------------------- /// /// OpenSky API service client. @@ -21,21 +19,8 @@ namespace OpenSkyApi /// /// /// ------------------------------------------------------------------------------------------------- - public partial class OpenSkyService + public abstract partial class OpenSkyService { - /// ------------------------------------------------------------------------------------------------- - /// - /// Initializes static members of the class. - /// - /// - /// sushi.at, 01/06/2021. - /// - /// ------------------------------------------------------------------------------------------------- - static OpenSkyService() - { - Instance = new OpenSkyService(new HttpClient()); - } - /// ------------------------------------------------------------------------------------------------- /// /// Initializes a new instance of the class. @@ -46,19 +31,15 @@ static OpenSkyService() /// /// The HTTP client. /// + /// + /// The base URL of the service. + /// /// ------------------------------------------------------------------------------------------------- - private OpenSkyService(HttpClient httpClient) : base(httpClient) + protected OpenSkyService(HttpClient httpClient, string baseUrl) : base(httpClient) { - this.BaseUrl = Settings.Default.OpenSkyAPIUrl; + this.BaseUrl = baseUrl; this._httpClient = httpClient; this._settings = new System.Lazy(this.CreateSerializerSettings); } - - /// ------------------------------------------------------------------------------------------------- - /// - /// Gets the single static instance. - /// - /// ------------------------------------------------------------------------------------------------- - public static OpenSkyService Instance { get; } } } \ No newline at end of file diff --git a/OpenSky.AgentMSFS/OpenAPIs/OpenSkyServiceBase.cs b/OpenSky.Agent.Simulator/OpenAPIs/OpenSkyServiceBase.cs similarity index 60% rename from OpenSky.AgentMSFS/OpenAPIs/OpenSkyServiceBase.cs rename to OpenSky.Agent.Simulator/OpenAPIs/OpenSkyServiceBase.cs index 96d3544..2ff3bdd 100644 --- a/OpenSky.AgentMSFS/OpenAPIs/OpenSkyServiceBase.cs +++ b/OpenSky.Agent.Simulator/OpenAPIs/OpenSkyServiceBase.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- @@ -10,17 +10,10 @@ namespace OpenSkyApi { using System; using System.Collections.Generic; - using System.Diagnostics; - using System.Linq; - using System.Net; using System.Net.Http; - using System.Text; using System.Threading; using System.Threading.Tasks; - using OpenSky.AgentMSFS; - using OpenSky.AgentMSFS.Properties; - /// ------------------------------------------------------------------------------------------------- /// /// OpenSky service client base class (implements auto-token refresh and JWT bearer. @@ -29,7 +22,7 @@ namespace OpenSkyApi /// sushi.at, 01/06/2021. /// /// ------------------------------------------------------------------------------------------------- - public class OpenSkyServiceBase + public abstract class OpenSkyServiceBase { /// ------------------------------------------------------------------------------------------------- /// @@ -60,7 +53,7 @@ public class OpenSkyServiceBase /// sushi.at, 01/06/2021. /// /// ------------------------------------------------------------------------------------------------- - public OpenSkyServiceBase() + protected OpenSkyServiceBase() { } @@ -75,7 +68,7 @@ public OpenSkyServiceBase() /// The HTTP client. /// /// ------------------------------------------------------------------------------------------------- - public OpenSkyServiceBase(HttpClient httpClient) + protected OpenSkyServiceBase(HttpClient httpClient) { this.httpClient = httpClient; @@ -110,53 +103,54 @@ public OpenSkyServiceBase(HttpClient httpClient) /// An asynchronous result that yields the create HTTP request message. /// /// ------------------------------------------------------------------------------------------------- - protected async Task CreateHttpRequestMessageAsync(CancellationToken cancellationToken) - { - var msg = new HttpRequestMessage(); - - // Check if the token needs to be refreshed - if (UserSessionService.Instance.CheckTokenNeedsRefresh()) - { - try - { - await this.RefreshToken(cancellationToken); - } - catch (HttpRequestException ex) - { - if (ex.InnerException is WebException webEx) - { - if (webEx.Status is WebExceptionStatus.ConnectFailure or WebExceptionStatus.NameResolutionFailure or WebExceptionStatus.SendFailure or WebExceptionStatus.ReceiveFailure) - { - // Server not available? Try again later - Debug.WriteLine($"Error refreshing tokens: {ex}"); - throw; - } - - Debug.WriteLine($"Error refreshing tokens: {ex}"); - UserSessionService.Instance.Logout(); - throw; - } - - Debug.WriteLine($"Error refreshing tokens: {ex}"); - UserSessionService.Instance.Logout(); - throw; - } - catch (Exception ex) - { - Debug.WriteLine($"Error refreshing tokens: {ex}"); - UserSessionService.Instance.Logout(); - throw; - } - } - - // Add the JWT token to the authorization header - if (UserSessionService.Instance.IsUserLoggedIn) - { - msg.Headers.Add("Authorization", $"Bearer {UserSessionService.Instance.OpenSkyApiToken}"); - } - - return msg; - } + protected abstract Task CreateHttpRequestMessageAsync(CancellationToken cancellationToken); + //protected async Task CreateHttpRequestMessageAsync(CancellationToken cancellationToken) + //{ + // var msg = new HttpRequestMessage(); + + // // Check if the token needs to be refreshed + // if (UserSessionService.Instance.CheckTokenNeedsRefresh()) + // { + // try + // { + // await this.RefreshToken(cancellationToken); + // } + // catch (HttpRequestException ex) + // { + // if (ex.InnerException is WebException webEx) + // { + // if (webEx.Status is WebExceptionStatus.ConnectFailure or WebExceptionStatus.NameResolutionFailure or WebExceptionStatus.SendFailure or WebExceptionStatus.ReceiveFailure) + // { + // // Server not available? Try again later + // Debug.WriteLine($"Error refreshing tokens: {ex}"); + // throw; + // } + + // Debug.WriteLine($"Error refreshing tokens: {ex}"); + // UserSessionService.Instance.Logout(); + // throw; + // } + + // Debug.WriteLine($"Error refreshing tokens: {ex}"); + // UserSessionService.Instance.Logout(); + // throw; + // } + // catch (Exception ex) + // { + // Debug.WriteLine($"Error refreshing tokens: {ex}"); + // UserSessionService.Instance.Logout(); + // throw; + // } + // } + + // // Add the JWT token to the authorization header + // if (UserSessionService.Instance.IsUserLoggedIn) + // { + // msg.Headers.Add("Authorization", $"Bearer {UserSessionService.Instance.OpenSkyApiToken}"); + // } + + // return msg; + //} /// ------------------------------------------------------------------------------------------------- /// @@ -254,108 +248,109 @@ private static Newtonsoft.Json.JsonSerializerSettings CreateSerializerSettings() /// An asynchronous result. /// /// ------------------------------------------------------------------------------------------------- - private async Task RefreshToken(CancellationToken cancellationToken) - { - try - { - if (!this.refreshTokenMutex.WaitOne(30 * 1000)) - { - // Timeout refreshing token - Debug.WriteLine("Timeout waiting for refresh token mutex."); - return; - } - - // Now that we have the mutex, check if another refresh was successful in the meantime - if (!UserSessionService.Instance.CheckTokenNeedsRefresh()) - { - return; - } - - var requestBody = new RefreshToken - { - Token = UserSessionService.Instance.OpenSkyApiToken, - Refresh = UserSessionService.Instance.RefreshToken - }; - - var urlBuilder = new StringBuilder(); - var baseUrl = Settings.Default.OpenSkyAPIUrl; - urlBuilder.Append(baseUrl != null ? baseUrl.TrimEnd('/') : "").Append("/Authentication/refreshToken"); - - using var request = new HttpRequestMessage(); - var content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(requestBody, this.settings.Value)); - content.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); - request.Content = content; - request.Method = new HttpMethod("POST"); - request.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("text/plain")); - - var url = urlBuilder.ToString(); - request.RequestUri = new Uri(url, UriKind.RelativeOrAbsolute); - - var response = await this.httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); - try - { - var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value); - if (response.Content is { Headers: { } }) - { - foreach (var header in response.Content.Headers) - { - headers[header.Key] = header.Value; - } - } - - var status = (int)response.StatusCode; - if (status == 200) - { - var objectResponse = await this.ReadObjectResponseAsync(response, headers, cancellationToken).ConfigureAwait(false); - if (objectResponse.Object == null) - { - throw new ApiException("Response was null which was not expected.", status, objectResponse.Text, headers, null); - } - - if (!objectResponse.Object.IsError) - { - UserSessionService.Instance.TokensWereRefreshed(objectResponse.Object.Data); - } - else - { - // Check if another refresh caused a server side concurrency issue but the other request completed the refresh successfully - if (!UserSessionService.Instance.CheckTokenNeedsRefresh()) - { - return; - } - - throw new ApiException($"Unable to refresh OpenSky token: {objectResponse.Object.Message}", 401, objectResponse.Text, headers, null); - } - } - else - { - // ReSharper disable once ConditionIsAlwaysTrueOrFalse - var responseData = response.Content == null ? null : await response.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new ApiException("The HTTP status code of the response was not expected (" + status + ").", status, responseData, headers, null); - } - } - finally - { - response.Dispose(); - } - } - catch (AbandonedMutexException) - { - //Ignore and retry - await this.RefreshToken(cancellationToken); - } - finally - { - try - { - this.refreshTokenMutex.ReleaseMutex(); - } - catch - { - // Ignore - } - } - } + protected abstract Task RefreshToken(CancellationToken cancellationToken); + //private async Task RefreshToken(CancellationToken cancellationToken) + //{ + // try + // { + // if (!this.refreshTokenMutex.WaitOne(30 * 1000)) + // { + // // Timeout refreshing token + // Debug.WriteLine("Timeout waiting for refresh token mutex."); + // return; + // } + + // // Now that we have the mutex, check if another refresh was successful in the meantime + // if (!UserSessionService.Instance.CheckTokenNeedsRefresh()) + // { + // return; + // } + + // var requestBody = new RefreshToken + // { + // Token = UserSessionService.Instance.OpenSkyApiToken, + // Refresh = UserSessionService.Instance.RefreshToken + // }; + + // var urlBuilder = new StringBuilder(); + // var baseUrl = Settings.Default.OpenSkyAPIUrl; + // urlBuilder.Append(baseUrl != null ? baseUrl.TrimEnd('/') : "").Append("/Authentication/refreshToken"); + + // using var request = new HttpRequestMessage(); + // var content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(requestBody, this.settings.Value)); + // content.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); + // request.Content = content; + // request.Method = new HttpMethod("POST"); + // request.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("text/plain")); + + // var url = urlBuilder.ToString(); + // request.RequestUri = new Uri(url, UriKind.RelativeOrAbsolute); + + // var response = await this.httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + // try + // { + // var headers = response.Headers.ToDictionary(h => h.Key, h => h.Value); + // if (response.Content is { Headers: { } }) + // { + // foreach (var header in response.Content.Headers) + // { + // headers[header.Key] = header.Value; + // } + // } + + // var status = (int)response.StatusCode; + // if (status == 200) + // { + // var objectResponse = await this.ReadObjectResponseAsync(response, headers, cancellationToken).ConfigureAwait(false); + // if (objectResponse.Object == null) + // { + // throw new ApiException("Response was null which was not expected.", status, objectResponse.Text, headers, null); + // } + + // if (!objectResponse.Object.IsError) + // { + // UserSessionService.Instance.TokensWereRefreshed(objectResponse.Object.Data); + // } + // else + // { + // // Check if another refresh caused a server side concurrency issue but the other request completed the refresh successfully + // if (!UserSessionService.Instance.CheckTokenNeedsRefresh()) + // { + // return; + // } + + // throw new ApiException($"Unable to refresh OpenSky token: {objectResponse.Object.Message}", 401, objectResponse.Text, headers, null); + // } + // } + // else + // { + // // ReSharper disable once ConditionIsAlwaysTrueOrFalse + // var responseData = response.Content == null ? null : await response.Content.ReadAsStringAsync().ConfigureAwait(false); + // throw new ApiException("The HTTP status code of the response was not expected (" + status + ").", status, responseData, headers, null); + // } + // } + // finally + // { + // response.Dispose(); + // } + // } + // catch (AbandonedMutexException) + // { + // //Ignore and retry + // await this.RefreshToken(cancellationToken); + // } + // finally + // { + // try + // { + // this.refreshTokenMutex.ReleaseMutex(); + // } + // catch + // { + // // Ignore + // } + // } + //} // ------------------------------------------------------------------------------------------------- /// diff --git a/OpenSky.AgentMSFS/OpenAPIs/ValidationProblemDetails.cs b/OpenSky.Agent.Simulator/OpenAPIs/ValidationProblemDetails.cs similarity index 99% rename from OpenSky.AgentMSFS/OpenAPIs/ValidationProblemDetails.cs rename to OpenSky.Agent.Simulator/OpenAPIs/ValidationProblemDetails.cs index ec31d4f..d69200e 100644 --- a/OpenSky.AgentMSFS/OpenAPIs/ValidationProblemDetails.cs +++ b/OpenSky.Agent.Simulator/OpenAPIs/ValidationProblemDetails.cs @@ -1,6 +1,6 @@ // -------------------------------------------------------------------------------------------------------------------- // -// OpenSky project 2021 +// OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- diff --git a/OpenSky.AgentMSFS/OpenAPIs/swagger.cs b/OpenSky.Agent.Simulator/OpenAPIs/swagger.cs similarity index 95% rename from OpenSky.AgentMSFS/OpenAPIs/swagger.cs rename to OpenSky.Agent.Simulator/OpenAPIs/swagger.cs index 502bc07..d8f2284 100644 --- a/OpenSky.AgentMSFS/OpenAPIs/swagger.cs +++ b/OpenSky.Agent.Simulator/OpenAPIs/swagger.cs @@ -4198,6 +4198,229 @@ public async System.Threading.Tasks.Task LittleNavmapMS } } + /// Free money :) + /// Success + /// A server side error occurred. + public System.Threading.Tasks.Task BobsYourUncleAsync() + { + return BobsYourUncleAsync(System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// Free money :) + /// Success + /// A server side error occurred. + public async System.Threading.Tasks.Task BobsYourUncleAsync(System.Threading.CancellationToken cancellationToken) + { + var urlBuilder_ = new System.Text.StringBuilder(); + urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/bobsYourUncle"); + + var client_ = _httpClient; + var disposeClient_ = false; + try + { + using (var request_ = await CreateHttpRequestMessageAsync(cancellationToken).ConfigureAwait(false)) + { + request_.Content = new System.Net.Http.StringContent(string.Empty, System.Text.Encoding.UTF8, "text/plain"); + request_.Method = new System.Net.Http.HttpMethod("POST"); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("text/plain")); + + PrepareRequest(client_, request_, urlBuilder_); + var url_ = urlBuilder_.ToString(); + request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); + PrepareRequest(client_, request_, url_); + + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + var disposeResponse_ = true; + try + { + var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value); + if (response_.Content != null && response_.Content.Headers != null) + { + foreach (var item_ in response_.Content.Headers) + headers_[item_.Key] = item_.Value; + } + + ProcessResponse(client_, response_); + + var status_ = (int)response_.StatusCode; + if (status_ == 200) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; + } + else + { + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); + } + } + finally + { + if (disposeResponse_) + response_.Dispose(); + } + } + } + finally + { + if (disposeClient_) + client_.Dispose(); + } + } + + /// Get the current account balances. + /// Success + /// A server side error occurred. + public System.Threading.Tasks.Task GetAccountBalancesAsync() + { + return GetAccountBalancesAsync(System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// Get the current account balances. + /// Success + /// A server side error occurred. + public async System.Threading.Tasks.Task GetAccountBalancesAsync(System.Threading.CancellationToken cancellationToken) + { + var urlBuilder_ = new System.Text.StringBuilder(); + urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/balances"); + + var client_ = _httpClient; + var disposeClient_ = false; + try + { + using (var request_ = await CreateHttpRequestMessageAsync(cancellationToken).ConfigureAwait(false)) + { + request_.Method = new System.Net.Http.HttpMethod("GET"); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("text/plain")); + + PrepareRequest(client_, request_, urlBuilder_); + var url_ = urlBuilder_.ToString(); + request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); + PrepareRequest(client_, request_, url_); + + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + var disposeResponse_ = true; + try + { + var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value); + if (response_.Content != null && response_.Content.Headers != null) + { + foreach (var item_ in response_.Content.Headers) + headers_[item_.Key] = item_.Value; + } + + ProcessResponse(client_, response_); + + var status_ = (int)response_.StatusCode; + if (status_ == 200) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; + } + else + { + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); + } + } + finally + { + if (disposeResponse_) + response_.Dispose(); + } + } + } + finally + { + if (disposeClient_) + client_.Dispose(); + } + } + + /// Get financial overview (with transactions of the last 30 days) + /// Success + /// A server side error occurred. + public System.Threading.Tasks.Task GetFinancialOverviewAsync() + { + return GetFinancialOverviewAsync(System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// Get financial overview (with transactions of the last 30 days) + /// Success + /// A server side error occurred. + public async System.Threading.Tasks.Task GetFinancialOverviewAsync(System.Threading.CancellationToken cancellationToken) + { + var urlBuilder_ = new System.Text.StringBuilder(); + urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/overview"); + + var client_ = _httpClient; + var disposeClient_ = false; + try + { + using (var request_ = await CreateHttpRequestMessageAsync(cancellationToken).ConfigureAwait(false)) + { + request_.Method = new System.Net.Http.HttpMethod("GET"); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("text/plain")); + + PrepareRequest(client_, request_, urlBuilder_); + var url_ = urlBuilder_.ToString(); + request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); + PrepareRequest(client_, request_, url_); + + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + var disposeResponse_ = true; + try + { + var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value); + if (response_.Content != null && response_.Content.Headers != null) + { + foreach (var item_ in response_.Content.Headers) + headers_[item_.Key] = item_.Value; + } + + ProcessResponse(client_, response_); + + var status_ = (int)response_.StatusCode; + if (status_ == 200) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; + } + else + { + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); + } + } + finally + { + if (disposeResponse_) + response_.Dispose(); + } + } + } + finally + { + if (disposeClient_) + client_.Dispose(); + } + } + /// Abort flight, return to planning stage (with potential penalties depending on flight phase /// and location) /// Identifier for the flight (plan). @@ -5951,22 +6174,22 @@ public async System.Threading.Tasks.Task } } - /// Get world population overview. + /// Get world statistics overview. /// Success /// A server side error occurred. - public System.Threading.Tasks.Task GetWorldPopulationOverviewAsync() + public System.Threading.Tasks.Task GetWorldStatisticsOverviewAsync() { - return GetWorldPopulationOverviewAsync(System.Threading.CancellationToken.None); + return GetWorldStatisticsOverviewAsync(System.Threading.CancellationToken.None); } /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// Get world population overview. + /// Get world statistics overview. /// Success /// A server side error occurred. - public async System.Threading.Tasks.Task GetWorldPopulationOverviewAsync(System.Threading.CancellationToken cancellationToken) + public async System.Threading.Tasks.Task GetWorldStatisticsOverviewAsync(System.Threading.CancellationToken cancellationToken) { var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/WorldPopulation"); + urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/WorldStatistics"); var client_ = _httpClient; var disposeClient_ = false; @@ -5998,7 +6221,7 @@ public async System.Threading.Tasks.Task Get var status_ = (int)response_.StatusCode; if (status_ == 200) { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_).ConfigureAwait(false); if (objectResponse_.Object == null) { throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); @@ -6045,7 +6268,7 @@ public async System.Threading.Tasks.Task PopulateAirportWithA throw new System.ArgumentNullException("icao"); var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/WorldPopulation/populateAircraft/{icao}"); + urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/WorldStatistics/populateAircraft/{icao}"); urlBuilder_.Replace("{icao}", System.Uri.EscapeDataString(ConvertToString(icao, System.Globalization.CultureInfo.InvariantCulture))); var client_ = _httpClient; @@ -6208,10 +6431,55 @@ private string ConvertToString(object value, System.Globalization.CultureInfo cu } } + /// Account balances model. + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.2.1.0 (Newtonsoft.Json v11.0.0.0)")] + public partial class AccountBalances + { + /// Gets or sets the account balance (of the user). + [Newtonsoft.Json.JsonProperty("accountBalance", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public long AccountBalance { get; set; } + + /// Gets or sets the airline account balance (if user has the permission). + [Newtonsoft.Json.JsonProperty("airlineAccountBalance", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public long? AirlineAccountBalance { get; set; } + + + } + + /// API standard response model. + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.2.1.0 (Newtonsoft.Json v11.0.0.0)")] + public partial class AccountBalancesApiResponse + { + [Newtonsoft.Json.JsonProperty("data", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public AccountBalances Data { get; set; } + + /// Gets or sets the error details (NULL if no error). + [Newtonsoft.Json.JsonProperty("errorDetails", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string ErrorDetails { get; set; } + + /// Gets or sets a value indicating whether this response is reporting an error. + [Newtonsoft.Json.JsonProperty("isError", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public bool IsError { get; set; } + + /// Gets or sets the message. + [Newtonsoft.Json.JsonProperty("message", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Message { get; set; } + + /// Gets or sets the status. + [Newtonsoft.Json.JsonProperty("status", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Status { get; set; } + + + } + /// Account overview model. [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.2.1.0 (Newtonsoft.Json v11.0.0.0)")] public partial class AccountOverview { + /// Gets or sets the name of the airline (if the user is a member of one). + [Newtonsoft.Json.JsonProperty("airlineName", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string AirlineName { get; set; } + /// Gets or sets the Date/Time of when the user joined. [Newtonsoft.Json.JsonProperty("joined", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public System.DateTimeOffset Joined { get; set; } @@ -6293,6 +6561,14 @@ public partial class Aircraft [Newtonsoft.Json.JsonProperty("latitude", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public double Latitude { get; set; } + /// Gets or sets the life time expense (for the current owner only). + [Newtonsoft.Json.JsonProperty("lifeTimeExpense", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public long LifeTimeExpense { get; set; } + + /// Gets or sets the life time income (for the current owner only). + [Newtonsoft.Json.JsonProperty("lifeTimeIncome", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public long LifeTimeIncome { get; set; } + /// Gets or sets the Date/Time until the aircraft is loading payload (cargo or pax). [Newtonsoft.Json.JsonProperty("loadingUntil", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public System.DateTimeOffset? LoadingUntil { get; set; } @@ -6731,7 +7007,7 @@ public partial class AirlineMemberAirlinePermissionHashSetDictionaryApiResponse } - /// Airline roles. 10 = BuyAircraft, 11 = SellAircraft, 12 = RentAircraft, 13 = RentOutAircraft, 14 = AssignAircraft, 15 = RenameAircraft, 20 = BuyFBO, 21 = SellFBO, 22 = RentFBO, 23 = RentOutFBO, 24 = RenameFBO, 25 = OrderFuel, 30 = AcceptJobs, 31 = Dispatch, 32 = OutsourceJobs, 33 = AbortJobs, 40 = ModifyAircraft, 41 = MaintainAircraft, 42 = ReplaceAircraftParts, 43 = PerformGroundOperations, 90 = ChangePermissions, 91 = BoardMember, 92 = AllPermissions + /// Airline roles. 10 = BuyAircraft, 11 = SellAircraft, 12 = RentAircraft, 13 = RentOutAircraft, 14 = AssignAircraft, 15 = RenameAircraft, 20 = BuyFBO, 21 = SellFBO, 22 = RentFBO, 23 = RentOutFBO, 24 = RenameFBO, 25 = OrderFuel, 30 = AcceptJobs, 31 = Dispatch, 32 = OutsourceJobs, 33 = AbortJobs, 40 = ModifyAircraft, 41 = MaintainAircraft, 42 = ReplaceAircraftParts, 43 = PerformGroundOperations, 50 = FinancialRecords, 90 = ChangePermissions, 91 = BoardMember, 92 = AllPermissions [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.2.1.0 (Newtonsoft.Json v11.0.0.0)")] public enum AirlinePermission { @@ -6775,6 +7051,8 @@ public enum AirlinePermission PerformGroundOperations = 43, + FinancialRecords = 50, + ChangePermissions = 90, BoardMember = 91, @@ -6822,6 +7100,10 @@ public partial class Airport [Newtonsoft.Json.JsonProperty("atisFrequency", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public int? AtisFrequency { get; set; } + /// Gets or sets the AV gas price in SkyBucks/Gallon. + [Newtonsoft.Json.JsonProperty("avGasPrice", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public float AvGasPrice { get; set; } + /// Gets or sets the city. [Newtonsoft.Json.JsonProperty("city", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [System.ComponentModel.DataAnnotations.StringLength(50)] @@ -6860,6 +7142,10 @@ public partial class Airport [Newtonsoft.Json.JsonProperty("isMilitary", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public bool IsMilitary { get; set; } + /// Gets or sets the jet fuel price in SkyBucks/Gallon. + [Newtonsoft.Json.JsonProperty("jetFuelPrice", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public float JetFuelPrice { get; set; } + /// Gets or sets the latitude of the airport. [Newtonsoft.Json.JsonProperty("latitude", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public double Latitude { get; set; } @@ -7771,6 +8057,132 @@ public partial class FinalReport public string FlightLog { get; set; } + } + + /// Financial categories. 0 = None, 1 = Aircraft, 2 = Fuel, 3 = Maintenance, 4 = AirportFees, 5 = Salaries, 6 = Loan, 7 = Interest, 8 = Shares, 9 = Dividend, 10 = FBO, 11 = Cargo, 12 = Passengers, 13 = SpecialtyJobs, 14 = Fines + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.2.1.0 (Newtonsoft.Json v11.0.0.0)")] + public enum FinancialCategory + { + None = 0, + + Aircraft = 1, + + Fuel = 2, + + Maintenance = 3, + + AirportFees = 4, + + Salaries = 5, + + Loan = 6, + + Interest = 7, + + Shares = 8, + + Dividend = 9, + + FBO = 10, + + Cargo = 11, + + Passengers = 12, + + SpecialtyJobs = 13, + + Fines = 14, + + } + + /// Financial overview model. + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.2.1.0 (Newtonsoft.Json v11.0.0.0)")] + public partial class FinancialOverview + { + /// Gets or sets the account balance (of the user). + [Newtonsoft.Json.JsonProperty("accountBalance", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public long AccountBalance { get; set; } + + /// Gets or sets the airline account balance (if user has the permission). + [Newtonsoft.Json.JsonProperty("airlineAccountBalance", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public long? AirlineAccountBalance { get; set; } + + /// Gets or sets the recent airline financial records (if user has the permission). + [Newtonsoft.Json.JsonProperty("recentAirlineFinancialRecords", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.Collections.Generic.ICollection RecentAirlineFinancialRecords { get; set; } + + /// Gets or sets the recent financial records (of the user). + [Newtonsoft.Json.JsonProperty("recentFinancialRecords", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.Collections.Generic.ICollection RecentFinancialRecords { get; set; } + + + } + + /// API standard response model. + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.2.1.0 (Newtonsoft.Json v11.0.0.0)")] + public partial class FinancialOverviewApiResponse + { + [Newtonsoft.Json.JsonProperty("data", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public FinancialOverview Data { get; set; } + + /// Gets or sets the error details (NULL if no error). + [Newtonsoft.Json.JsonProperty("errorDetails", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string ErrorDetails { get; set; } + + /// Gets or sets a value indicating whether this response is reporting an error. + [Newtonsoft.Json.JsonProperty("isError", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public bool IsError { get; set; } + + /// Gets or sets the message. + [Newtonsoft.Json.JsonProperty("message", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Message { get; set; } + + /// Gets or sets the status. + [Newtonsoft.Json.JsonProperty("status", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Status { get; set; } + + + } + + /// Financial record model. + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.2.1.0 (Newtonsoft.Json v11.0.0.0)")] + public partial class FinancialRecord + { + /// Gets or sets the aircraft registry (optional, if record relates to an aircraft). + [Newtonsoft.Json.JsonProperty("aircraftRegistry", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [System.ComponentModel.DataAnnotations.StringLength(10, MinimumLength = 5)] + public string AircraftRegistry { get; set; } + + [Newtonsoft.Json.JsonProperty("category", Required = Newtonsoft.Json.Required.Always)] + public FinancialCategory Category { get; set; } + + /// Gets or sets the child records. + [Newtonsoft.Json.JsonProperty("childRecords", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.Collections.Generic.ICollection ChildRecords { get; set; } + + /// Gets or sets the description of the record. + [Newtonsoft.Json.JsonProperty("description", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public string Description { get; set; } + + /// Gets or sets the expense amount in SkyBucks. + [Newtonsoft.Json.JsonProperty("expense", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public long Expense { get; set; } + + /// Gets or sets the identifier for the financial record. + [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Always)] + [System.ComponentModel.DataAnnotations.Required(AllowEmptyStrings = true)] + public System.Guid Id { get; set; } + + /// Gets or sets the income amount in SkyBucks. + [Newtonsoft.Json.JsonProperty("income", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public long Income { get; set; } + + /// Gets or sets the timestamp of the record. + [Newtonsoft.Json.JsonProperty("timestamp", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.DateTimeOffset Timestamp { get; set; } + + } /// Flight model. @@ -8774,7 +9186,7 @@ public partial class PieChartValue /// Gets or sets the value. [Newtonsoft.Json.JsonProperty("value", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public int Value { get; set; } + public long Value { get; set; } } @@ -9563,9 +9975,9 @@ public partial class WorldMapFlightIEnumerableApiResponse } - /// World population overview model. + /// World statistics overview model. [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.2.1.0 (Newtonsoft.Json v11.0.0.0)")] - public partial class WorldPopulationOverview + public partial class WorldStatisticsOverview { /// Gets or sets a pie chart series for aircraft categories. [Newtonsoft.Json.JsonProperty("aircraftCategories", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] @@ -9583,10 +9995,38 @@ public partial class WorldPopulationOverview [Newtonsoft.Json.JsonProperty("approachTypes", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public System.Collections.Generic.ICollection ApproachTypes { get; set; } + /// Gets or sets the completed flights. + [Newtonsoft.Json.JsonProperty("completedFlights", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public int CompletedFlights { get; set; } + + /// Gets or sets a pie chart series for flight aircraft categories. + [Newtonsoft.Json.JsonProperty("flightAircraftCategories", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.Collections.Generic.ICollection FlightAircraftCategories { get; set; } + + /// Gets or sets a pie chart series for flight operators. + [Newtonsoft.Json.JsonProperty("flightOperators", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.Collections.Generic.ICollection FlightOperators { get; set; } + /// Gets or sets a pie chart series for fuel availability at airports. [Newtonsoft.Json.JsonProperty("fuelAvailability", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public System.Collections.Generic.ICollection FuelAvailability { get; set; } + /// Gets or sets a pie chart series for job categories. + [Newtonsoft.Json.JsonProperty("jobAircraftCategories", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.Collections.Generic.ICollection JobAircraftCategories { get; set; } + + /// Gets or sets a pie chart series for job operators. + [Newtonsoft.Json.JsonProperty("jobOperators", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.Collections.Generic.ICollection JobOperators { get; set; } + + /// Gets or sets the jobs generated. + [Newtonsoft.Json.JsonProperty("jobsGenerated", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public int JobsGenerated { get; set; } + + /// Gets or sets a pie chart series for job types. + [Newtonsoft.Json.JsonProperty("jobTypes", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.Collections.Generic.ICollection JobTypes { get; set; } + /// Gets or sets a pie chart series for runway lights. [Newtonsoft.Json.JsonProperty("runwayLights", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public System.Collections.Generic.ICollection RunwayLights { get; set; } @@ -9607,6 +10047,10 @@ public partial class WorldPopulationOverview [Newtonsoft.Json.JsonProperty("totalApproaches", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public int TotalApproaches { get; set; } + /// Gets or sets the total number of jobs. + [Newtonsoft.Json.JsonProperty("totalJobs", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public int TotalJobs { get; set; } + /// Gets or sets the total number of runways. [Newtonsoft.Json.JsonProperty("totalRunways", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public int TotalRunways { get; set; } @@ -9616,10 +10060,10 @@ public partial class WorldPopulationOverview /// API standard response model. [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.2.1.0 (Newtonsoft.Json v11.0.0.0)")] - public partial class WorldPopulationOverviewApiResponse + public partial class WorldStatisticsOverviewApiResponse { [Newtonsoft.Json.JsonProperty("data", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public WorldPopulationOverview Data { get; set; } + public WorldStatisticsOverview Data { get; set; } /// Gets or sets the error details (NULL if no error). [Newtonsoft.Json.JsonProperty("errorDetails", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] diff --git a/OpenSky.AgentMSFS/OpenAPIs/swagger.json b/OpenSky.Agent.Simulator/OpenAPIs/swagger.json similarity index 94% rename from OpenSky.AgentMSFS/OpenAPIs/swagger.json rename to OpenSky.Agent.Simulator/OpenAPIs/swagger.json index cb13e19..881ad01 100644 --- a/OpenSky.AgentMSFS/OpenAPIs/swagger.json +++ b/OpenSky.Agent.Simulator/OpenAPIs/swagger.json @@ -2283,6 +2283,102 @@ } } }, + "/bobsYourUncle": { + "post": { + "tags": [ + "Financial" + ], + "summary": "Free money :)", + "description": "sushi.at, 25/01/2022.", + "operationId": "BobsYourUncle", + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/StringApiResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/StringApiResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/StringApiResponse" + } + } + } + } + } + } + }, + "/balances": { + "get": { + "tags": [ + "Financial" + ], + "summary": "Get the current account balances.", + "description": "sushi.at, 25/01/2022.", + "operationId": "GetAccountBalances", + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/AccountBalancesApiResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/AccountBalancesApiResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/AccountBalancesApiResponse" + } + } + } + } + } + } + }, + "/overview": { + "get": { + "tags": [ + "Financial" + ], + "summary": "Get financial overview (with transactions of the last 30 days)", + "description": "sushi.at, 24/01/2022.", + "operationId": "GetFinancialOverview", + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/FinancialOverviewApiResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/FinancialOverviewApiResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/FinancialOverviewApiResponse" + } + } + } + } + } + } + }, "/Flight/abort/{flightID}": { "post": { "tags": [ @@ -3243,31 +3339,31 @@ } } }, - "/WorldPopulation": { + "/WorldStatistics": { "get": { "tags": [ - "WorldPopulation" + "WorldStatistics" ], - "summary": "Get world population overview.", + "summary": "Get world statistics overview.", "description": "sushi.at, 02/07/2021.", - "operationId": "GetWorldPopulationOverview", + "operationId": "GetWorldStatisticsOverview", "responses": { "200": { "description": "Success", "content": { "text/plain": { "schema": { - "$ref": "#/components/schemas/WorldPopulationOverviewApiResponse" + "$ref": "#/components/schemas/WorldStatisticsOverviewApiResponse" } }, "application/json": { "schema": { - "$ref": "#/components/schemas/WorldPopulationOverviewApiResponse" + "$ref": "#/components/schemas/WorldStatisticsOverviewApiResponse" } }, "text/json": { "schema": { - "$ref": "#/components/schemas/WorldPopulationOverviewApiResponse" + "$ref": "#/components/schemas/WorldStatisticsOverviewApiResponse" } } } @@ -3275,10 +3371,10 @@ } } }, - "/WorldPopulation/populateAircraft/{icao}": { + "/WorldStatistics/populateAircraft/{icao}": { "post": { "tags": [ - "WorldPopulation" + "WorldStatistics" ], "summary": "Manually request to populate an airport and return info text results.", "description": "sushi.at, 05/07/2021.", @@ -3321,9 +3417,61 @@ }, "components": { "schemas": { + "AccountBalances": { + "type": "object", + "properties": { + "accountBalance": { + "type": "integer", + "description": "Gets or sets the account balance (of the user).", + "format": "int64" + }, + "airlineAccountBalance": { + "type": "integer", + "description": "Gets or sets the airline account balance (if user has the permission).", + "format": "int64", + "nullable": true + } + }, + "additionalProperties": false, + "description": "Account balances model." + }, + "AccountBalancesApiResponse": { + "type": "object", + "properties": { + "data": { + "$ref": "#/components/schemas/AccountBalances" + }, + "errorDetails": { + "type": "string", + "description": "Gets or sets the error details (NULL if no error).", + "nullable": true + }, + "isError": { + "type": "boolean", + "description": "Gets or sets a value indicating whether this response is reporting an error." + }, + "message": { + "type": "string", + "description": "Gets or sets the message.", + "nullable": true + }, + "status": { + "type": "string", + "description": "Gets or sets the status.", + "nullable": true + } + }, + "additionalProperties": false, + "description": "API standard response model." + }, "AccountOverview": { "type": "object", "properties": { + "airlineName": { + "type": "string", + "description": "Gets or sets the name of the airline (if the user is a member of one).", + "nullable": true + }, "joined": { "type": "string", "description": "Gets or sets the Date/Time of when the user joined.", @@ -3426,6 +3574,16 @@ "format": "double", "readOnly": true }, + "lifeTimeExpense": { + "type": "integer", + "description": "Gets or sets the life time expense (for the current owner only).", + "format": "int64" + }, + "lifeTimeIncome": { + "type": "integer", + "description": "Gets or sets the life time income (for the current owner only).", + "format": "int64" + }, "loadingUntil": { "type": "string", "description": "Gets or sets the Date/Time until the aircraft is loading payload (cargo or pax).", @@ -3994,12 +4152,13 @@ 41, 42, 43, + 50, 90, 91, 92 ], "type": "integer", - "description": "Airline roles. 10 = BuyAircraft, 11 = SellAircraft, 12 = RentAircraft, 13 = RentOutAircraft, 14 = AssignAircraft, 15 = RenameAircraft, 20 = BuyFBO, 21 = SellFBO, 22 = RentFBO, 23 = RentOutFBO, 24 = RenameFBO, 25 = OrderFuel, 30 = AcceptJobs, 31 = Dispatch, 32 = OutsourceJobs, 33 = AbortJobs, 40 = ModifyAircraft, 41 = MaintainAircraft, 42 = ReplaceAircraftParts, 43 = PerformGroundOperations, 90 = ChangePermissions, 91 = BoardMember, 92 = AllPermissions", + "description": "Airline roles. 10 = BuyAircraft, 11 = SellAircraft, 12 = RentAircraft, 13 = RentOutAircraft, 14 = AssignAircraft, 15 = RenameAircraft, 20 = BuyFBO, 21 = SellFBO, 22 = RentFBO, 23 = RentOutFBO, 24 = RenameFBO, 25 = OrderFuel, 30 = AcceptJobs, 31 = Dispatch, 32 = OutsourceJobs, 33 = AbortJobs, 40 = ModifyAircraft, 41 = MaintainAircraft, 42 = ReplaceAircraftParts, 43 = PerformGroundOperations, 50 = FinancialRecords, 90 = ChangePermissions, 91 = BoardMember, 92 = AllPermissions", "format": "int32", "x-enumNames": [ "BuyAircraft", @@ -4022,6 +4181,7 @@ "MaintainAircraft", "ReplaceAircraftParts", "PerformGroundOperations", + "FinancialRecords", "ChangePermissions", "BoardMember", "AllPermissions" @@ -4047,6 +4207,7 @@ "MaintainAircraft", "ReplaceAircraftParts", "PerformGroundOperations", + "FinancialRecords", "ChangePermissions", "BoardMember", "AllPermissions" @@ -4105,6 +4266,11 @@ "format": "int32", "nullable": true }, + "avGasPrice": { + "type": "number", + "description": "Gets or sets the AV gas price in SkyBucks/Gallon.", + "format": "float" + }, "city": { "maxLength": 50, "minLength": 0, @@ -4147,6 +4313,11 @@ "type": "boolean", "description": "Gets or sets a value indicating whether the airport is a military one." }, + "jetFuelPrice": { + "type": "number", + "description": "Gets or sets the jet fuel price in SkyBucks/Gallon.", + "format": "float" + }, "latitude": { "type": "number", "description": "Gets or sets the latitude of the airport.", @@ -5406,6 +5577,179 @@ "additionalProperties": false, "description": "Flight final report model." }, + "FinancialCategory": { + "enum": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14 + ], + "type": "integer", + "description": "Financial categories. 0 = None, 1 = Aircraft, 2 = Fuel, 3 = Maintenance, 4 = AirportFees, 5 = Salaries, 6 = Loan, 7 = Interest, 8 = Shares, 9 = Dividend, 10 = FBO, 11 = Cargo, 12 = Passengers, 13 = SpecialtyJobs, 14 = Fines", + "format": "int32", + "x-enumNames": [ + "None", + "Aircraft", + "Fuel", + "Maintenance", + "AirportFees", + "Salaries", + "Loan", + "Interest", + "Shares", + "Dividend", + "FBO", + "Cargo", + "Passengers", + "SpecialtyJobs", + "Fines" + ], + "x-enum-varnames": [ + "None", + "Aircraft", + "Fuel", + "Maintenance", + "AirportFees", + "Salaries", + "Loan", + "Interest", + "Shares", + "Dividend", + "FBO", + "Cargo", + "Passengers", + "SpecialtyJobs", + "Fines" + ] + }, + "FinancialOverview": { + "type": "object", + "properties": { + "accountBalance": { + "type": "integer", + "description": "Gets or sets the account balance (of the user).", + "format": "int64" + }, + "airlineAccountBalance": { + "type": "integer", + "description": "Gets or sets the airline account balance (if user has the permission).", + "format": "int64", + "nullable": true + }, + "recentAirlineFinancialRecords": { + "type": "array", + "items": { + "$ref": "#/components/schemas/FinancialRecord" + }, + "description": "Gets or sets the recent airline financial records (if user has the permission).", + "nullable": true + }, + "recentFinancialRecords": { + "type": "array", + "items": { + "$ref": "#/components/schemas/FinancialRecord" + }, + "description": "Gets or sets the recent financial records (of the user).", + "nullable": true + } + }, + "additionalProperties": false, + "description": "Financial overview model." + }, + "FinancialOverviewApiResponse": { + "type": "object", + "properties": { + "data": { + "$ref": "#/components/schemas/FinancialOverview" + }, + "errorDetails": { + "type": "string", + "description": "Gets or sets the error details (NULL if no error).", + "nullable": true + }, + "isError": { + "type": "boolean", + "description": "Gets or sets a value indicating whether this response is reporting an error." + }, + "message": { + "type": "string", + "description": "Gets or sets the message.", + "nullable": true + }, + "status": { + "type": "string", + "description": "Gets or sets the status.", + "nullable": true + } + }, + "additionalProperties": false, + "description": "API standard response model." + }, + "FinancialRecord": { + "required": [ + "category", + "description", + "id" + ], + "type": "object", + "properties": { + "aircraftRegistry": { + "maxLength": 10, + "minLength": 5, + "type": "string", + "description": "Gets or sets the aircraft registry (optional, if record relates to an aircraft).", + "nullable": true + }, + "category": { + "$ref": "#/components/schemas/FinancialCategory" + }, + "childRecords": { + "type": "array", + "items": { + "$ref": "#/components/schemas/FinancialRecord" + }, + "description": "Gets or sets the child records.", + "nullable": true + }, + "description": { + "type": "string", + "description": "Gets or sets the description of the record." + }, + "expense": { + "type": "integer", + "description": "Gets or sets the expense amount in SkyBucks.", + "format": "int64" + }, + "id": { + "type": "string", + "description": "Gets or sets the identifier for the financial record.", + "format": "uuid" + }, + "income": { + "type": "integer", + "description": "Gets or sets the income amount in SkyBucks.", + "format": "int64" + }, + "timestamp": { + "type": "string", + "description": "Gets or sets the timestamp of the record.", + "format": "date-time" + } + }, + "additionalProperties": false, + "description": "Financial record model." + }, "Flight": { "required": [ "id" @@ -6693,7 +7037,7 @@ "value": { "type": "integer", "description": "Gets or sets the value.", - "format": "int32" + "format": "int64" } }, "additionalProperties": false, @@ -7670,7 +8014,7 @@ "additionalProperties": false, "description": "API standard response model." }, - "WorldPopulationOverview": { + "WorldStatisticsOverview": { "type": "object", "properties": { "aircraftCategories": { @@ -7705,6 +8049,27 @@ "description": "Gets or sets a pie chart series for approach types.", "nullable": true }, + "completedFlights": { + "type": "integer", + "description": "Gets or sets the completed flights.", + "format": "int32" + }, + "flightAircraftCategories": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PieChartValue" + }, + "description": "Gets or sets a pie chart series for flight aircraft categories.", + "nullable": true + }, + "flightOperators": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PieChartValue" + }, + "description": "Gets or sets a pie chart series for flight operators.", + "nullable": true + }, "fuelAvailability": { "type": "array", "items": { @@ -7713,6 +8078,35 @@ "description": "Gets or sets a pie chart series for fuel availability at airports.", "nullable": true }, + "jobAircraftCategories": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PieChartValue" + }, + "description": "Gets or sets a pie chart series for job categories.", + "nullable": true + }, + "jobOperators": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PieChartValue" + }, + "description": "Gets or sets a pie chart series for job operators.", + "nullable": true + }, + "jobsGenerated": { + "type": "integer", + "description": "Gets or sets the jobs generated.", + "format": "int32" + }, + "jobTypes": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PieChartValue" + }, + "description": "Gets or sets a pie chart series for job types.", + "nullable": true + }, "runwayLights": { "type": "array", "items": { @@ -7744,6 +8138,11 @@ "description": "Gets or sets the total number of approaches.", "format": "int32" }, + "totalJobs": { + "type": "integer", + "description": "Gets or sets the total number of jobs.", + "format": "int32" + }, "totalRunways": { "type": "integer", "description": "Gets or sets the total number of runways.", @@ -7751,13 +8150,13 @@ } }, "additionalProperties": false, - "description": "World population overview model." + "description": "World statistics overview model." }, - "WorldPopulationOverviewApiResponse": { + "WorldStatisticsOverviewApiResponse": { "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/WorldPopulationOverview" + "$ref": "#/components/schemas/WorldStatisticsOverview" }, "errorDetails": { "type": "string", diff --git a/OpenSky.Agent.Simulator/OpenSky.Agent.Simulator.csproj b/OpenSky.Agent.Simulator/OpenSky.Agent.Simulator.csproj new file mode 100644 index 0000000..b34fee1 --- /dev/null +++ b/OpenSky.Agent.Simulator/OpenSky.Agent.Simulator.csproj @@ -0,0 +1,120 @@ + + + + + + Debug + AnyCPU + {30C467E8-2EEE-41E5-BE01-0142A61BA171} + Library + Properties + OpenSky.Agent.Simulator + OpenSky.Agent.Simulator + v4.8 + 512 + true + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + bin\Debug\OpenSky.Agent.Simulator.xml + latest + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + bin\Release\OpenSky.Agent.Simulator.xml + latest + + + + ..\packages\JetBrains.Annotations.2021.3.0\lib\net20\JetBrains.Annotations.dll + + + ..\packages\Microsoft.Maps.MapControl.WPF.1.0.0.3\lib\net40-Client\Microsoft.Maps.MapControl.WPF.dll + + + ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll + + + ..\packages\OpenSky.FlightLogXML.0.1.4\lib\net48\OpenSky.FlightLogXML.dll + + + ..\packages\MSFT.ParallelExtensionsExtras.1.2.0\lib\ParallelExtensionsExtras.dll + + + + + + + + + + + + + ..\packages\XDMessaging.Lite.5.0.6\lib\net452\XDMessaging.Lite.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OpenSkyApi + OpenSkyService + NSwagCSharp + http://localhost:5000/swagger/v1/swagger.json + /ClientBaseClass:OpenSkyServiceBase /UseHttpRequestMessageCreationMethod:true + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + \ No newline at end of file diff --git a/OpenSky.Agent.Simulator/OpenSky.Agent.Simulator.csproj.DotSettings b/OpenSky.Agent.Simulator/OpenSky.Agent.Simulator.csproj.DotSettings new file mode 100644 index 0000000..4887f94 --- /dev/null +++ b/OpenSky.Agent.Simulator/OpenSky.Agent.Simulator.csproj.DotSettings @@ -0,0 +1,2 @@ + + CSharp100 \ No newline at end of file diff --git a/OpenSky.Agent.Simulator/Properties/AssemblyInfo.cs b/OpenSky.Agent.Simulator/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..744cf75 --- /dev/null +++ b/OpenSky.Agent.Simulator/Properties/AssemblyInfo.cs @@ -0,0 +1,21 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// OpenSky project 2021-2022 +// +// -------------------------------------------------------------------------------------------------------------------- + +using System.Reflection; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("OpenSky.Agent.Simulator")] +[assembly: AssemblyDescription("OpenSky Agent Simulator Interface Library")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("OpenSky")] +[assembly: AssemblyProduct("OpenSky")] +[assembly: AssemblyCopyright("OpenSky project 2021-2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: ComVisible(false)] +[assembly: Guid("30c467e8-2eee-41e5-be01-0142a61ba171")] +[assembly: AssemblyVersion("0.4.0")] +[assembly: AssemblyFileVersion("0.4.0")] \ No newline at end of file diff --git a/OpenSky.Agent.Simulator/Simulator.cs b/OpenSky.Agent.Simulator/Simulator.cs new file mode 100644 index 0000000..5d8cdac --- /dev/null +++ b/OpenSky.Agent.Simulator/Simulator.cs @@ -0,0 +1,93 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// OpenSky project 2021-2022 +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace OpenSky.Agent.Simulator +{ + using System.Collections.Concurrent; + + using OpenSky.Agent.Simulator.Enums; + using OpenSky.Agent.Simulator.Models; + using OpenSky.AgentMSFS.Models; + + using OpenSkyApi; + + /// ------------------------------------------------------------------------------------------------- + /// + /// Simulator interface class. + /// + /// + /// sushi.at, 30/01/2022. + /// + /// ------------------------------------------------------------------------------------------------- + public abstract class Simulator + { + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets the simulator instance. + /// + /// ------------------------------------------------------------------------------------------------- + public static Simulator Instance { get; private set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Sets the simulator instance. + /// + /// + /// sushi.at, 31/01/2022. + /// + /// + /// The simulator. + /// + /// ------------------------------------------------------------------------------------------------- + public static void SetSimulatorInstance(Simulator simulator) + { + Instance = simulator; + } + + public abstract PrimaryTracking PrimaryTracking { get; } + + public abstract SecondaryTracking SecondaryTracking { get; } + + public abstract WeightAndBalance WeightAndBalance { get; } + + public abstract AircraftIdentity AircraftIdentity { get; } + + public abstract FuelTanks FuelTanks { get; } + + public abstract PayloadStations PayloadStations { get; } + + public abstract LandingAnalysis LandingAnalysis { get; } + + public abstract bool Connected { get; } + + public abstract FlightPhase FlightPhase { get; } + + public abstract TrackingStatus TrackingStatus { get; } + + public abstract VerticalProfile VerticalProfile { get; } + + public abstract string WarpInfo { get; } + + public abstract string PauseInfo { get; } + + public abstract bool WasAirborne { get; } + + public abstract string TrackingDuration { get; } + + public abstract bool IsTurning { get; } + + public abstract int PrimaryTrackingProcessingQueueLength { get; } + + public abstract int SecondaryTrackingProcessingQueueLength { get; } + + public abstract int LandingAnalysisProcessingQueueLength { get; } + + public abstract ObservableConcurrentDictionary SampleRates { get; } + + public abstract string LastDistancePositionReport { get; } + + } +} \ No newline at end of file diff --git a/OpenSky.Agent.Simulator/Tools/StringValueAttribute.cs b/OpenSky.Agent.Simulator/Tools/StringValueAttribute.cs new file mode 100644 index 0000000..eedbf3e --- /dev/null +++ b/OpenSky.Agent.Simulator/Tools/StringValueAttribute.cs @@ -0,0 +1,52 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// OpenSky project 2021-2022 +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace OpenSky.Agent.Simulator.Tools +{ + using System; + + using JetBrains.Annotations; + + /// ------------------------------------------------------------------------------------------------- + /// + /// This attribute is used to represent a string value for a value in an enum. + /// + /// + /// sushi.at, 19/03/2021. + /// + /// + /// ------------------------------------------------------------------------------------------------- + [AttributeUsage(AttributeTargets.Field)] + public class StringValueAttribute : Attribute + { + /// ------------------------------------------------------------------------------------------------- + /// + /// Initializes a new instance of the class. + /// + /// + /// sushi.at, 19/03/2021. + /// + /// + /// The string value to store. + /// + /// ------------------------------------------------------------------------------------------------- + public StringValueAttribute([NotNull] string value) + { + this.StringValue = value; + } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets or sets gets the string value. + /// + /// + /// The string value. + /// + /// ------------------------------------------------------------------------------------------------- + [NotNull] + public string StringValue { get; protected set; } + } +} \ No newline at end of file diff --git a/OpenSky.Agent.Simulator/packages.config b/OpenSky.Agent.Simulator/packages.config new file mode 100644 index 0000000..41d07b5 --- /dev/null +++ b/OpenSky.Agent.Simulator/packages.config @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/OpenSky.AgentMSFS.sln b/OpenSky.Agent.sln similarity index 56% rename from OpenSky.AgentMSFS.sln rename to OpenSky.Agent.sln index b3ddceb..b5297e4 100644 --- a/OpenSky.AgentMSFS.sln +++ b/OpenSky.Agent.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.31025.194 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSky.AgentMSFS", "OpenSky.AgentMSFS\OpenSky.AgentMSFS.csproj", "{26FAA45D-B4A3-4228-8AF3-E5811BCFC765}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSky.Agent", "OpenSky.Agent\OpenSky.Agent.csproj", "{26FAA45D-B4A3-4228-8AF3-E5811BCFC765}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3E7B79A5-C09B-488A-9C72-2E80F02C902B}" ProjectSection(SolutionItems) = preProject @@ -13,6 +13,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Installer", "Installer\Installer.wixproj", "{853790E9-5CAA-4EBC-B4C3-C563C3242F1D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSky.Agent.SimConnectMSFS", "OpenSky.Agent.SimConnectMSFS\OpenSky.Agent.SimConnectMSFS.csproj", "{1F9CBEDE-669D-4510-BCA2-E6AD29D6A498}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSky.Agent.Simulator", "OpenSky.Agent.Simulator\OpenSky.Agent.Simulator.csproj", "{30C467E8-2EEE-41E5-BE01-0142A61BA171}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -35,6 +39,22 @@ Global {853790E9-5CAA-4EBC-B4C3-C563C3242F1D}.Release|Any CPU.ActiveCfg = Release|x86 {853790E9-5CAA-4EBC-B4C3-C563C3242F1D}.Release|x86.ActiveCfg = Release|x86 {853790E9-5CAA-4EBC-B4C3-C563C3242F1D}.Release|x86.Build.0 = Release|x86 + {1F9CBEDE-669D-4510-BCA2-E6AD29D6A498}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F9CBEDE-669D-4510-BCA2-E6AD29D6A498}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F9CBEDE-669D-4510-BCA2-E6AD29D6A498}.Debug|x86.ActiveCfg = Debug|Any CPU + {1F9CBEDE-669D-4510-BCA2-E6AD29D6A498}.Debug|x86.Build.0 = Debug|Any CPU + {1F9CBEDE-669D-4510-BCA2-E6AD29D6A498}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F9CBEDE-669D-4510-BCA2-E6AD29D6A498}.Release|Any CPU.Build.0 = Release|Any CPU + {1F9CBEDE-669D-4510-BCA2-E6AD29D6A498}.Release|x86.ActiveCfg = Release|Any CPU + {1F9CBEDE-669D-4510-BCA2-E6AD29D6A498}.Release|x86.Build.0 = Release|Any CPU + {30C467E8-2EEE-41E5-BE01-0142A61BA171}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {30C467E8-2EEE-41E5-BE01-0142A61BA171}.Debug|Any CPU.Build.0 = Debug|Any CPU + {30C467E8-2EEE-41E5-BE01-0142A61BA171}.Debug|x86.ActiveCfg = Debug|Any CPU + {30C467E8-2EEE-41E5-BE01-0142A61BA171}.Debug|x86.Build.0 = Debug|Any CPU + {30C467E8-2EEE-41E5-BE01-0142A61BA171}.Release|Any CPU.ActiveCfg = Release|Any CPU + {30C467E8-2EEE-41E5-BE01-0142A61BA171}.Release|Any CPU.Build.0 = Release|Any CPU + {30C467E8-2EEE-41E5-BE01-0142A61BA171}.Release|x86.ActiveCfg = Release|Any CPU + {30C467E8-2EEE-41E5-BE01-0142A61BA171}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/OpenSky.AgentMSFS.sln.DotSettings b/OpenSky.Agent.sln.DotSettings similarity index 99% rename from OpenSky.AgentMSFS.sln.DotSettings rename to OpenSky.Agent.sln.DotSettings index 85d00e8..8eb4f77 100644 --- a/OpenSky.AgentMSFS.sln.DotSettings +++ b/OpenSky.Agent.sln.DotSettings @@ -591,6 +591,7 @@ OpenSky project $CURRENT_YEAR$ True True True + True True True True diff --git a/OpenSky.AgentMSFS/App.config.debug b/OpenSky.Agent/App.config.debug similarity index 100% rename from OpenSky.AgentMSFS/App.config.debug rename to OpenSky.Agent/App.config.debug diff --git a/OpenSky.AgentMSFS/App.config.release b/OpenSky.Agent/App.config.release similarity index 100% rename from OpenSky.AgentMSFS/App.config.release rename to OpenSky.Agent/App.config.release diff --git a/OpenSky.AgentMSFS/App.xaml b/OpenSky.Agent/App.xaml similarity index 98% rename from OpenSky.AgentMSFS/App.xaml rename to OpenSky.Agent/App.xaml index 1d77526..b858495 100644 --- a/OpenSky.AgentMSFS/App.xaml +++ b/OpenSky.Agent/App.xaml @@ -1,7 +1,7 @@  + #05826c + + #08c6a4 + + DarkRed + + #CC0000 + + #29323c + + #1a1e22 + + Yellow + + DarkOrange + + Orange + + Black + + White + + diff --git a/OpenSky.Agent.Simulator/Simulator.Data.cs b/OpenSky.Agent.Simulator/Simulator.Data.cs new file mode 100644 index 0000000..52d5d02 --- /dev/null +++ b/OpenSky.Agent.Simulator/Simulator.Data.cs @@ -0,0 +1,242 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// OpenSky project 2021-2022 +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace OpenSky.Agent.Simulator +{ + using OpenSky.Agent.Simulator.Models; + + /// ------------------------------------------------------------------------------------------------- + /// + /// Simulator interface - data structures. + /// + /// ------------------------------------------------------------------------------------------------- + public partial class Simulator + { + /// ------------------------------------------------------------------------------------------------- + /// + /// The last aircraft identity data received from the simulator. + /// + /// ------------------------------------------------------------------------------------------------- + private AircraftIdentity aircraftIdentity; + + /// ------------------------------------------------------------------------------------------------- + /// + /// The last fuel tanks data received from the simulator. + /// + /// ------------------------------------------------------------------------------------------------- + private FuelTanks fuelTanks; + + /// ------------------------------------------------------------------------------------------------- + /// + /// The last landing analysis data received from the simulator. + /// + /// ------------------------------------------------------------------------------------------------- + private LandingAnalysis landingAnalysis; + + /// ------------------------------------------------------------------------------------------------- + /// + /// The last payload stations data received from the simulator. + /// + /// ------------------------------------------------------------------------------------------------- + private PayloadStations payloadStations; + + /// ------------------------------------------------------------------------------------------------- + /// + /// The last primary tracking data received from the simulator. + /// + /// ------------------------------------------------------------------------------------------------- + private PrimaryTracking primaryTracking; + + /// ------------------------------------------------------------------------------------------------- + /// + /// The last secondary tracking data received from the simulator. + /// + /// ------------------------------------------------------------------------------------------------- + private SecondaryTracking secondaryTracking; + + /// ------------------------------------------------------------------------------------------------- + /// + /// The last slew aircraft into position data received from the simulator. + /// + /// ------------------------------------------------------------------------------------------------- + private SlewAircraftIntoPosition slewAircraftIntoPosition; + + /// ------------------------------------------------------------------------------------------------- + /// + /// The last weight and balance data received from the simulator. + /// + /// ------------------------------------------------------------------------------------------------- + private WeightAndBalance weightAndBalance; + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets the aircraft identity data. + /// + /// ------------------------------------------------------------------------------------------------- + public AircraftIdentity AircraftIdentity + { + get => this.aircraftIdentity; + + set + { + if (Equals(this.aircraftIdentity, value)) + { + return; + } + + this.aircraftIdentity = value; + this.OnPropertyChanged(); + } + } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets the fuel tanks data. + /// + /// ------------------------------------------------------------------------------------------------- + public FuelTanks FuelTanks + { + get => this.fuelTanks; + + set + { + if (Equals(this.fuelTanks, value)) + { + return; + } + + this.fuelTanks = value; + this.OnPropertyChanged(); + } + } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets the landing analysis data. + /// + /// ------------------------------------------------------------------------------------------------- + public LandingAnalysis LandingAnalysis + { + get => this.landingAnalysis; + + set + { + if (Equals(this.landingAnalysis, value)) + { + return; + } + + this.landingAnalysis = value; + this.OnPropertyChanged(); + } + } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets the payload stations data. + /// + /// ------------------------------------------------------------------------------------------------- + public PayloadStations PayloadStations + { + get => this.payloadStations; + + set + { + if (Equals(this.payloadStations, value)) + { + return; + } + + this.payloadStations = value; + this.OnPropertyChanged(); + } + } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets the primary tracking data. + /// + /// ------------------------------------------------------------------------------------------------- + public PrimaryTracking PrimaryTracking + { + get => this.primaryTracking; + + set + { + if (Equals(this.primaryTracking, value)) + { + return; + } + + this.primaryTracking = value; + this.OnPropertyChanged(); + } + } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets the secondary tracking data. + /// + /// ------------------------------------------------------------------------------------------------- + public SecondaryTracking SecondaryTracking + { + get => this.secondaryTracking; + + set + { + if (Equals(this.secondaryTracking, value)) + { + return; + } + + this.secondaryTracking = value; + this.OnPropertyChanged(); + } + } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets the slew aircraft into position data. + /// + /// ------------------------------------------------------------------------------------------------- + public SlewAircraftIntoPosition SlewAircraftIntoPosition + { + get => this.slewAircraftIntoPosition; + + protected set + { + if (Equals(this.slewAircraftIntoPosition, value)) + { + return; + } + + this.slewAircraftIntoPosition = value; + this.OnPropertyChanged(); + } + } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets the weight and balance data. + /// + /// ------------------------------------------------------------------------------------------------- + public WeightAndBalance WeightAndBalance + { + get => this.weightAndBalance; + + set + { + if (Equals(this.weightAndBalance, value)) + { + return; + } + + this.weightAndBalance = value; + this.OnPropertyChanged(); + } + } + } +} \ No newline at end of file diff --git a/OpenSky.Agent.SimConnectMSFS/SimConnect.Flight.cs b/OpenSky.Agent.Simulator/Simulator.Flight.cs similarity index 88% rename from OpenSky.Agent.SimConnectMSFS/SimConnect.Flight.cs rename to OpenSky.Agent.Simulator/Simulator.Flight.cs index ef00c33..ce15ac9 100644 --- a/OpenSky.Agent.SimConnectMSFS/SimConnect.Flight.cs +++ b/OpenSky.Agent.Simulator/Simulator.Flight.cs @@ -1,19 +1,20 @@ // -------------------------------------------------------------------------------------------------------------------- -// +// // OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- -namespace OpenSky.Agent.SimConnectMSFS +namespace OpenSky.Agent.Simulator { using System; - using System.Collections.Generic; using System.Device.Location; using System.Diagnostics; using System.IO; using System.IO.Compression; using System.Text; using System.Threading; + using System.Windows; + using System.Windows.Media; using JetBrains.Annotations; @@ -21,24 +22,20 @@ namespace OpenSky.Agent.SimConnectMSFS using OpenSky.Agent.Simulator.Enums; using OpenSky.Agent.Simulator.Models; - using OpenSky.AgentMSFS.Models; - using OpenSky.AgentMSFS.SimConnect.Helpers; - using OpenSky.AgentMSFS.SimConnect.Structs; + using OpenSky.Agent.Simulator.Tools; using OpenSky.FlightLogXML; using OpenSkyApi; using PositionReport = OpenSkyApi.PositionReport; + using TrackingEventMarker = OpenSky.Agent.Simulator.Models.TrackingEventMarker; /// ------------------------------------------------------------------------------------------------- - /// - /// Simconnect client - flight tracking code. - /// - /// - /// sushi.at, 17/03/2021. - /// + /// + /// Simulator interface - flight. + /// /// ------------------------------------------------------------------------------------------------- - public partial class SimConnect + public partial class Simulator { /// ------------------------------------------------------------------------------------------------- /// @@ -112,13 +109,6 @@ public partial class SimConnect /// ------------------------------------------------------------------------------------------------- private DateTime lastPositionReportUpload = DateTime.MinValue; - /// ------------------------------------------------------------------------------------------------- - /// - /// The pause info string. - /// - /// ------------------------------------------------------------------------------------------------- - private string pauseInfo; - /// ------------------------------------------------------------------------------------------------- /// /// The time saved because of simulation rate above 1 (equals warp delay at the end of the flight). @@ -254,12 +244,14 @@ public Flight Flight this.trackingEventMarkers.Add(runwayMarker); this.TrackingEventMarkerAdded?.Invoke(this, runwayMarker); } + foreach (var runway in value.Origin.Runways) { var runwayMarker = new TrackingEventMarker(runway); this.trackingEventMarkers.Add(runwayMarker); this.TrackingEventMarkerAdded?.Invoke(this, runwayMarker); } + foreach (var runway in value.Destination.Runways) { var runwayMarker = new TrackingEventMarker(runway); @@ -269,7 +261,8 @@ public Flight Flight } }; - this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Fuel].Expected = $"{value.FuelGallons:F1} gal, {value.FuelGallons * 3.78541:F1} liters ▶ {value.FuelGallons * value.Aircraft.Type.FuelWeightPerGallon:F1} lbs, {value.FuelGallons * value.Aircraft.Type.FuelWeightPerGallon * 0.453592:F1} kg"; + this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Fuel].Expected = + $"{value.FuelGallons:F1} gal, {value.FuelGallons * 3.78541:F1} liters ▶ {value.FuelGallons * value.Aircraft.Type.FuelWeightPerGallon:F1} lbs, {value.FuelGallons * value.Aircraft.Type.FuelWeightPerGallon * 0.453592:F1} kg"; this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Payload].Expected = $"{value.PayloadPounds:F1} lbs, {value.PayloadPounds * 0.453592:F1} kg"; this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.PlaneModel].Expected = $"{value.Aircraft.Type.Name} (v{value.Aircraft.Type.VersionNumber})"; @@ -279,7 +272,7 @@ public Flight Flight if (!value.Resume) { Debug.WriteLine("Preparing to track new flight"); - this.flightLoadingTempStructs = null; + this.flightLoadingTempModels = null; this.TrackingStatus = TrackingStatus.Preparing; Application.Current.Dispatcher.BeginInvoke(addAirports); @@ -313,7 +306,7 @@ public Flight Flight this.CheckCloudSave(); this.LoadFlight(); - this.flightLoadingTempStructs = new FlightLoadingTempStructs + this.flightLoadingTempModels = new FlightLoadingTempModels { FuelTanks = new FuelTanks { @@ -330,7 +323,7 @@ public Flight Flight FuelTankExternal2Quantity = value.FuelTankExternal2Quantity ?? 0 }, PayloadStations = new PayloadStations(), // todo restore payload stations once we have that, all 0s for now - SlewPlaneIntoPosition = new SlewPlaneIntoPosition + SlewAircraftIntoPosition = new SlewAircraftIntoPosition { Latitude = value.Latitude ?? 0, Longitude = value.Longitude ?? 0, @@ -344,13 +337,14 @@ public Flight Flight } }; - this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Fuel].Expected = $"{this.flightLoadingTempStructs.FuelTanks.TotalQuantity:F1} gal, {this.flightLoadingTempStructs.FuelTanks.TotalQuantity * 3.78541:F1} liters ▶ {this.flightLoadingTempStructs.FuelTanks.TotalQuantity * value.Aircraft.Type.FuelWeightPerGallon:F1} lbs, {this.flightLoadingTempStructs.FuelTanks.TotalQuantity * value.Aircraft.Type.FuelWeightPerGallon * 0.453592:F1} kg"; + this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Fuel].Expected = + $"{this.flightLoadingTempModels.FuelTanks.TotalQuantity:F1} gal, {this.flightLoadingTempModels.FuelTanks.TotalQuantity * 3.78541:F1} liters ▶ {this.flightLoadingTempModels.FuelTanks.TotalQuantity * value.Aircraft.Type.FuelWeightPerGallon:F1} lbs, {this.flightLoadingTempModels.FuelTanks.TotalQuantity * value.Aircraft.Type.FuelWeightPerGallon * 0.453592:F1} kg"; } } else { Debug.WriteLine("Flight set to NULL, stopping tracking"); - this.flightLoadingTempStructs = null; + this.flightLoadingTempModels = null; this.StopTracking(false); this.lastFlightLogAutoSave = DateTime.MinValue; this.simbriefOfpLoaded = false; @@ -367,42 +361,13 @@ public Flight Flight } } - /// ------------------------------------------------------------------------------------------------- - /// - /// Gets the pause info string. - /// - /// - /// ------------------------------------------------------------------------------------------------- - public override string PauseInfo - { - get => this.pauseInfo; - - protected set - { - if (Equals(this.pauseInfo, value)) - { - return; - } - - this.pauseInfo = value; - this.OnPropertyChanged(); - } - } - - /// ------------------------------------------------------------------------------------------------- - /// - /// Gets the tracking conditions. - /// - /// ------------------------------------------------------------------------------------------------- - public Dictionary TrackingConditions { get; } - /// ------------------------------------------------------------------------------------------------- /// /// Gets the duration of the tracking session. /// /// /// ------------------------------------------------------------------------------------------------- - public override string TrackingDuration + public string TrackingDuration { get => this.trackingDuration; @@ -423,7 +388,7 @@ protected set /// Gets the current tracking status. /// /// ------------------------------------------------------------------------------------------------- - public override TrackingStatus TrackingStatus + public TrackingStatus TrackingStatus { get => this.trackingStatus; @@ -459,7 +424,7 @@ protected set /// Gets the warp info string. /// /// ------------------------------------------------------------------------------------------------- - public override string WarpInfo + public string WarpInfo { get => this.warpInfo; @@ -487,9 +452,9 @@ protected set /// /// /// ------------------------------------------------------------------------------------------------- - public override void StartTracking() + public void StartTracking() { - Debug.WriteLine("SimConnect asked to start/resume tracking..."); + Debug.WriteLine("Simulator asked to start/resume tracking..."); if (!this.CanStartTracking) { throw new Exception("Not all tracking conditions met, cannot start tracking."); @@ -506,7 +471,7 @@ public override void StartTracking() this.TrackingStatus = TrackingStatus.GroundOperations; this.trackingStarted = DateTime.UtcNow; - this.AddTrackingEvent(this.PrimaryTrackingStruct, this.SecondaryTrackingStruct, FlightTrackingEventType.TrackingStarted, OpenSkyColors.OpenSkyTealLight, "Flight tracking started"); + this.AddTrackingEvent(this.PrimaryTracking, this.SecondaryTracking, FlightTrackingEventType.TrackingStarted, OpenSkyColors.OpenSkyTealLight, "Flight tracking started"); SpeechSoundPacks.Instance.PlaySpeechEvent(SpeechEvent.TrackingStartedGroundHandling); } else @@ -518,7 +483,7 @@ public override void StartTracking() this.TrackingStatus = TrackingStatus.Tracking; Debug.WriteLine("Flight tracking starting..."); SpeechSoundPacks.Instance.PlaySpeechEvent(SpeechEvent.TrackingStarted); - this.AddTrackingEvent(this.PrimaryTrackingStruct, this.SecondaryTrackingStruct, FlightTrackingEventType.TrackingStarted, OpenSkyColors.OpenSkyTealLight, "Flight tracking started"); + this.AddTrackingEvent(this.PrimaryTracking, this.SecondaryTracking, FlightTrackingEventType.TrackingStarted, OpenSkyColors.OpenSkyTealLight, "Flight tracking started"); } if (this.TrackingStatus == TrackingStatus.Resuming) @@ -526,7 +491,7 @@ public override void StartTracking() this.TrackingStatus = TrackingStatus.Tracking; Debug.WriteLine("Flight tracking resuming..."); SpeechSoundPacks.Instance.PlaySpeechEvent(SpeechEvent.TrackingResumed); - this.AddTrackingEvent(this.PrimaryTrackingStruct, this.SecondaryTrackingStruct, FlightTrackingEventType.TrackingResumed, OpenSkyColors.OpenSkyTealLight, "Flight tracking resumed"); + this.AddTrackingEvent(this.PrimaryTracking, this.SecondaryTracking, FlightTrackingEventType.TrackingResumed, OpenSkyColors.OpenSkyTealLight, "Flight tracking resumed"); // Check if we just resumed a save that failed to upload if (this.FlightPhase == FlightPhase.PostFlight) @@ -589,7 +554,7 @@ public void StopTracking(bool resumeLater) // Abort flight try { - var result = OpenSkyService.Instance.AbortFlightAsync(this.Flight.Id).Result; + var result = this.openSkyServiceInstance.AbortFlightAsync(this.Flight.Id).Result; if (result.IsError) { Debug.WriteLine("Error aborting flight on OpenSky: " + result.Message + "\r\n" + result.ErrorDetails); @@ -639,7 +604,7 @@ public void StopTracking(bool resumeLater) } else { - this.AddTrackingEvent(this.PrimaryTrackingStruct, this.SecondaryTrackingStruct, FlightTrackingEventType.TrackingPaused, OpenSkyColors.OpenSkyTealLight, "Flight tracking paused"); + this.AddTrackingEvent(this.PrimaryTracking, this.SecondaryTracking, FlightTrackingEventType.TrackingPaused, OpenSkyColors.OpenSkyTealLight, "Flight tracking paused"); this.SaveFlight(); SpeechSoundPacks.Instance.PlaySpeechEvent(SpeechEvent.FlightSavedPaused); this.UploadPositionReport(); @@ -654,11 +619,11 @@ public void StopTracking(bool resumeLater) this.PauseFlight(); - this.flightLoadingTempStructs = new FlightLoadingTempStructs + this.flightLoadingTempModels = new FlightLoadingTempModels { FuelTanks = this.FuelTanks, - PayloadStations = this.PayloadStationsStruct, - SlewPlaneIntoPosition = SlewPlaneIntoPosition.FromPrimaryTracking(this.PrimaryTrackingStruct) + PayloadStations = this.PayloadStations, + SlewAircraftIntoPosition = SlewAircraftIntoPosition.FromPrimaryTracking(this.PrimaryTracking) }; } catch (Exception ex) @@ -679,6 +644,89 @@ public void StopTracking(bool resumeLater) } } + /// ------------------------------------------------------------------------------------------------- + /// + /// Check if there is a (newer) cloud save for this flight. + /// + /// + /// sushi.at, 14/11/2021. + /// + /// ------------------------------------------------------------------------------------------------- + private void CheckCloudSave() + { + Debug.WriteLine($"Checking if cloud-save for flight {this.Flight?.Id} is more recent than local save..."); + try + { + if (this.Flight == null) + { + throw new Exception("No flight loaded that could be restored!"); + } + + if (!this.Flight.HasAutoSaveLog || !this.Flight.LastAutoSave.HasValue) + { + // Flight has no cloud-save + return; + } + + if (!this.flightSaveMutex.WaitOne(30 * 1000)) + { + throw new Exception("Timeout waiting for save flight mutex."); + } + + var flightSaveDirectory = "%localappdata%\\OpenSky\\Flights\\"; + flightSaveDirectory = Environment.ExpandEnvironmentVariables(flightSaveDirectory); + var saveFileName = $"{flightSaveDirectory}\\opensky-flight-{this.Flight.Id}.save"; + + var downloadCloudSave = false; + if (!File.Exists(saveFileName)) + { + downloadCloudSave = true; + } + else + { + var localSaveTime = File.GetLastWriteTimeUtc(saveFileName); + if (this.Flight.LastAutoSave.Value.UtcDateTime > localSaveTime) + { + downloadCloudSave = true; + } + } + + if (downloadCloudSave) + { + var result = this.openSkyServiceInstance.DownloadFlightAutoSaveAsync(this.Flight.Id).Result; + if (!result.IsError) + { + var base64 = result.Data; + if (base64 != null) + { + var binary = Convert.FromBase64String(base64); + File.WriteAllBytes(saveFileName, binary); + } + } + else + { + Debug.WriteLine("Error downloading cloud save: " + result.Message + "\r\n" + result.ErrorDetails); + } + } + } + catch (Exception ex) + { + Debug.WriteLine("Error downloading cloud save: " + ex); + throw; + } + finally + { + try + { + this.flightSaveMutex.ReleaseMutex(); + } + catch + { + // Ignore + } + } + } + /// ------------------------------------------------------------------------------------------------- /// /// Delete save file for current flight. @@ -754,18 +802,18 @@ private void FinishUpFlightTracking() var positionReport = new PositionReport { Id = this.Flight.Id, - AirspeedTrue = this.PrimaryTrackingStruct.AirspeedTrue, - Altitude = this.PrimaryTrackingStruct.Altitude, - BankAngle = this.PrimaryTrackingStruct.BankAngle, - FlightPhase = this.PrimaryTrackingStruct.CrashSequence != CrashSequence.Off ? FlightPhase.Crashed : this.FlightPhase, - GroundSpeed = this.PrimaryTrackingStruct.GroundSpeed, - Heading = this.PrimaryTrackingStruct.Heading, - Latitude = this.PrimaryTrackingStruct.Latitude, - Longitude = this.PrimaryTrackingStruct.Longitude, - OnGround = this.PrimaryTrackingStruct.OnGround, - PitchAngle = this.PrimaryTrackingStruct.PitchAngle, - RadioHeight = this.PrimaryTrackingStruct.RadioHeight, - VerticalSpeedSeconds = this.PrimaryTrackingStruct.VerticalSpeedSeconds, + AirspeedTrue = this.PrimaryTracking.AirspeedTrue, + Altitude = this.PrimaryTracking.Altitude, + BankAngle = this.PrimaryTracking.BankAngle, + FlightPhase = this.PrimaryTracking.Crash ? FlightPhase.Crashed : this.FlightPhase, + GroundSpeed = this.PrimaryTracking.GroundSpeed, + Heading = this.PrimaryTracking.Heading, + Latitude = this.PrimaryTracking.Latitude, + Longitude = this.PrimaryTracking.Longitude, + OnGround = this.PrimaryTracking.OnGround, + PitchAngle = this.PrimaryTracking.PitchAngle, + RadioHeight = this.PrimaryTracking.RadioHeight, + VerticalSpeedSeconds = this.PrimaryTracking.VerticalSpeedSeconds, TimeWarpTimeSavedSeconds = (int)this.timeSavedBecauseOfSimRate.TotalSeconds, FuelTankCenterQuantity = this.FuelTanks.FuelTankCenterQuantity, @@ -781,8 +829,8 @@ private void FinishUpFlightTracking() FuelTankExternal2Quantity = this.FuelTanks.FuelTankExternal2Quantity }; - this.RefreshStructNow(Requests.FuelTanks); - this.RefreshStructNow(Requests.PayloadStations); + this.RefreshModelNow(Requests.FuelTanks); + this.RefreshModelNow(Requests.PayloadStations); Thread.Sleep(500); var saveFile = this.GenerateSaveFile(); @@ -808,10 +856,11 @@ private void FinishUpFlightTracking() FlightLog = base64String }; - var result = OpenSkyService.Instance.CompleteFlightAsync(finalReport).Result; + var result = this.openSkyServiceInstance.CompleteFlightAsync(finalReport).Result; if (result.IsError) { Debug.WriteLine("Error submitting final flight report: " + result.Message + "\r\n" + result.ErrorDetails); + // todo how to handle this? save to a special file or only offer retry? Or does the user have to resume from the last save? } else @@ -828,6 +877,7 @@ private void FinishUpFlightTracking() catch (Exception ex) { Debug.WriteLine("Error submitting final flight report: " + ex); + // todo how to handle this? save to a special file or only offer retry? Or does the user have to resume from the last save? } finally @@ -857,89 +907,6 @@ private void FinishUpFlightTracking() } } - /// ------------------------------------------------------------------------------------------------- - /// - /// Check if there is a (newer) cloud save for this flight. - /// - /// - /// sushi.at, 14/11/2021. - /// - /// ------------------------------------------------------------------------------------------------- - private void CheckCloudSave() - { - Debug.WriteLine($"Checking if cloud-save for flight {this.Flight?.Id} is more recent than local save..."); - try - { - if (this.Flight == null) - { - throw new Exception("No flight loaded that could be restored!"); - } - - if (!this.Flight.HasAutoSaveLog || !this.Flight.LastAutoSave.HasValue) - { - // Flight has no cloud-save - return; - } - - if (!this.flightSaveMutex.WaitOne(30 * 1000)) - { - throw new Exception("Timeout waiting for save flight mutex."); - } - - var flightSaveDirectory = "%localappdata%\\OpenSky\\Flights\\"; - flightSaveDirectory = Environment.ExpandEnvironmentVariables(flightSaveDirectory); - var saveFileName = $"{flightSaveDirectory}\\opensky-flight-{this.Flight.Id}.save"; - - var downloadCloudSave = false; - if (!File.Exists(saveFileName)) - { - downloadCloudSave = true; - } - else - { - var localSaveTime = File.GetLastWriteTimeUtc(saveFileName); - if (this.Flight.LastAutoSave.Value.UtcDateTime > localSaveTime) - { - downloadCloudSave = true; - } - } - - if (downloadCloudSave) - { - var result = OpenSkyService.Instance.DownloadFlightAutoSaveAsync(this.Flight.Id).Result; - if (!result.IsError) - { - var base64 = result.Data; - if (base64 != null) - { - var binary = Convert.FromBase64String(base64); - File.WriteAllBytes(saveFileName, binary); - } - } - else - { - Debug.WriteLine("Error downloading cloud save: " + result.Message + "\r\n" + result.ErrorDetails); - } - } - } - catch (Exception ex) - { - Debug.WriteLine("Error downloading cloud save: " + ex); - throw; - } - finally - { - try - { - this.flightSaveMutex.ReleaseMutex(); - } - catch - { - // Ignore - } - } - } - /// ------------------------------------------------------------------------------------------------- /// /// Loads the tracking details of a saved flight. @@ -1005,6 +972,47 @@ private void LoadFlight() } } + /// ------------------------------------------------------------------------------------------------- + /// + /// Pause the current flight on OpenSky. + /// + /// + /// sushi.at, 15/11/2021. + /// + /// + /// Thrown when an exception error condition occurs. + /// + /// ------------------------------------------------------------------------------------------------- + private void PauseFlight() + { + if (this.Flight == null) + { + throw new Exception("No flight loaded that could be paused."); + } + + new Thread( + () => + { + try + { + var result = this.openSkyServiceInstance.PauseFlightAsync(this.Flight.Id).Result; + if (result.IsError) + { + Debug.WriteLine("Error pausing flight: " + result.Message + "\r\n" + result.ErrorDetails); + } + else + { + this.Flight = null; + } + } + catch (Exception ex) + { + Debug.WriteLine("Error pausing flight: " + ex); + } + }) + { Name = "SimConnect.Flight.Pause" }.Start(); + } + /// ------------------------------------------------------------------------------------------------- /// /// Saves the current flight. @@ -1035,8 +1043,8 @@ private void SaveFlight() throw new Exception("Timeout waiting for save flight mutex."); } - this.RefreshStructNow(Requests.FuelTanks); - this.RefreshStructNow(Requests.PayloadStations); + this.RefreshModelNow(Requests.FuelTanks); + this.RefreshModelNow(Requests.PayloadStations); Thread.Sleep(500); Debug.WriteLine($"Saving flight {this.Flight?.Id}"); @@ -1095,7 +1103,7 @@ private void SaveFlight() } } }) - { Name = "SimConnect.Flight.SaveFlight" }.Start(); + { Name = "SimConnect.Flight.SaveFlight" }.Start(); } /// ------------------------------------------------------------------------------------------------- @@ -1126,7 +1134,7 @@ private void TrackFlight(ProcessPrimaryTracking ppt) if (Math.Abs(ppt.Old.SimulationRate - ppt.New.SimulationRate) > 0) { Debug.WriteLine($"SimRate changed to {ppt.New.SimulationRate}"); - this.AddTrackingEvent(ppt.New, this.SecondaryTrackingStruct, FlightTrackingEventType.SimRateChanged, Colors.DarkViolet, $"Simrate changed: {ppt.New.SimulationRate}"); + this.AddTrackingEvent(ppt.New, this.SecondaryTracking, FlightTrackingEventType.SimRateChanged, Colors.DarkViolet, $"Simrate changed: {ppt.New.SimulationRate}"); // Was there an active simrate above 1? if (this.lastActiveSimRate.HasValue && this.lastActiveSimRateActivated.HasValue) @@ -1148,10 +1156,10 @@ private void TrackFlight(ProcessPrimaryTracking ppt) // todo Check if user has paused the sim (but didn't use the pause button we provide) ... check if lat/lon isn't changing while in flight - if (this.PrimaryTrackingStruct.CrashSequence != CrashSequence.Off) + if (this.PrimaryTracking.Crash) { // Plane crashed - this.AddTrackingEvent(ppt.New, this.SecondaryTrackingStruct, FlightTrackingEventType.Crashed, Colors.DarkRed, "Aircraft crashed"); + this.AddTrackingEvent(ppt.New, this.SecondaryTracking, FlightTrackingEventType.Crashed, OpenSkyColors.OpenSkyRed, "Aircraft crashed"); // todo play some ELT sound? to be proper annoying :) this.FinishUpFlightTracking(); @@ -1178,47 +1186,6 @@ private void TrackFlight(ProcessPrimaryTracking ppt) } } - /// ------------------------------------------------------------------------------------------------- - /// - /// Pause the current flight on OpenSky. - /// - /// - /// sushi.at, 15/11/2021. - /// - /// - /// Thrown when an exception error condition occurs. - /// - /// ------------------------------------------------------------------------------------------------- - private void PauseFlight() - { - if (this.Flight == null) - { - throw new Exception("No flight loaded that could be paused."); - } - - new Thread( - () => - { - try - { - var result = OpenSkyService.Instance.PauseFlightAsync(this.Flight.Id).Result; - if (result.IsError) - { - Debug.WriteLine("Error pausing flight: " + result.Message + "\r\n" + result.ErrorDetails); - } - else - { - this.Flight = null; - } - } - catch (Exception ex) - { - Debug.WriteLine("Error pausing flight: " + ex); - } - }) - { Name = "SimConnect.Flight.Pause" }.Start(); - } - /// ------------------------------------------------------------------------------------------------- /// /// Upload auto-save to OpenSky. @@ -1263,7 +1230,7 @@ private void UploadAutoSave() var bytes = File.ReadAllBytes(saveFileName); var base64String = Convert.ToBase64String(bytes); - var result = OpenSkyService.Instance.UploadFlightAutoSaveAsync(this.Flight.Id, base64String).Result; + var result = this.openSkyServiceInstance.UploadFlightAutoSaveAsync(this.Flight.Id, base64String).Result; if (!result.IsError) { this.lastAutoSaveUpload = DateTime.UtcNow; @@ -1302,7 +1269,7 @@ private void UploadAutoSave() } } }) - { Name = "SimConnect.Flight.UploadAutoSave" }.Start(); + { Name = "SimConnect.Flight.UploadAutoSave" }.Start(); } /// ------------------------------------------------------------------------------------------------- @@ -1333,18 +1300,18 @@ private void UploadPositionReport() var positionReport = new PositionReport { Id = this.Flight.Id, - AirspeedTrue = this.PrimaryTrackingStruct.AirspeedTrue, - Altitude = this.PrimaryTrackingStruct.Altitude, - BankAngle = this.PrimaryTrackingStruct.BankAngle, - FlightPhase = this.PrimaryTrackingStruct.CrashSequence != CrashSequence.Off ? FlightPhase.Crashed : this.FlightPhase, - GroundSpeed = this.PrimaryTrackingStruct.GroundSpeed, - Heading = this.PrimaryTrackingStruct.Heading, - Latitude = this.PrimaryTrackingStruct.Latitude, - Longitude = this.PrimaryTrackingStruct.Longitude, - OnGround = this.PrimaryTrackingStruct.OnGround, - PitchAngle = this.PrimaryTrackingStruct.PitchAngle, - RadioHeight = this.PrimaryTrackingStruct.RadioHeight, - VerticalSpeedSeconds = this.PrimaryTrackingStruct.VerticalSpeedSeconds, + AirspeedTrue = this.PrimaryTracking.AirspeedTrue, + Altitude = this.PrimaryTracking.Altitude, + BankAngle = this.PrimaryTracking.BankAngle, + FlightPhase = this.PrimaryTracking.Crash ? FlightPhase.Crashed : this.FlightPhase, + GroundSpeed = this.PrimaryTracking.GroundSpeed, + Heading = this.PrimaryTracking.Heading, + Latitude = this.PrimaryTracking.Latitude, + Longitude = this.PrimaryTracking.Longitude, + OnGround = this.PrimaryTracking.OnGround, + PitchAngle = this.PrimaryTracking.PitchAngle, + RadioHeight = this.PrimaryTracking.RadioHeight, + VerticalSpeedSeconds = this.PrimaryTracking.VerticalSpeedSeconds, TimeWarpTimeSavedSeconds = (int)this.timeSavedBecauseOfSimRate.TotalSeconds, FuelTankCenterQuantity = this.FuelTanks.FuelTankCenterQuantity, @@ -1360,7 +1327,7 @@ private void UploadPositionReport() FuelTankExternal2Quantity = this.FuelTanks.FuelTankExternal2Quantity }; - var result = OpenSkyService.Instance.PositionReportAsync(positionReport).Result; + var result = this.openSkyServiceInstance.PositionReportAsync(positionReport).Result; if (!result.IsError) { @@ -1391,7 +1358,7 @@ private void UploadPositionReport() } } }) - { Name = "SimConnect.Flight.UploadPositionReport" }.Start(); + { Name = "SimConnect.Flight.UploadPositionReport" }.Start(); } } } \ No newline at end of file diff --git a/OpenSky.Agent.SimConnectMSFS/SimConnect.GroundHandling.cs b/OpenSky.Agent.Simulator/Simulator.GroundHandling.cs similarity index 95% rename from OpenSky.Agent.SimConnectMSFS/SimConnect.GroundHandling.cs rename to OpenSky.Agent.Simulator/Simulator.GroundHandling.cs index df71919..2cbf162 100644 --- a/OpenSky.Agent.SimConnectMSFS/SimConnect.GroundHandling.cs +++ b/OpenSky.Agent.Simulator/Simulator.GroundHandling.cs @@ -1,27 +1,27 @@ // -------------------------------------------------------------------------------------------------------------------- -// +// // OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- -namespace OpenSky.AgentMSFS.SimConnect +namespace OpenSky.Agent.Simulator { using System; using System.Diagnostics; using System.Threading; - using OpenSky.Agent.Simulator; - using OpenSky.AgentMSFS.Models; + using OpenSky.Agent.Simulator.Enums; + using OpenSky.Agent.Simulator.Tools; using OpenSky.FlightLogXML; using TomsToolbox.Essentials; /// ------------------------------------------------------------------------------------------------- /// - /// Simconnect client - ground handling code. + /// Simulator interface - ground handling. /// /// ------------------------------------------------------------------------------------------------- - public partial class SimConnect + public partial class Simulator { /// ------------------------------------------------------------------------------------------------- /// @@ -214,7 +214,7 @@ public bool SkipGroundHandling(bool startTracking) this.timeSavedBecauseOfSimRate = this.timeSavedBecauseOfSimRate.AddSeconds(secondsToSkip); this.WarpInfo = this.timeSavedBecauseOfSimRate.TotalSeconds >= 1 ? $"Yes, saved {this.timeSavedBecauseOfSimRate:hh\\:mm\\:ss} [*]" : "No [*]"; - this.AddTrackingEvent(this.PrimaryTrackingStruct, this.SecondaryTrackingStruct, FlightTrackingEventType.SkippedGroundHandling, OpenSkyColors.OpenSkyWarningOrange, "Skipped ground handling"); + this.AddTrackingEvent(this.PrimaryTracking, this.SecondaryTracking, FlightTrackingEventType.SkippedGroundHandling, OpenSkyColors.OpenSkyWarningOrange, "Skipped ground handling"); return true; } @@ -244,7 +244,7 @@ public bool SpeedUpGroundHandling() this.WarpInfo = this.timeSavedBecauseOfSimRate.TotalSeconds >= 1 ? $"Yes, saved {this.timeSavedBecauseOfSimRate:hh\\:mm\\:ss} [*]" : "No [*]"; this.Flight.FuelLoadingComplete = DateTimeOffset.UtcNow.AddSeconds(fuelSecondsLeft / 2); this.Flight.PayloadLoadingComplete = DateTimeOffset.UtcNow.AddSeconds(payloadSecondsLeft / 2); - this.AddTrackingEvent(this.PrimaryTrackingStruct, this.SecondaryTrackingStruct, FlightTrackingEventType.SkippedHalfGroundHandling, OpenSkyColors.OpenSkyWarningOrange, "Skipped half ground handling"); + this.AddTrackingEvent(this.PrimaryTracking, this.SecondaryTracking, FlightTrackingEventType.SkippedHalfGroundHandling, OpenSkyColors.OpenSkyWarningOrange, "Skipped half ground handling"); return true; } @@ -353,7 +353,7 @@ private void DoGroundHandling() { this.FuelLoadingComplete = true; this.PayloadLoadingComplete = true; - this.AddTrackingEvent(this.PrimaryTrackingStruct, this.SecondaryTrackingStruct, FlightTrackingEventType.GroundHandlingComplete, OpenSkyColors.OpenSkyTealLight, "Ground handling complete"); + this.AddTrackingEvent(this.PrimaryTracking, this.SecondaryTracking, FlightTrackingEventType.GroundHandlingComplete, OpenSkyColors.OpenSkyTealLight, "Ground handling complete"); if (this.TrackingStatus == TrackingStatus.GroundOperations) { diff --git a/OpenSky.Agent.SimConnectMSFS/SimConnect.Process.PositionReports.cs b/OpenSky.Agent.Simulator/Simulator.Markers.cs similarity index 54% rename from OpenSky.Agent.SimConnectMSFS/SimConnect.Process.PositionReports.cs rename to OpenSky.Agent.Simulator/Simulator.Markers.cs index fd57896..14f3ba2 100644 --- a/OpenSky.Agent.SimConnectMSFS/SimConnect.Process.PositionReports.cs +++ b/OpenSky.Agent.Simulator/Simulator.Markers.cs @@ -1,35 +1,47 @@ // -------------------------------------------------------------------------------------------------------------------- -// +// // OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- -namespace OpenSky.AgentMSFS.SimConnect +namespace OpenSky.Agent.Simulator { using System; + using System.Collections.Generic; + using System.Collections.ObjectModel; using System.Device.Location; + using System.Diagnostics; using System.Windows; + using System.Windows.Media; using JetBrains.Annotations; using Microsoft.Maps.MapControl.WPF; + using OpenSky.Agent.Simulator.Enums; using OpenSky.Agent.Simulator.Models; - using OpenSky.AgentMSFS.Models; - using OpenSky.AgentMSFS.SimConnect.Structs; + using OpenSky.Agent.Simulator.Tools; + using OpenSky.FlightLogXML; using OpenSkyApi; + using TrackingEventLogEntry = OpenSky.Agent.Simulator.Models.TrackingEventLogEntry; + using TrackingEventMarker = OpenSky.Agent.Simulator.Models.TrackingEventMarker; + /// ------------------------------------------------------------------------------------------------- - /// - /// Simconnect client - position reports code. - /// - /// - /// sushi.at, 17/03/2021. - /// + /// + /// Simulator interface - map markers. + /// /// ------------------------------------------------------------------------------------------------- - public partial class SimConnect + public partial class Simulator { + /// ------------------------------------------------------------------------------------------------- + /// + /// The tracking event markers. + /// + /// ------------------------------------------------------------------------------------------------- + private readonly List trackingEventMarkers = new(); + /// ------------------------------------------------------------------------------------------------- /// /// The last distance comparison used for a position report. @@ -53,6 +65,20 @@ public partial class SimConnect [CanBeNull] private GeoCoordinate lastPositionReport; + /// ------------------------------------------------------------------------------------------------- + /// + /// Occurs when the plane's location changed. + /// + /// ------------------------------------------------------------------------------------------------- + public event EventHandler LocationChanged; + + /// ------------------------------------------------------------------------------------------------- + /// + /// Occurs when SimConnect adds a new tracking event marker. + /// + /// ------------------------------------------------------------------------------------------------- + public event EventHandler TrackingEventMarkerAdded; + /// ------------------------------------------------------------------------------------------------- /// /// Gets the aircraft trail locations collection to draw a poly line on the map. @@ -81,6 +107,96 @@ private set } } + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets the tracking event log entries. + /// + /// ------------------------------------------------------------------------------------------------- + public ObservableCollection TrackingEventLogEntries { get; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Replay simbrief waypoint and tracking event markers (new tracking view was opened). + /// + /// + /// sushi.at, 18/03/2021. + /// + /// ------------------------------------------------------------------------------------------------- + public void ReplayMapMarkers() + { + Debug.WriteLine("SimConnect is replaying map markers to listeners..."); + + UpdateGUIDelegate restoreMarkers = () => + { + foreach (var waypointMarker in this.simbriefWaypointMarkers) + { + this.SimbriefWaypointMarkerAdded?.Invoke(this, waypointMarker); + } + + lock (this.trackingEventMarkers) + { + foreach (var trackingEventMarker in this.trackingEventMarkers) + { + this.TrackingEventMarkerAdded?.Invoke(this, trackingEventMarker); + } + } + }; + Application.Current.Dispatcher.BeginInvoke(restoreMarkers); + } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Add a tracking event to the map and log. + /// + /// + /// sushi.at, 31/01/2022. + /// + /// + /// The primary Simconnect tracking data. + /// + /// + /// The secondary Simconnect tracking data. + /// + /// + /// The flight tracking event type. + /// + /// + /// The color to use for the marker. + /// + /// + /// The event text (what happened?). + /// + /// ------------------------------------------------------------------------------------------------- + private void AddTrackingEvent(PrimaryTracking primary, SecondaryTracking secondary, FlightTrackingEventType type, Color color, string text) + { + if (this.TrackingStatus != TrackingStatus.Tracking && this.TrackingStatus != TrackingStatus.GroundOperations) + { + return; + } + + UpdateGUIDelegate addTrackingEvent = () => + { + Debug.WriteLine($"Adding tracking event: {text}"); + if (this.lastNonPositionReportMarker == null || this.lastNonPositionReportMarker.GetDistanceTo(primary) >= 20) + { + lock (this.trackingEventMarkers) + { + var newMarker = new TrackingEventMarker(primary, secondary, this.WeightAndBalance.FuelTotalQuantity, 16, color, text); + this.lastNonPositionReportMarker = newMarker; + this.trackingEventMarkers.Add(newMarker); + this.TrackingEventMarkerAdded?.Invoke(this, newMarker); + } + } + else + { + this.lastNonPositionReportMarker.AddEventToMarker(DateTime.UtcNow, text); + } + + this.TrackingEventLogEntries.Add(new TrackingEventLogEntry(type, DateTime.UtcNow, color, text, primary.MapLocation)); + }; + Application.Current.Dispatcher.BeginInvoke(addTrackingEvent); + } + /// ------------------------------------------------------------------------------------------------- /// /// Adds a position report to the map if needed (poly line point and position report point if requested). @@ -108,8 +224,8 @@ private void AddPositionReport(PrimaryTracking primary) { lock (this.trackingEventMarkers) { - this.AircraftTrailLocations.Add(new AircraftTrailLocation(DateTime.UtcNow, primary, this.SecondaryTrackingStruct, this.WeightAndBalanceStruct.FuelTotalQuantity)); - var newMarker = new TrackingEventMarker(primary, this.SecondaryTrackingStruct, this.WeightAndBalanceStruct.FuelTotalQuantity, 8, OpenSkyColors.OpenSkyTeal, "Position report"); + this.AircraftTrailLocations.Add(new AircraftTrailLocation(DateTime.UtcNow, primary, this.SecondaryTracking, this.WeightAndBalance.FuelTotalQuantity)); + var newMarker = new TrackingEventMarker(primary, this.SecondaryTracking, this.WeightAndBalance.FuelTotalQuantity, 8, OpenSkyColors.OpenSkyTeal, "Position report"); this.trackingEventMarkers.Add(newMarker); this.TrackingEventMarkerAdded?.Invoke(this, newMarker); } @@ -139,7 +255,7 @@ private void AddPositionReport(PrimaryTracking primary) } else { - var radioHeight = this.AircraftIdentityStruct.EngineType is EngineType.Jet or EngineType.Turboprop ? 2500 : 1000; + var radioHeight = this.AircraftIdentity.EngineType is EngineType.Jet or EngineType.Turboprop ? 2500 : 1000; if (primary.RadioHeight < radioHeight) { if (this.IsTurning) @@ -180,8 +296,8 @@ private void AddPositionReport(PrimaryTracking primary) { lock (this.trackingEventMarkers) { - this.AircraftTrailLocations.Add(new AircraftTrailLocation(DateTime.UtcNow, primary, this.SecondaryTrackingStruct, this.WeightAndBalanceStruct.FuelTotalQuantity)); - var newMarker = new TrackingEventMarker(primary, this.SecondaryTrackingStruct, this.WeightAndBalanceStruct.FuelTotalQuantity, 8, OpenSkyColors.OpenSkyTeal, "Position report"); + this.AircraftTrailLocations.Add(new AircraftTrailLocation(DateTime.UtcNow, primary, this.SecondaryTracking, this.WeightAndBalance.FuelTotalQuantity)); + var newMarker = new TrackingEventMarker(primary, this.SecondaryTracking, this.WeightAndBalance.FuelTotalQuantity, 8, OpenSkyColors.OpenSkyTeal, "Position report"); this.trackingEventMarkers.Add(newMarker); this.TrackingEventMarkerAdded?.Invoke(this, newMarker); } diff --git a/OpenSky.Agent.SimConnectMSFS/SimConnect.Process.ChangeOverTime.cs b/OpenSky.Agent.Simulator/Simulator.Process.ChangeOverTime.cs similarity index 93% rename from OpenSky.Agent.SimConnectMSFS/SimConnect.Process.ChangeOverTime.cs rename to OpenSky.Agent.Simulator/Simulator.Process.ChangeOverTime.cs index c369b52..a8c8659 100644 --- a/OpenSky.Agent.SimConnectMSFS/SimConnect.Process.ChangeOverTime.cs +++ b/OpenSky.Agent.Simulator/Simulator.Process.ChangeOverTime.cs @@ -1,29 +1,24 @@ // -------------------------------------------------------------------------------------------------------------------- -// +// // OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- -namespace OpenSky.AgentMSFS.SimConnect +namespace OpenSky.Agent.Simulator { using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; - using OpenSky.Agent.SimConnectMSFS.Structs; - using OpenSky.AgentMSFS.Models; - using OpenSky.AgentMSFS.SimConnect.Structs; + using OpenSky.Agent.Simulator.Models; /// ------------------------------------------------------------------------------------------------- - /// - /// Simconnect client - change over time tracking code. - /// - /// - /// sushi.at, 17/03/2021. - /// + /// + /// Simulator interface - change over time processing. + /// /// ------------------------------------------------------------------------------------------------- - public partial class SimConnect + public partial class Simulator { /// ------------------------------------------------------------------------------------------------- /// diff --git a/OpenSky.Agent.SimConnectMSFS/SimConnect.Process.FlightPhases.cs b/OpenSky.Agent.Simulator/Simulator.Process.FlightPhases.cs similarity index 85% rename from OpenSky.Agent.SimConnectMSFS/SimConnect.Process.FlightPhases.cs rename to OpenSky.Agent.Simulator/Simulator.Process.FlightPhases.cs index ac3669b..659703e 100644 --- a/OpenSky.Agent.SimConnectMSFS/SimConnect.Process.FlightPhases.cs +++ b/OpenSky.Agent.Simulator/Simulator.Process.FlightPhases.cs @@ -1,10 +1,10 @@ // -------------------------------------------------------------------------------------------------------------------- -// +// // OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- -namespace OpenSky.AgentMSFS.SimConnect +namespace OpenSky.Agent.Simulator { using System; using System.Device.Location; @@ -12,23 +12,18 @@ namespace OpenSky.AgentMSFS.SimConnect using System.Media; using System.Reflection; - using OpenSky.Agent.Simulator; using OpenSky.Agent.Simulator.Enums; - using OpenSky.AgentMSFS.Models; - using OpenSky.AgentMSFS.SimConnect.Enums; + using OpenSky.Agent.Simulator.Models; using OpenSky.FlightLogXML; using OpenSkyApi; /// ------------------------------------------------------------------------------------------------- - /// - /// Simconnect client - data processing code. - /// - /// - /// sushi.at, 17/03/2021. - /// + /// + /// Simulator interface - flight phase processing. + /// /// ------------------------------------------------------------------------------------------------- - public partial class SimConnect + public partial class Simulator { /// ------------------------------------------------------------------------------------------------- /// @@ -183,19 +178,19 @@ private void TransitionFlightPhase() var unknownFlightPhase = true; var newNextStepFlashing = false; - var currentPosition = this.PrimaryTrackingStruct.GeoCoordinate; + var currentPosition = this.PrimaryTracking.GeoCoordinate; var distanceToDepartureAirport = new GeoCoordinate(this.Flight?.Origin.Latitude ?? 0, this.Flight?.Origin.Longitude ?? 0).GetDistanceTo(currentPosition) / 1000 * 0.539957; var distanceToDestinationAirport = new GeoCoordinate(this.Flight?.Destination.Latitude ?? 0, this.Flight?.Destination.Longitude ?? 0).GetDistanceTo(currentPosition) / 1000 * 0.539957; var distanceToAlternateAirport = new GeoCoordinate(this.Flight?.Alternate.Latitude ?? 0, this.Flight?.Alternate.Longitude ?? 0).GetDistanceTo(currentPosition) / 1000 * 0.539957; - if (!this.WasAirborne && this.PrimaryTrackingStruct.RadioHeight >= 50) + if (!this.WasAirborne && this.PrimaryTracking.RadioHeight >= 50) { this.WasAirborne = true; - this.AddTrackingEvent(this.PrimaryTrackingStruct, this.SecondaryTrackingStruct, FlightTrackingEventType.Airborne, OpenSkyColors.OpenSkyTeal, "Airborne"); + this.AddTrackingEvent(this.PrimaryTracking, this.SecondaryTracking, FlightTrackingEventType.Airborne, OpenSkyColors.OpenSkyTeal, "Airborne"); } // InMenu - if (this.PrimaryTrackingStruct.OnGround && Math.Abs(Math.Round(this.PrimaryTrackingStruct.Latitude, 1)) < 0.5 && Math.Abs(Math.Round(this.PrimaryTrackingStruct.Longitude, 1)) < 0.5) + if (this.PrimaryTracking.OnGround && Math.Abs(Math.Round(this.PrimaryTracking.Latitude, 1)) < 0.5 && Math.Abs(Math.Round(this.PrimaryTracking.Longitude, 1)) < 0.5) { this.FlightPhase = FlightPhase.Briefing; this.NextFlightStep = string.Empty; @@ -208,17 +203,16 @@ private void TransitionFlightPhase() player.Play(); SpeechSoundPacks.Instance.PlaySpeechEvent(SpeechEvent.AbortedSimMainMenu); this.StopTracking(false); - this.fsConnect.SetText("Tracking aborted, sim returned to main menu.", 5); } } // PreFlight - if (!this.WasAirborne && this.PrimaryTrackingStruct.OnGround && !this.SecondaryTrackingStruct.EngineRunning && this.SecondaryTrackingStruct.Pushback == Pushback.NoPushback) + if (!this.WasAirborne && this.PrimaryTracking.OnGround && !this.SecondaryTracking.EngineRunning && this.SecondaryTracking.Pushback == Pushback.NoPushback) { if (unknownFlightPhase) { this.FlightPhase = FlightPhase.PreFlight; - this.NextFlightStep = this.TrackingStatus == TrackingStatus.GroundOperations ? "Next step: Wait for ground handling to complete" : $"Next step: Turn on the engine{(this.AircraftIdentityStruct.EngineCount > 1 ? "s" : string.Empty)}"; + this.NextFlightStep = this.TrackingStatus == TrackingStatus.GroundOperations ? "Next step: Wait for ground handling to complete" : $"Next step: Turn on the engine{(this.AircraftIdentity.EngineCount > 1 ? "s" : string.Empty)}"; newNextStepFlashing = this.TrackingStatus != TrackingStatus.GroundOperations; unknownFlightPhase = false; } @@ -229,7 +223,7 @@ private void TransitionFlightPhase() } // Pushback - if (this.SecondaryTrackingStruct.Pushback != Pushback.NoPushback) + if (this.SecondaryTracking.Pushback != Pushback.NoPushback) { if (unknownFlightPhase) { @@ -245,7 +239,7 @@ private void TransitionFlightPhase() } // TaxiOut - if (!this.WasAirborne && this.SecondaryTrackingStruct.EngineRunning && this.PrimaryTrackingStruct.GroundSpeed < 40 && this.PrimaryTrackingStruct.OnGround && this.SecondaryTrackingStruct.Pushback == Pushback.NoPushback) + if (!this.WasAirborne && this.SecondaryTracking.EngineRunning && this.PrimaryTracking.GroundSpeed < 40 && this.PrimaryTracking.OnGround && this.SecondaryTracking.Pushback == Pushback.NoPushback) { if (unknownFlightPhase) { @@ -261,8 +255,8 @@ private void TransitionFlightPhase() } // Takeoff - var departureRadioHeight = this.AircraftIdentityStruct.EngineType is EngineType.Jet or EngineType.Turboprop ? 1000 : 100; - if (!this.WasAirborne && this.PrimaryTrackingStruct.GroundSpeed > 40 && this.PrimaryTrackingStruct.RadioHeight <= departureRadioHeight) + var departureRadioHeight = this.AircraftIdentity.EngineType is EngineType.Jet or EngineType.Turboprop ? 1000 : 100; + if (!this.WasAirborne && this.PrimaryTracking.GroundSpeed > 40 && this.PrimaryTracking.RadioHeight <= departureRadioHeight) { if (unknownFlightPhase) { @@ -277,7 +271,7 @@ private void TransitionFlightPhase() } // Departure - if (distanceToDepartureAirport < 10 && this.VerticalProfile == VerticalProfile.Climbing && !this.PrimaryTrackingStruct.OnGround) + if (distanceToDepartureAirport < 10 && this.VerticalProfile == VerticalProfile.Climbing && !this.PrimaryTracking.OnGround) { if (unknownFlightPhase) { @@ -292,8 +286,8 @@ private void TransitionFlightPhase() } // Climb - var approachDistance = this.AircraftIdentityStruct.EngineType is EngineType.Jet or EngineType.Turboprop ? 40 : 10; - if (distanceToDepartureAirport >= approachDistance && this.VerticalProfile == VerticalProfile.Climbing && !this.PrimaryTrackingStruct.OnGround) + var approachDistance = this.AircraftIdentity.EngineType is EngineType.Jet or EngineType.Turboprop ? 40 : 10; + if (distanceToDepartureAirport >= approachDistance && this.VerticalProfile == VerticalProfile.Climbing && !this.PrimaryTracking.OnGround) { if (unknownFlightPhase) { @@ -308,7 +302,7 @@ private void TransitionFlightPhase() } // Cruise - if (distanceToDestinationAirport >= approachDistance && distanceToAlternateAirport >= approachDistance && this.VerticalProfile == VerticalProfile.Level && !this.PrimaryTrackingStruct.OnGround) + if (distanceToDestinationAirport >= approachDistance && distanceToAlternateAirport >= approachDistance && this.VerticalProfile == VerticalProfile.Level && !this.PrimaryTracking.OnGround) { if (unknownFlightPhase) { @@ -323,7 +317,7 @@ private void TransitionFlightPhase() } // Descent - if (distanceToDestinationAirport >= approachDistance && distanceToAlternateAirport >= approachDistance && this.VerticalProfile == VerticalProfile.Descending && !this.PrimaryTrackingStruct.OnGround) + if (distanceToDestinationAirport >= approachDistance && distanceToAlternateAirport >= approachDistance && this.VerticalProfile == VerticalProfile.Descending && !this.PrimaryTracking.OnGround) { if (unknownFlightPhase) { @@ -338,7 +332,7 @@ private void TransitionFlightPhase() } // Approach - if ((distanceToDestinationAirport < approachDistance || distanceToAlternateAirport < approachDistance) && !this.PrimaryTrackingStruct.OnGround && this.PrimaryTrackingStruct.RadioHeight > 500) + if ((distanceToDestinationAirport < approachDistance || distanceToAlternateAirport < approachDistance) && !this.PrimaryTracking.OnGround && this.PrimaryTracking.RadioHeight > 500) { if (unknownFlightPhase) { @@ -353,7 +347,7 @@ private void TransitionFlightPhase() } // Landing - if (this.WasAirborne && this.PrimaryTrackingStruct.RadioHeight <= 500 && this.PrimaryTrackingStruct.GroundSpeed >= 40 && this.SecondaryTrackingStruct.EngineRunning) + if (this.WasAirborne && this.PrimaryTracking.RadioHeight <= 500 && this.PrimaryTracking.GroundSpeed >= 40 && this.SecondaryTracking.EngineRunning) { // Landing is allowed to override descent in case of return to origin airport or I guess landing anywhere but the destination/alternate if (unknownFlightPhase || this.FlightPhase == FlightPhase.Descent) @@ -372,7 +366,7 @@ private void TransitionFlightPhase() // GoAround todo // TaxiIn - if (this.WasAirborne && this.SecondaryTrackingStruct.EngineRunning && this.PrimaryTrackingStruct.GroundSpeed < 40 && this.PrimaryTrackingStruct.OnGround) + if (this.WasAirborne && this.SecondaryTracking.EngineRunning && this.PrimaryTracking.GroundSpeed < 40 && this.PrimaryTracking.OnGround) { if (unknownFlightPhase) { @@ -394,7 +388,7 @@ private void TransitionFlightPhase() } // PostFlight - if (this.WasAirborne && this.PrimaryTrackingStruct.OnGround && !this.SecondaryTrackingStruct.EngineRunning) + if (this.WasAirborne && this.PrimaryTracking.OnGround && !this.SecondaryTracking.EngineRunning) { if (unknownFlightPhase) { @@ -409,7 +403,7 @@ private void TransitionFlightPhase() } } - if (this.PrimaryTrackingStruct.CrashSequence != CrashSequence.Off) + if (this.PrimaryTracking.Crash) { // todo save pre-crash flight phase to submit as part of crash report? implement this in the systems section? diff --git a/OpenSky.Agent.SimConnectMSFS/SimConnect.Process.Landing.cs b/OpenSky.Agent.Simulator/Simulator.Process.Landing.cs similarity index 74% rename from OpenSky.Agent.SimConnectMSFS/SimConnect.Process.Landing.cs rename to OpenSky.Agent.Simulator/Simulator.Process.Landing.cs index ae328c0..94b4750 100644 --- a/OpenSky.Agent.SimConnectMSFS/SimConnect.Process.Landing.cs +++ b/OpenSky.Agent.Simulator/Simulator.Process.Landing.cs @@ -1,29 +1,25 @@ // -------------------------------------------------------------------------------------------------------------------- -// +// // OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- -namespace OpenSky.AgentMSFS.SimConnect +namespace OpenSky.Agent.Simulator { using System; using System.Collections.ObjectModel; using System.Diagnostics; - using System.Windows; - using OpenSky.Agent.SimConnectMSFS.Helpers; - using OpenSky.AgentMSFS.Properties; - - using OpenSky.AgentMSFS.Models; - using OpenSky.AgentMSFS.SimConnect.Helpers; + using OpenSky.Agent.Simulator.Enums; + using OpenSky.Agent.Simulator.Models; using OpenSky.FlightLogXML; /// ------------------------------------------------------------------------------------------------- /// - /// Simconnect client - landing analysis code. + /// Simulator interface - landing processing. /// /// ------------------------------------------------------------------------------------------------- - public partial class SimConnect + public partial class Simulator { /// ------------------------------------------------------------------------------------------------- /// @@ -70,14 +66,15 @@ private void CheckForAndAnalyseLanding(ProcessLandingAnalysis pla) if (this.LandingReports.Count == 1) { // First landing for this flight - this.AddTrackingEvent(this.PrimaryTrackingStruct, this.SecondaryTrackingStruct, FlightTrackingEventType.Touchdown, OpenSkyColors.OpenSkyTeal, "Touchdown"); + this.AddTrackingEvent(this.PrimaryTracking, this.SecondaryTracking, FlightTrackingEventType.Touchdown, OpenSkyColors.OpenSkyTeal, "Touchdown"); // Show landing report notification now? - if (LandingReportNotification.AsSoonAsPossible.Equals(LandingReportNotification.Parse(Settings.Default.LandingReportNotification))) - { - UpdateGUIDelegate showNotification = () => new Views.LandingReport().Show(); - Application.Current.Dispatcher.BeginInvoke(showNotification); - } + // todo RESTORE THIS, via event to agent main project + //if (LandingReportNotification.AsSoonAsPossible.Equals(LandingReportNotification.Parse(Settings.Default.LandingReportNotification))) + //{ + // UpdateGUIDelegate showNotification = () => new Views.LandingReport().Show(); + // Application.Current.Dispatcher.BeginInvoke(showNotification); + //} } } } diff --git a/OpenSky.Agent.SimConnectMSFS/SimConnect.Process.Lights.cs b/OpenSky.Agent.Simulator/Simulator.Process.Lights.cs similarity index 56% rename from OpenSky.Agent.SimConnectMSFS/SimConnect.Process.Lights.cs rename to OpenSky.Agent.Simulator/Simulator.Process.Lights.cs index f0b34f2..c1c1a6a 100644 --- a/OpenSky.Agent.SimConnectMSFS/SimConnect.Process.Lights.cs +++ b/OpenSky.Agent.Simulator/Simulator.Process.Lights.cs @@ -1,28 +1,25 @@ // -------------------------------------------------------------------------------------------------------------------- -// +// // OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- -namespace OpenSky.AgentMSFS.SimConnect +namespace OpenSky.Agent.Simulator { using System.Diagnostics; - using OpenSky.AgentMSFS.Models; - using OpenSky.AgentMSFS.SimConnect.Helpers; + using OpenSky.Agent.Simulator.Enums; + using OpenSky.Agent.Simulator.Models; using OpenSky.FlightLogXML; using OpenSkyApi; /// ------------------------------------------------------------------------------------------------- - /// - /// Simconnect client - lights monitoring code. - /// - /// - /// sushi.at, 17/03/2021. - /// + /// + /// Simulator interface - lights. + /// /// ------------------------------------------------------------------------------------------------- - public partial class SimConnect + public partial class Simulator { /// ------------------------------------------------------------------------------------------------- /// @@ -46,49 +43,47 @@ private void MonitorLights(ProcessSecondaryTracking pst) { if (pst.Old.LightBeacon != pst.New.LightBeacon) { - this.AddTrackingEvent(this.PrimaryTrackingStruct, pst.New, FlightTrackingEventType.Beacon, OpenSkyColors.OpenSkyLightYellow, pst.New.LightBeacon ? "Beacon on" : "Beacon off"); + this.AddTrackingEvent(this.PrimaryTracking, pst.New, FlightTrackingEventType.Beacon, OpenSkyColors.OpenSkyLightYellow, pst.New.LightBeacon ? "Beacon on" : "Beacon off"); // Engine running? if (!pst.New.LightBeacon && pst.New.EngineRunning && (this.TrackingStatus is TrackingStatus.GroundOperations or TrackingStatus.Tracking)) { - this.AddTrackingEvent(this.PrimaryTrackingStruct, pst.New, FlightTrackingEventType.BeaconOffEnginesOn, OpenSkyColors.OpenSkyRed, "Beacon turned off while engine was running"); - this.fsConnect.SetText("OpenSky Warning: Beacon turned off while engine was running", 5); + this.AddTrackingEvent(this.PrimaryTracking, pst.New, FlightTrackingEventType.BeaconOffEnginesOn, OpenSkyColors.OpenSkyRed, "Beacon turned off while engine was running"); } } if (pst.Old.LightNav != pst.New.LightNav) { - this.AddTrackingEvent(this.PrimaryTrackingStruct, pst.New, FlightTrackingEventType.NavLights, OpenSkyColors.OpenSkyLightYellow, pst.New.LightNav ? "Nav lights on" : "Nav lights off"); + this.AddTrackingEvent(this.PrimaryTracking, pst.New, FlightTrackingEventType.NavLights, OpenSkyColors.OpenSkyLightYellow, pst.New.LightNav ? "Nav lights on" : "Nav lights off"); } if (pst.Old.LightStrobe != pst.New.LightStrobe) { - this.AddTrackingEvent(this.PrimaryTrackingStruct, pst.New, FlightTrackingEventType.Strobe, OpenSkyColors.OpenSkyLightYellow, pst.New.LightStrobe ? "Strobe lights on" : "Strobe lights off"); + this.AddTrackingEvent(this.PrimaryTracking, pst.New, FlightTrackingEventType.Strobe, OpenSkyColors.OpenSkyLightYellow, pst.New.LightStrobe ? "Strobe lights on" : "Strobe lights off"); } if (pst.Old.LightTaxi != pst.New.LightTaxi) { - this.AddTrackingEvent(this.PrimaryTrackingStruct, pst.New, FlightTrackingEventType.TaxiLights, OpenSkyColors.OpenSkyLightYellow, pst.New.LightTaxi ? "Taxi lights on" : "Taxi lights off"); + this.AddTrackingEvent(this.PrimaryTracking, pst.New, FlightTrackingEventType.TaxiLights, OpenSkyColors.OpenSkyLightYellow, pst.New.LightTaxi ? "Taxi lights on" : "Taxi lights off"); } if (pst.Old.LightLanding != pst.New.LightLanding) { - this.AddTrackingEvent(this.PrimaryTrackingStruct, pst.New, FlightTrackingEventType.LandingLights, OpenSkyColors.OpenSkyLightYellow, pst.New.LightLanding ? "Landing lights on" : "Landing lights off"); + this.AddTrackingEvent(this.PrimaryTracking, pst.New, FlightTrackingEventType.LandingLights, OpenSkyColors.OpenSkyLightYellow, pst.New.LightLanding ? "Landing lights on" : "Landing lights off"); } if (this.TrackingStatus == TrackingStatus.Tracking) { - if (this.AircraftIdentityStruct.EngineType is EngineType.Jet or EngineType.Turboprop) + if (this.AircraftIdentity.EngineType is EngineType.Jet or EngineType.Turboprop) { // 10000 feet landing lights (give 500 feet spare) - if (this.PrimaryTrackingStruct.IndicatedAltitude < 9500 && !this.PrimaryTrackingStruct.OnGround && !pst.New.LightLanding) + if (this.PrimaryTracking.IndicatedAltitude < 9500 && !this.PrimaryTracking.OnGround && !pst.New.LightLanding) { if (!this.landingLightWarningActive) { - Debug.WriteLine($"Landing lights 10K: indicated {this.PrimaryTrackingStruct.IndicatedAltitude}, alt {this.PrimaryTrackingStruct.Altitude}"); + Debug.WriteLine($"Landing lights 10K: indicated {this.PrimaryTracking.IndicatedAltitude}, alt {this.PrimaryTracking.Altitude}"); this.landingLightWarningActive = true; - this.AddTrackingEvent(this.PrimaryTrackingStruct, pst.New, FlightTrackingEventType.LandingLightsOffBelow10K, OpenSkyColors.OpenSkyRed, "Landing lights off below 10k feet"); - this.fsConnect.SetText("OpenSky Warning: Landing lights off below 10k feet", 5); + this.AddTrackingEvent(this.PrimaryTracking, pst.New, FlightTrackingEventType.LandingLightsOffBelow10K, OpenSkyColors.OpenSkyRed, "Landing lights off below 10k feet"); } } else @@ -99,13 +94,12 @@ private void MonitorLights(ProcessSecondaryTracking pst) else { // 300 feet AGL landing lights - if (this.PrimaryTrackingStruct.RadioHeight < 300 && !this.PrimaryTrackingStruct.OnGround && !pst.New.LightLanding) + if (this.PrimaryTracking.RadioHeight < 300 && !this.PrimaryTracking.OnGround && !pst.New.LightLanding) { if (!this.landingLightWarningActive) { this.landingLightWarningActive = true; - this.AddTrackingEvent(this.PrimaryTrackingStruct, pst.New, FlightTrackingEventType.LandingLightsOffBelow300AGL, OpenSkyColors.OpenSkyRed, "Landing lights off below 300 feet AGL"); - this.fsConnect.SetText("OpenSky Warning: Landing lights off below 300 feet AGL", 5); + this.AddTrackingEvent(this.PrimaryTracking, pst.New, FlightTrackingEventType.LandingLightsOffBelow300AGL, OpenSkyColors.OpenSkyRed, "Landing lights off below 300 feet AGL"); } } else diff --git a/OpenSky.Agent.SimConnectMSFS/SimConnect.Process.Systems.cs b/OpenSky.Agent.Simulator/Simulator.Process.Systems.cs similarity index 69% rename from OpenSky.Agent.SimConnectMSFS/SimConnect.Process.Systems.cs rename to OpenSky.Agent.Simulator/Simulator.Process.Systems.cs index 5ccb83a..754ab41 100644 --- a/OpenSky.Agent.SimConnectMSFS/SimConnect.Process.Systems.cs +++ b/OpenSky.Agent.Simulator/Simulator.Process.Systems.cs @@ -1,10 +1,10 @@ // -------------------------------------------------------------------------------------------------------------------- -// +// // OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- -namespace OpenSky.AgentMSFS.SimConnect +namespace OpenSky.Agent.Simulator { using System; using System.Diagnostics; @@ -12,27 +12,19 @@ namespace OpenSky.AgentMSFS.SimConnect using System.Reflection; using System.Windows; - using OpenSky.Agent.Simulator; using OpenSky.Agent.Simulator.Enums; using OpenSky.Agent.Simulator.Models; - using OpenSky.AgentMSFS.Properties; - - using OpenSky.AgentMSFS.Models; - using OpenSky.AgentMSFS.SimConnect.Enums; - using OpenSky.AgentMSFS.SimConnect.Helpers; + using OpenSky.Agent.Simulator.Tools; using OpenSky.FlightLogXML; - using TrackingEventMarker = Models.TrackingEventMarker; + using TrackingEventMarker = OpenSky.Agent.Simulator.Models.TrackingEventMarker; /// ------------------------------------------------------------------------------------------------- - /// - /// Simconnect client - systems monitoring code. - /// - /// - /// sushi.at, 17/03/2021. - /// + /// + /// Simulator interface - systems processing. + /// /// ------------------------------------------------------------------------------------------------- - public partial class SimConnect + public partial class Simulator { /// ------------------------------------------------------------------------------------------------- /// @@ -48,6 +40,13 @@ public partial class SimConnect /// ------------------------------------------------------------------------------------------------- private DateTime lastStall = DateTime.MinValue; + /// ------------------------------------------------------------------------------------------------- + /// + /// Is the 250 below 10000 speed limit warning currently active? + /// + /// ------------------------------------------------------------------------------------------------- + private bool speedLimitWarningActive; + /// ------------------------------------------------------------------------------------------------- /// /// Monitor primary systems. @@ -67,7 +66,7 @@ private void MonitorPrimarySystems(ProcessPrimaryTracking ppt) if ((DateTime.UtcNow - this.lastOverspeed).TotalSeconds > 10) { this.lastOverspeed = DateTime.UtcNow; - this.AddTrackingEvent(ppt.New, this.SecondaryTrackingStruct, FlightTrackingEventType.Overspeed, OpenSkyColors.OpenSkyRed, "Overspeed"); + this.AddTrackingEvent(ppt.New, this.SecondaryTracking, FlightTrackingEventType.Overspeed, OpenSkyColors.OpenSkyRed, "Overspeed"); } } @@ -77,10 +76,25 @@ private void MonitorPrimarySystems(ProcessPrimaryTracking ppt) if ((DateTime.UtcNow - this.lastStall).TotalSeconds > 10) { this.lastStall = DateTime.UtcNow; - this.AddTrackingEvent(ppt.New, this.SecondaryTrackingStruct, FlightTrackingEventType.Stall, OpenSkyColors.OpenSkyRed, "Stall"); + this.AddTrackingEvent(ppt.New, this.SecondaryTracking, FlightTrackingEventType.Stall, OpenSkyColors.OpenSkyRed, "Stall"); } } + // 10000 feet speed limit 250 knots (give 500 feet spare) + if (ppt.New.IndicatedAltitude < 9500 && !ppt.New.OnGround && ppt.New.AirspeedIndicated > 250) + { + if (!this.speedLimitWarningActive) + { + Debug.WriteLine($"Speed limit 250 below 10K: indicated {ppt.New.IndicatedAltitude}, alt {ppt.New.Altitude} => {ppt.New.AirspeedIndicated} knots"); + this.speedLimitWarningActive = true; + this.AddTrackingEvent(ppt.New, this.SecondaryTracking, FlightTrackingEventType.SpeedLimit250Below10K, OpenSkyColors.OpenSkyRed, "Speed over 250 below 10k feet"); + } + } + else + { + this.speedLimitWarningActive = false; + } + // Slew activated? if (ppt.New.SlewActive && (this.TrackingStatus is TrackingStatus.GroundOperations or TrackingStatus.Tracking)) { @@ -90,7 +104,6 @@ private void MonitorPrimarySystems(ProcessPrimaryTracking ppt) player.Play(); SpeechSoundPacks.Instance.PlaySpeechEvent(SpeechEvent.AbortedSlew); this.StopTracking(false); - this.fsConnect.SetText("OpenSky Warning: Tracking aborted, slew detected.", 5); } // Teleport to another position? @@ -107,7 +120,6 @@ private void MonitorPrimarySystems(ProcessPrimaryTracking ppt) player.Play(); SpeechSoundPacks.Instance.PlaySpeechEvent(SpeechEvent.AbortedTeleport); this.StopTracking(false); - this.fsConnect.SetText("OpenSky Warning: Tracking aborted, teleport detected.", 5); } } } @@ -128,7 +140,7 @@ private void MonitorSecondarySystems(ProcessSecondaryTracking pst) // Was the engine turned off/on? if (pst.Old.EngineRunning != pst.New.EngineRunning) { - this.AddTrackingEvent(this.PrimaryTrackingStruct, pst.New, FlightTrackingEventType.Engine, OpenSkyColors.OpenSkyTealLight, pst.New.EngineRunning ? "Engine started" : "Engine shut down"); + this.AddTrackingEvent(this.PrimaryTracking, pst.New, FlightTrackingEventType.Engine, OpenSkyColors.OpenSkyTealLight, pst.New.EngineRunning ? "Engine started" : "Engine shut down"); if (pst.New.EngineRunning && this.TrackingStatus == TrackingStatus.Tracking) { SpeechSoundPacks.Instance.PlaySpeechEvent(SpeechEvent.WelcomeOpenSky); @@ -143,25 +155,27 @@ private void MonitorSecondarySystems(ProcessSecondaryTracking pst) player.PlaySync(); SpeechSoundPacks.Instance.PlaySpeechEvent(SpeechEvent.AbortedEnginesGroundHandling); this.StopTracking(false); - this.fsConnect.SetText("OpenSky Warning: Tracking aborted, you cannot start your engines while ground handling isn't complete!", 5); } // Was the beacon light off when the engine was started? if (pst.New.EngineRunning && !pst.New.LightBeacon && (this.TrackingStatus is TrackingStatus.GroundOperations or TrackingStatus.Tracking)) { - this.AddTrackingEvent(this.PrimaryTrackingStruct, pst.New, FlightTrackingEventType.BeaconOffEnginesOn, OpenSkyColors.OpenSkyRed, "Beacon turned off when engine was started"); - this.fsConnect.SetText("OpenSky Warning: Beacon turned off when engine was started", 5); + this.AddTrackingEvent(this.PrimaryTracking, pst.New, FlightTrackingEventType.BeaconOffEnginesOn, OpenSkyColors.OpenSkyRed, "Beacon turned off when engine was started"); } // Was the taxi or landing light on when turning on/off the engine? if ((pst.New.LightTaxi || pst.New.LightLanding) && (this.TrackingStatus is TrackingStatus.GroundOperations or TrackingStatus.Tracking)) { - this.AddTrackingEvent(this.PrimaryTrackingStruct, pst.New, FlightTrackingEventType.TaxiLandingLightsEngine, OpenSkyColors.OpenSkyRed, $"OpenSky Warning: Taxi and/or Landing light on when engine was turned {(pst.New.EngineRunning ? "on" : "off")}"); - this.fsConnect.SetText($"OpenSky Warning: Taxi and/or Landing light on when engine was turned {(pst.New.EngineRunning ? "on" : "off")}", 5); + this.AddTrackingEvent( + this.PrimaryTracking, + pst.New, + FlightTrackingEventType.TaxiLandingLightsEngine, + OpenSkyColors.OpenSkyRed, + $"OpenSky Warning: Taxi and/or Landing light on when engine was turned {(pst.New.EngineRunning ? "on" : "off")}"); } // Was the engine turned off on the ground, not moving, while tracking? -> End tracking session, save reports and report to API - if (!pst.New.EngineRunning && this.PrimaryTrackingStruct.OnGround && this.PrimaryTrackingStruct.GroundSpeed < 1 && this.TrackingStatus == TrackingStatus.Tracking) + if (!pst.New.EngineRunning && this.PrimaryTracking.OnGround && this.PrimaryTracking.GroundSpeed < 1 && this.TrackingStatus == TrackingStatus.Tracking) { // todo expand this to battery off and proper shutdown/secure flow for extra xp (enable/disable in the settings) @@ -172,7 +186,6 @@ private void MonitorSecondarySystems(ProcessSecondaryTracking pst) var player = new SoundPlayer(assembly.GetManifestResourceStream("OpenSky.AgentMSFS.Resources.OSnegative.wav")); player.PlaySync(); SpeechSoundPacks.Instance.PlaySpeechEvent(SpeechEvent.EngineOffNeverAirborne); - this.fsConnect.SetText("OpenSky Warning: Engine was turned off, but the plane was never airborne, aborting...", 5); this.StopTracking(false); } else @@ -184,8 +197,7 @@ private void MonitorSecondarySystems(ProcessSecondaryTracking pst) { if (!this.taxiInTurned) { - this.AddTrackingEvent(this.PrimaryTrackingStruct, pst.New, FlightTrackingEventType.EngineOffRunway, OpenSkyColors.OpenSkyWarningOrange, "Engine turned off on the runway?"); - this.fsConnect.SetText("OpenSky Warning: Engine turned off on the runway?", 5); + this.AddTrackingEvent(this.PrimaryTracking, pst.New, FlightTrackingEventType.EngineOffRunway, OpenSkyColors.OpenSkyWarningOrange, "Engine turned off on the runway?"); } this.taxiInStarted = false; @@ -194,19 +206,20 @@ private void MonitorSecondarySystems(ProcessSecondaryTracking pst) // Add one last position report UpdateGUIDelegate addPositionReport = () => { - this.AircraftTrailLocations.Add(new AircraftTrailLocation(DateTime.UtcNow, this.PrimaryTrackingStruct, pst.New, this.WeightAndBalanceStruct.FuelTotalQuantity)); - this.TrackingEventMarkerAdded?.Invoke(this, new TrackingEventMarker(this.PrimaryTrackingStruct, pst.New, this.WeightAndBalanceStruct.FuelTotalQuantity, 8, OpenSkyColors.OpenSkyTeal, "Position report")); + this.AircraftTrailLocations.Add(new AircraftTrailLocation(DateTime.UtcNow, this.PrimaryTracking, pst.New, this.WeightAndBalance.FuelTotalQuantity)); + this.TrackingEventMarkerAdded?.Invoke(this, new TrackingEventMarker(this.PrimaryTracking, pst.New, this.WeightAndBalance.FuelTotalQuantity, 8, OpenSkyColors.OpenSkyTeal, "Position report")); }; Application.Current.Dispatcher.Invoke(addPositionReport); - this.AddTrackingEvent(this.PrimaryTrackingStruct, pst.New, FlightTrackingEventType.TrackingStopped, OpenSkyColors.OpenSkyTealLight, "Flight tracking stopped"); + this.AddTrackingEvent(this.PrimaryTracking, pst.New, FlightTrackingEventType.TrackingStopped, OpenSkyColors.OpenSkyTealLight, "Flight tracking stopped"); // Show landing report notification now? - if (LandingReportNotification.AfterTurningEnginesOff.Equals(LandingReportNotification.Parse(Settings.Default.LandingReportNotification))) - { - UpdateGUIDelegate showNotification = () => new Views.LandingReport().Show(); - Application.Current.Dispatcher.BeginInvoke(showNotification); - } + // TODO RESTORE THIS + //if (LandingReportNotification.AfterTurningEnginesOff.Equals(LandingReportNotification.Parse(Settings.Default.LandingReportNotification))) + //{ + // UpdateGUIDelegate showNotification = () => new Views.LandingReport().Show(); + // Application.Current.Dispatcher.BeginInvoke(showNotification); + //} // Actually finish up the tracking session now SpeechSoundPacks.Instance.PlaySpeechEvent(SpeechEvent.FlightCompleteSubmitting); @@ -224,33 +237,32 @@ private void MonitorSecondarySystems(ProcessSecondaryTracking pst) player.PlaySync(); SpeechSoundPacks.Instance.PlaySpeechEvent(SpeechEvent.AbortedPushbackGroundHandling); this.StopTracking(false); - this.fsConnect.SetText("OpenSky Warning: Tracking aborted, you cannot start your pushback while ground handling isn't complete!", 5); } // Pushback start? if (pst.Old.Pushback == Pushback.NoPushback && pst.New.Pushback != Pushback.NoPushback) { - this.AddTrackingEvent(this.PrimaryTrackingStruct, pst.New, FlightTrackingEventType.PushbackStarted, OpenSkyColors.OpenSkyTealLight, "Pushback started"); + this.AddTrackingEvent(this.PrimaryTracking, pst.New, FlightTrackingEventType.PushbackStarted, OpenSkyColors.OpenSkyTealLight, "Pushback started"); } // Pushback finished? if (pst.Old.Pushback != Pushback.NoPushback && pst.New.Pushback == Pushback.NoPushback) { - this.AddTrackingEvent(this.PrimaryTrackingStruct, pst.New, FlightTrackingEventType.PushbackFinished, OpenSkyColors.OpenSkyTealLight, "Pushback finished"); + this.AddTrackingEvent(this.PrimaryTracking, pst.New, FlightTrackingEventType.PushbackFinished, OpenSkyColors.OpenSkyTealLight, "Pushback finished"); } // Was the battery master turned off/on? if (pst.Old.ElectricalMasterBattery != pst.New.ElectricalMasterBattery && (this.TrackingStatus is TrackingStatus.GroundOperations or TrackingStatus.Tracking)) { - this.AddTrackingEvent(this.PrimaryTrackingStruct, pst.New, FlightTrackingEventType.BatteryMaster, OpenSkyColors.OpenSkyTealLight, pst.New.ElectricalMasterBattery ? "Battery master on" : "Battery master off"); + this.AddTrackingEvent(this.PrimaryTracking, pst.New, FlightTrackingEventType.BatteryMaster, OpenSkyColors.OpenSkyTealLight, pst.New.ElectricalMasterBattery ? "Battery master on" : "Battery master off"); } // Was the landing gear lowered/raised? if (pst.Old.GearHandle != pst.New.GearHandle) { - if (!this.PrimaryTrackingStruct.OnGround) + if (!this.PrimaryTracking.OnGround) { - this.AddTrackingEvent(this.PrimaryTrackingStruct, pst.New, FlightTrackingEventType.LandingGear, OpenSkyColors.OpenSkyTealLight, pst.New.GearHandle ? "Landing gear lowered" : "Landing gear raised"); + this.AddTrackingEvent(this.PrimaryTracking, pst.New, FlightTrackingEventType.LandingGear, OpenSkyColors.OpenSkyTealLight, pst.New.GearHandle ? "Landing gear lowered" : "Landing gear raised"); // todo add check that removes xp if gear is still lowered above a certain agl depending on engine type (if gear is retractable)? } @@ -258,7 +270,7 @@ private void MonitorSecondarySystems(ProcessSecondaryTracking pst) { if (!pst.New.GearHandle) { - this.AddTrackingEvent(this.PrimaryTrackingStruct, pst.New, FlightTrackingEventType.GearUpOnGround, OpenSkyColors.OpenSkyRed, "Tried to raise landing gear on the ground"); + this.AddTrackingEvent(this.PrimaryTracking, pst.New, FlightTrackingEventType.GearUpOnGround, OpenSkyColors.OpenSkyRed, "Tried to raise landing gear on the ground"); } } } @@ -266,43 +278,43 @@ private void MonitorSecondarySystems(ProcessSecondaryTracking pst) // Was the flaps position changed? if (Math.Abs(pst.Old.FlapsHandle - pst.New.FlapsHandle) > 1) { - this.AddTrackingEvent(this.PrimaryTrackingStruct, pst.New, FlightTrackingEventType.Flaps, OpenSkyColors.OpenSkyTealLight, $"Flaps set to {(int)pst.New.FlapsHandle} %"); + this.AddTrackingEvent(this.PrimaryTracking, pst.New, FlightTrackingEventType.Flaps, OpenSkyColors.OpenSkyTealLight, $"Flaps set to {(int)pst.New.FlapsHandle} %"); } // Was the autopilot engaged/disengaged? if (pst.Old.AutoPilot != pst.New.AutoPilot) { - this.AddTrackingEvent(this.PrimaryTrackingStruct, pst.New, FlightTrackingEventType.AutoPilot, OpenSkyColors.OpenSkyTealLight, pst.New.AutoPilot ? "AP engaged" : "AP disengaged"); + this.AddTrackingEvent(this.PrimaryTracking, pst.New, FlightTrackingEventType.AutoPilot, OpenSkyColors.OpenSkyTealLight, pst.New.AutoPilot ? "AP engaged" : "AP disengaged"); } // Was the parking brake set/released? if (pst.Old.ParkingBrake != pst.New.ParkingBrake) { - this.AddTrackingEvent(this.PrimaryTrackingStruct, pst.New, FlightTrackingEventType.ParkingBrake, OpenSkyColors.OpenSkyTealLight, pst.New.ParkingBrake ? "Parking brake set" : "Parking brake released"); + this.AddTrackingEvent(this.PrimaryTracking, pst.New, FlightTrackingEventType.ParkingBrake, OpenSkyColors.OpenSkyTealLight, pst.New.ParkingBrake ? "Parking brake set" : "Parking brake released"); } // Were the spoilers armed/disarmed? if (pst.Old.SpoilersArmed != pst.New.SpoilersArmed) { - this.AddTrackingEvent(this.PrimaryTrackingStruct, pst.New, FlightTrackingEventType.Spoilers, OpenSkyColors.OpenSkyTealLight, pst.New.SpoilersArmed ? "Spoilers armed" : "Spoilers disarmed"); + this.AddTrackingEvent(this.PrimaryTracking, pst.New, FlightTrackingEventType.Spoilers, OpenSkyColors.OpenSkyTealLight, pst.New.SpoilersArmed ? "Spoilers armed" : "Spoilers disarmed"); } // Was the APU turned on/off? if (pst.Old.ApuGenerator != pst.New.ApuGenerator) { - this.AddTrackingEvent(this.PrimaryTrackingStruct, pst.New, FlightTrackingEventType.APU, OpenSkyColors.OpenSkyTealLight, pst.New.ApuGenerator ? "APU started" : "APU shut down"); + this.AddTrackingEvent(this.PrimaryTracking, pst.New, FlightTrackingEventType.APU, OpenSkyColors.OpenSkyTealLight, pst.New.ApuGenerator ? "APU started" : "APU shut down"); } // Were the seatbelt signs turned on/off if (pst.Old.SeatBeltSign != pst.New.SeatBeltSign) { - this.AddTrackingEvent(this.PrimaryTrackingStruct, pst.New, FlightTrackingEventType.SeatbeltSigns, OpenSkyColors.OpenSkyTealLight, pst.New.SeatBeltSign ? "Seat belt signs on" : "Seat belt signs off"); + this.AddTrackingEvent(this.PrimaryTracking, pst.New, FlightTrackingEventType.SeatbeltSigns, OpenSkyColors.OpenSkyTealLight, pst.New.SeatBeltSign ? "Seat belt signs on" : "Seat belt signs off"); } // Were the no smoking signs turned on/off if (pst.Old.NoSmokingSign != pst.New.NoSmokingSign) { - this.AddTrackingEvent(this.PrimaryTrackingStruct, pst.New, FlightTrackingEventType.NoSmokingSigns, OpenSkyColors.OpenSkyTealLight, pst.New.NoSmokingSign ? "No smoking signs on" : "No smoking signs off"); + this.AddTrackingEvent(this.PrimaryTracking, pst.New, FlightTrackingEventType.NoSmokingSigns, OpenSkyColors.OpenSkyTealLight, pst.New.NoSmokingSign ? "No smoking signs on" : "No smoking signs off"); } // Was the crash detection turned off? @@ -314,7 +326,6 @@ private void MonitorSecondarySystems(ProcessSecondaryTracking pst) player.PlaySync(); SpeechSoundPacks.Instance.PlaySpeechEvent(SpeechEvent.AbortedCrashDetectOff); this.StopTracking(false); - this.fsConnect.SetText("OpenSky Warning: Tracking aborted, crash detection turned off!", 5); } // Was unlimited fuel turned on? @@ -326,7 +337,6 @@ private void MonitorSecondarySystems(ProcessSecondaryTracking pst) player.PlaySync(); SpeechSoundPacks.Instance.PlaySpeechEvent(SpeechEvent.AbortedUnlimitedFuel); this.StopTracking(false); - this.fsConnect.SetText("OpenSky Warning: Tracking aborted, unlimited fuel turned on!", 5); } // Was the time in the sim changed? @@ -341,7 +351,6 @@ private void MonitorSecondarySystems(ProcessSecondaryTracking pst) player.PlaySync(); SpeechSoundPacks.Instance.PlaySpeechEvent(SpeechEvent.AbortedTimeBackwards); this.StopTracking(false); - this.fsConnect.SetText("OpenSky Warning: Tracking aborted, time moved backwards!", 5); } if (timeDelta.TotalSeconds > 30) @@ -352,7 +361,6 @@ private void MonitorSecondarySystems(ProcessSecondaryTracking pst) player.PlaySync(); SpeechSoundPacks.Instance.PlaySpeechEvent(SpeechEvent.AbortedTimeChanged); this.StopTracking(false); - this.fsConnect.SetText("OpenSky Warning: Tracking aborted, time changed in sim!", 5); } } } diff --git a/OpenSky.Agent.SimConnectMSFS/SimConnect.Process.cs b/OpenSky.Agent.Simulator/Simulator.Process.cs similarity index 65% rename from OpenSky.Agent.SimConnectMSFS/SimConnect.Process.cs rename to OpenSky.Agent.Simulator/Simulator.Process.cs index a12d92f..76f1dc8 100644 --- a/OpenSky.Agent.SimConnectMSFS/SimConnect.Process.cs +++ b/OpenSky.Agent.Simulator/Simulator.Process.cs @@ -1,49 +1,32 @@ // -------------------------------------------------------------------------------------------------------------------- -// +// // OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- -namespace OpenSky.AgentMSFS.SimConnect +namespace OpenSky.Agent.Simulator { using System; using System.Collections.Concurrent; - using System.Collections.Generic; - using System.Collections.ObjectModel; using System.Device.Location; using System.Diagnostics; using System.Media; using System.Reflection; using System.Threading; - using System.Windows; - using System.Windows.Media; using JetBrains.Annotations; using Microsoft.Maps.MapControl.WPF; - using OpenSky.Agent.SimConnectMSFS.Helpers; - using OpenSky.Agent.SimConnectMSFS.Structs; - using OpenSky.Agent.Simulator; using OpenSky.Agent.Simulator.Enums; - using OpenSky.AgentMSFS.Models; - using OpenSky.AgentMSFS.SimConnect.Enums; - using OpenSky.AgentMSFS.SimConnect.Helpers; - using OpenSky.AgentMSFS.SimConnect.Structs; - using OpenSky.FlightLogXML; - - using TrackingEventLogEntry = OpenSky.Agent.Simulator.Models.TrackingEventLogEntry; - using TrackingEventMarker = Models.TrackingEventMarker; + using OpenSky.Agent.Simulator.Models; /// ------------------------------------------------------------------------------------------------- - /// - /// Simconnect client - data processing code. - /// - /// - /// sushi.at, 13/03/2021. - /// + /// + /// Simulator interface - data processing. + /// /// ------------------------------------------------------------------------------------------------- - public partial class SimConnect + public partial class Simulator { /// ------------------------------------------------------------------------------------------------- /// @@ -51,7 +34,7 @@ public partial class SimConnect /// /// ------------------------------------------------------------------------------------------------- [NotNull] - private readonly ConcurrentQueue landingAnalysisProcessingQueue; + protected readonly ConcurrentQueue landingAnalysisProcessingQueue; /// ------------------------------------------------------------------------------------------------- /// @@ -59,7 +42,7 @@ public partial class SimConnect /// /// ------------------------------------------------------------------------------------------------- [NotNull] - private readonly ConcurrentQueue primaryTrackingProcessingQueue; + protected readonly ConcurrentQueue primaryTrackingProcessingQueue; /// ------------------------------------------------------------------------------------------------- /// @@ -67,35 +50,21 @@ public partial class SimConnect /// /// ------------------------------------------------------------------------------------------------- [NotNull] - private readonly ConcurrentQueue secondaryTrackingProcessingQueue; - - /// ------------------------------------------------------------------------------------------------- - /// - /// The tracking event markers. - /// - /// ------------------------------------------------------------------------------------------------- - private readonly List trackingEventMarkers = new(); - - /// ------------------------------------------------------------------------------------------------- - /// - /// Occurs when the plane's location changed. - /// - /// ------------------------------------------------------------------------------------------------- - public event EventHandler LocationChanged; + protected readonly ConcurrentQueue secondaryTrackingProcessingQueue; /// ------------------------------------------------------------------------------------------------- /// - /// Occurs when SimConnect adds a new tracking event marker. + /// Gets the length of the landing analysis processing queue. /// /// ------------------------------------------------------------------------------------------------- - public event EventHandler TrackingEventMarkerAdded; + public int LandingAnalysisProcessingQueueLength => this.landingAnalysisProcessingQueue.Count; /// ------------------------------------------------------------------------------------------------- /// - /// Gets the length of the landing analysis processing queue. + /// The last received/request date times dictionary. /// /// ------------------------------------------------------------------------------------------------- - public int LandingAnalysisProcessingQueueLength => this.landingAnalysisProcessingQueue.Count; + public ObservableConcurrentDictionary LastReceivedTimes { get; } /// ------------------------------------------------------------------------------------------------- /// @@ -106,92 +75,55 @@ public partial class SimConnect /// ------------------------------------------------------------------------------------------------- /// - /// Gets the length of the secondary tracking processing queue. + /// The sample rates/request dictionary. /// /// ------------------------------------------------------------------------------------------------- - public int SecondaryTrackingProcessingQueueLength => this.secondaryTrackingProcessingQueue.Count; + public ObservableConcurrentDictionary SampleRates { get; } /// ------------------------------------------------------------------------------------------------- /// - /// Gets the tracking event log entries. + /// Gets the length of the secondary tracking processing queue. /// /// ------------------------------------------------------------------------------------------------- - public ObservableCollection TrackingEventLogEntries { get; } + public int SecondaryTrackingProcessingQueueLength => this.secondaryTrackingProcessingQueue.Count; /// ------------------------------------------------------------------------------------------------- /// - /// Add a tracking event to the map and log. + /// Refresh the request-associated data model object NOW, don't wait for normal refresh interval. /// /// - /// sushi.at, 16/03/2021. + /// sushi.at, 31/01/2022. /// - /// - /// The primary Simconnect tracking data. - /// - /// - /// The secondary Simconnect tracking data. - /// - /// - /// The flight tracking event type. - /// - /// - /// The color to use for the marker. - /// - /// - /// The event text (what happened?). + /// + /// The request ID type to refresh. /// /// ------------------------------------------------------------------------------------------------- - private void AddTrackingEvent(PrimaryTracking primary, SecondaryTracking secondary, FlightTrackingEventType type, Color color, string text) + public void RefreshModelNow(Requests request) { - if (this.TrackingStatus != TrackingStatus.Tracking && this.TrackingStatus != TrackingStatus.GroundOperations) - { - return; - } - - UpdateGUIDelegate addTrackingEvent = () => - { - Debug.WriteLine($"Adding tracking event: {text}"); - if (this.lastNonPositionReportMarker == null || this.lastNonPositionReportMarker.GetDistanceTo(primary) >= 20) - { - lock (this.trackingEventMarkers) - { - var newMarker = new TrackingEventMarker(primary, secondary, this.WeightAndBalanceStruct.FuelTotalQuantity, 16, color, text); - this.lastNonPositionReportMarker = newMarker; - this.trackingEventMarkers.Add(newMarker); - this.TrackingEventMarkerAdded?.Invoke(this, newMarker); - } - } - else - { - this.lastNonPositionReportMarker.AddEventToMarker(DateTime.UtcNow, text); - } - - this.TrackingEventLogEntries.Add(new TrackingEventLogEntry(type, DateTime.UtcNow, color, text, primary.MapLocation)); - }; - Application.Current.Dispatcher.BeginInvoke(addTrackingEvent); + this.LastReceivedTimes[request] = null; } /// ------------------------------------------------------------------------------------------------- /// - /// Monitor tracking start conditions. + /// Monitor start/resume tracking conditions. /// /// - /// sushi.at, 28/03/2021. + /// sushi.at, 31/01/2022. /// - /// - /// The secondary Simconnect tracking data (old and new). + /// + /// The secondary tracking data. /// /// ------------------------------------------------------------------------------------------------- - private void MonitorTrackingStartConditions(ProcessSecondaryTracking pst) + protected void MonitorTrackingStartConditions(SecondaryTracking secondary) { if (this.Flight != null && this.TrackingStatus == TrackingStatus.Preparing || this.TrackingStatus == TrackingStatus.Resuming) { this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.DateTime].Expected = $"{DateTime.UtcNow.AddHours(this.Flight?.UtcOffset ?? 0):HH:mm dd.MM.yyyy}"; - this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.DateTime].Current = $"{pst.New.UtcDateTime:HH:mm dd.MM.yyyy}"; - this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.PlaneModel].Current = this.AircraftIdentityStruct.Type; + this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.DateTime].Current = $"{secondary.UtcDateTime:HH:mm dd.MM.yyyy}"; + this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.PlaneModel].Current = this.AircraftIdentity.Type; this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.DateTime].ConditionMet = - this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.DateTime].AutoSet || Math.Abs((DateTime.UtcNow.AddHours(this.Flight?.UtcOffset ?? 0) - pst.New.UtcDateTime).TotalMinutes) < 1; + this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.DateTime].AutoSet || Math.Abs((DateTime.UtcNow.AddHours(this.Flight?.UtcOffset ?? 0) - secondary.UtcDateTime).TotalMinutes) < 1; this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.PlaneModel].ConditionMet = this.Flight?.Aircraft.Type.MatchesAircraftInSimulator() ?? false; if (this.TrackingStatus == TrackingStatus.Preparing) @@ -199,21 +131,24 @@ private void MonitorTrackingStartConditions(ProcessSecondaryTracking pst) this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Fuel].Enabled = true; this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Payload].Enabled = true; - this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Fuel].Current = $"{this.WeightAndBalanceStruct.FuelTotalQuantity:F1} gal, {this.WeightAndBalanceStruct.FuelTotalQuantity * 3.78541:F1} liters ▶ {this.WeightAndBalanceStruct.FuelTotalQuantity * this.Flight?.Aircraft.Type.FuelWeightPerGallon:F1} lbs, {this.WeightAndBalanceStruct.FuelTotalQuantity * this.Flight?.Aircraft.Type.FuelWeightPerGallon * 0.453592:F1} kg"; - this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Payload].Current = $"{this.PayloadStationsStruct.TotalWeight:F1} lbs, {this.PayloadStationsStruct.TotalWeight * 0.453592:F1} kg"; + this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Fuel].Current = + $"{this.WeightAndBalance.FuelTotalQuantity:F1} gal, {this.WeightAndBalance.FuelTotalQuantity * 3.78541:F1} liters ▶ {this.WeightAndBalance.FuelTotalQuantity * this.Flight?.Aircraft.Type.FuelWeightPerGallon:F1} lbs, {this.WeightAndBalance.FuelTotalQuantity * this.Flight?.Aircraft.Type.FuelWeightPerGallon * 0.453592:F1} kg"; + this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Payload].Current = $"{this.PayloadStations.TotalWeight:F1} lbs, {this.PayloadStations.TotalWeight * 0.453592:F1} kg"; this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Fuel].ConditionMet = - this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Fuel].AutoSet || Math.Abs(this.WeightAndBalanceStruct.FuelTotalQuantity - this.Flight?.FuelGallons ?? 0) < 0.27; // Allow roughly 1 liter of margin + this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Fuel].AutoSet || Math.Abs((int)(this.WeightAndBalance.FuelTotalQuantity - this.Flight?.FuelGallons ?? 0)) < 0.27; // Allow roughly 1 liter of margin this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Payload].ConditionMet = - this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Payload].AutoSet || Math.Abs(this.PayloadStationsStruct.TotalWeight - this.Flight?.PayloadPounds ?? 0) < 2.2; // Allow 1 kg of margin + this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Payload].AutoSet || Math.Abs((int)(this.PayloadStations.TotalWeight - this.Flight?.PayloadPounds ?? 0)) < 2.2; // Allow 1 kg of margin this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.RealismSettings].Expected = "No slew, No unlimited fuel,\r\nCrash detection, SimRate=1"; - this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.RealismSettings].ConditionMet = !this.PrimaryTrackingStruct.SlewActive && !pst.New.UnlimitedFuel && pst.New.CrashDetection && Math.Abs(this.PrimaryTrackingStruct.SimulationRate - 1) == 0; + this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.RealismSettings].ConditionMet = + !this.PrimaryTracking.SlewActive && !secondary.UnlimitedFuel && secondary.CrashDetection && Math.Abs((int)(this.PrimaryTracking.SimulationRate - 1)) == 0; this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Location].Current = - $"{this.PrimaryTrackingStruct.GeoCoordinate.GetDistanceTo(new GeoCoordinate(this.Flight?.Origin.Latitude ?? 0, this.Flight?.Origin.Longitude ?? 0)) / 1000:F2} km from starting location - {(this.PrimaryTrackingStruct.OnGround ? "On ground" : "Airborne")}"; - this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Location].ConditionMet = this.PrimaryTrackingStruct.GeoCoordinate.GetDistanceTo(new GeoCoordinate(this.Flight?.Origin.Latitude ?? 0, this.Flight?.Origin.Longitude ?? 0)) < 5000; + $"{this.PrimaryTracking.GeoCoordinate.GetDistanceTo(new GeoCoordinate(this.Flight?.Origin.Latitude ?? 0, this.Flight?.Origin.Longitude ?? 0)) / 1000:F2} km from starting location - {(this.PrimaryTracking.OnGround ? "On ground" : "Airborne")}"; + this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Location].ConditionMet = + this.PrimaryTracking.GeoCoordinate.GetDistanceTo(new GeoCoordinate(this.Flight?.Origin.Latitude ?? 0, this.Flight?.Origin.Longitude ?? 0)) < 5000; } if (this.TrackingStatus == TrackingStatus.Resuming) @@ -225,9 +160,11 @@ private void MonitorTrackingStartConditions(ProcessSecondaryTracking pst) else { this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Fuel].Enabled = true; - this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Fuel].Current = $"{this.WeightAndBalanceStruct.FuelTotalQuantity:F1} gal, {this.WeightAndBalanceStruct.FuelTotalQuantity * 3.78541:F1} liters ▶ {this.WeightAndBalanceStruct.FuelTotalQuantity * this.Flight?.Aircraft.Type.FuelWeightPerGallon:F1} lbs, {this.WeightAndBalanceStruct.FuelTotalQuantity * this.Flight?.Aircraft.Type.FuelWeightPerGallon * 0.453592:F1} kg"; + this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Fuel].Current = + $"{this.WeightAndBalance.FuelTotalQuantity:F1} gal, {this.WeightAndBalance.FuelTotalQuantity * 3.78541:F1} liters ▶ {this.WeightAndBalance.FuelTotalQuantity * this.Flight?.Aircraft.Type.FuelWeightPerGallon:F1} lbs, {this.WeightAndBalance.FuelTotalQuantity * this.Flight?.Aircraft.Type.FuelWeightPerGallon * 0.453592:F1} kg"; this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Fuel].ConditionMet = - this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Fuel].AutoSet || Math.Abs(this.WeightAndBalanceStruct.FuelTotalQuantity - this.flightLoadingTempStructs.FuelTanks.TotalQuantity) < 0.81; // Allow roughly 3 liters of margin, as it can be very hard to get this right otherwise + this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Fuel].AutoSet || + Math.Abs(this.WeightAndBalance.FuelTotalQuantity - this.flightLoadingTempModels.FuelTanks.TotalQuantity) < 0.81; // Allow roughly 3 liters of margin, as it can be very hard to get this right otherwise } if (this.Flight?.Aircraft.Type.RequiresManualLoading != true) @@ -237,52 +174,53 @@ private void MonitorTrackingStartConditions(ProcessSecondaryTracking pst) else { this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Payload].Enabled = true; - this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Payload].Current = $"{this.PayloadStationsStruct.TotalWeight:F1} lbs, {this.PayloadStationsStruct.TotalWeight * 0.453592:F1} kg"; + this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Payload].Current = $"{this.PayloadStations.TotalWeight:F1} lbs, {this.PayloadStations.TotalWeight * 0.453592:F1} kg"; this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Payload].ConditionMet = - this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Payload].AutoSet || Math.Abs((double)(this.PayloadStationsStruct.TotalWeight - this.Flight?.PayloadPounds)) < 2.2; // Allow 1 kg of margin + this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Payload].AutoSet || Math.Abs((double)(this.PayloadStations.TotalWeight - this.Flight?.PayloadPounds)) < 2.2; // Allow 1 kg of margin } - var currentLocation = $"{this.PrimaryTrackingStruct.GeoCoordinate.GetDistanceTo(this.flightLoadingTempStructs?.SlewPlaneIntoPosition.GeoCoordinate ?? new GeoCoordinate(0, 0, 0)) / 1000:F2} km from resume location"; - currentLocation += $"\r\nLatitude: {this.flightLoadingTempStructs?.SlewPlaneIntoPosition.Latitude:F4}"; - currentLocation += $"\r\nLongitude: {this.flightLoadingTempStructs?.SlewPlaneIntoPosition.Longitude:F4}"; - currentLocation += $"\r\nAltitude (AGL): {this.flightLoadingTempStructs?.SlewPlaneIntoPosition.RadioHeight:F0}"; + var currentLocation = $"{this.PrimaryTracking.GeoCoordinate.GetDistanceTo(this.flightLoadingTempModels?.SlewAircraftIntoPosition.GeoCoordinate ?? new GeoCoordinate(0, 0, 0)) / 1000:F2} km from resume location"; + currentLocation += $"\r\nLatitude: {this.flightLoadingTempModels?.SlewAircraftIntoPosition.Latitude:F4}"; + currentLocation += $"\r\nLongitude: {this.flightLoadingTempModels?.SlewAircraftIntoPosition.Longitude:F4}"; + currentLocation += $"\r\nAltitude (AGL): {this.flightLoadingTempModels?.SlewAircraftIntoPosition.RadioHeight:F0}"; this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.RealismSettings].Expected = "No unlimited fuel,\r\nCrash detection, SimRate=1"; - this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.RealismSettings].ConditionMet = !pst.New.UnlimitedFuel && pst.New.CrashDetection && Math.Abs(this.PrimaryTrackingStruct.SimulationRate - 1) == 0; + this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.RealismSettings].ConditionMet = !secondary.UnlimitedFuel && secondary.CrashDetection && Math.Abs((int)(this.PrimaryTracking.SimulationRate - 1)) == 0; this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Location].Current = currentLocation; this.TrackingConditions[(int)Agent.Simulator.Models.TrackingConditions.Location].ConditionMet = - (this.PrimaryTrackingStruct.GeoCoordinate.GetDistanceTo(this.flightLoadingTempStructs?.SlewPlaneIntoPosition.GeoCoordinate ?? new GeoCoordinate(0, 0, 0)) < 100) && - Math.Abs(this.PrimaryTrackingStruct.RadioHeight - this.flightLoadingTempStructs?.SlewPlaneIntoPosition.RadioHeight ?? -1000) < 50; + (this.PrimaryTracking.GeoCoordinate.GetDistanceTo(this.flightLoadingTempModels?.SlewAircraftIntoPosition.GeoCoordinate ?? new GeoCoordinate(0, 0, 0)) < 100) && + Math.Abs((int)(this.PrimaryTracking.RadioHeight - this.flightLoadingTempModels?.SlewAircraftIntoPosition.RadioHeight ?? -1000)) < 50; } } } /// ------------------------------------------------------------------------------------------------- /// - /// Process the landing analysis data (old vs new) + /// Process aircraft identity. /// /// - /// sushi.at, 25/03/2021. + /// sushi.at, 31/01/2022. /// /// ------------------------------------------------------------------------------------------------- - private void ProcessLandingAnalysis() + protected void ProcessAircraftIdentity() { - while (!this.close) + try { - while (this.landingAnalysisProcessingQueue.TryDequeue(out var pla)) + // Make sure the player didn't use the dev mode to switch the plane + if (this.Flight != null && (this.TrackingStatus is TrackingStatus.GroundOperations or TrackingStatus.Tracking) && !this.Flight.Aircraft.Type.MatchesAircraftInSimulator()) { - try - { - this.CheckForAndAnalyseLanding(pla); - } - catch (Exception ex) - { - Debug.WriteLine("Error processing landing analysis: " + ex); - } + Debug.WriteLine("OpenSky Warning: Tracking aborted, aircraft type was changed."); + var assembly = Assembly.GetExecutingAssembly(); + var player = new SoundPlayer(assembly.GetManifestResourceStream("OpenSky.AgentMSFS.Resources.OSnegative.wav")); + player.PlaySync(); + SpeechSoundPacks.Instance.PlaySpeechEvent(SpeechEvent.AbortedAircraftType); + this.StopTracking(false); } - - Thread.Sleep(500); + } + catch (Exception ex) + { + Debug.WriteLine("Error processing plane identity: " + ex); } } @@ -291,24 +229,24 @@ private void ProcessLandingAnalysis() /// Process the payload stations. /// /// - /// sushi.at, 26/11/2021. + /// sushi.at, 31/01/2022. /// - /// - /// The old payload stations. + /// + /// The older data. /// - /// - /// The new payload stations. + /// + /// The newer data. /// /// ------------------------------------------------------------------------------------------------- - private void ProcessPayloadStations(PayloadStations oldPayload, PayloadStations newPayload) + protected void ProcessPayloadStations(PayloadStations older, PayloadStations newer) { try { if (this.Flight != null && (this.TrackingStatus is TrackingStatus.GroundOperations or TrackingStatus.Tracking)) { - if (Math.Abs(oldPayload.TotalWeight - newPayload.TotalWeight) > 0.1) + if (Math.Abs(older.TotalWeight - newer.TotalWeight) > 0.1) { - if (Math.Abs(newPayload.TotalWeight - this.Flight.PayloadPounds) > this.Flight.Aircraft.Type.MaxPayloadDeltaAllowed) + if (Math.Abs(newer.TotalWeight - this.Flight.PayloadPounds) > this.Flight.Aircraft.Type.MaxPayloadDeltaAllowed) { Debug.WriteLine("OpenSky Warning: Tracking aborted, payload changed below required load."); var assembly = Assembly.GetExecutingAssembly(); @@ -316,7 +254,6 @@ private void ProcessPayloadStations(PayloadStations oldPayload, PayloadStations player.PlaySync(); SpeechSoundPacks.Instance.PlaySpeechEvent(SpeechEvent.AbortedPayloadChange); this.StopTracking(false); - this.fsConnect.SetText("OpenSky Warning: Tracking aborted, payload changed.", 5); } } } @@ -329,31 +266,74 @@ private void ProcessPayloadStations(PayloadStations oldPayload, PayloadStations /// ------------------------------------------------------------------------------------------------- /// - /// Process the plane identity. + /// Process the weight and balance. /// /// /// sushi.at, 28/03/2021. /// + /// + /// The old weight and balance. + /// + /// + /// The new weight and balance. + /// /// ------------------------------------------------------------------------------------------------- - private void ProcessPlaneIdentity() + protected void ProcessWeightAndBalance(WeightAndBalance oldWB, WeightAndBalance newWB) { try { - // Make sure the player didn't use the dev mode to switch the plane - if (this.Flight != null && (this.TrackingStatus is TrackingStatus.GroundOperations or TrackingStatus.Tracking) && !this.Flight.Aircraft.Type.MatchesAircraftInSimulator()) + if (this.Flight != null && (this.TrackingStatus is TrackingStatus.GroundOperations or TrackingStatus.Tracking)) { - Debug.WriteLine("OpenSky Warning: Tracking aborted, aircraft type was changed."); - var assembly = Assembly.GetExecutingAssembly(); - var player = new SoundPlayer(assembly.GetManifestResourceStream("OpenSky.AgentMSFS.Resources.OSnegative.wav")); - player.PlaySync(); - SpeechSoundPacks.Instance.PlaySpeechEvent(SpeechEvent.AbortedAircraftType); - this.StopTracking(false); - this.fsConnect.SetText("OpenSky Warning: Tracking aborted, aircraft type was changed.", 5); + // Did the fuel go up? + if (newWB.FuelTotalQuantity > oldWB.FuelTotalQuantity) + { + if (newWB.FuelTotalQuantity - oldWB.FuelTotalQuantity > 0.5) + { + Debug.WriteLine("OpenSky Warning: Tracking aborted, fuel increased."); + var assembly = Assembly.GetExecutingAssembly(); + var player = new SoundPlayer(assembly.GetManifestResourceStream("OpenSky.AgentMSFS.Resources.OSnegative.wav")); + player.PlaySync(); + SpeechSoundPacks.Instance.PlaySpeechEvent(SpeechEvent.AbortedFuelIncreased); + this.StopTracking(false); + } + else + { + Debug.WriteLine($"Small fuel jump detected: {newWB.FuelTotalQuantity - oldWB.FuelTotalQuantity} gallons"); + } + } } } catch (Exception ex) { - Debug.WriteLine("Error processing plane identity: " + ex); + Debug.WriteLine("Error processing weight and balance: " + ex); + } + } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Process the landing analysis data (old vs new) + /// + /// + /// sushi.at, 25/03/2021. + /// + /// ------------------------------------------------------------------------------------------------- + private void ProcessLandingAnalysis() + { + while (!this.close) + { + while (this.landingAnalysisProcessingQueue.TryDequeue(out var pla)) + { + try + { + this.CheckForAndAnalyseLanding(pla); + } + catch (Exception ex) + { + Debug.WriteLine("Error processing landing analysis: " + ex); + } + } + + Thread.Sleep(500); } } @@ -423,7 +403,7 @@ private void ProcessSecondaryTracking() this.MonitorLights(pst); this.TransitionFlightPhase(); this.MonitorSecondarySystems(pst); - this.MonitorTrackingStartConditions(pst); + this.MonitorTrackingStartConditions(pst.New); } catch (Exception ex) { @@ -434,51 +414,5 @@ private void ProcessSecondaryTracking() Thread.Sleep(500); } } - - /// ------------------------------------------------------------------------------------------------- - /// - /// Process the weight and balance. - /// - /// - /// sushi.at, 28/03/2021. - /// - /// - /// The old weight and balance. - /// - /// - /// The new weight and balance. - /// - /// ------------------------------------------------------------------------------------------------- - private void ProcessWeightAndBalance(WeightAndBalance oldWB, WeightAndBalance newWB) - { - try - { - if (this.Flight != null && (this.TrackingStatus is TrackingStatus.GroundOperations or TrackingStatus.Tracking)) - { - // Did the fuel go up? - if (newWB.FuelTotalQuantity > oldWB.FuelTotalQuantity) - { - if (newWB.FuelTotalQuantity - oldWB.FuelTotalQuantity > 0.5) - { - Debug.WriteLine("OpenSky Warning: Tracking aborted, fuel increased."); - var assembly = Assembly.GetExecutingAssembly(); - var player = new SoundPlayer(assembly.GetManifestResourceStream("OpenSky.AgentMSFS.Resources.OSnegative.wav")); - player.PlaySync(); - SpeechSoundPacks.Instance.PlaySpeechEvent(SpeechEvent.AbortedFuelIncreased); - this.StopTracking(false); - this.fsConnect.SetText("OpenSky Warning: Tracking aborted, fuel increased.", 5); - } - else - { - Debug.WriteLine($"Small fuel jump detected: {newWB.FuelTotalQuantity - oldWB.FuelTotalQuantity} gallons"); - } - } - } - } - catch (Exception ex) - { - Debug.WriteLine("Error processing weight and balance: " + ex); - } - } } } \ No newline at end of file diff --git a/OpenSky.Agent.SimConnectMSFS/SimConnect.SaveLoadXML.cs b/OpenSky.Agent.Simulator/Simulator.SaveLoadXML.cs similarity index 94% rename from OpenSky.Agent.SimConnectMSFS/SimConnect.SaveLoadXML.cs rename to OpenSky.Agent.Simulator/Simulator.SaveLoadXML.cs index 3adcfc9..0514415 100644 --- a/OpenSky.Agent.SimConnectMSFS/SimConnect.SaveLoadXML.cs +++ b/OpenSky.Agent.Simulator/Simulator.SaveLoadXML.cs @@ -1,10 +1,10 @@ // -------------------------------------------------------------------------------------------------------------------- -// +// // OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- -namespace OpenSky.AgentMSFS.SimConnect +namespace OpenSky.Agent.Simulator { using System; using System.Device.Location; @@ -17,22 +17,22 @@ namespace OpenSky.AgentMSFS.SimConnect using Microsoft.Maps.MapControl.WPF; - using OpenSky.Agent.Simulator; + using OpenSky.Agent.Simulator.Enums; using OpenSky.Agent.Simulator.Models; - using OpenSky.AgentMSFS.Models; + using OpenSky.Agent.Simulator.Tools; using OpenSky.FlightLogXML; using OpenSkyApi; using TrackingEventLogEntry = OpenSky.Agent.Simulator.Models.TrackingEventLogEntry; - using TrackingEventMarker = Models.TrackingEventMarker; + using TrackingEventMarker = OpenSky.Agent.Simulator.Models.TrackingEventMarker; /// ------------------------------------------------------------------------------------------------- /// - /// Simconnect client - flight save/load code. + /// Simulator interface - save/load. /// /// ------------------------------------------------------------------------------------------------- - public partial class SimConnect + public partial class Simulator { /// ------------------------------------------------------------------------------------------------- /// @@ -41,6 +41,87 @@ public partial class SimConnect /// ------------------------------------------------------------------------------------------------- private const string AgentIdentifier = "OpenSky.AgentMSFS"; + /// ------------------------------------------------------------------------------------------------- + /// + /// Generates a XML save file for the current flight. + /// + /// + /// sushi.at, 22/03/2021. + /// + /// ------------------------------------------------------------------------------------------------- + private XElement GenerateSaveFile() + { + if ((this.TrackingStatus != TrackingStatus.Tracking && this.TrackingStatus != TrackingStatus.GroundOperations) || this.Flight == null) + { + Debug.WriteLine("Not generating save file cause we are either not tracking or there is no active flight"); + return null; + } + + try + { + Debug.WriteLine("Generating flight save XML file..."); + var log = new FlightLogXML.FlightLog + { + Agent = AgentIdentifier, + AgentVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(), + OpenSkyUser = "TODO", //UserSessionService.Instance.Username, TODO restore/workaround + LocalTimeZone = TimeZoneInfo.Local.BaseUtcOffset.TotalHours, + TrackingStarted = this.trackingStarted ?? DateTime.MinValue, + TrackingStopped = DateTime.UtcNow, + WasAirborne = this.WasAirborne, + TimeSavedBecauseOfSimRate = this.timeSavedBecauseOfSimRate, + TotalPaused = this.totalPaused, + + FlightID = this.Flight.Id, + AircraftRegistry = this.Flight.Aircraft.Registry, + UtcOffset = this.Flight.UtcOffset, + + Origin = new FlightLogAirport + { + Icao = this.Flight.Origin.Icao, + Name = this.Flight.Origin.Name, + Latitude = this.Flight.Origin.Latitude, + Longitude = this.Flight.Origin.Longitude + }, + Destination = new FlightLogAirport + { + Icao = this.Flight.Destination.Icao, + Name = this.Flight.Destination.Name, + Latitude = this.Flight.Destination.Latitude, + Longitude = this.Flight.Destination.Longitude + }, + Alternate = new FlightLogAirport + { + Icao = this.Flight.Alternate.Icao, + Name = this.Flight.Alternate.Name, + Latitude = this.Flight.Alternate.Latitude, + Longitude = this.Flight.Alternate.Longitude + }, + + FuelGallons = this.Flight.FuelGallons ?? 0, + Payload = this.Flight.PayloadSummary, + PayloadPounds = this.Flight.PayloadPounds + }; + + log.TrackingEventLogEntries.AddRange(this.TrackingEventLogEntries); + lock (this.trackingEventMarkers) + { + log.TrackingEventMarkers.AddRange(this.trackingEventMarkers.Select(m => m.Marker)); + } + + log.PositionReports.AddRange(this.AircraftTrailLocations.Cast().Select(loc => loc.Position)); + log.TouchDowns.AddRange(this.LandingReports); + log.NavLogWaypoints.AddRange(this.simbriefWaypointMarkers.Select(w => w.WayPoint)); + + return log.GenerateFlightLog(); + } + catch (Exception ex) + { + Debug.WriteLine("Flight save file creation failed: " + ex); + throw; + } + } + /// ------------------------------------------------------------------------------------------------- /// /// Restores a save file. @@ -139,12 +220,14 @@ private void RestoreSaveFile(string saveFile) this.trackingEventMarkers.Add(runwayMarker); this.TrackingEventMarkerAdded?.Invoke(this, runwayMarker); } + foreach (var runway in this.Flight.Origin.Runways) { var runwayMarker = new TrackingEventMarker(runway); this.trackingEventMarkers.Add(runwayMarker); this.TrackingEventMarkerAdded?.Invoke(this, runwayMarker); } + foreach (var runway in this.Flight.Destination.Runways) { var runwayMarker = new TrackingEventMarker(runway); @@ -201,93 +284,5 @@ private void RestoreSaveFile(string saveFile) // Now that everything has been loaded, replay any and all map markers this.ReplayMapMarkers(); } - - /// ------------------------------------------------------------------------------------------------- - /// - /// The flight loading temporary structs. - /// - /// ------------------------------------------------------------------------------------------------- - private FlightLoadingTempStructs flightLoadingTempStructs; - - /// ------------------------------------------------------------------------------------------------- - /// - /// Generates a XML save file for the current flight. - /// - /// - /// sushi.at, 22/03/2021. - /// - /// ------------------------------------------------------------------------------------------------- - private XElement GenerateSaveFile() - { - if ((this.TrackingStatus != TrackingStatus.Tracking && this.TrackingStatus != TrackingStatus.GroundOperations) || this.Flight == null) - { - Debug.WriteLine("Not generating save file cause we are either not tracking or there is no active flight"); - return null; - } - - try - { - Debug.WriteLine("Generating flight save XML file..."); - var log = new FlightLogXML.FlightLog - { - Agent = AgentIdentifier, - AgentVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(), - OpenSkyUser = UserSessionService.Instance.Username, - LocalTimeZone = TimeZoneInfo.Local.BaseUtcOffset.TotalHours, - TrackingStarted = this.trackingStarted ?? DateTime.MinValue, - TrackingStopped = DateTime.UtcNow, - WasAirborne = this.WasAirborne, - TimeSavedBecauseOfSimRate = this.timeSavedBecauseOfSimRate, - TotalPaused = this.totalPaused, - - FlightID = this.Flight.Id, - AircraftRegistry = this.Flight.Aircraft.Registry, - UtcOffset = this.Flight.UtcOffset, - - Origin = new FlightLogAirport - { - Icao = this.Flight.Origin.Icao, - Name = this.Flight.Origin.Name, - Latitude = this.Flight.Origin.Latitude, - Longitude = this.Flight.Origin.Longitude - }, - Destination = new FlightLogAirport - { - Icao = this.Flight.Destination.Icao, - Name = this.Flight.Destination.Name, - Latitude = this.Flight.Destination.Latitude, - Longitude = this.Flight.Destination.Longitude - }, - Alternate = new FlightLogAirport - { - Icao = this.Flight.Alternate.Icao, - Name = this.Flight.Alternate.Name, - Latitude = this.Flight.Alternate.Latitude, - Longitude = this.Flight.Alternate.Longitude - }, - - FuelGallons = this.Flight.FuelGallons ?? 0, - Payload = this.Flight.PayloadSummary, - PayloadPounds = this.Flight.PayloadPounds - }; - - log.TrackingEventLogEntries.AddRange(this.TrackingEventLogEntries); - lock (this.trackingEventMarkers) - { - log.TrackingEventMarkers.AddRange(this.trackingEventMarkers.Select(m => m.Marker)); - } - - log.PositionReports.AddRange(this.AircraftTrailLocations.Cast().Select(loc => loc.Position)); - log.TouchDowns.AddRange(this.LandingReports); - log.NavLogWaypoints.AddRange(this.simbriefWaypointMarkers.Select(w => w.WayPoint)); - - return log.GenerateFlightLog(); - } - catch (Exception ex) - { - Debug.WriteLine("Flight save file creation failed: " + ex); - throw; - } - } } } \ No newline at end of file diff --git a/OpenSky.Agent.Simulator/Simulator.cs b/OpenSky.Agent.Simulator/Simulator.cs index 40bc2f7..1a057dd 100644 --- a/OpenSky.Agent.Simulator/Simulator.cs +++ b/OpenSky.Agent.Simulator/Simulator.cs @@ -8,195 +8,210 @@ namespace OpenSky.Agent.Simulator { using System; using System.Collections.Concurrent; + using System.Collections.Generic; + using System.Collections.ObjectModel; using System.ComponentModel; + using System.Diagnostics; using System.Runtime.CompilerServices; + using System.Threading; using JetBrains.Annotations; + using Microsoft.Maps.MapControl.WPF; + using OpenSky.Agent.Simulator.Enums; using OpenSky.Agent.Simulator.Models; - using OpenSky.AgentMSFS.Models; + using OpenSky.FlightLogXML; using OpenSkyApi; + using TrackingEventLogEntry = OpenSky.Agent.Simulator.Models.TrackingEventLogEntry; + /// ------------------------------------------------------------------------------------------------- /// - /// Simulator interface class. + /// Simulator interface. /// /// /// sushi.at, 30/01/2022. /// /// ------------------------------------------------------------------------------------------------- - public abstract class Simulator : INotifyPropertyChanged + public abstract partial class Simulator : INotifyPropertyChanged { /// ------------------------------------------------------------------------------------------------- /// - /// Occurs when a property value changes. - /// - /// ------------------------------------------------------------------------------------------------- - public event PropertyChangedEventHandler PropertyChanged; - - /// ------------------------------------------------------------------------------------------------- - /// - /// Gets the simulator instance. - /// - /// ------------------------------------------------------------------------------------------------- - public static Simulator Instance { get; private set; } - - /// ------------------------------------------------------------------------------------------------- - /// - /// Gets the aircraft identity data. - /// - /// ------------------------------------------------------------------------------------------------- - public abstract AircraftIdentity AircraftIdentity { get; } - - /// ------------------------------------------------------------------------------------------------- - /// - /// Gets a value indicating whether the simulator is connected. - /// - /// ------------------------------------------------------------------------------------------------- - public abstract bool Connected { get; protected set; } - - /// ------------------------------------------------------------------------------------------------- - /// - /// Gets the flight phase. - /// - /// ------------------------------------------------------------------------------------------------- - public abstract FlightPhase FlightPhase { get; } - - /// ------------------------------------------------------------------------------------------------- - /// - /// Gets the fuel tanks data. - /// - /// ------------------------------------------------------------------------------------------------- - public abstract FuelTanks FuelTanks { get; } - - /// ------------------------------------------------------------------------------------------------- - /// - /// Gets a value indicating whether the sim is paused (proper pause, not ESC menu and definitely - /// not active pause). - /// - /// ------------------------------------------------------------------------------------------------- - public abstract bool IsPaused { get; } - - /// ------------------------------------------------------------------------------------------------- - /// - /// Gets a value indicating whether the aircraft is currently turning. - /// - /// ------------------------------------------------------------------------------------------------- - public abstract bool IsTurning { get; } - - /// ------------------------------------------------------------------------------------------------- - /// - /// Gets the landing analysis data. + /// Set to true to close the simulator client. /// /// ------------------------------------------------------------------------------------------------- - public abstract LandingAnalysis LandingAnalysis { get; } + protected bool close; /// ------------------------------------------------------------------------------------------------- /// - /// Gets the length of the landing analysis processing queue. + /// The flight loading temporary models. /// /// ------------------------------------------------------------------------------------------------- - public abstract int LandingAnalysisProcessingQueueLength { get; } + protected FlightLoadingTempModels flightLoadingTempModels; /// ------------------------------------------------------------------------------------------------- /// - /// Gets the last distance position report. + /// The time the last pause started. /// /// ------------------------------------------------------------------------------------------------- - public abstract string LastDistancePositionReport { get; } + protected DateTime? pauseStarted; /// ------------------------------------------------------------------------------------------------- /// - /// Gets information describing the pause status. + /// The total paused timespan. /// /// ------------------------------------------------------------------------------------------------- - public abstract string PauseInfo { get; protected set; } + protected TimeSpan totalPaused = TimeSpan.Zero; /// ------------------------------------------------------------------------------------------------- /// - /// Gets the payload stations data. + /// The OpenSky service instance. /// /// ------------------------------------------------------------------------------------------------- - public abstract PayloadStations PayloadStations { get; } + private readonly OpenSkyService openSkyServiceInstance; /// ------------------------------------------------------------------------------------------------- /// - /// Gets the primary tracking data. + /// True if we are connected to the simulator. /// /// ------------------------------------------------------------------------------------------------- - public abstract PrimaryTracking PrimaryTracking { get; } + private bool connected; /// ------------------------------------------------------------------------------------------------- /// - /// Gets the length of the primary tracking processing queue. + /// The pause info string. /// /// ------------------------------------------------------------------------------------------------- - public abstract int PrimaryTrackingProcessingQueueLength { get; } + private string pauseInfo; /// ------------------------------------------------------------------------------------------------- /// - /// Gets the sample rates. - /// - /// ------------------------------------------------------------------------------------------------- - public abstract ObservableConcurrentDictionary SampleRates { get; } - - /// ------------------------------------------------------------------------------------------------- - /// - /// Gets the secondary tracking data. - /// - /// ------------------------------------------------------------------------------------------------- - public abstract SecondaryTracking SecondaryTracking { get; } - - /// ------------------------------------------------------------------------------------------------- - /// - /// Gets the length of the secondary tracking processing queue. + /// Initializes a new instance of the class. /// + /// + /// sushi.at, 31/01/2022. + /// + /// + /// The OpenSky service instance. + /// /// ------------------------------------------------------------------------------------------------- - public abstract int SecondaryTrackingProcessingQueueLength { get; } + protected Simulator(OpenSkyService openSkyServiceInstance) + { + this.openSkyServiceInstance = openSkyServiceInstance; + this.primaryTrackingProcessingQueue = new ConcurrentQueue(); + this.secondaryTrackingProcessingQueue = new ConcurrentQueue(); + this.landingAnalysisProcessingQueue = new ConcurrentQueue(); + this.TrackingEventLogEntries = new ObservableCollection(); + this.AircraftTrailLocations = new LocationCollection(); + this.SimbriefRouteLocations = new LocationCollection(); + this.LandingReports = new ObservableCollection(); + + // Default values and init data structures + this.SampleRates = new ObservableConcurrentDictionary + { + { Requests.Primary, 50 }, + { Requests.Secondary, 500 }, + { Requests.FuelTanks, 15000 }, + { Requests.PayloadStations, 15000 }, + { Requests.PlaneIdentity, 15000 }, + { Requests.WeightAndBalance, 15000 }, + { Requests.LandingAnalysis, 500 } + }; + + this.LastReceivedTimes = new ObservableConcurrentDictionary(); + foreach (Requests request in Enum.GetValues(typeof(Requests))) + { + this.LastReceivedTimes.Add(request, null); + } + + this.TrackingConditions = new Dictionary + { + { (int)Agent.Simulator.Models.TrackingConditions.DateTime, new TrackingCondition { AutoSet = true } }, + { (int)Agent.Simulator.Models.TrackingConditions.Fuel, new TrackingCondition { AutoSet = true } }, + { (int)Agent.Simulator.Models.TrackingConditions.Payload, new TrackingCondition { AutoSet = true } }, + { (int)Agent.Simulator.Models.TrackingConditions.PlaneModel, new TrackingCondition() }, + { (int)Agent.Simulator.Models.TrackingConditions.RealismSettings, new TrackingCondition { Expected = "No slew, No unlimited fuel,\r\nCrash detection, SimRate=1" } }, + { (int)Agent.Simulator.Models.TrackingConditions.Location, new TrackingCondition() } + }; + + // Start our worker threads + new Thread(this.ProcessPrimaryTracking) { Name = "Simulator.ProcessPrimaryTracking" }.Start(); + new Thread(this.ProcessSecondaryTracking) { Name = "Simulator.ProcessSecondaryTracking" }.Start(); + new Thread(this.ProcessLandingAnalysis) { Name = "Simulator.ProcessLandingAnalysis" }.Start(); + } /// ------------------------------------------------------------------------------------------------- /// - /// Gets information about the tracking duration. + /// Occurs when a property value changes. /// /// ------------------------------------------------------------------------------------------------- - public abstract string TrackingDuration { get; protected set; } + public event PropertyChangedEventHandler PropertyChanged; /// ------------------------------------------------------------------------------------------------- /// - /// Gets the tracking status. + /// Gets the simulator instance. /// /// ------------------------------------------------------------------------------------------------- - public abstract TrackingStatus TrackingStatus { get; protected set; } + public static Simulator Instance { get; private set; } /// ------------------------------------------------------------------------------------------------- /// - /// Gets the vertical profile. + /// Gets a value indicating whether the simulator is connected. /// /// ------------------------------------------------------------------------------------------------- - public abstract VerticalProfile VerticalProfile { get; } + public bool Connected + { + get => this.connected; + + protected set + { + if (Equals(this.connected, value)) + { + return; + } + + this.connected = value; + this.OnPropertyChanged(); + } + } /// ------------------------------------------------------------------------------------------------- /// - /// Gets information describing the warp status. + /// Gets a value indicating whether the sim is paused (proper pause, not ESC menu and definitely + /// not active pause). /// /// ------------------------------------------------------------------------------------------------- - public abstract string WarpInfo { get; protected set; } + public abstract bool IsPaused { get; } /// ------------------------------------------------------------------------------------------------- /// - /// Gets a value indicating whether the aircraft was airborne. + /// Gets the pause info string. /// /// ------------------------------------------------------------------------------------------------- - public abstract bool WasAirborne { get; } + public string PauseInfo + { + get => this.pauseInfo; + + protected set + { + if (Equals(this.pauseInfo, value)) + { + return; + } + + this.pauseInfo = value; + this.OnPropertyChanged(); + } + } /// ------------------------------------------------------------------------------------------------- /// - /// Gets the weight and balance data. + /// Gets the tracking conditions. /// /// ------------------------------------------------------------------------------------------------- - public abstract WeightAndBalance WeightAndBalance { get; } + public Dictionary TrackingConditions { get; } /// ------------------------------------------------------------------------------------------------- /// @@ -219,10 +234,19 @@ public static void SetSimulatorInstance(Simulator simulator) /// Close all connections and dispose the simulator client. /// /// - /// sushi.at, 31/01/2022. + /// sushi.at, 13/03/2021. /// /// ------------------------------------------------------------------------------------------------- - public abstract void Close(); + public void Close() + { + Debug.WriteLine("SimConnect simulator interface closing down..."); + if (this.TrackingStatus is TrackingStatus.GroundOperations or TrackingStatus.Tracking) + { + this.StopTracking(false); + } + + this.close = true; + } /// ------------------------------------------------------------------------------------------------- /// @@ -237,29 +261,6 @@ public static void SetSimulatorInstance(Simulator simulator) /// ------------------------------------------------------------------------------------------------- public abstract void Pause(bool pause); - /// ------------------------------------------------------------------------------------------------- - /// - /// Refresh the request-associated data model object NOW, don't wait for normal refresh interval. - /// - /// - /// sushi.at, 31/01/2022. - /// - /// - /// The request ID type to refresh. - /// - /// ------------------------------------------------------------------------------------------------- - public abstract void RefreshModelNow(Requests request); - - /// ------------------------------------------------------------------------------------------------- - /// - /// Starts flight tracking. - /// - /// - /// sushi.at, 31/01/2022. - /// - /// ------------------------------------------------------------------------------------------------- - public abstract void StartTracking(); - /// ------------------------------------------------------------------------------------------------- /// /// Sets the aircraft registration in the simulator. diff --git a/OpenSky.Agent.SimConnectMSFS/SimConnect.Simbrief.cs b/OpenSky.Agent.Simulator/Simulator.simBrief.cs similarity index 97% rename from OpenSky.Agent.SimConnectMSFS/SimConnect.Simbrief.cs rename to OpenSky.Agent.Simulator/Simulator.simBrief.cs index a81b364..9ceb7fb 100644 --- a/OpenSky.Agent.SimConnectMSFS/SimConnect.Simbrief.cs +++ b/OpenSky.Agent.Simulator/Simulator.simBrief.cs @@ -1,10 +1,10 @@ // -------------------------------------------------------------------------------------------------------------------- -// +// // OpenSky project 2021-2022 // // -------------------------------------------------------------------------------------------------------------------- -namespace OpenSky.AgentMSFS.SimConnect +namespace OpenSky.Agent.Simulator { using System; using System.Collections.Generic; @@ -15,14 +15,15 @@ namespace OpenSky.AgentMSFS.SimConnect using Microsoft.Maps.MapControl.WPF; - using OpenSky.AgentMSFS.Models; + using OpenSky.Agent.Simulator.Models; + using OpenSky.Agent.Simulator.Tools; /// ------------------------------------------------------------------------------------------------- /// - /// Simconnect client - simbrief flight plan import code. + /// Simulator interface - simBrief. /// /// ------------------------------------------------------------------------------------------------- - public partial class SimConnect + public partial class Simulator { /// ------------------------------------------------------------------------------------------------- /// diff --git a/OpenSky.Agent/Tools/UpdateGUIDelegate.cs b/OpenSky.Agent.Simulator/Tools/UpdateGUIDelegate.cs similarity index 95% rename from OpenSky.Agent/Tools/UpdateGUIDelegate.cs rename to OpenSky.Agent.Simulator/Tools/UpdateGUIDelegate.cs index 264107d..3972cca 100644 --- a/OpenSky.Agent/Tools/UpdateGUIDelegate.cs +++ b/OpenSky.Agent.Simulator/Tools/UpdateGUIDelegate.cs @@ -4,7 +4,7 @@ // // -------------------------------------------------------------------------------------------------------------------- -namespace OpenSky.AgentMSFS.Tools +namespace OpenSky.Agent.Simulator.Tools { /// ------------------------------------------------------------------------------------------------- /// diff --git a/OpenSky.Agent.Simulator/packages.config b/OpenSky.Agent.Simulator/packages.config index 41d07b5..5069735 100644 --- a/OpenSky.Agent.Simulator/packages.config +++ b/OpenSky.Agent.Simulator/packages.config @@ -5,6 +5,7 @@ - + + \ No newline at end of file diff --git a/OpenSky.Agent/App.xaml.cs b/OpenSky.Agent/App.xaml.cs index f7a042e..8858d96 100644 --- a/OpenSky.Agent/App.xaml.cs +++ b/OpenSky.Agent/App.xaml.cs @@ -18,7 +18,8 @@ namespace OpenSky.AgentMSFS using JetBrains.Annotations; using OpenSky.Agent.Simulator; - using OpenSky.AgentMSFS.Models; + using OpenSky.Agent.Simulator.Enums; + using OpenSky.Agent.Simulator.Tools; using OpenSky.AgentMSFS.Properties; using OpenSky.AgentMSFS.Tools; diff --git a/OpenSky.Agent/Controls/OpenSkyMessageBox.xaml.cs b/OpenSky.Agent/Controls/OpenSkyMessageBox.xaml.cs index f9f11a8..faea237 100644 --- a/OpenSky.Agent/Controls/OpenSkyMessageBox.xaml.cs +++ b/OpenSky.Agent/Controls/OpenSkyMessageBox.xaml.cs @@ -15,7 +15,6 @@ namespace OpenSky.AgentMSFS.Controls using OpenSky.Agent.Simulator.Tools; using OpenSky.AgentMSFS.Controls.Models; - using OpenSky.AgentMSFS.Tools; /// ------------------------------------------------------------------------------------------------- /// diff --git a/OpenSky.Agent/Controls/OpenSkyNotification.xaml.cs b/OpenSky.Agent/Controls/OpenSkyNotification.xaml.cs index 8eb0686..591c227 100644 --- a/OpenSky.Agent/Controls/OpenSkyNotification.xaml.cs +++ b/OpenSky.Agent/Controls/OpenSkyNotification.xaml.cs @@ -13,7 +13,6 @@ namespace OpenSky.AgentMSFS.Controls using OpenSky.Agent.Simulator.Tools; using OpenSky.AgentMSFS.Controls.Models; - using OpenSky.AgentMSFS.Tools; /// ------------------------------------------------------------------------------------------------- /// diff --git a/OpenSky.Agent/Controls/OpenSkyWindow.cs b/OpenSky.Agent/Controls/OpenSkyWindow.cs index bc4d75e..d330c83 100644 --- a/OpenSky.Agent/Controls/OpenSkyWindow.cs +++ b/OpenSky.Agent/Controls/OpenSkyWindow.cs @@ -19,8 +19,8 @@ namespace OpenSky.AgentMSFS.Controls using System.Windows.Interop; using System.Windows.Shapes; + using OpenSky.Agent.Simulator.Tools; using OpenSky.AgentMSFS.Controls.Models; - using OpenSky.AgentMSFS.Tools; using Button = System.Windows.Controls.Button; using Cursors = System.Windows.Input.Cursors; diff --git a/OpenSky.Agent/Converters/CanSetWeightAndBalancesConverter.cs b/OpenSky.Agent/Converters/CanSetWeightAndBalancesConverter.cs index b52b63f..83d03ad 100644 --- a/OpenSky.Agent/Converters/CanSetWeightAndBalancesConverter.cs +++ b/OpenSky.Agent/Converters/CanSetWeightAndBalancesConverter.cs @@ -10,7 +10,7 @@ namespace OpenSky.AgentMSFS.Converters using System.Globalization; using System.Windows.Data; - using OpenSky.AgentMSFS.Models; + using OpenSky.Agent.Simulator.Enums; /// ------------------------------------------------------------------------------------------------- /// diff --git a/OpenSky.Agent/Converters/CgColorConverter.cs b/OpenSky.Agent/Converters/CgColorConverter.cs index 0e17a3d..4c1e90b 100644 --- a/OpenSky.Agent/Converters/CgColorConverter.cs +++ b/OpenSky.Agent/Converters/CgColorConverter.cs @@ -11,6 +11,7 @@ namespace OpenSky.AgentMSFS.Converters using System.Windows.Data; using System.Windows.Media; + using OpenSky.Agent.Simulator; using OpenSky.Agent.Simulator.Models; /// ------------------------------------------------------------------------------------------------- diff --git a/OpenSky.Agent/Converters/CgLateralColorConverter.cs b/OpenSky.Agent/Converters/CgLateralColorConverter.cs index 3d26206..33eaf47 100644 --- a/OpenSky.Agent/Converters/CgLateralColorConverter.cs +++ b/OpenSky.Agent/Converters/CgLateralColorConverter.cs @@ -11,6 +11,8 @@ namespace OpenSky.AgentMSFS.Converters using System.Windows.Data; using System.Windows.Media; + using OpenSky.Agent.Simulator; + /// ------------------------------------------------------------------------------------------------- /// /// Center of gravity lateral to color converter (green within limits, red outside the limits) diff --git a/OpenSky.Agent/Converters/WeightsColorConverter.cs b/OpenSky.Agent/Converters/WeightsColorConverter.cs index a0150e2..0e9fb79 100644 --- a/OpenSky.Agent/Converters/WeightsColorConverter.cs +++ b/OpenSky.Agent/Converters/WeightsColorConverter.cs @@ -11,6 +11,7 @@ namespace OpenSky.AgentMSFS.Converters using System.Windows.Data; using System.Windows.Media; + using OpenSky.Agent.Simulator; using OpenSky.Agent.Simulator.Models; /// ------------------------------------------------------------------------------------------------- diff --git a/OpenSky.Agent/OpenSky.Agent.csproj b/OpenSky.Agent/OpenSky.Agent.csproj index 3f1da33..0249188 100644 --- a/OpenSky.Agent/OpenSky.Agent.csproj +++ b/OpenSky.Agent/OpenSky.Agent.csproj @@ -135,10 +135,7 @@ - - - @@ -163,7 +160,6 @@ - @@ -394,7 +390,7 @@ 13.0.1 - 0.1.4 + 0.1.5 19.4.0.48 diff --git a/OpenSky.Agent/Tools/ExceptionExtensions.cs b/OpenSky.Agent/Tools/ExceptionExtensions.cs index f6bad70..51cd61a 100644 --- a/OpenSky.Agent/Tools/ExceptionExtensions.cs +++ b/OpenSky.Agent/Tools/ExceptionExtensions.cs @@ -15,11 +15,10 @@ namespace OpenSky.AgentMSFS.Tools using Newtonsoft.Json; - using OpenSky.Agent.Simulator; + using OpenSky.Agent.Simulator.OpenAPIs; using OpenSky.AgentMSFS.Controls; using OpenSky.AgentMSFS.Controls.Models; using OpenSky.AgentMSFS.MVVM; - using OpenSky.AgentMSFS.OpenAPIs; using OpenSky.AgentMSFS.Views; using OpenSkyApi; diff --git a/OpenSky.Agent/UserSessionService.cs b/OpenSky.Agent/UserSessionService.cs index d00cbf5..5e6a7ad 100644 --- a/OpenSky.Agent/UserSessionService.cs +++ b/OpenSky.Agent/UserSessionService.cs @@ -261,7 +261,7 @@ public async Task ForceTokenRefresh() try { - var result = await OpenSkyService.Instance.GetUserRolesAsync(); + var result = await AgentOpenSkyService.Instance.GetUserRolesAsync(); return !result.IsError; } catch (Exception ex) @@ -313,7 +313,7 @@ public async Task RefreshLinkedAccounts() { try { - var result = await OpenSkyService.Instance.GetLinkedAccountsAsync(); + var result = await AgentOpenSkyService.Instance.GetLinkedAccountsAsync(); if (!result.IsError) { this.LinkedAccounts = result.Data; @@ -344,7 +344,7 @@ public async Task RefreshUserAccountOverview() { try { - var result = await OpenSkyService.Instance.GetAccountOverviewAsync(); + var result = await AgentOpenSkyService.Instance.GetAccountOverviewAsync(); if (!result.IsError) { this.AccountOverview = result.Data; @@ -400,7 +400,7 @@ public async Task UpdateUserRoles() { try { - var result = await OpenSkyService.Instance.GetUserRolesAsync(); + var result = await AgentOpenSkyService.Instance.GetUserRolesAsync(); if (!result.IsError) { this.userRoles.Clear(); diff --git a/OpenSky.Agent/Views/AircraftTypes.xaml b/OpenSky.Agent/Views/AircraftTypes.xaml index c0a26a0..0f18ea1 100644 --- a/OpenSky.Agent/Views/AircraftTypes.xaml +++ b/OpenSky.Agent/Views/AircraftTypes.xaml @@ -17,12 +17,12 @@ xmlns:controls="clr-namespace:OpenSky.AgentMSFS.Controls" xmlns:models="clr-namespace:OpenSky.AgentMSFS.Views.Models" xmlns:converters="clr-namespace:OpenSky.AgentMSFS.Converters" - xmlns:openSkyApi="clr-namespace:OpenSkyApi" xmlns:system="clr-namespace:System;assembly=mscorlib" xmlns:ui="http://schemas.modernwpf.com/2019" xmlns:dgx="urn:tom-englert.de/DataGridExtensions" xmlns:tools="clr-namespace:OpenSky.AgentMSFS.Tools" xmlns:componentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase" + xmlns:openSkyApi="clr-namespace:OpenSkyApi;assembly=OpenSky.Agent.Simulator" mc:Ignorable="d" d:DesignWidth="2000" Loaded="AircraftTypesOnLoaded" Title="Aircraft Types" Height="800" Width="1400" HorizontalScrollBar="False" VerticalScrollBar="False" LoadingText="{Binding LoadingText}"> @@ -505,17 +505,17 @@ Max payload Δ lbs Comments - - - - - + + + + + - - + + diff --git a/OpenSky.Agent/Views/AircraftTypes.xaml.cs b/OpenSky.Agent/Views/AircraftTypes.xaml.cs index 2a21083..caae608 100644 --- a/OpenSky.Agent/Views/AircraftTypes.xaml.cs +++ b/OpenSky.Agent/Views/AircraftTypes.xaml.cs @@ -10,7 +10,6 @@ namespace OpenSky.AgentMSFS.Views using DataGridExtensions; - using OpenSky.Agent.Simulator; using OpenSky.AgentMSFS.Views.Models; /// ------------------------------------------------------------------------------------------------- diff --git a/OpenSky.Agent/Views/FlightTracking.xaml b/OpenSky.Agent/Views/FlightTracking.xaml index d1dd61e..39c5a9b 100644 --- a/OpenSky.Agent/Views/FlightTracking.xaml +++ b/OpenSky.Agent/Views/FlightTracking.xaml @@ -18,8 +18,8 @@ xmlns:controls="clr-namespace:OpenSky.AgentMSFS.Controls" xmlns:viewModels="clr-namespace:OpenSky.AgentMSFS.Views.Models" xmlns:converters="clr-namespace:OpenSky.AgentMSFS.Converters" - xmlns:models="clr-namespace:OpenSky.AgentMSFS.Models" xmlns:sf="http://schemas.syncfusion.com/wpf" + xmlns:simulator="clr-namespace:OpenSky.Agent.Simulator.Models;assembly=OpenSky.Agent.Simulator" mc:Ignorable="d" LoadingText="{Binding LoadingText}" Title="Flight Tracking" Height="1000" Width="1300" Loaded="FlightTrackingLoaded" Unloaded="FlightTrackingOnUnloaded" FontSize="14" HorizontalScrollBar="False" VerticalScrollBar="False"> @@ -546,7 +546,7 @@ - + diff --git a/OpenSky.Agent/Views/FlightTracking.xaml.cs b/OpenSky.Agent/Views/FlightTracking.xaml.cs index 17bf064..52ba161 100644 --- a/OpenSky.Agent/Views/FlightTracking.xaml.cs +++ b/OpenSky.Agent/Views/FlightTracking.xaml.cs @@ -23,8 +23,6 @@ namespace OpenSky.AgentMSFS.Views using OpenSky.Agent.Simulator.Tools; using OpenSky.AgentMSFS.Controls; using OpenSky.AgentMSFS.Converters; - using OpenSky.AgentMSFS.Models; - using OpenSky.AgentMSFS.Tools; using OpenSky.AgentMSFS.Views.Models; /// ------------------------------------------------------------------------------------------------- diff --git a/OpenSky.Agent/Views/LandingReport.xaml.cs b/OpenSky.Agent/Views/LandingReport.xaml.cs index 0a51822..038d2c7 100644 --- a/OpenSky.Agent/Views/LandingReport.xaml.cs +++ b/OpenSky.Agent/Views/LandingReport.xaml.cs @@ -9,9 +9,9 @@ namespace OpenSky.AgentMSFS.Views using System; using System.Windows; + using OpenSky.Agent.Simulator.Tools; using OpenSky.AgentMSFS.Native; using OpenSky.AgentMSFS.Native.PInvoke.Enums; - using OpenSky.AgentMSFS.Tools; /// ------------------------------------------------------------------------------------------------- /// diff --git a/OpenSky.Agent/Views/LoginNotification.xaml.cs b/OpenSky.Agent/Views/LoginNotification.xaml.cs index af004f3..c04d950 100644 --- a/OpenSky.Agent/Views/LoginNotification.xaml.cs +++ b/OpenSky.Agent/Views/LoginNotification.xaml.cs @@ -9,6 +9,7 @@ namespace OpenSky.AgentMSFS.Views using System; using System.Windows; + using OpenSky.Agent.Simulator.Tools; using OpenSky.AgentMSFS.Tools; using OpenSky.AgentMSFS.Views.Models; diff --git a/OpenSky.Agent/Views/Models/AircraftTypesViewModel.cs b/OpenSky.Agent/Views/Models/AircraftTypesViewModel.cs index f214353..0c0a77c 100644 --- a/OpenSky.Agent/Views/Models/AircraftTypesViewModel.cs +++ b/OpenSky.Agent/Views/Models/AircraftTypesViewModel.cs @@ -13,18 +13,14 @@ namespace OpenSky.AgentMSFS.Views.Models using System.Threading; using System.Windows; - using OpenSky.Agent.Simulator; using OpenSky.Agent.Simulator.Tools; using OpenSky.AgentMSFS.Controls; using OpenSky.AgentMSFS.Controls.Models; using OpenSky.AgentMSFS.MVVM; - using OpenSky.AgentMSFS.OpenAPIs; using OpenSky.AgentMSFS.Tools; using OpenSkyApi; - using Simulator = OpenSkyApi.Simulator; - /// ------------------------------------------------------------------------------------------------- /// /// Aircraft types view model. diff --git a/OpenSky.Agent/Views/Models/AutoUpdateViewModel.cs b/OpenSky.Agent/Views/Models/AutoUpdateViewModel.cs index 7e5c6cb..fc7e42c 100644 --- a/OpenSky.Agent/Views/Models/AutoUpdateViewModel.cs +++ b/OpenSky.Agent/Views/Models/AutoUpdateViewModel.cs @@ -16,6 +16,7 @@ namespace OpenSky.AgentMSFS.Views.Models using Newtonsoft.Json; + using OpenSky.Agent.Simulator.Tools; using OpenSky.AgentMSFS.Controls; using OpenSky.AgentMSFS.Controls.Models; using OpenSky.AgentMSFS.MVVM; diff --git a/OpenSky.Agent/Views/Models/FlightTrackingViewModel.FuelTanks.cs b/OpenSky.Agent/Views/Models/FlightTrackingViewModel.FuelTanks.cs index cedba57..83c3b7a 100644 --- a/OpenSky.Agent/Views/Models/FlightTrackingViewModel.FuelTanks.cs +++ b/OpenSky.Agent/Views/Models/FlightTrackingViewModel.FuelTanks.cs @@ -135,8 +135,8 @@ private void SetFuelTanks() fuelTanks.UpdateQuantitiesFromDictionary(quantities); this.Simulator.SetFuelTanks(fuelTanks); - this.Simulator.RefreshStructNow(Requests.FuelTanks); - this.Simulator.RefreshStructNow(Requests.WeightAndBalance); + this.Simulator.RefreshModelNow(Requests.FuelTanks); + this.Simulator.RefreshModelNow(Requests.WeightAndBalance); } catch (Exception ex) { diff --git a/OpenSky.Agent/Views/Models/FlightTrackingViewModel.Map.cs b/OpenSky.Agent/Views/Models/FlightTrackingViewModel.Map.cs index f077a94..e5c1b05 100644 --- a/OpenSky.Agent/Views/Models/FlightTrackingViewModel.Map.cs +++ b/OpenSky.Agent/Views/Models/FlightTrackingViewModel.Map.cs @@ -18,12 +18,11 @@ namespace OpenSky.AgentMSFS.Views.Models using Microsoft.Maps.MapControl.WPF; - using OpenSky.Agent.Simulator; + using OpenSky.Agent.Simulator.Models; + using OpenSky.Agent.Simulator.Tools; using OpenSky.AgentMSFS.Controls; using OpenSky.AgentMSFS.Controls.Models; - using OpenSky.AgentMSFS.Models; using OpenSky.AgentMSFS.MVVM; - using OpenSky.AgentMSFS.Tools; using OpenSkyApi; diff --git a/OpenSky.Agent/Views/Models/FlightTrackingViewModel.PayloadStations.cs b/OpenSky.Agent/Views/Models/FlightTrackingViewModel.PayloadStations.cs index d0ba3e2..111f40c 100644 --- a/OpenSky.Agent/Views/Models/FlightTrackingViewModel.PayloadStations.cs +++ b/OpenSky.Agent/Views/Models/FlightTrackingViewModel.PayloadStations.cs @@ -115,8 +115,8 @@ private void SetPayloadStations() payloadStations.Weight20 = this.PayloadStationWeights[19]; this.Simulator.SetPayloadStations(payloadStations); - this.Simulator.RefreshStructNow(Requests.PayloadStations); - this.Simulator.RefreshStructNow(Requests.WeightAndBalance); + this.Simulator.RefreshModelNow(Requests.PayloadStations); + this.Simulator.RefreshModelNow(Requests.WeightAndBalance); } catch (Exception ex) { diff --git a/OpenSky.Agent/Views/Models/FlightTrackingViewModel.cs b/OpenSky.Agent/Views/Models/FlightTrackingViewModel.cs index bade68d..34e17eb 100644 --- a/OpenSky.Agent/Views/Models/FlightTrackingViewModel.cs +++ b/OpenSky.Agent/Views/Models/FlightTrackingViewModel.cs @@ -22,7 +22,6 @@ namespace OpenSky.AgentMSFS.Views.Models using OpenSky.Agent.Simulator.Tools; using OpenSky.AgentMSFS.Controls; using OpenSky.AgentMSFS.Controls.Models; - using OpenSky.AgentMSFS.Models; using OpenSky.AgentMSFS.MVVM; using OpenSky.AgentMSFS.Tools; @@ -899,7 +898,7 @@ private void StartTracking() } // Set the plane registration - this.Simulator.SetPlaneRegistry(this.Simulator.Flight?.Aircraft.Registry); + this.Simulator.SetAircraftRegistry(this.Simulator.Flight?.Aircraft.Registry); // Wait a bit to make sure all structs have updated, especially time in sim Thread.Sleep(this.Simulator.SampleRates[Requests.Secondary] + 1000); @@ -1094,7 +1093,7 @@ private void StartTracking() this.Simulator.SetFuelAndPayloadFromSave(); // Set the plane registration - this.Simulator.SetPlaneRegistry(this.Simulator.Flight?.Aircraft.Registry); + this.Simulator.SetAircraftRegistry(this.Simulator.Flight?.Aircraft.Registry); // Start five second countdown? if (this.Simulator.PrimaryTracking.SlewActive) diff --git a/OpenSky.Agent/Views/Models/LandingReportViewModel.cs b/OpenSky.Agent/Views/Models/LandingReportViewModel.cs index 451037c..0d5c1c4 100644 --- a/OpenSky.Agent/Views/Models/LandingReportViewModel.cs +++ b/OpenSky.Agent/Views/Models/LandingReportViewModel.cs @@ -17,7 +17,6 @@ namespace OpenSky.AgentMSFS.Views.Models using OpenSky.Agent.Simulator.Tools; using OpenSky.AgentMSFS.MVVM; - using OpenSky.AgentMSFS.Tools; using OpenSky.FlightLogXML; using OpenSkyApi; diff --git a/OpenSky.Agent/Views/Models/LoginNotificationViewModel.cs b/OpenSky.Agent/Views/Models/LoginNotificationViewModel.cs index 2fd0d32..ea1126a 100644 --- a/OpenSky.Agent/Views/Models/LoginNotificationViewModel.cs +++ b/OpenSky.Agent/Views/Models/LoginNotificationViewModel.cs @@ -12,10 +12,8 @@ namespace OpenSky.AgentMSFS.Views.Models using System.Reflection; using System.Threading; - using OpenSky.Agent.Simulator; using OpenSky.Agent.Simulator.Tools; using OpenSky.AgentMSFS.MVVM; - using OpenSky.AgentMSFS.Tools; /// ------------------------------------------------------------------------------------------------- /// diff --git a/OpenSky.Agent/Views/Models/NewFlightNotificationViewModel.cs b/OpenSky.Agent/Views/Models/NewFlightNotificationViewModel.cs index 663192c..e147826 100644 --- a/OpenSky.Agent/Views/Models/NewFlightNotificationViewModel.cs +++ b/OpenSky.Agent/Views/Models/NewFlightNotificationViewModel.cs @@ -14,7 +14,6 @@ namespace OpenSky.AgentMSFS.Views.Models using OpenSky.Agent.Simulator; using OpenSky.Agent.Simulator.Tools; using OpenSky.AgentMSFS.MVVM; - using OpenSky.AgentMSFS.Tools; /// ------------------------------------------------------------------------------------------------- /// @@ -52,8 +51,8 @@ public class NewFlightNotificationViewModel : ViewModel public NewFlightNotificationViewModel() { this.Timeout = 60 * 1000; - this.FlightNumber = $"{SimConnect.SimConnect.Instance.Flight?.FullFlightNumber}"; - this.Airports = $"{SimConnect.SimConnect.Instance.Flight?.Origin.Icao} - {SimConnect.SimConnect.Instance.Flight?.Destination.Icao}"; + this.FlightNumber = $"{Simulator.Instance.Flight?.FullFlightNumber}"; + this.Airports = $"{Simulator.Instance.Flight?.Origin.Icao} - {Simulator.Instance.Flight?.Destination.Icao}"; var assembly = Assembly.GetExecutingAssembly(); var player = new SoundPlayer(assembly.GetManifestResourceStream("OpenSky.AgentMSFS.Resources.OSannouncement.wav")); @@ -63,7 +62,7 @@ public NewFlightNotificationViewModel() () => { Thread.Sleep(2000); - SpeechSoundPacks.Instance.PlaySpeechEvent(SpeechEvent.ReadyForBoarding, true, SimConnect.SimConnect.Instance.Flight?.FlightNumber.ToString()); + SpeechSoundPacks.Instance.PlaySpeechEvent(SpeechEvent.ReadyForBoarding, true, Simulator.Instance.Flight?.FlightNumber.ToString()); }) { Name = "OpenSky.NewFlightNotificationViewModel.SpeechFlightNumber" }.Start(); diff --git a/OpenSky.Agent/Views/Models/SettingsViewModel.cs b/OpenSky.Agent/Views/Models/SettingsViewModel.cs index e21202d..e4fcdac 100644 --- a/OpenSky.Agent/Views/Models/SettingsViewModel.cs +++ b/OpenSky.Agent/Views/Models/SettingsViewModel.cs @@ -21,6 +21,7 @@ namespace OpenSky.AgentMSFS.Views.Models using Microsoft.Win32; using OpenSky.Agent.Simulator; + using OpenSky.Agent.Simulator.Tools; using OpenSky.AgentMSFS.Controls; using OpenSky.AgentMSFS.Controls.Models; using OpenSky.AgentMSFS.Models; @@ -543,7 +544,7 @@ private void LogoutOpenSkyUser() { try { - var result = OpenSkyService.Instance.RevokeTokenAsync(new RevokeToken { Token = this.UserSession.RefreshToken }).Result; + var result = AgentOpenSkyService.Instance.RevokeTokenAsync(new RevokeToken { Token = this.UserSession.RefreshToken }).Result; if (result.IsError) { this.LogoutOpenSkyUserCommand.ReportProgress( @@ -658,7 +659,7 @@ private void SaveSettings() SimbriefUsername = this.SimBriefUsername }; - var result = OpenSkyService.Instance.UpdateLinkedAccountsAsync(linkedAccounts).Result; + var result = AgentOpenSkyService.Instance.UpdateLinkedAccountsAsync(linkedAccounts).Result; if (!result.IsError) { _ = UserSessionService.Instance.RefreshLinkedAccounts(); @@ -758,7 +759,7 @@ private void UpdateProfileImage() try { - var result = OpenSkyService.Instance.UploadProfileImageAsync(new FileParameter(File.OpenRead(fileName), fileName, fileName.ToLowerInvariant().EndsWith(".png") ? "image/png" : "image/jpeg")).Result; + var result = AgentOpenSkyService.Instance.UploadProfileImageAsync(new FileParameter(File.OpenRead(fileName), fileName, fileName.ToLowerInvariant().EndsWith(".png") ? "image/png" : "image/jpeg")).Result; if (result.IsError) { this.UpdateProfileImageCommand.ReportProgress( diff --git a/OpenSky.Agent/Views/Models/StartupViewModel.cs b/OpenSky.Agent/Views/Models/StartupViewModel.cs index 965668f..593ea2a 100644 --- a/OpenSky.Agent/Views/Models/StartupViewModel.cs +++ b/OpenSky.Agent/Views/Models/StartupViewModel.cs @@ -24,10 +24,9 @@ namespace OpenSky.AgentMSFS.Views.Models using JetBrains.Annotations; using OpenSky.Agent.Simulator; + using OpenSky.Agent.Simulator.Enums; using OpenSky.Agent.Simulator.Tools; - using OpenSky.AgentMSFS.Models; using OpenSky.AgentMSFS.MVVM; - using OpenSky.AgentMSFS.Tools; using OpenSkyApi; diff --git a/OpenSky.Agent/Views/NewFlightNotification.xaml.cs b/OpenSky.Agent/Views/NewFlightNotification.xaml.cs index 4a16557..577fa31 100644 --- a/OpenSky.Agent/Views/NewFlightNotification.xaml.cs +++ b/OpenSky.Agent/Views/NewFlightNotification.xaml.cs @@ -9,6 +9,7 @@ namespace OpenSky.AgentMSFS.Views using System; using System.Windows; + using OpenSky.Agent.Simulator.Tools; using OpenSky.AgentMSFS.Tools; using OpenSky.AgentMSFS.Views.Models; diff --git a/OpenSky.Agent/Views/SoundPackTester.xaml b/OpenSky.Agent/Views/SoundPackTester.xaml index 5943e1a..c715d27 100644 --- a/OpenSky.Agent/Views/SoundPackTester.xaml +++ b/OpenSky.Agent/Views/SoundPackTester.xaml @@ -16,9 +16,9 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:controls="clr-namespace:OpenSky.AgentMSFS.Controls" xmlns:models="clr-namespace:OpenSky.AgentMSFS.Views.Models" - xmlns:agentMsfs="clr-namespace:OpenSky.AgentMSFS" xmlns:ui="http://schemas.modernwpf.com/2019" xmlns:converters="clr-namespace:OpenSky.AgentMSFS.Converters" + xmlns:simulator="clr-namespace:OpenSky.Agent.Simulator;assembly=OpenSky.Agent.Simulator" mc:Ignorable="d" Loaded="SoundPackTesterOnLoaded" Title="Sound Pack Tester" Height="450" Width="1200" ResizeMode="CanResize" ShowMinMaxButtons="True" FontSize="14" HorizontalScrollBar="False" VerticalScrollBar="False" SizeToContent="Height"> @@ -43,7 +43,7 @@ - + diff --git a/changelog.txt b/changelog.txt index 7328f38..a313e98 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,11 @@ OpenSky Agent for MSFS Changelog ====================================================================================== +-------------------------------------------------------------------------------------- +Version 0.4.0 (ALPHA4) +-------------------------------------------------------------------------------------- +- Common simulator interface code extracted and separated from SimConnect code + -------------------------------------------------------------------------------------- Version 0.3.7 (ALPHA3) -------------------------------------------------------------------------------------- From 41d840a78e625f66fdb18cb61cd7402a224d06d2 Mon Sep 17 00:00:00 2001 From: "sushi.at" Date: Tue, 1 Feb 2022 23:18:28 +0000 Subject: [PATCH 7/9] Test flight Increased speed limit check to 260 Fixed aircraft image not heading and following Fixed scrolling listbox crash --- .../Simulator.Process.Systems.cs | 4 +- OpenSky.Agent.Simulator/Simulator.Process.cs | 46 ++++++++++++------- OpenSky.Agent/Controls/ScrollingListBox.cs | 9 +++- OpenSky.Agent/Views/FlightTracking.xaml.cs | 4 +- 4 files changed, 42 insertions(+), 21 deletions(-) diff --git a/OpenSky.Agent.Simulator/Simulator.Process.Systems.cs b/OpenSky.Agent.Simulator/Simulator.Process.Systems.cs index 56e4e14..fef07b6 100644 --- a/OpenSky.Agent.Simulator/Simulator.Process.Systems.cs +++ b/OpenSky.Agent.Simulator/Simulator.Process.Systems.cs @@ -80,8 +80,8 @@ private void MonitorPrimarySystems(ProcessPrimaryTracking ppt) } } - // 10000 feet speed limit 250 knots (give 500 feet spare) - if (ppt.New.IndicatedAltitude < 9500 && !ppt.New.OnGround && ppt.New.AirspeedIndicated > 250) + // 10000 feet speed limit 250 knots (give 500 feet and 10 knots spare) + if (ppt.New.IndicatedAltitude < 9500 && !ppt.New.OnGround && ppt.New.AirspeedIndicated > 260) { if (!this.speedLimitWarningActive) { diff --git a/OpenSky.Agent.Simulator/Simulator.Process.cs b/OpenSky.Agent.Simulator/Simulator.Process.cs index d4adf05..c7b6264 100644 --- a/OpenSky.Agent.Simulator/Simulator.Process.cs +++ b/OpenSky.Agent.Simulator/Simulator.Process.cs @@ -354,20 +354,27 @@ private void ProcessPrimaryTracking() { try { - this.CheckChangesOverTime(ppt.New); - this.MonitorPrimarySystems(ppt); - this.AddPositionReport(ppt.New); - this.TrackFlight(ppt); - - // Fire the location changed event? - if (!ppt.Old.MapLocation.Equals(ppt.New.MapLocation)) + if (ppt.Old != null && ppt.New != null) { - newLocation = ppt.New.MapLocation; + this.CheckChangesOverTime(ppt.New); + this.MonitorPrimarySystems(ppt); + this.AddPositionReport(ppt.New); + this.TrackFlight(ppt); + + // Fire the location changed event? + if (!ppt.Old.MapLocation.Equals(ppt.New.MapLocation)) + { + newLocation = ppt.New.MapLocation; + } + + // Are we close to landing? + this.SampleRates[Requests.LandingAnalysis] = this.WasAirborne && ppt.New.RadioHeight < 500 ? 25 : 500; + this.OnPropertyChanged(nameof(this.SampleRates)); + } + else + { + Debug.WriteLine("Dequeued primary tracking containing at least one NULL value."); } - - // Are we close to landing? - this.SampleRates[Requests.LandingAnalysis] = this.WasAirborne && ppt.New.RadioHeight < 500 ? 25 : 500; - this.OnPropertyChanged(nameof(this.SampleRates)); } catch (Exception ex) { @@ -400,10 +407,17 @@ private void ProcessSecondaryTracking() { try { - this.MonitorLights(pst); - this.TransitionFlightPhase(); - this.MonitorSecondarySystems(pst); - this.MonitorTrackingStartConditions(pst.New); + if (pst.Old != null && pst.New != null) + { + this.MonitorLights(pst); + this.TransitionFlightPhase(); + this.MonitorSecondarySystems(pst); + this.MonitorTrackingStartConditions(pst.New); + } + else + { + Debug.WriteLine("Dequeued secondary tracking containing at least one NULL value."); + } } catch (Exception ex) { diff --git a/OpenSky.Agent/Controls/ScrollingListBox.cs b/OpenSky.Agent/Controls/ScrollingListBox.cs index 4b6696b..3ba2374 100644 --- a/OpenSky.Agent/Controls/ScrollingListBox.cs +++ b/OpenSky.Agent/Controls/ScrollingListBox.cs @@ -56,7 +56,14 @@ protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e) { if (e.NewItems?.Count > 0) { - this.ScrollIntoView(e.NewItems[e.NewItems.Count - 1]); + try + { + this.ScrollIntoView(e.NewItems[e.NewItems.Count - 1]); + } + catch + { + // Ignore + } } base.OnItemsChanged(e); diff --git a/OpenSky.Agent/Views/FlightTracking.xaml.cs b/OpenSky.Agent/Views/FlightTracking.xaml.cs index 9969cb6..6013f37 100644 --- a/OpenSky.Agent/Views/FlightTracking.xaml.cs +++ b/OpenSky.Agent/Views/FlightTracking.xaml.cs @@ -106,12 +106,12 @@ private void AddAircraftAndTrailsToMap() aircraftPosition.SetValue(Panel.ZIndexProperty, 999); aircraftPosition.SetValue(MapLayer.PositionOriginProperty, PositionOrigin.Center); var rotateTransform = new RotateTransform { CenterX = 20, CenterY = 20 }; - var headingBinding = new Binding { Source = this.DataContext, Path = new PropertyPath("SimConnect.PrimaryTracking.Heading"), Mode = BindingMode.OneWay }; + var headingBinding = new Binding { Source = this.DataContext, Path = new PropertyPath("Simulator.PrimaryTracking.Heading"), Mode = BindingMode.OneWay }; BindingOperations.SetBinding(rotateTransform, RotateTransform.AngleProperty, headingBinding); aircraftPosition.RenderTransform = rotateTransform; var aircraftDrawingImage = this.FindResource("OpenSkyLogoPointingUpForMap") as DrawingImage; aircraftPosition.Source = aircraftDrawingImage; - var positionBinding = new Binding { Source = this.DataContext, Path = new PropertyPath("SimConnect.PrimaryTracking.MapLocation"), Mode = BindingMode.OneWay }; + var positionBinding = new Binding { Source = this.DataContext, Path = new PropertyPath("Simulator.PrimaryTracking.MapLocation"), Mode = BindingMode.OneWay }; BindingOperations.SetBinding(aircraftPosition, MapLayer.PositionProperty, positionBinding); this.MapView.Children.Add(aircraftPosition); } From 117b9cd58e4727cac0828e58285f7c515202cf43 Mon Sep 17 00:00:00 2001 From: "sushi.at" Date: Wed, 2 Feb 2022 10:28:11 +0000 Subject: [PATCH 8/9] Updated installer to work with new project name --- Installer/Installer.wixproj | 6 +++--- Installer/Product.wxs | 2 +- changelog.txt | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Installer/Installer.wixproj b/Installer/Installer.wixproj index 127f53e..3b8eeeb 100644 --- a/Installer/Installer.wixproj +++ b/Installer/Installer.wixproj @@ -6,7 +6,7 @@ 3.10 853790e9-5caa-4ebc-b4c3-c563c3242f1d 2.0 - OpenSky.AgentMSFS + OpenSky.Agent Package @@ -58,7 +58,7 @@ To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Wix.targets.--> - + @@ -84,7 +84,7 @@ - "..\..\StellarHeat\DevToolkit.StellarHeat.exe" -dr:INSTALLFOLDER -cg:OpenSky.AgentMSFS.Libraries -dir:"..\..\..\OpenSky.AgentMSFS\bin\$(Configuration)" -out:"..\..\Libraries.wxs" + "..\..\StellarHeat\DevToolkit.StellarHeat.exe" -dr:INSTALLFOLDER -cg:OpenSky.Agent.Libraries -dir:"..\..\..\OpenSky.Agent\bin\$(Configuration)" -out:"..\..\Libraries.wxs" "C:\Program Files (x86)\WiX Toolset v3.11\bin\heat.exe" dir "..\..\..\SoundPacks" -o "..\..\SoundPacks.wxs" -cg OpenSky.SoundPacks -sfrag -gg -suid -dr INSTALLFOLDER -var var.SoundPackSourceFolder -v -t ..\..\win64.xslt \ No newline at end of file diff --git a/Installer/Product.wxs b/Installer/Product.wxs index 2e40533..63f0983 100644 --- a/Installer/Product.wxs +++ b/Installer/Product.wxs @@ -55,7 +55,7 @@ - + diff --git a/changelog.txt b/changelog.txt index a313e98..851b94e 100644 --- a/changelog.txt +++ b/changelog.txt @@ -6,6 +6,7 @@ OpenSky Agent for MSFS Changelog Version 0.4.0 (ALPHA4) -------------------------------------------------------------------------------------- - Common simulator interface code extracted and separated from SimConnect code +- Minor bug fixes and improvements -------------------------------------------------------------------------------------- Version 0.3.7 (ALPHA3) From 9a3786aa4fd906aad2005d3277f00ca23cc17584 Mon Sep 17 00:00:00 2001 From: "sushi.at" Date: Wed, 2 Feb 2022 10:30:59 +0000 Subject: [PATCH 9/9] Changed release build target platform to x64 as well --- OpenSky.Agent.SimConnectMSFS/OpenSky.Agent.SimConnectMSFS.csproj | 1 + OpenSky.Agent.Simulator/OpenSky.Agent.Simulator.csproj | 1 + 2 files changed, 2 insertions(+) diff --git a/OpenSky.Agent.SimConnectMSFS/OpenSky.Agent.SimConnectMSFS.csproj b/OpenSky.Agent.SimConnectMSFS/OpenSky.Agent.SimConnectMSFS.csproj index 21f1f87..0869344 100644 --- a/OpenSky.Agent.SimConnectMSFS/OpenSky.Agent.SimConnectMSFS.csproj +++ b/OpenSky.Agent.SimConnectMSFS/OpenSky.Agent.SimConnectMSFS.csproj @@ -37,6 +37,7 @@ 4 bin\Release\OpenSky.Agent.SimConnectMSFS.xml latest + x64 diff --git a/OpenSky.Agent.Simulator/OpenSky.Agent.Simulator.csproj b/OpenSky.Agent.Simulator/OpenSky.Agent.Simulator.csproj index bba5503..c3dc59c 100644 --- a/OpenSky.Agent.Simulator/OpenSky.Agent.Simulator.csproj +++ b/OpenSky.Agent.Simulator/OpenSky.Agent.Simulator.csproj @@ -37,6 +37,7 @@ 4 bin\Release\OpenSky.Agent.Simulator.xml latest + x64