From 0ea53157a830dcb068dc8718539fa376632a1313 Mon Sep 17 00:00:00 2001 From: Jerker Dahlblom Date: Fri, 1 Mar 2024 20:51:17 +0200 Subject: [PATCH] Remove dcs bios classlibrarycommon projects (#495) * Remove dcs-bios classlibrarycommon projects Will be added as submodules * Add submodules --- .gitmodules | 3 + .../ClassLibraryCommon.csproj | 56 -- src/ClassLibraryCommon/Common.cs | 347 ----------- src/ClassLibraryCommon/CommonEnums.cs | 90 --- .../UserControlSpinningWheel.xaml | 35 -- .../UserControlSpinningWheel.xaml.cs | 86 --- src/ClassLibraryCommon/DCSAircraft.cs | 543 ------------------ src/ClassLibraryCommon/DarkMode.cs | 97 ---- src/ClassLibraryCommon/DarkMode/Button.xaml | 59 -- src/ClassLibraryCommon/DarkMode/CheckBox.xaml | 92 --- src/ClassLibraryCommon/DarkMode/ComboBox.xaml | 286 --------- .../DarkMode/ComboBoxItem.xaml | 101 ---- .../DarkMode/ContextMenu.xaml | 39 -- src/ClassLibraryCommon/DarkMode/DataGrid.xaml | 84 --- .../DarkMode/DataGridCell.xaml | 41 -- .../DarkMode/DataGridColumnHeader.xaml | 33 -- src/ClassLibraryCommon/DarkMode/GroupBox.xaml | 47 -- src/ClassLibraryCommon/DarkMode/Label.xaml | 25 - src/ClassLibraryCommon/DarkMode/Menu.xaml | 23 - src/ClassLibraryCommon/DarkMode/MenuItem.xaml | 303 ---------- .../DarkMode/RadioButton.xaml | 86 --- .../DarkMode/ScrollBar.xaml | 368 ------------ .../DarkMode/StatusBar.xaml | 21 - .../DarkMode/TabControl.xaml | 69 --- .../DarkMode/TabControlItem.xaml | 211 ------- src/ClassLibraryCommon/DarkMode/TextBox.xaml | 48 -- src/ClassLibraryCommon/DarkMode/ToolBar.xaml | 194 ------- src/ClassLibraryCommon/DarkMode/Window.xaml | 15 - src/ClassLibraryCommon/EnumEx.cs | 37 -- src/ClassLibraryCommon/Extensions.cs | 32 -- src/ClassLibraryCommon/GamingPanelSkeleton.cs | 24 - .../Images/gear-image-darkmode.png | Bin 9805 -> 0 bytes src/ClassLibraryCommon/Images/gear-image.png | Bin 4039 -> 0 bytes .../SerializeCriticalAttribute.cs | 6 - .../SerializeCriticalCustomAttribute.cs | 6 - src/ClassLibraryCommon/app.config | 223 ------- src/ClassLibraryCommon/dcs-bios_modules.txt | 51 -- .../DCSBIOSAircraftLoadStatus.cs | 59 -- .../ControlLocator/DCSBIOSControlComparer.cs | 31 - .../ControlLocator/DCSBIOSControlLocator.cs | 467 --------------- src/DCS-BIOS/DCS-BIOS.csproj | 48 -- src/DCS-BIOS/DCSBIOS.cs | 327 ----------- src/DCS-BIOS/DCSBIOSProtocolParser.cs | 268 --------- src/DCS-BIOS/EventArgs/BIOSEventHandler.cs | 136 ----- .../EventArgs/DCSBIOSBulkDataEventArgs.cs | 7 - .../EventArgs/DCSBIOSConnectionEventArgs.cs | 7 - .../EventArgs/DCSBIOSDataEventArgs.cs | 9 - .../EventArgs/DCSBIOSStringDataEventArgs.cs | 9 - .../IAsyncDcsBiosBulkDataListener.cs | 11 - .../Interfaces/IDCSBIOSStringListener.cs | 9 - .../Interfaces/IDcsBiosBulkDataListener.cs | 11 - .../Interfaces/IDcsBiosConnectionListener.cs | 9 - src/DCS-BIOS/Interfaces/IDcsBiosListener.cs | 9 - src/DCS-BIOS/Json/DCSBIOSControl.cs | 76 --- src/DCS-BIOS/Json/DCSBIOSControlInput.cs | 27 - src/DCS-BIOS/Json/DCSBIOSControlOutput.cs | 58 -- src/DCS-BIOS/Serialized/DCSBIOSInput.cs | 283 --------- .../Serialized/DCSBIOSInputInterface.cs | 160 ------ src/DCS-BIOS/Serialized/DCSBIOSOutput.cs | 406 ------------- .../Serialized/DCSBIOSOutputFormula.cs | 213 ------- src/DCS-BIOS/StringClasses/DCSBIOSString.cs | 102 ---- .../StringClasses/DCSBIOSStringListener.cs | 186 ------ .../StringClasses/DCSBIOSStringManager.cs | 34 -- src/DCS-BIOS/app.config | 235 -------- src/DCS-BIOS/icon_image.ico | Bin 370070 -> 0 bytes .../misc/DCSBIOSArduinoInformation.cs | 420 -------------- src/DCS-BIOS/misc/DCSBIOSCommon.cs | 19 - src/DCS-BIOS/misc/DCSBIOSConstants.cs | 10 - src/DCS-BIOS/misc/JaceExtended.cs | 44 -- src/DCS-BIOS/misc/LuaAssistant.cs | 245 -------- src/DCSFPCommon | 1 + src/DCSFlightpanels.sln | 56 +- src/DCSFlightpanels/DCSFlightpanels.csproj | 8 +- src/NonVisuals/NonVisuals.csproj | 4 +- src/Tests/ClassLibraryCommon/CommonTests.cs | 145 ----- src/Tests/DCSFPTests.csproj | 1 - .../DcsBios/DCSBIOSControlLocatorTests.cs | 249 -------- .../DcsBios/DCSBIOSInputInterfaceTests.cs | 163 ------ src/Tests/DcsBios/DCSBIOSInputTests.cs | 129 ----- src/Tests/DcsBios/DCSBIOSOutputTests.cs | 185 ------ 80 files changed, 38 insertions(+), 8619 deletions(-) create mode 100644 .gitmodules delete mode 100644 src/ClassLibraryCommon/ClassLibraryCommon.csproj delete mode 100644 src/ClassLibraryCommon/Common.cs delete mode 100644 src/ClassLibraryCommon/CommonEnums.cs delete mode 100644 src/ClassLibraryCommon/CustomControls/UserControlSpinningWheel.xaml delete mode 100644 src/ClassLibraryCommon/CustomControls/UserControlSpinningWheel.xaml.cs delete mode 100644 src/ClassLibraryCommon/DCSAircraft.cs delete mode 100644 src/ClassLibraryCommon/DarkMode.cs delete mode 100644 src/ClassLibraryCommon/DarkMode/Button.xaml delete mode 100644 src/ClassLibraryCommon/DarkMode/CheckBox.xaml delete mode 100644 src/ClassLibraryCommon/DarkMode/ComboBox.xaml delete mode 100644 src/ClassLibraryCommon/DarkMode/ComboBoxItem.xaml delete mode 100644 src/ClassLibraryCommon/DarkMode/ContextMenu.xaml delete mode 100644 src/ClassLibraryCommon/DarkMode/DataGrid.xaml delete mode 100644 src/ClassLibraryCommon/DarkMode/DataGridCell.xaml delete mode 100644 src/ClassLibraryCommon/DarkMode/DataGridColumnHeader.xaml delete mode 100644 src/ClassLibraryCommon/DarkMode/GroupBox.xaml delete mode 100644 src/ClassLibraryCommon/DarkMode/Label.xaml delete mode 100644 src/ClassLibraryCommon/DarkMode/Menu.xaml delete mode 100644 src/ClassLibraryCommon/DarkMode/MenuItem.xaml delete mode 100644 src/ClassLibraryCommon/DarkMode/RadioButton.xaml delete mode 100644 src/ClassLibraryCommon/DarkMode/ScrollBar.xaml delete mode 100644 src/ClassLibraryCommon/DarkMode/StatusBar.xaml delete mode 100644 src/ClassLibraryCommon/DarkMode/TabControl.xaml delete mode 100644 src/ClassLibraryCommon/DarkMode/TabControlItem.xaml delete mode 100644 src/ClassLibraryCommon/DarkMode/TextBox.xaml delete mode 100644 src/ClassLibraryCommon/DarkMode/ToolBar.xaml delete mode 100644 src/ClassLibraryCommon/DarkMode/Window.xaml delete mode 100644 src/ClassLibraryCommon/EnumEx.cs delete mode 100644 src/ClassLibraryCommon/Extensions.cs delete mode 100644 src/ClassLibraryCommon/GamingPanelSkeleton.cs delete mode 100644 src/ClassLibraryCommon/Images/gear-image-darkmode.png delete mode 100644 src/ClassLibraryCommon/Images/gear-image.png delete mode 100644 src/ClassLibraryCommon/SerializeCriticalAttribute.cs delete mode 100644 src/ClassLibraryCommon/SerializeCriticalCustomAttribute.cs delete mode 100644 src/ClassLibraryCommon/app.config delete mode 100644 src/ClassLibraryCommon/dcs-bios_modules.txt delete mode 100644 src/DCS-BIOS/ControlLocator/DCSBIOSAircraftLoadStatus.cs delete mode 100644 src/DCS-BIOS/ControlLocator/DCSBIOSControlComparer.cs delete mode 100644 src/DCS-BIOS/ControlLocator/DCSBIOSControlLocator.cs delete mode 100644 src/DCS-BIOS/DCS-BIOS.csproj delete mode 100644 src/DCS-BIOS/DCSBIOS.cs delete mode 100644 src/DCS-BIOS/DCSBIOSProtocolParser.cs delete mode 100644 src/DCS-BIOS/EventArgs/BIOSEventHandler.cs delete mode 100644 src/DCS-BIOS/EventArgs/DCSBIOSBulkDataEventArgs.cs delete mode 100644 src/DCS-BIOS/EventArgs/DCSBIOSConnectionEventArgs.cs delete mode 100644 src/DCS-BIOS/EventArgs/DCSBIOSDataEventArgs.cs delete mode 100644 src/DCS-BIOS/EventArgs/DCSBIOSStringDataEventArgs.cs delete mode 100644 src/DCS-BIOS/Interfaces/IAsyncDcsBiosBulkDataListener.cs delete mode 100644 src/DCS-BIOS/Interfaces/IDCSBIOSStringListener.cs delete mode 100644 src/DCS-BIOS/Interfaces/IDcsBiosBulkDataListener.cs delete mode 100644 src/DCS-BIOS/Interfaces/IDcsBiosConnectionListener.cs delete mode 100644 src/DCS-BIOS/Interfaces/IDcsBiosListener.cs delete mode 100644 src/DCS-BIOS/Json/DCSBIOSControl.cs delete mode 100644 src/DCS-BIOS/Json/DCSBIOSControlInput.cs delete mode 100644 src/DCS-BIOS/Json/DCSBIOSControlOutput.cs delete mode 100644 src/DCS-BIOS/Serialized/DCSBIOSInput.cs delete mode 100644 src/DCS-BIOS/Serialized/DCSBIOSInputInterface.cs delete mode 100644 src/DCS-BIOS/Serialized/DCSBIOSOutput.cs delete mode 100644 src/DCS-BIOS/Serialized/DCSBIOSOutputFormula.cs delete mode 100644 src/DCS-BIOS/StringClasses/DCSBIOSString.cs delete mode 100644 src/DCS-BIOS/StringClasses/DCSBIOSStringListener.cs delete mode 100644 src/DCS-BIOS/StringClasses/DCSBIOSStringManager.cs delete mode 100644 src/DCS-BIOS/app.config delete mode 100644 src/DCS-BIOS/icon_image.ico delete mode 100644 src/DCS-BIOS/misc/DCSBIOSArduinoInformation.cs delete mode 100644 src/DCS-BIOS/misc/DCSBIOSCommon.cs delete mode 100644 src/DCS-BIOS/misc/DCSBIOSConstants.cs delete mode 100644 src/DCS-BIOS/misc/JaceExtended.cs delete mode 100644 src/DCS-BIOS/misc/LuaAssistant.cs create mode 160000 src/DCSFPCommon delete mode 100644 src/Tests/ClassLibraryCommon/CommonTests.cs delete mode 100644 src/Tests/DcsBios/DCSBIOSControlLocatorTests.cs delete mode 100644 src/Tests/DcsBios/DCSBIOSInputInterfaceTests.cs delete mode 100644 src/Tests/DcsBios/DCSBIOSInputTests.cs delete mode 100644 src/Tests/DcsBios/DCSBIOSOutputTests.cs diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..437805fa8 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "src/DCSFPCommon"] + path = src/DCSFPCommon + url = https://github.com/DCS-Skunkworks/DCSFPCommon diff --git a/src/ClassLibraryCommon/ClassLibraryCommon.csproj b/src/ClassLibraryCommon/ClassLibraryCommon.csproj deleted file mode 100644 index b4a27ad53..000000000 --- a/src/ClassLibraryCommon/ClassLibraryCommon.csproj +++ /dev/null @@ -1,56 +0,0 @@ - - - net6.0-windows - Library - true - true - true - en - - - bin\x64\Debug\ - MinimumRecommendedRules.ruleset - - - bin\x64\Release\ - none - MinimumRecommendedRules.ruleset - - .allowedextension - - - - - - - - - - Always - - - - - - - - - - - - - - - - - - - - - - - 1.0.478.6527 - 1.0.478.6527 - ClassLibraryCommon - - \ No newline at end of file diff --git a/src/ClassLibraryCommon/Common.cs b/src/ClassLibraryCommon/Common.cs deleted file mode 100644 index d6bb289db..000000000 --- a/src/ClassLibraryCommon/Common.cs +++ /dev/null @@ -1,347 +0,0 @@ -using System.Windows.Input; - -namespace ClassLibraryCommon -{ - using NLog; - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Security.Cryptography; - using System.Text; - using System.Windows; - using System.Windows.Media; - - [Flags] - public enum EmulationMode - { - DCSBIOSInputEnabled = 1, - DCSBIOSOutputEnabled = 2, - KeyboardEmulationOnly = 4, - SRSEnabled = 8, - NS430Enabled = 16 - } - - /// - /// Common functions used by multiple projects. - /// - public static class Common - { - private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - private static int _emulationModesFlag; - - - /// - /// Checks the setting "JSON Directory". This folder must contain all the JSON files - /// - /// - /// - /// 0, 0 : folder not found, json not found - /// 1, 0 : folder found, json not found - /// 1, 1 : folder found, json found - /// - public static Tuple CheckJSONDirectory(string jsonDirectory) - { - jsonDirectory = Environment.ExpandEnvironmentVariables(jsonDirectory); - - if (string.IsNullOrEmpty(jsonDirectory) || !Directory.Exists(jsonDirectory)) - { - /* - * Folder not found - */ - return new Tuple(false, false); - } - - var files = Directory.EnumerateFiles(jsonDirectory); - - /* - * This is not optimal, the thing is that there is no single file to rely - * on in order to determine that this folder is the DCS-BIOS JSON directory. - * Files can be changed (although rare) but it cannot be taken for certain - * that this doesn't happen. - * - * The solution is to count the number of json files in the folder. - * This gives a fairly certain indication that the folder is in fact - * the JSON folder. There are JSON files in other folders but not many. - */ - var jsonFound = files.Count(filename => filename.ToLower().EndsWith(".json")) >= 10; - - return new Tuple(true, jsonFound); - } - - public static APIModeEnum APIModeUsed { get; set; } = 0; - - public static void PlaySoundFile(string soundFile, double volume, bool showException = false) //Volume 0 - 100 - { - try - { - if (string.IsNullOrEmpty(soundFile) || !File.Exists(soundFile)) - { - return; - } - MediaPlayer mediaPlayer = new(); - mediaPlayer.Open(new Uri(soundFile)); - mediaPlayer.Volume = volume / 100.0f; - mediaPlayer.Play(); - } - catch (Exception ex) - { - if (showException) - { - ShowErrorMessageBox(ex); - } - } - } - - public static string GetHex(uint i, bool includePrefix = true, bool lowercase = true, bool padLengthTo4 = true) - { - return GetHex((int)i, includePrefix, lowercase, padLengthTo4); - } - - public static string GetHex(int i, bool includePrefix = true, bool lowercase = true, bool padLengthTo4 = true) - { - var formatter = lowercase ? "x" : "X"; - var s = i.ToString(formatter); - if (padLengthTo4) - { - s = s.PadLeft(4, '0'); - } - if (includePrefix) s = s.Insert(0, "0x"); - - return s; - } - - public static string RemoveCurlyBrackets(string s) - { - return string.IsNullOrEmpty(s) ? null : s.Replace("{", "").Replace("}", ""); - } - - public static string RemoveLControl(string keySequence) - { - return true switch - { - _ when keySequence.Contains("RMENU + LCONTROL") => keySequence.Replace("+ LCONTROL", string.Empty), - _ when keySequence.Contains("LCONTROL + RMENU") => keySequence.Replace("LCONTROL +", string.Empty), - _ => keySequence - }; - } - - public static readonly List GamingPanelSkeletons = new() - { - new GamingPanelSkeleton(GamingPanelVendorEnum.Saitek, GamingPanelEnum.PZ55SwitchPanel), - new GamingPanelSkeleton(GamingPanelVendorEnum.Saitek, GamingPanelEnum.PZ69RadioPanel), - new GamingPanelSkeleton(GamingPanelVendorEnum.Saitek, GamingPanelEnum.PZ70MultiPanel), - new GamingPanelSkeleton(GamingPanelVendorEnum.Saitek, GamingPanelEnum.BackLitPanel), - new GamingPanelSkeleton(GamingPanelVendorEnum.Saitek, GamingPanelEnum.TPM), - new GamingPanelSkeleton(GamingPanelVendorEnum.MadCatz, GamingPanelEnum.FarmingPanel), - new GamingPanelSkeleton(GamingPanelVendorEnum.Elgato, GamingPanelEnum.StreamDeckMini), - new GamingPanelSkeleton(GamingPanelVendorEnum.Elgato, GamingPanelEnum.StreamDeckMiniV2), - new GamingPanelSkeleton(GamingPanelVendorEnum.Elgato, GamingPanelEnum.StreamDeck), - new GamingPanelSkeleton(GamingPanelVendorEnum.Elgato, GamingPanelEnum.StreamDeckV2), - new GamingPanelSkeleton(GamingPanelVendorEnum.Elgato, GamingPanelEnum.StreamDeckMK2), - new GamingPanelSkeleton(GamingPanelVendorEnum.Elgato, GamingPanelEnum.StreamDeckXL), - new GamingPanelSkeleton(GamingPanelVendorEnum.Elgato, GamingPanelEnum.StreamDeckXLRev2), - new GamingPanelSkeleton(GamingPanelVendorEnum.CockpitMaster, GamingPanelEnum.CDU737), - new GamingPanelSkeleton(GamingPanelVendorEnum.Elgato, GamingPanelEnum.StreamDeckPlus) - }; - - private static void ValidateEmulationModeFlag() - { - if (!IsEmulationModesFlagSet(EmulationMode.KeyboardEmulationOnly)) return; - - if (IsEmulationModesFlagSet(EmulationMode.DCSBIOSOutputEnabled) || - IsEmulationModesFlagSet(EmulationMode.DCSBIOSInputEnabled)) - { - throw new Exception($"Invalid emulation modes flag : {_emulationModesFlag}"); - } - } - - public static void SetEmulationModesFlag(int flag) - { - _emulationModesFlag = flag; - ValidateEmulationModeFlag(); - } - - public static int GetEmulationModesFlag() - { - ValidateEmulationModeFlag(); - return _emulationModesFlag; - } - - public static void SetEmulationModes(EmulationMode emulationMode) - { - _emulationModesFlag |= (int)emulationMode; - ValidateEmulationModeFlag(); - } - - public static bool IsEmulationModesFlagSet(EmulationMode flagValue) - { - return (_emulationModesFlag & (int)flagValue) > 0; - } - - public static void ClearEmulationModesFlag(EmulationMode flagValue) - { - _emulationModesFlag &= ~(int)flagValue; - } - - public static void ResetEmulationModesFlag() - { - _emulationModesFlag = 0; - } - - public static bool NoDCSBIOSEnabled() - { - ValidateEmulationModeFlag(); - return !IsEmulationModesFlagSet(EmulationMode.DCSBIOSInputEnabled) && !IsEmulationModesFlagSet(EmulationMode.DCSBIOSOutputEnabled); - } - - public static bool KeyEmulationOnly() - { - ValidateEmulationModeFlag(); - return IsEmulationModesFlagSet(EmulationMode.KeyboardEmulationOnly); - } - - public static bool FullDCSBIOSEnabled() - { - ValidateEmulationModeFlag(); - return IsEmulationModesFlagSet(EmulationMode.DCSBIOSOutputEnabled) && IsEmulationModesFlagSet(EmulationMode.DCSBIOSInputEnabled); - } - - public static bool PartialDCSBIOSEnabled() - { - ValidateEmulationModeFlag(); - return IsEmulationModesFlagSet(EmulationMode.DCSBIOSOutputEnabled) || IsEmulationModesFlagSet(EmulationMode.DCSBIOSInputEnabled); - } - - public static string GetMd5Hash(string input) - { - var md5 = MD5.Create(); - - // Convert the input string to a byte array and compute the hash. - var data = md5.ComputeHash(Encoding.UTF8.GetBytes(input)); - - // Create a new Stringbuilder to collect the bytes - // and create a string. - var sBuilder = new StringBuilder(); - - // Loop through each byte of the hashed data - // and format each one as a hexadecimal string. - foreach (var t in data) - { - sBuilder.Append(t.ToString("x2")); - } - - // Return the hexadecimal string. - return sBuilder.ToString().ToUpperInvariant(); - } - - public static string GetRandomMd5Hash() - { - var bytes = RandomNumberGenerator.GetBytes(16); - return BitConverter.ToString(bytes).Replace("-", string.Empty).ToLower(); - } - - public static void ShowMessageBox(string message) - { - MessageBox.Show(message, "", MessageBoxButton.OK, MessageBoxImage.Information); - } - - public static void ShowErrorMessageBox(Exception ex, string message = null) - { - Logger.Error(ex, message); - MessageBox.Show(ex.Message, $"Details logged to error log.{Environment.NewLine}{ex.Source}", MessageBoxButton.OK, MessageBoxImage.Error); - } - - public static string GetApplicationPath() - { - return AppDomain.CurrentDomain.BaseDirectory; - } - - /// - /// Returns the relative path from "relativeTo" to "path". - /// ATTN : relativeTo must end with a \ if it is a path only, not an object. - /// - /// - /// - /// - public static string GetRelativePath(string relativeTo, string path) - { - var uriRelativeTo = new Uri(relativeTo); - var rel = Uri.UnescapeDataString(uriRelativeTo.MakeRelativeUri(new Uri(path)).ToString()).Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); - if (!rel.Contains(Path.DirectorySeparatorChar.ToString())) - { - rel = $".{Path.DirectorySeparatorChar}{rel}"; - } - return rel; - } - - public static IEnumerable FindVisualChildren(DependencyObject dependencyObject) where T : DependencyObject - { - if (dependencyObject == null) yield break; - - for (var i = 0; i < VisualTreeHelper.GetChildrenCount(dependencyObject); i++) - { - var child = VisualTreeHelper.GetChild(dependencyObject, i); - if (child is T o) - { - yield return o; - } - - foreach (var childOfChild in FindVisualChildren(child)) - { - yield return childOfChild; - } - } - } - - - public static T FindVisualParent(DependencyObject child) where T : DependencyObject - { - if (child == null) - { - return null; - } - var parentObj = VisualTreeHelper.GetParent(child); - - return parentObj switch - { - //we've reached the end of the tree - null => null, - // check if the parent matches the type we are requested - T parent => parent, - // here, To find the next parent in the tree. we are using recursion until we found the requested type or reached to the end of tree. - _ => FindVisualParent(parentObj) - }; - } - - //^[A-Za-z0-9 . \t]*(MouseEnter){1}(\s\+\=)\s* - public static void UIElement_OnMouseEnterHandIcon(object sender, MouseEventArgs e) - { - Mouse.OverrideCursor = Cursors.Hand; - } - - public static void UIElement_OnMouseLeaveNormalIcon(object sender, MouseEventArgs e) - { - Mouse.OverrideCursor = Cursors.Arrow; - } - - public static int GetNthIndexOf(string s, char c, int instance) - { - if (string.IsNullOrEmpty(s)) return -1; - - var count = 0; - for (var i = 0; i < s.Length; i++) - { - if (s[i] == c) - { - count++; - if (count == instance) - { - return i; - } - } - } - return -1; - } - } -} diff --git a/src/ClassLibraryCommon/CommonEnums.cs b/src/ClassLibraryCommon/CommonEnums.cs deleted file mode 100644 index ef99dd0df..000000000 --- a/src/ClassLibraryCommon/CommonEnums.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System.ComponentModel; - -namespace ClassLibraryCommon -{ - - public enum RadioPanelPZ69Display - { - UpperActive, - UpperStandby, - LowerActive, - LowerStandby - } - - /// - /// Used for identifying what a copy package (user copies setting) contains so that the pasting process is easier. - /// - public enum CopyContentType - { - KeyStroke, - KeySequence, - DCSBIOS, - BIPLink, - OSCommand - } - - /// - /// The two Windows API:s supported for creating key emulation. - /// - public enum APIModeEnum - { - KeybdEvent = 0, - SendInput = 1 - } - - /// - /// The supported manufacturer's Vendor IDs (VID). - /// - public enum GamingPanelVendorEnum - { - Saitek = 0x6A3, - MadCatz = 0x0738, - Elgato = 0xFD9, - CockpitMaster = 0x0483 - } - - /// - /// The Product ID (PID) of the supported panels. - /// - public enum GamingPanelEnum - { - [Description("Cockpit Master 737 CDU")] - CDU737 = 0x5b36, - [Description("Unknown Panel")] - Unknown = 0, - [Description("Saitek PZ55 Switch Panel")] - PZ55SwitchPanel = 0xD67, - [Description("Saitek PZ69 Radio Panel")] - PZ69RadioPanel = 0xD05, - [Description("Saitek PZ70 Multi Panel")] - PZ70MultiPanel = 0xD06, - [Description("Saitek BIP Back Lit Panel")] - BackLitPanel = 0xB4E, - [Description("Saitek TPM Panel")] - TPM = 0xB4D, - [Description("StreamDeck Mini")] - StreamDeckMini = 0x0063, - [Description("StreamDeck Mini V2")] - StreamDeckMiniV2 = 0x0090, - [Description("StreamDeck")] - StreamDeck = 0x0060, - [Description("StreamDeck V2")] - StreamDeckV2 = 0x006D, - [Description("StreamDeck MK.2")] - StreamDeckMK2 = 0x0080, - [Description("StreamDeck XL")] - StreamDeckXL = 0x006C, - [Description("StreamDeck XL Rev2")] - StreamDeckXLRev2 = 0x008F, - [Description("StreamDeck Plus")] - StreamDeckPlus = 0x0084, - [Description("Logitech Farming Side Panel")] - FarmingPanel = 0x2218 - } - - public enum Axis - { - X, - Y - } -} diff --git a/src/ClassLibraryCommon/CustomControls/UserControlSpinningWheel.xaml b/src/ClassLibraryCommon/CustomControls/UserControlSpinningWheel.xaml deleted file mode 100644 index 0d440a6dc..000000000 --- a/src/ClassLibraryCommon/CustomControls/UserControlSpinningWheel.xaml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - diff --git a/src/ClassLibraryCommon/CustomControls/UserControlSpinningWheel.xaml.cs b/src/ClassLibraryCommon/CustomControls/UserControlSpinningWheel.xaml.cs deleted file mode 100644 index 8a63e3365..000000000 --- a/src/ClassLibraryCommon/CustomControls/UserControlSpinningWheel.xaml.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Timers; -using System.Windows; -using System.Windows.Media.Imaging; - -namespace ClassLibraryCommon.CustomControls -{ - /// - /// Interaction logic for UserControlSpinningWheel.xaml - /// - public partial class UserControlSpinningWheel : IDisposable - { - public static readonly DependencyProperty DoSpinProperty = DependencyProperty.Register( - nameof(DoSpin), typeof(bool), typeof(UserControlSpinningWheel), new PropertyMetadata(default(bool))); - - private readonly Timer _stopGearTimer = new(5000); - public bool DoSpin - { - get { return (bool)GetValue(DoSpinProperty); } - set - { - SetValue(DoSpinProperty, value); - ImageConnected.IsEnabled = value; - } - } - - public UserControlSpinningWheel() - { - InitializeComponent(); - - if (DarkMode.DarkModeEnabled) - { - ImageConnected.Source = new BitmapImage(new Uri("/ClassLibraryCommon;component/Images/gear-image-darkmode.png", UriKind.Relative)); - } - _stopGearTimer.Elapsed += TimerStopRotation; - } - - public void Dispose() - { - _stopGearTimer?.Dispose(); - GC.SuppressFinalize(this); - } - - private void TimerStopRotation(object sender, ElapsedEventArgs e) - { - try - { - Dispatcher?.BeginInvoke((Action)(() => ImageConnected.IsEnabled = false)); - _stopGearTimer.Stop(); - } - catch (Exception) - { - // ignore - } - } - - public void Stop() - { - _stopGearTimer.Stop(); - } - - public void RotateGear(int howLong = 5000) - { - try - { - if (ImageConnected.IsEnabled) - { - return; - } - - ImageConnected.IsEnabled = true; - if (_stopGearTimer.Enabled) - { - _stopGearTimer.Stop(); - } - - _stopGearTimer.Interval = howLong; - _stopGearTimer.Start(); - } - catch (Exception) - { - // ignore - } - } - } -} diff --git a/src/ClassLibraryCommon/DCSAircraft.cs b/src/ClassLibraryCommon/DCSAircraft.cs deleted file mode 100644 index 892fabf1e..000000000 --- a/src/ClassLibraryCommon/DCSAircraft.cs +++ /dev/null @@ -1,543 +0,0 @@ -namespace ClassLibraryCommon -{ - using NLog; - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - - /// - /// Holds information about currently selected aircraft / module (DCS aircraft/helicopter). - /// This class reads all modules from dcs-bios_modules.txt and the user can then select between these - /// when creating a new DCSFP profile. - /// - public class DCSAircraft - { - private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - - private static readonly object Lock = new(); - private static List _modulesList = new(); - - public static DCSAircraft SelectedAircraft { get; set; } - public const string DCSBIOS_META_DATA_START_FILE_NAME = "MetadataStart.json"; - public const string DCSBIOS_META_DATA_END_FILE_NAME = "MetadataEnd.json"; - public const string DCSBIOS_COMMON_DATA_FILE_NAME = "CommonData.json"; - private const string DCSBIOS_META_DATA_START_MODULE = "MetadataStart"; - private const string DCSBIOS_META_DATA_END_MODULE = "MetadataEnd"; - private const string DCSBIOS_COMMON_DATA_MODULE = "CommonData"; - - private DCSAircraft(int id, string description, string jsonFilename) - { - ID = id; - JSONFilename = jsonFilename; - Description = description; - } - - public static void Init() - { - AddInternalModules(); - } - - public int ID { get; } - - public string JSONFilename { get; } - - public string LuaFilename - { - get => JSONFilename.Replace(".json", ".lua"); - } - - public bool IsMetaModule - { - get => JSONFilename.Contains(DCSBIOS_META_DATA_END_MODULE) || JSONFilename.Contains(DCSBIOS_META_DATA_START_MODULE) || JSONFilename.Contains(DCSBIOS_COMMON_DATA_MODULE); - } - - /// - /// This is not exact science - /// - public string ModuleLuaName - { - get => JSONFilename.Replace(".json", "").Replace("-", "_").Replace(" ", "_"); - } - - public string DCSName - { - get => JSONFilename.Replace(".json", ""); - } - - public string Description { get; } - - public bool UseGenericRadio { get; set; } - - /// - /// This can be used to any purpose. - /// Right now used that is true then A-10C II, false => A-10C. - /// They have differing radios which means different pre-programmed radios. - /// - public bool Option1 { get; set; } - - public static List Modules - { - get - { - lock (Lock) - { - return _modulesList; - } - } - } - - public static bool HasDCSBIOSModules - { - get - { - lock (Lock) - { - return _modulesList.Count - 3 > 0; // Three modules are not DCS-BIOS - } - } - } - - public static int DCSBIOSModulesCount - { - get - { - lock (Lock) - { - return _modulesList.Count - 3; // Three modules are not DCS-BIOS - } - } - } - - private static void AddInternalModules() - { - lock (Lock) - { - if (!_modulesList.Exists(o => o.ID == 1)) - { - var module = new DCSAircraft(1, "NoFrameLoadedYet", "NOFRAMELOADEDYET"); - _modulesList.Add(module); - } - - if (!_modulesList.Exists(o => o.ID == 2)) - { - var module = new DCSAircraft(2, "Key Emulation", "KEYEMULATOR"); - _modulesList.Add(module); - } - if (!_modulesList.Exists(o => o.ID == 3)) - { - var module = new DCSAircraft(3, "Key Emulation with SRS support", "KEYEMULATOR_SRS"); - _modulesList.Add(module); - } - } - } - - public static void FillModulesListFromDcsBios(string dcsbiosJsonFolder, bool loadInternalModules) - { - lock (Lock) - { - _modulesList.Clear(); - if (loadInternalModules) - { - AddInternalModules(); - } - } - - var dcsbiosConfigFile = $"{AppDomain.CurrentDomain.BaseDirectory}dcs-bios_modules.txt"; - if (!File.Exists(dcsbiosConfigFile)) - { - LogErrorAndThrowException($"Failed to find {dcsbiosConfigFile} in base directory."); - return; - } - - var result = Common.CheckJSONDirectory(dcsbiosJsonFolder); - if (result.Item1 == false && result.Item2 == false) - { - Logger.Error("Failed to find DCS-BIOS JSON location."); - return; - } - - var stringArray = File.ReadAllLines(dcsbiosConfigFile); - - //Inject these static DCS-BIOS modules - - lock (Lock) - { - _modulesList.Add(new DCSAircraft(500, DCSBIOS_META_DATA_END_MODULE, DCSBIOS_META_DATA_END_FILE_NAME)); - _modulesList.Add(new DCSAircraft(501, DCSBIOS_META_DATA_START_MODULE, DCSBIOS_META_DATA_START_FILE_NAME)); - _modulesList.Add(new DCSAircraft(502, DCSBIOS_COMMON_DATA_MODULE, DCSBIOS_COMMON_DATA_FILE_NAME)); - } - - // A-10C|5|A-10C Thunderbolt/II - foreach (var s in stringArray) - { - if (s.StartsWith("--") || !s.Contains('|')) - { - continue; - } - - var parts = s.Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries); - - - var json = parts[0] + ".json"; - var id = int.Parse(parts[1]); - var properName = parts[2]; - - lock (Lock) - { - _modulesList.Add(new DCSAircraft(id, properName, json)); - } - } - - lock (Lock) - { - _modulesList = _modulesList.OrderBy(o => o.Description).ToList(); - } - } - - private static void LogErrorAndThrowException(string message) - { - Logger.Error(message); - throw new Exception(message); - } - - public static DCSAircraft GetAircraft(int id) - { - var module = Modules.FirstOrDefault(x => x.ID == id); - if (module == null) - { - LogErrorAndThrowException($"Failed to determine aircraft ID ({id}) in your bindings file."); - } - return module; - } - - public static void SetNoFrameLoadedYetAsProfile() - { - var module = Modules.FirstOrDefault(IsNoFrameLoadedYet); - if (module == null) - { - LogErrorAndThrowException($"DCSAircraft : Failed to find internal module NoFrameLoadedYet. Modules loaded : {Modules.Count}"); - } - - SelectedAircraft = module; - } - - - public static DCSAircraft GetNoFrameLoadedYet() - { - var module = Modules.FirstOrDefault(IsNoFrameLoadedYet); - if (module == null) - { - LogErrorAndThrowException($"DCSAircraft : Failed to find internal module NoFrameLoadedYet. Modules loaded : {Modules.Count}"); - } - return module; - } - - public static DCSAircraft GetKeyEmulator() - { - var module = Modules.FirstOrDefault(IsKeyEmulator); - if (module == null) - { - LogErrorAndThrowException($"DCSAircraft : Failed to find internal module KeyEmulator. Modules loaded : {Modules.Count}"); - } - return module; - } - - public static DCSAircraft GetKeyEmulatorSRS() - { - var module = Modules.FirstOrDefault(IsKeyEmulatorSRS); - if (module == null) - { - LogErrorAndThrowException($"DCSFPProfile : Failed to find internal module KeyEmulatorSRS. Modules loaded : {Modules.Count}"); - } - return module; - } - - public static bool HasNS430() - { - return Modules.Exists(IsNS430); - } - - public static DCSAircraft GetNS430() - { - return Modules.FirstOrDefault(IsNS430); - } - - - public static bool IsNoFrameLoadedYet(DCSAircraft dcsfpModule) - { - /*if (dcsfpModule == null) - { - LogErrorAndThrowException("DCSAircraft IsNoFrameLoadedYet : Parameter dcsfpModule is null."); - }*/ - return dcsfpModule.ID == 1; - } - - public static bool IsKeyEmulator(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 2; - } - - public static bool IsKeyEmulatorSRS(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 3; - } - - public static bool IsFlamingCliff(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 4; - } - - public static bool IsA10C(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 5; - } - - public static bool IsA4E(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 6; - } - - public static bool IsAH6(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 7; - } - - public static bool IsAJS37(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 8; - } - - public static bool IsAlphajet(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 9; - } - - public static bool IsAV8B(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 10; - } - - public static bool IsBf109K4(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 11; - } - - public static bool IsC101(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 12; - } - - public static bool IsC130(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 13; - } - - public static bool IsChristenEagleII(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 14; - } - - public static bool IsEdge540(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 15; - } - - public static bool IsF14B(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 16; - } - - public static bool IsF15E(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 44; - } - - public static bool IsF16C(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 17; - } - - public static bool IsF5E(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 18; - } - - public static bool IsF86F(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 19; - } - - public static bool IsFA18C(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 20; - } - - public static bool IsFW190A8(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 21; - } - - public static bool IsFW190D9(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 22; - } - - public static bool IsI16(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 23; - } - - public static bool IsJF17(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 24; - } - - public static bool IsKa50(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 25; - } - - public static bool IsL39(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 26; - } - - public static bool IsM2000C(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 27; - } - - public static bool IsMB339PAN(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 28; - } - - public static bool IsMi8MT(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 29; - } - - public static bool IsMiG15bis(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 30; - } - - public static bool IsMiG19P(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 31; - } - - public static bool IsMiG21Bis(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 32; - } - - public static bool IsNS430(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 33; - } - - public static bool IsP47D(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 34; - } - - public static bool IsP51D(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 35; - } - - public static bool IsSA342(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 36; - } - - public static bool IsSpitfireLFMkIX(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 37; - } - - public static bool IsUH1H(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 38; - } - - public static bool IsYak52(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 39; - } - public static bool IsT45C(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 43; - } - public static bool IsMi24P(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 42; - } - - public static bool IsMosquito(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 45; - } - - public static bool IsAH64D(DCSAircraft dcsfpModule) - { - return dcsfpModule.ID == 46; - } - - - public static DCSAircraft GetBackwardCompatible(string oldEnumValue) - { - int? moduleNumber = oldEnumValue switch - { - "KEYEMULATOR" => 2, - "KEYEMULATOR_SRS" => 3, - "A4E" => 6, - "A10C" => 5, - "AH6J" => 7, - "AJS37" => 8, - "Alphajet" => 9, - "AV8BNA" => 10, - "Bf109" => 11, - "C101CC" => 12, - "ChristenEagle" => 14, - "Edge540" => 15, - "F5E" => 18, - "F14B" => 16, - "F16C" => 17, - "FA18C" => 20, - "F86F" => 19, - "FC3" => 4, - "Fw190a8" => 21, - "Fw190d9" => 22, - "Hercules" => 13, - "I16" => 23, - "JF17" => 24, - "Ka50" => 25, - "L39ZA" => 26, - "M2000C" => 27, - "MB339" => 28, - "Mi8" => 29, - "Mig15bis" => 30, - "Mig19P" => 31, - "Mig21Bis" => 32, - "NS430" => 33, - "P51D" => 35, - "P47D" => 34, - "SA342M" => 36, - "SpitfireLFMkIX" => 37, - "UH1H" => 38, - "Yak52" => 39, - _ => null - }; - if (moduleNumber != null) - { - return Modules.Find(o => o.ID == moduleNumber); - } - - LogErrorAndThrowException("Failed to determine profile ID (null) in your bindings file."); - return null; //just to avoid compilation problem "error CS0161 not all code paths return a value" - } - } -} diff --git a/src/ClassLibraryCommon/DarkMode.cs b/src/ClassLibraryCommon/DarkMode.cs deleted file mode 100644 index 05266ccc2..000000000 --- a/src/ClassLibraryCommon/DarkMode.cs +++ /dev/null @@ -1,97 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Windows; -using System.Windows.Media; -using Theraot.Collections; - -namespace ClassLibraryCommon -{ - public static class DarkMode - { - private static bool _darkModeEnabled; - - [DllImport("dwmapi.dll", PreserveSig = true)] - private static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref bool attrValue, int attrSize); - - public static bool DarkModeEnabled { - get => _darkModeEnabled; - set { - _darkModeEnabled = value; - if (_darkModeEnabled) - { - SetDarkMode(); - } - else - { - ClearDarkMode(); - } - } - } - - private static void SetDependencyObjectDarkMode(DependencyObject dependencyObject) - { - if (dependencyObject is FrameworkElement) - { - if (dependencyObject.GetType().BaseType != typeof(Window)) return; - - var value = true; - DwmSetWindowAttribute(new System.Windows.Interop.WindowInteropHelper((Window)dependencyObject).Handle, 20, ref value, Marshal.SizeOf(value)); - - var bc = new BrushConverter(); - ((Window)dependencyObject).Background = (Brush)bc.ConvertFrom("#FF242424"); - } - } - - public static void SetFrameworkElementDarkMode(FrameworkElement frameworkElement) - { - if (DarkModeEnabled) - { - SetDependencyObjectDarkMode(frameworkElement); - } - } - - private static void SetDarkMode() - { - Application.Current.Resources.MergedDictionaries.Clear(); - List darkModeResources = new() - { - new ResourceDictionary { Source = new Uri("pack://application:,,,/ClassLibraryCommon;component/DarkMode/ComboBox.xaml") }, - new ResourceDictionary { Source = new Uri("pack://application:,,,/ClassLibraryCommon;component/DarkMode/ComboBoxItem.xaml") }, - new ResourceDictionary { Source = new Uri("pack://application:,,,/ClassLibraryCommon;component/DarkMode/CheckBox.xaml") }, - new ResourceDictionary { Source = new Uri("pack://application:,,,/ClassLibraryCommon;component/DarkMode/Window.xaml") }, - new ResourceDictionary { Source = new Uri("pack://application:,,,/ClassLibraryCommon;component/DarkMode/Label.xaml") }, - new ResourceDictionary { Source = new Uri("pack://application:,,,/ClassLibraryCommon;component/DarkMode/Button.xaml") }, - new ResourceDictionary { Source = new Uri("pack://application:,,,/ClassLibraryCommon;component/DarkMode/TabControl.xaml") }, - new ResourceDictionary { Source = new Uri("pack://application:,,,/ClassLibraryCommon;component/DarkMode/TabControlItem.xaml") }, - new ResourceDictionary { Source = new Uri("pack://application:,,,/ClassLibraryCommon;component/DarkMode/TextBox.xaml") }, - new ResourceDictionary { Source = new Uri("pack://application:,,,/ClassLibraryCommon;component/DarkMode/GroupBox.xaml") }, - new ResourceDictionary { Source = new Uri("pack://application:,,,/ClassLibraryCommon;component/DarkMode/ToolBar.xaml") }, - new ResourceDictionary { Source = new Uri("pack://application:,,,/ClassLibraryCommon;component/DarkMode/StatusBar.xaml") }, - new ResourceDictionary { Source = new Uri("pack://application:,,,/ClassLibraryCommon;component/DarkMode/RadioButton.xaml") }, - new ResourceDictionary { Source = new Uri("pack://application:,,,/ClassLibraryCommon;component/DarkMode/DataGrid.xaml") }, - new ResourceDictionary { Source = new Uri("pack://application:,,,/ClassLibraryCommon;component/DarkMode/DataGridColumnHeader.xaml") }, - new ResourceDictionary { Source = new Uri("pack://application:,,,/ClassLibraryCommon;component/DarkMode/DataGridCell.xaml") }, - new ResourceDictionary { Source = new Uri("pack://application:,,,/ClassLibraryCommon;component/DarkMode/ContextMenu.xaml") }, - new ResourceDictionary { Source = new Uri("pack://application:,,,/ClassLibraryCommon;component/DarkMode/Menu.xaml") }, - new ResourceDictionary { Source = new Uri("pack://application:,,,/ClassLibraryCommon;component/DarkMode/MenuItem.xaml") }, - new ResourceDictionary { Source = new Uri("pack://application:,,,/ClassLibraryCommon;component/DarkMode/ScrollBar.xaml") } - }; - Application.Current.Resources.MergedDictionaries.AddRange(darkModeResources); - } - - public static void ClearDarkMode() - { - Application.Current.Resources.MergedDictionaries.Clear(); - } - - public static SolidColorBrush TextBoxSelectedBackgroundColor - { - get { return _darkModeEnabled ? Brushes.IndianRed : Brushes.Yellow; } - } - public static SolidColorBrush TextBoxUnselectedBackgroundColor - { - get { return _darkModeEnabled ? new SolidColorBrush( Color.FromArgb(255, 56, 56, 56)) : Brushes.White; } //"#FF383838" - } - } -} diff --git a/src/ClassLibraryCommon/DarkMode/Button.xaml b/src/ClassLibraryCommon/DarkMode/Button.xaml deleted file mode 100644 index f12619707..000000000 --- a/src/ClassLibraryCommon/DarkMode/Button.xaml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/ClassLibraryCommon/DarkMode/CheckBox.xaml b/src/ClassLibraryCommon/DarkMode/CheckBox.xaml deleted file mode 100644 index 8d561f342..000000000 --- a/src/ClassLibraryCommon/DarkMode/CheckBox.xaml +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/ClassLibraryCommon/DarkMode/ComboBox.xaml b/src/ClassLibraryCommon/DarkMode/ComboBox.xaml deleted file mode 100644 index d55a8980d..000000000 --- a/src/ClassLibraryCommon/DarkMode/ComboBox.xaml +++ /dev/null @@ -1,286 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/ClassLibraryCommon/DarkMode/ComboBoxItem.xaml b/src/ClassLibraryCommon/DarkMode/ComboBoxItem.xaml deleted file mode 100644 index 0726105be..000000000 --- a/src/ClassLibraryCommon/DarkMode/ComboBoxItem.xaml +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/ClassLibraryCommon/DarkMode/ContextMenu.xaml b/src/ClassLibraryCommon/DarkMode/ContextMenu.xaml deleted file mode 100644 index 356039f80..000000000 --- a/src/ClassLibraryCommon/DarkMode/ContextMenu.xaml +++ /dev/null @@ -1,39 +0,0 @@ - - - \ No newline at end of file diff --git a/src/ClassLibraryCommon/DarkMode/DataGrid.xaml b/src/ClassLibraryCommon/DarkMode/DataGrid.xaml deleted file mode 100644 index 9356459f2..000000000 --- a/src/ClassLibraryCommon/DarkMode/DataGrid.xaml +++ /dev/null @@ -1,84 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/ClassLibraryCommon/DarkMode/DataGridCell.xaml b/src/ClassLibraryCommon/DarkMode/DataGridCell.xaml deleted file mode 100644 index afb04a81c..000000000 --- a/src/ClassLibraryCommon/DarkMode/DataGridCell.xaml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/ClassLibraryCommon/DarkMode/DataGridColumnHeader.xaml b/src/ClassLibraryCommon/DarkMode/DataGridColumnHeader.xaml deleted file mode 100644 index ff38cbe3e..000000000 --- a/src/ClassLibraryCommon/DarkMode/DataGridColumnHeader.xaml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/ClassLibraryCommon/DarkMode/GroupBox.xaml b/src/ClassLibraryCommon/DarkMode/GroupBox.xaml deleted file mode 100644 index 816516586..000000000 --- a/src/ClassLibraryCommon/DarkMode/GroupBox.xaml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/ClassLibraryCommon/DarkMode/Label.xaml b/src/ClassLibraryCommon/DarkMode/Label.xaml deleted file mode 100644 index 025fc660f..000000000 --- a/src/ClassLibraryCommon/DarkMode/Label.xaml +++ /dev/null @@ -1,25 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/ClassLibraryCommon/DarkMode/Menu.xaml b/src/ClassLibraryCommon/DarkMode/Menu.xaml deleted file mode 100644 index 85cc08caf..000000000 --- a/src/ClassLibraryCommon/DarkMode/Menu.xaml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/ClassLibraryCommon/DarkMode/MenuItem.xaml b/src/ClassLibraryCommon/DarkMode/MenuItem.xaml deleted file mode 100644 index b37302042..000000000 --- a/src/ClassLibraryCommon/DarkMode/MenuItem.xaml +++ /dev/null @@ -1,303 +0,0 @@ - - - - - - - - - - - - - - - M 0,0 L 3.5,4 L 7,0 Z - M 0,4 L 3.5,0 L 7,4 Z - M 0,0 L 4,3.5 L 0,7 Z - F1 M 10.0,1.2 L 4.7,9.1 L 4.5,9.1 L 0,5.2 L 1.3,3.5 L 4.3,6.1L 8.3,0 L 10.0,1.2 Z - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/ClassLibraryCommon/DarkMode/RadioButton.xaml b/src/ClassLibraryCommon/DarkMode/RadioButton.xaml deleted file mode 100644 index 3b7b41738..000000000 --- a/src/ClassLibraryCommon/DarkMode/RadioButton.xaml +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/ClassLibraryCommon/DarkMode/ScrollBar.xaml b/src/ClassLibraryCommon/DarkMode/ScrollBar.xaml deleted file mode 100644 index 79d80ccba..000000000 --- a/src/ClassLibraryCommon/DarkMode/ScrollBar.xaml +++ /dev/null @@ -1,368 +0,0 @@ - - - - #FFE8EDF9 - #FFC5CBF9 - #FF7381F9 - - #FFE8EDF9 - #FFC5CBF9 - #FF888888 - - #FFC5CBF9 - #FFDDDDDD - - #FF9F9F9F - #FF3F3F3F - #FF2F2F2F - - #FF3843C4 - #FF2F2F2F - - - #FF444444 - sc#1, 0.004391443, 0.002428215, 0.242281124 - - - #FFCCCCCC - #FF888888 - #FF444444 - - #FF888888 - #FF444444 - - #FFAAAAAA - #FF888888 - - Black - - - #FFC5CBF9 - Black - #FFC5CBF9 - - #FF3843C4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/ClassLibraryCommon/DarkMode/StatusBar.xaml b/src/ClassLibraryCommon/DarkMode/StatusBar.xaml deleted file mode 100644 index aee7ff88a..000000000 --- a/src/ClassLibraryCommon/DarkMode/StatusBar.xaml +++ /dev/null @@ -1,21 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/ClassLibraryCommon/DarkMode/TabControl.xaml b/src/ClassLibraryCommon/DarkMode/TabControl.xaml deleted file mode 100644 index 57b9706a9..000000000 --- a/src/ClassLibraryCommon/DarkMode/TabControl.xaml +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/ClassLibraryCommon/DarkMode/TabControlItem.xaml b/src/ClassLibraryCommon/DarkMode/TabControlItem.xaml deleted file mode 100644 index ad1bd1571..000000000 --- a/src/ClassLibraryCommon/DarkMode/TabControlItem.xaml +++ /dev/null @@ -1,211 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/ClassLibraryCommon/DarkMode/TextBox.xaml b/src/ClassLibraryCommon/DarkMode/TextBox.xaml deleted file mode 100644 index ff01a9aa4..000000000 --- a/src/ClassLibraryCommon/DarkMode/TextBox.xaml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/src/ClassLibraryCommon/DarkMode/ToolBar.xaml b/src/ClassLibraryCommon/DarkMode/ToolBar.xaml deleted file mode 100644 index da2790543..000000000 --- a/src/ClassLibraryCommon/DarkMode/ToolBar.xaml +++ /dev/null @@ -1,194 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/ClassLibraryCommon/DarkMode/Window.xaml b/src/ClassLibraryCommon/DarkMode/Window.xaml deleted file mode 100644 index 2d7222bb8..000000000 --- a/src/ClassLibraryCommon/DarkMode/Window.xaml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/ClassLibraryCommon/EnumEx.cs b/src/ClassLibraryCommon/EnumEx.cs deleted file mode 100644 index 0ae6055d0..000000000 --- a/src/ClassLibraryCommon/EnumEx.cs +++ /dev/null @@ -1,37 +0,0 @@ -namespace ClassLibraryCommon -{ - using System; - using System.ComponentModel; - - public static class EnumEx - { - public static T GetValueFromDescription(string description) - { - var type = typeof(T); - if (!type.IsEnum) - { - throw new InvalidOperationException(); - } - - foreach (var field in type.GetFields()) - { - if (Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) is DescriptionAttribute attribute) - { - if (attribute.Description.Equals(description)) - { - return (T)field.GetValue(null); - } - } - else - { - if (field.Name.Equals(description)) - { - return (T)field.GetValue(null); - } - } - } - - throw new ArgumentException($"Could not find enum value {description} in enum {typeof(T)}", nameof(description)); - } - } -} diff --git a/src/ClassLibraryCommon/Extensions.cs b/src/ClassLibraryCommon/Extensions.cs deleted file mode 100644 index 00de05bb2..000000000 --- a/src/ClassLibraryCommon/Extensions.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace ClassLibraryCommon -{ - using System; - using System.ComponentModel; - using System.Windows.Input; - - public static class Extensions - { - public static string GetEnumDescriptionField(this Enum value) - { - var field = value.GetType().GetField(value.ToString()); - if (field == null) - { - return string.Empty; - } - - var attributes = field.GetCustomAttributes(typeof(DescriptionAttribute), true); - return attributes.Length > 0 ? ((DescriptionAttribute)attributes[0]).Description : string.Empty; - } - - public static Key RealKey(this KeyEventArgs e) - { - return e.Key switch - { - Key.System => e.SystemKey, - Key.ImeProcessed => e.ImeProcessedKey, - Key.DeadCharProcessed => e.DeadCharProcessedKey, - _ => e.Key - }; - } - } -} diff --git a/src/ClassLibraryCommon/GamingPanelSkeleton.cs b/src/ClassLibraryCommon/GamingPanelSkeleton.cs deleted file mode 100644 index 090f9fa42..000000000 --- a/src/ClassLibraryCommon/GamingPanelSkeleton.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace ClassLibraryCommon -{ - /// - /// Minimum information needed about a gaming panel. Type and manufacturer. - /// - public class GamingPanelSkeleton - { - public GamingPanelEnum GamingPanelType { get; } - public int VendorId { get; } - public int ProductId { get; } - - public GamingPanelSkeleton(GamingPanelVendorEnum gamingPanelVendor, GamingPanelEnum gamingPanelsEnum) - { - GamingPanelType = gamingPanelsEnum; - VendorId = (int)gamingPanelVendor; - ProductId = (int)gamingPanelsEnum; - } - - public override string ToString() - { - return $"Skeleton : {GamingPanelType} {VendorId} {ProductId}"; - } - } -} diff --git a/src/ClassLibraryCommon/Images/gear-image-darkmode.png b/src/ClassLibraryCommon/Images/gear-image-darkmode.png deleted file mode 100644 index 6a48917cd047e55bae1af4676add7f5adcf16988..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9805 zcmeHrc{r5a|NlM1*!PenOe0yx%-HuWl3jKo#u)oD89OmZA%#MS>|2NyMP!MjEU6Sx zwro8VA&hN)x9WL5&-43z|M^_k@B7~~*LCK;?{nVgb>8pSd7pE=&Pg&i)n{hlV*mhv z+2E9}1pq+6R|r5y13nxBE8PJA`YpoBF318K3MT{xxO@5H;X&a9JRBe91vZ9_e!byz zZw$_qFk!EE!^MCuY1RcT`$_x8gz(t8fM}Js56trEyV_x7_&TJ?U@Uc6_WX(BKSc2I zsD=!f_^@MB(Nu5x=-D^dHdnJ2q?WhezH=LjJ98C+ns;~<{rI|lWl@>)g_Z)U#XYTl z{r-J;m%hl<=?Blnt;~*2;Yg;jAyPi#@4hZ_y#HGH+^;BFO+0yN(_eGXFLB(wPq^=9 znv|HHDeW;qgEt!|GenrM?^nbOGXs;4!t17k${14J8*`oc_SkD3B-P)%jLPjfk=AS7 zwq#byN)_1O>FhBO?RUL7`uYh8B}i$q%u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bAUD#5?iPOc4|24)naC|2^^b6t%#&%)2 zJc!;y9Z)}Q>ullEDBnCtAoSoZ8%#*d80Vaz{;@`?a0ndVG2{YZ*T>Dnb#@8k;Xx}^;-6#t~ z)kw9VYnW$`N0qE~@(3-c3?fFs z*t#MTpW!C5UD7Xc%;zVQv&)3z7u24z-lpE!Rm1Tc+wdoXIUe-M2>S4cr+ABrm})fa za*p-)H*t8uMMq3N&{bR%ON4F-84kERD{g)szno=MUi$dCU1ul=s?Nh2Wt?ssKr&i~ zcN$-?lm%ow8x;I_5JTAXO9>v4P`v3=p({*k7=-9Sh=nJ5Jrz?51(xSqeoM_Mxvt<{ zx(-5YXdVnDf>v%q2|OdZ!MNO#6p;vjDIRijnF!>?N^60=y zZ|m>222rgTIpDSz91C5S+lc~KOV0NuAGJ&K0)7#HeP8T){+&bPa*3d18ZcY7m^dOe zwo34xw_Hh?Y|-EgDBT%5gVZMLIJsQ_1>WW i|H1tq#AfZm5GY_9S>9jTvmJ5fGl0Bls#~Uw3jGhN{CkK1 diff --git a/src/ClassLibraryCommon/SerializeCriticalAttribute.cs b/src/ClassLibraryCommon/SerializeCriticalAttribute.cs deleted file mode 100644 index c53edf509..000000000 --- a/src/ClassLibraryCommon/SerializeCriticalAttribute.cs +++ /dev/null @@ -1,6 +0,0 @@ -using System; - -namespace ClassLibraryCommon { - public class SerializeCriticalAttribute : Attribute { - } -} diff --git a/src/ClassLibraryCommon/SerializeCriticalCustomAttribute.cs b/src/ClassLibraryCommon/SerializeCriticalCustomAttribute.cs deleted file mode 100644 index 03dcb5b76..000000000 --- a/src/ClassLibraryCommon/SerializeCriticalCustomAttribute.cs +++ /dev/null @@ -1,6 +0,0 @@ -using System; - -namespace ClassLibraryCommon { - public class SerializeCriticalCustomAttribute : Attribute { - } -} diff --git a/src/ClassLibraryCommon/app.config b/src/ClassLibraryCommon/app.config deleted file mode 100644 index 0dd47ccaf..000000000 --- a/src/ClassLibraryCommon/app.config +++ /dev/null @@ -1,223 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/ClassLibraryCommon/dcs-bios_modules.txt b/src/ClassLibraryCommon/dcs-bios_modules.txt deleted file mode 100644 index b4dc9371c..000000000 --- a/src/ClassLibraryCommon/dcs-bios_modules.txt +++ /dev/null @@ -1,51 +0,0 @@ --- Following text is used by DCSFlightpanels GUI to pick up DCS-BIOS modules. --- ID range 1-3 is used internally in DCSFlightpanels. New modules must have an uniques ID. - --- Format: --- Module(JSON Name)|ID|Pretty Name - -FC3|4|Flaming Cliffs 3 -A-10C|5|A-10C Thunderbolt/II -A-4E-C|6|A-4E Skyhawk -AH-6J|7|AH-6J Littlebird -AJS37|8|AJS-37 Viggen -Alphajet|9|Alphajet -AV8BNA|10|AV-8B Night Attack -Bf-109K-4|11|Bf 109 K-4 Kurfurst -C-101|12|C-101 Aviojet -MirageF1|13|Mirage F1 -Christen Eagle II|14|Christen Eagle II -Edge540|15|Edge 540 -F-14|16|F-14A/B Tomcat -F-16C_50|17|F-16C Viper -F-5E-3|18|F-5E Tiger II -F-86F Sabre|19|F-86F Sabre -FA-18C_hornet|20|F/A-18C Hornet -FW-190A8|21|Fw 190 A-8 Anton -FW-190D9|22|Fw 190 D-9 Dora -I-16|23|I-16 -JF-17|24|JF-17 Thunder -Ka-50|25|Ka-50 Black Shark/III -L-39|26|L-39 Albatros -M-2000C|27|M-2000C -MB-339|28|MB-339A/PAN -Mi-8MT|29|Mi-8MT -Mig-15bis|30|MiG-15bis -Mig-19P|31|MiG-19P Farmer -Mig-21Bis|32|MiG-21bis -NS430|33|NS 430 GPS -P-47D|34|P-47D Thunderbolt -P-51D|35|TF/P-51D Mustang -SA342|36|SA342 Gazelle -SpitfireLFMkIX|37|Spitfire LF Mk. IX -UH-1H|38|UH-1H Huey -Yak-52|39|Yak-52 -F-22A|40|F-22A Raptor -A-29B|41|A-29B Super Tucano -Mi-24P|42|Mi-24P HIND -VNAO_T-45|43|T-45 Goshawk -F-15E|44|F-15E Strike Eagle -Mosquito|45|Mosquito FB Mk. VI -AH-64D|46|AH-64D Apache -MH-60R|47|MH-60R SeaHawk -NS-430|48|NS-430 Navigation System diff --git a/src/DCS-BIOS/ControlLocator/DCSBIOSAircraftLoadStatus.cs b/src/DCS-BIOS/ControlLocator/DCSBIOSAircraftLoadStatus.cs deleted file mode 100644 index 7d92c6122..000000000 --- a/src/DCS-BIOS/ControlLocator/DCSBIOSAircraftLoadStatus.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System.Collections.Generic; -using System.Linq; - -namespace DCS_BIOS.ControlLocator -{ - /// - /// Convenience class for DCSBIOSControlLocator. - /// - internal class DCSBIOSAircraftLoadStatus - { - private string Filename { get; } - private bool Loaded { get; set; } - private static readonly List LoadStatusList = new(); - - private DCSBIOSAircraftLoadStatus(string filename, bool loaded) - { - Filename = filename; - Loaded = loaded; - } - - public static void Clear() - { - LoadStatusList.Clear(); - } - - public static void SetLoaded(string filename, bool loaded) - { - if (!IsRegistered(filename)) - { - LoadStatusList.Add(new DCSBIOSAircraftLoadStatus(filename, loaded)); // <-- loaded set here - return; - } - - foreach (var loadStatus in LoadStatusList.Where(loadStatus => loadStatus.Filename == filename)) - { - loadStatus.Loaded = loaded; - } - } - - public static bool IsLoaded(string filename) - { - return LoadStatusList.Exists(loadStatus => loadStatus.Filename == filename && loadStatus.Loaded); - } - - private static bool IsRegistered(string filename) - { - return LoadStatusList.Exists(loadStatus => loadStatus.Filename == filename); - } - - public static void Remove(string filename) - { - var itemToRemove = LoadStatusList.SingleOrDefault(r => r.Filename == filename); - if (itemToRemove != null) - { - LoadStatusList.Remove(itemToRemove); - } - } - } -} diff --git a/src/DCS-BIOS/ControlLocator/DCSBIOSControlComparer.cs b/src/DCS-BIOS/ControlLocator/DCSBIOSControlComparer.cs deleted file mode 100644 index 2ab5f32fb..000000000 --- a/src/DCS-BIOS/ControlLocator/DCSBIOSControlComparer.cs +++ /dev/null @@ -1,31 +0,0 @@ -using DCS_BIOS.Json; -using System.Collections.Generic; - -namespace DCS_BIOS.ControlLocator -{ - internal class DCSBIOSControlComparer : IEqualityComparer - { - // DCSBIOSControls are equal if their names are equal. - public bool Equals(DCSBIOSControl x, DCSBIOSControl y) - { - - //Check whether the compared objects reference the same data. - if (ReferenceEquals(x, y)) return true; - - //Check whether any of the compared objects is null. - if (ReferenceEquals(x, null) || ReferenceEquals(y, null)) - return false; - - //Check whether the products' properties are equal. - return x.Identifier == y.Identifier; - } - - // If Equals() returns true for a pair of objects - // then GetHashCode() must return the same value for these objects. - public int GetHashCode(DCSBIOSControl dcsbiosControl) - { - //Get hash code for the Identifier field if it is not null. - return dcsbiosControl.Identifier == null ? 0 : dcsbiosControl.Identifier.GetHashCode(); - } - } -} diff --git a/src/DCS-BIOS/ControlLocator/DCSBIOSControlLocator.cs b/src/DCS-BIOS/ControlLocator/DCSBIOSControlLocator.cs deleted file mode 100644 index f4ff340fc..000000000 --- a/src/DCS-BIOS/ControlLocator/DCSBIOSControlLocator.cs +++ /dev/null @@ -1,467 +0,0 @@ -using System.Globalization; -using DCS_BIOS.Json; -using DCS_BIOS.StringClasses; - - -namespace DCS_BIOS.ControlLocator -{ - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using ClassLibraryCommon; - using misc; - using Serialized; - using Newtonsoft.Json; - using NLog; - - /// - /// Reads the aircraft's / helicopter's JSON file containing the cockpit controls. - /// Whenever a class needs a specific DCS-BIOS control it asks for the control using - /// this centralized class. There are separate functions for getting an input or output control. - /// - public static class DCSBIOSControlLocator - { - private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - - private static List _dcsbiosControls = new(); - private static readonly object LockObject = new(); - private static DCSAircraft _dcsAircraft; - private static string _jsonDirectory; - private const string DCSBIOS_JSON_NOT_FOUND_ERROR_MESSAGE = "Error loading DCS-BIOS JSON. Check that the DCS-BIOS location setting points to the JSON directory."; - - public static DCSAircraft DCSAircraft - { - get => _dcsAircraft; - set - { - if (_dcsAircraft != value) - { - _dcsAircraft = value; - LuaAssistant.DCSAircraft = _dcsAircraft; - Reset(); - } - } - } - - public static string JSONDirectory - { - get => _jsonDirectory; - set - { - _jsonDirectory = Environment.ExpandEnvironmentVariables(value); - LuaAssistant.JSONDirectory = _jsonDirectory; - } - } - - public static DCSBIOSControl GetControl(string controlId) - { - lock (LockObject) - { - if (Common.IsEmulationModesFlagSet(EmulationMode.KeyboardEmulationOnly)) - { - return null; - } - - try - { - LoadControls(); - - if (!_dcsbiosControls.Exists(controlObject => controlObject.Identifier.Equals(controlId))) - { - throw new Exception($"Error, control {controlId} does not exist. ({DCSAircraft.Description})"); - } - - return _dcsbiosControls.Single(controlObject => controlObject.Identifier.Equals(controlId)); - } - catch (InvalidOperationException ioe) - { - throw new Exception($"Check DCS-BIOS version. Failed to find control {controlId} for airframe {DCSAircraft.Description} ({DCSAircraft.JSONFilename}). Did you switch airframe type for the profile and have existing control(s) for the previous type saved?{Environment.NewLine}{ioe.Message}"); - } - } - } - - public static DCSBIOSOutput GetDCSBIOSOutput(string controlId, DCSBiosOutputType dcsBiosOutputType) - { - return dcsBiosOutputType == DCSBiosOutputType.IntegerType ? GetUIntDCSBIOSOutput(controlId) : GetStringDCSBIOSOutput(controlId); - } - - public static DCSBIOSOutput GetUIntDCSBIOSOutput(string controlId) - { - lock (LockObject) - { - if (Common.IsEmulationModesFlagSet(EmulationMode.KeyboardEmulationOnly)) - { - throw new Exception("DCSBIOSControlLocator.GetDCSBIOSOutput() Should not be called when only key emulator is active"); - } - - try - { - var control = GetControl(controlId); - var dcsBIOSOutput = new DCSBIOSOutput(); - dcsBIOSOutput.Consume(control, DCSBiosOutputType.IntegerType); - return dcsBIOSOutput; - } - catch (InvalidOperationException ioe) - { - throw new Exception($"Check DCS-BIOS version. Failed to create DCSBIOSOutput based on control {controlId} for profile {DCSAircraft.JSONFilename}{Environment.NewLine}{ioe.Message}"); - } - } - } - - public static DCSBIOSOutput GetStringDCSBIOSOutput(string controlId) - { - lock (LockObject) - { - if (Common.IsEmulationModesFlagSet(EmulationMode.KeyboardEmulationOnly)) - { - throw new Exception("DCSBIOSControlLocator.GetDCSBIOSOutput() Should not be called when only key emulator is active"); - } - - try - { - var control = GetControl(controlId); - var dcsBIOSOutput = new DCSBIOSOutput(); - dcsBIOSOutput.Consume(control, DCSBiosOutputType.StringType); - DCSBIOSStringManager.AddListeningAddress(dcsBIOSOutput); - return dcsBIOSOutput; - } - catch (InvalidOperationException ioe) - { - throw new Exception($"Check DCS-BIOS version. Failed to create DCSBIOSOutput based on control {controlId} for profile {DCSAircraft.JSONFilename}{Environment.NewLine}{ioe.Message}"); - } - } - } - - /// - /// Simple loading of module's controls regardless of current context (chosen airframe, profile etc.). - /// Member DCSAircraft is not taken into account. - /// - /// - public static List GetModuleControlsFromJson(string filename, bool onlyDirectResult = false)//variable name is terrible, should be changed. - { - var result = new List(); - - try - { - lock (LockObject) - { - var directoryInfo = new DirectoryInfo(_jsonDirectory); - IEnumerable files; - try - { - files = directoryInfo.EnumerateFiles(filename, SearchOption.TopDirectoryOnly); - } - catch (Exception ex) - { - throw new Exception($"Failed to find DCS-BIOS json files. -> {Environment.NewLine}{ex.Message}"); - } - - foreach (var file in files) - { - var controls = ReadControlsFromDocJson(file.FullName); - if (!onlyDirectResult) - { - _dcsbiosControls.AddRange(controls); - } - result.AddRange(controls); - } - - DCSBIOSAircraftLoadStatus.SetLoaded(filename, true); - } - } - catch (Exception ex) - { - throw new Exception($"{DCSBIOS_JSON_NOT_FOUND_ERROR_MESSAGE} ==>[{_jsonDirectory}]<=={Environment.NewLine}{ex.Message}{Environment.NewLine}{ex.StackTrace}"); - } - - return result; - } - - /// - /// Loads meta controls and returns them in a list. - /// - public static List GetMetaControls() - { - var controlList = GetModuleControlsFromJson(DCSAircraft.DCSBIOS_META_DATA_START_FILE_NAME, true); - controlList.AddRange(GetModuleControlsFromJson(DCSAircraft.DCSBIOS_META_DATA_END_FILE_NAME, true)); - controlList.AddRange(GetModuleControlsFromJson(DCSAircraft.DCSBIOS_COMMON_DATA_FILE_NAME, true)); - return controlList; - } - - public static IEnumerable GetControls() - { - LoadControls(); - - // Remove duplicates which may come from loading NS430 or other additional profiles - return _dcsbiosControls.Distinct(new DCSBIOSControlComparer()).ToList(); - } - - public static IEnumerable GetOutputControls(DCSBiosOutputType dcsBiosOutputType) - { - /*"CM_CHAFFCNT_DISPLAY": { - "category": "Countermeasures", - "control_type": "display", - "description": "Chaff Counter", - "identifier": "CM_CHAFFCNT_DISPLAY", - "inputs": [ ], - "outputs": [ { - "address": 5408, - "description": "Chaff Counter", - "max_length": 2, - "suffix": "", - "type": "string" - } ] - },*/ - if (!Common.IsEmulationModesFlagSet(EmulationMode.DCSBIOSOutputEnabled)) - { - return null; - } - - LoadControls(); - return _dcsbiosControls.Where(o => o.Outputs.Count > 0 && o.Outputs.Any(x => x.OutputDataType == dcsBiosOutputType)); - } - - public static IEnumerable GetInputControls() - { - if (!Common.IsEmulationModesFlagSet(EmulationMode.DCSBIOSInputEnabled)) - { - return null; - } - - LoadControls(); - return _dcsbiosControls.Where(controlObject => controlObject.Inputs.Count > 0); - } - - public static List> GlobalControlSearch(string keyword) - { - var returnList = new List>(); - try - { - - lock (LockObject) - { - var directoryInfo = new DirectoryInfo(_jsonDirectory); - IEnumerable files; - try - { - files = directoryInfo.EnumerateFiles("*.json", SearchOption.TopDirectoryOnly); - } - catch (Exception ex) - { - throw new Exception($"Failed to find DCS-BIOS json files. -> {Environment.NewLine}{ex.Message}"); - } - - foreach (var file in files) - { - var controls = ReadControlsFromDocJson(file.FullName); - - if(controls == null || controls.Count == 0) continue; - - foreach (var dcsbiosControl in controls) - { - if(dcsbiosControl.Identifier.ToLower(CultureInfo.InvariantCulture).Contains(keyword.ToLower(CultureInfo.InvariantCulture)) || - dcsbiosControl.Description.ToLower(CultureInfo.InvariantCulture).Contains(keyword.ToLower(CultureInfo.InvariantCulture))) - { - returnList.Add(new Tuple(file.Name, dcsbiosControl)); - } - } - } - } - } - catch (Exception ex) - { - throw new Exception($"{DCSBIOS_JSON_NOT_FOUND_ERROR_MESSAGE} ==>[{_jsonDirectory}]<=={Environment.NewLine}{ex.Message}{Environment.NewLine}{ex.StackTrace}"); - } - - return returnList; - } - - public static string GetLuaCommand(string dcsbiosIdentifier, bool includeSignature) - { - return LuaAssistant.GetLuaCommand(dcsbiosIdentifier, includeSignature); - } - - /// - /// Checks DCSAircraft and EmulationMode loads appropriate modules (NS430 or FC3 +/- Meta modules). - /// Set DCSAircraft and JSON path before calling this. - /// - /// - private static void LoadControls() - { - /* - * Load profile for current airframe - * Remove/Add NS430 - * Load Common Data - * Load Metadata End - * - * This function will have to change when (if) new types of profiles are added to DCS-BIOS - */ - - - /* - * Check if already loaded. - */ - if (_dcsbiosControls.Count > 0) - { - return; - } - - try - { - if (DCSAircraft.IsNoFrameLoadedYet(_dcsAircraft) || - Common.IsEmulationModesFlagSet(EmulationMode.KeyboardEmulationOnly)) - { - return; - } - - if (!Common.IsEmulationModesFlagSet(EmulationMode.NS430Enabled) && DCSAircraft.HasNS430()) - { - if (DCSBIOSAircraftLoadStatus.IsLoaded(DCSAircraft.GetNS430().JSONFilename)) - { - //Discard all DCS-BIOS controls if user "unloaded" NS430. Not possible to remove them specifically - //Better to force load all controls - Reset(); - } - else - { - DCSBIOSAircraftLoadStatus.Remove(DCSAircraft.GetNS430().JSONFilename); - } - } - - if (Common.IsEmulationModesFlagSet(EmulationMode.NS430Enabled)) - { - ReadDataFromJsonFile(DCSAircraft.GetNS430().JSONFilename); - } - - if (DCSAircraft.IsFlamingCliff(DCSAircraft)) - { - LoadCommonData(_jsonDirectory); - LoadMetaDataEnd(_jsonDirectory); - } - else - { - LoadCommonData(_jsonDirectory); - LoadMetaDataEnd(_jsonDirectory); - - // Load the controls for the actual aircraft/helicopter - ReadDataFromJsonFile(DCSAircraft.JSONFilename); - } - - // Remove duplicates which may come from loading NS430 or other additional profiles - _dcsbiosControls = _dcsbiosControls.Distinct(new DCSBIOSControlComparer()).ToList(); - } - catch (Exception ex) - { - throw new Exception($"{DCSBIOS_JSON_NOT_FOUND_ERROR_MESSAGE} ==>[{_jsonDirectory}]<==", ex); - } - } - - private static List ReadControlsFromDocJson(string fileFullPath) - { - // input is a map from category string to a map from key string to control definition - // we read it all then flatten the grand children (the control definitions) - var input = File.ReadAllText(fileFullPath); - try - { - return JsonConvert.DeserializeObject>>(input)! - .Values - .SelectMany(category => category.Values) - .ToList(); - } - catch (Exception e) - { - Logger.Error(e, "ReadControlsFromDocJson : Failed to read DCS-BIOS JSON."); - } - - return null; - } - - private static void LoadMetaDataEnd(string jsonDirectory) - { - if (DCSBIOSAircraftLoadStatus.IsLoaded(DCSAircraft.DCSBIOS_META_DATA_END_FILE_NAME) || Common.IsEmulationModesFlagSet(EmulationMode.KeyboardEmulationOnly) || DCSAircraft.IsNoFrameLoadedYet(_dcsAircraft)) - { - return; - } - - try - { - lock (LockObject) - { - _dcsbiosControls.AddRange(ReadControlsFromDocJson(jsonDirectory + $"\\{DCSAircraft.DCSBIOS_META_DATA_END_FILE_NAME}")); - - DCSBIOSAircraftLoadStatus.SetLoaded(DCSAircraft.DCSBIOS_META_DATA_END_FILE_NAME, true); - } - } - catch (Exception ex) - { - throw new Exception($"{DCSBIOS_JSON_NOT_FOUND_ERROR_MESSAGE} ==>[{jsonDirectory}]<=={Environment.NewLine}{ex.Message}{Environment.NewLine}{ex.StackTrace}"); - } - } - - private static void LoadCommonData(string jsonDirectory) - { - if (DCSBIOSAircraftLoadStatus.IsLoaded(DCSAircraft.DCSBIOS_COMMON_DATA_FILE_NAME) || Common.IsEmulationModesFlagSet(EmulationMode.KeyboardEmulationOnly) || DCSAircraft.IsNoFrameLoadedYet(_dcsAircraft)) - { - return; - } - - try - { - lock (LockObject) - { - _dcsbiosControls.AddRange(ReadControlsFromDocJson(jsonDirectory + $"\\{DCSAircraft.DCSBIOS_COMMON_DATA_FILE_NAME}")); - DCSBIOSAircraftLoadStatus.SetLoaded(DCSAircraft.DCSBIOS_COMMON_DATA_FILE_NAME, true); - } - } - catch (Exception ex) - { - throw new Exception($"{DCSBIOS_JSON_NOT_FOUND_ERROR_MESSAGE} ==>[{jsonDirectory}]<=={Environment.NewLine}{ex.Message}{Environment.NewLine}{ex.StackTrace}"); - } - } - - private static void ReadDataFromJsonFile(string filename) - { - if (DCSBIOSAircraftLoadStatus.IsLoaded(filename) || filename == DCSAircraft.GetKeyEmulator().JSONFilename || filename == DCSAircraft.GetNoFrameLoadedYet().JSONFilename) - { - return; - } - - try - { - lock (LockObject) - { - var directoryInfo = new DirectoryInfo(_jsonDirectory); - IEnumerable files; - try - { - files = directoryInfo.EnumerateFiles(filename, SearchOption.TopDirectoryOnly); - } - catch (Exception ex) - { - throw new Exception($"Failed to find DCS-BIOS json files. -> {Environment.NewLine}{ex.Message}"); - } - - foreach (var file in files) - { - var controls = ReadControlsFromDocJson(file.FullName); - _dcsbiosControls.AddRange(controls); - } - - DCSBIOSAircraftLoadStatus.SetLoaded(filename, true); - } - } - catch (Exception ex) - { - throw new Exception($"{DCSBIOS_JSON_NOT_FOUND_ERROR_MESSAGE} ==>[{_jsonDirectory}]<=={Environment.NewLine}{ex.Message}{Environment.NewLine}{ex.StackTrace}"); - } - } - - private static void Reset() - { - DCSBIOSAircraftLoadStatus.Clear(); - _dcsbiosControls.Clear(); - LuaAssistant.Reset(); - } - } -} diff --git a/src/DCS-BIOS/DCS-BIOS.csproj b/src/DCS-BIOS/DCS-BIOS.csproj deleted file mode 100644 index a0c68a660..000000000 --- a/src/DCS-BIOS/DCS-BIOS.csproj +++ /dev/null @@ -1,48 +0,0 @@ - - - net6.0-windows - Library - DCS_BIOS - true - true - en - - - - - - bin\x64\Debug\ - MinimumRecommendedRules.ruleset - - - bin\x64\Release\ - none - MinimumRecommendedRules.ruleset - - .allowedextension - - - - - - - - - - - - - - - - - - - - - For using DCS-BIOS from C# based projects - ArturDCS (Jerker Dahlblom) - 2.1.865.6527 - 2.1.865.6527 - - \ No newline at end of file diff --git a/src/DCS-BIOS/DCSBIOS.cs b/src/DCS-BIOS/DCSBIOS.cs deleted file mode 100644 index 0f7137ec3..000000000 --- a/src/DCS-BIOS/DCSBIOS.cs +++ /dev/null @@ -1,327 +0,0 @@ - -// ReSharper disable All -/* - * Do not adhere to naming standard in DCS-BIOS code, standard are based on DCS-BIOS json files and byte streamnaming - */ - -using System.Diagnostics; -using DCS_BIOS.EventArgs; -using DCS_BIOS.StringClasses; -using NLog; -namespace DCS_BIOS -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Net.Sockets; - using System.Text; - using System.Threading; - using System.Timers; - - [Flags] - public enum DcsBiosNotificationMode - { - Parse = 2, - PassThrough = 4 - } - - /// - /// Main class in project. Sends commands to DCS-BIOS and receives data about all cockpit controls - /// in the aircraft. - /// - public class DCSBIOS : IDisposable - { - internal static readonly Logger logger = LogManager.GetCurrentClassLogger(); - //public delegate void DcsDataReceivedEventHandler(byte[] bytes); - //public event DcsDataReceivedEventHandler OnDcsDataReceived; - - private static DCSBIOS _dcsBIOSInstance; - - /************************ - **********UDP************ - ************************/ - private UdpClient _udpReceiveClient; - private UdpClient _udpSendClient; - private Thread _dcsbiosListeningThread; - private System.Timers.Timer _udpReceiveThrottleTimer = new(10) { AutoReset = true }; //Throttle UDP receive every 10 ms in case nothing is available - private AutoResetEvent _udpReceiveThrottleAutoResetEvent = new(false); - public string ReceiveFromIpUdp { get; set; } = "239.255.50.10"; - public string SendToIpUdp { get; set; } = "127.0.0.1"; - public int ReceivePortUdp { get; set; } = 5010; - public int SendPortUdp { get; set; } = 7778; - private IPEndPoint _ipEndPointReceiverUdp; - private IPEndPoint _ipEndPointSenderUdp; - public string ReceivedDataUdp { get; } = null; - /************************ - ************************* - ************************/ - - private readonly object _lockExceptionObject = new(); - private Exception _lastException; - private DCSBIOSProtocolParser _dcsProtocolParser; - private readonly DcsBiosNotificationMode _dcsBiosNotificationMode; - private readonly object _lockObjectForSendingData = new(); - private volatile bool _isRunning; - public bool IsRunning - { - get => _isRunning; - } - - public DCSBIOS(string ipFromUdp, string ipToUdp, int portFromUdp, int portToUdp, DcsBiosNotificationMode dcsNotificationMode) - { - - if (!string.IsNullOrEmpty(ipFromUdp) && IPAddress.TryParse(ipFromUdp, out _)) - { - ReceiveFromIpUdp = ipFromUdp; - } - - if (!string.IsNullOrEmpty(ipToUdp) && IPAddress.TryParse(ipToUdp, out _)) - { - SendToIpUdp = ipToUdp; - } - - if (portFromUdp > 0) - { - ReceivePortUdp = portFromUdp; - } - - if (portToUdp > 0) - { - SendPortUdp = portToUdp; - } - - _dcsBiosNotificationMode = dcsNotificationMode; - _dcsBIOSInstance = this; - - Startup(); - } - - public void Dispose() - { - DCSBIOSStringManager.Close(); - Dispose(true); - GC.SuppressFinalize(this); - } - - private void Dispose(bool disposing) - { - if (disposing) - { - _udpReceiveClient?.Dispose(); - _udpSendClient?.Dispose(); - _dcsProtocolParser?.Dispose(); - Shutdown(); - } - } - - public void Startup() - { - try - { - if (_isRunning) - { - return; - } - - _dcsProtocolParser = DCSBIOSProtocolParser.GetParser(); - - _ipEndPointReceiverUdp = new IPEndPoint(IPAddress.Any, ReceivePortUdp); - _ipEndPointSenderUdp = new IPEndPoint(IPAddress.Parse(SendToIpUdp), SendPortUdp); - - _udpReceiveClient = new UdpClient(); - _udpReceiveClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); - _udpReceiveClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 200); - _udpReceiveClient.Client.Bind(_ipEndPointReceiverUdp); - _udpReceiveClient.JoinMulticastGroup(IPAddress.Parse(ReceiveFromIpUdp)); - - _udpSendClient = new UdpClient(); - _udpSendClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); - _udpSendClient.EnableBroadcast = true; - - _udpReceiveThrottleTimer.Elapsed += UdpReceiveThrottleTimer_Elapsed; - _udpReceiveThrottleTimer.Start(); - _dcsbiosListeningThread = new Thread(ReceiveDataUdp); - - _isRunning = true; - _dcsProtocolParser.Startup(); - _dcsbiosListeningThread.Start(); - } - catch (Exception ex) - { - SetLastException(ex); - logger.Error(ex, "DCSBIOS.Startup()"); - if (_udpReceiveClient != null && _udpReceiveClient.Client.Connected) - { - _udpReceiveClient.Close(); - _udpReceiveClient = null; - } - if (_udpSendClient != null && _udpSendClient.Client != null && _udpSendClient.Client.Connected) - { - _udpSendClient.Close(); - _udpSendClient = null; - } - } - } - - public void Shutdown() - { - try - { - _isRunning = false; - _udpReceiveThrottleAutoResetEvent.Set(); - _udpReceiveClient?.Close(); - _dcsProtocolParser?.Shutdown(); - - _udpReceiveClient = null; - _udpReceiveClient = null; - _dcsProtocolParser = null; - _udpReceiveThrottleTimer.Stop(); - } - catch (Exception ex) - { - SetLastException(ex); - logger.Error(ex, "DCSBIOS.Shutdown()"); - } - } - - private void UdpReceiveThrottleTimer_Elapsed(object sender, ElapsedEventArgs e) - { - _udpReceiveThrottleAutoResetEvent.Set(); - } - - public void ReceiveDataUdp() - { - try - { - while (_isRunning) - { - try - { - if (_udpReceiveClient.Available > 0) - { - BIOSEventHandler.ConnectionActive(this); - var byteData = _udpReceiveClient.Receive(ref _ipEndPointReceiverUdp); - if ((_dcsBiosNotificationMode & DcsBiosNotificationMode.Parse) == DcsBiosNotificationMode.Parse) - { - _dcsProtocolParser.AddArray(byteData); - } - if ((_dcsBiosNotificationMode & DcsBiosNotificationMode.PassThrough) == DcsBiosNotificationMode.PassThrough) - { - BIOSEventHandler.AsyncDCSBIOSBulkDataAvailable(this, byteData); - } - continue; - } - _udpReceiveThrottleAutoResetEvent.WaitOne(); // Minimizes CPU hit - } - catch (SocketException) - { - continue; - } - } - - } - catch (Exception ex) - { - if (!ex.Message.Contains("WSACancelBlockingCall")) - { - SetLastException(ex); - logger.Error(ex, "DCSBIOS.ReceiveData()"); - } - } - } - - public static DCSBIOS GetInstance() - { - return _dcsBIOSInstance; - } - - public static int Send(string stringData) - { - Debug.WriteLine($"Sending command : {stringData}"); - return _dcsBIOSInstance.SendDataFunction(stringData); - } - - public static void Send(string[] stringArray) - { - if (stringArray != null) - { - Send(stringArray.ToList()); - } - } - - public static void Send(List stringList) - { - if (stringList != null) - { - stringList.ForEach(s => _dcsBIOSInstance.SendDataFunction(s)); - } - } - - public int SendDataFunction(string stringData) - { - var result = 0; - lock (_lockObjectForSendingData) - { - try - { - //byte[] bytes = _iso8859_1.GetBytes(stringData); - var unicodeBytes = Encoding.Unicode.GetBytes(stringData); - var asciiBytes = new List(stringData.Length); - asciiBytes.AddRange(Encoding.Convert(Encoding.Unicode, Encoding.ASCII, unicodeBytes)); - result = _udpSendClient.Send(asciiBytes.ToArray(), asciiBytes.ToArray().Length, _ipEndPointSenderUdp); - //result = _udpSendClient.Send(bytes, bytes.Length, _ipEndPointSender); - } - catch (Exception ex) - { - SetLastException(ex); - logger.Error(ex, "DCSBIOS.SendDataFunction()"); - } - } - return result; - } - - private void SetLastException(Exception ex) - { - try - { - if (ex == null) - { - return; - } - logger.Error(ex, "Via DCSBIOS.SetLastException()"); - var message = ex.GetType() + Environment.NewLine + ex.Message + Environment.NewLine + ex.StackTrace; - lock (_lockExceptionObject) - { - _lastException = new Exception(message); - } - } - catch (Exception) - { - // ignore - } - } - - public Exception GetLastException(bool resetException = false) - { - Exception result; - lock (_lockExceptionObject) - { - result = _lastException; - if (resetException) - { - _lastException = null; - } - } - return result; - } - - public bool HasLastException() - { - lock (_lockExceptionObject) - { - return _lastException != null; - } - } - } -} diff --git a/src/DCS-BIOS/DCSBIOSProtocolParser.cs b/src/DCS-BIOS/DCSBIOSProtocolParser.cs deleted file mode 100644 index 004ab57ff..000000000 --- a/src/DCS-BIOS/DCSBIOSProtocolParser.cs +++ /dev/null @@ -1,268 +0,0 @@ - -// ReSharper disable All -/* - * Do not adhere to naming standard in DCS-BIOS code, standard are based on DCS-BIOS json files and byte streamnaming - */ - -using System.Diagnostics; - -namespace DCS_BIOS -{ - using System; - using System.Collections.Concurrent; - using System.Collections.Generic; - using System.Linq; - using System.Threading; - - using DCS_BIOS.EventArgs; - using DCS_BIOS.misc; - using NLog; - - public enum DCSBiosStateEnum - { - WAIT_FOR_SYNC = 0, - ADDRESS_LOW = 1, - ADDRESS_HIGH = 2, - COUNT_LOW = 3, - COUNT_HIGH = 4, - DATA_LOW = 5, - DATA_HIGH = 6, - } - - /// - /// Reads and interprets the data stream sent from DCS-BIOS. - /// When a DCS-BIOS Control value has been received it - /// checks whether anyone is listening for the specific Address - /// and if so then broadcast the information. - /// - internal class DCSBIOSProtocolParser : IDisposable - { - internal static readonly Logger logger = LogManager.GetCurrentClassLogger(); - - private readonly List _errorsLogged = new(10); - - private DCSBiosStateEnum _state; - private uint _address; - private uint _count; - private uint _data; - private byte _syncByteCount; - private bool _shutdown; - private static readonly object _lockListOfAddressesToBroascastObject = new(); - private readonly List _listOfAddressesToBroascast = new(); - public static DCSBIOSProtocolParser DCSBIOSProtocolParserSO; - private AutoResetEvent _autoResetEvent = new(false); - - private readonly ConcurrentQueue _arraysToProcess = new(); - private Thread _processingThread; - - private DCSBIOSProtocolParser() - { - _state = DCSBiosStateEnum.WAIT_FOR_SYNC; - _syncByteCount = 0; - DCSBIOSProtocolParserSO = this; - _shutdown = false; - - // Add addresses that are specifix to the send cycle - _listOfAddressesToBroascast.Add(DCSBIOSConstants.META_MODULE_START_ADDRESS); // MetadataStart - _listOfAddressesToBroascast.Add(DCSBIOSConstants.META_MODULE_END_ADDRESS); // MetadataEnd - } - - protected virtual void Dispose(bool disposing) - { - _shutdown = true; - if (disposing) - { - // dispose managed resources - _autoResetEvent?.Dispose(); - _autoResetEvent = null; - } - // free native resources - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - public void Startup() - { - _shutdown = false; - _processingThread = new Thread(ThreadedProcessArrays); - _processingThread.Start(); - } - - public void Shutdown() - { - _shutdown = true; - _autoResetEvent.Set(); - } - - private void ThreadedProcessArrays() - { - try - { - var interval = 0; - while (!_shutdown) - { - try - { - if (interval >= 100) - { - //Debug.Print("_arraysToProcess.Count = " + _arraysToProcess.Count); - interval = 0; - } - - byte[] array = null; - while (_arraysToProcess.TryDequeue(out array)) - { - if (array != null) - { - for (int i = 0; i < array.Length; i++) - { - ProcessByte(array[i]); - } - } - } - - interval++; - } - catch (Exception ex) - { - logger.Error(ex, $"DCSBIOSProtocolParser.ProcessArrays(), arrays to process : {_arraysToProcess.Count}"); - } - _autoResetEvent?.WaitOne(); - } - } - catch (Exception ex) - { - logger.Error(ex, $"DCSBIOSProtocolParser.ProcessArrays(), arrays to process : {_arraysToProcess.Count}"); - } - } - - public static void RegisterAddressToBroadCast(uint address) - { - GetParser(); - lock (_lockListOfAddressesToBroascastObject) - { - if (!DCSBIOSProtocolParserSO._listOfAddressesToBroascast.Any(u => u == address)) - { - DCSBIOSProtocolParserSO._listOfAddressesToBroascast.Add(address); - } - } - } - - public static DCSBIOSProtocolParser GetParser() - { - if (DCSBIOSProtocolParserSO == null) - { - DCSBIOSProtocolParserSO = new DCSBIOSProtocolParser(); - } - return DCSBIOSProtocolParserSO; - } - - public void AddArray(byte[] bytes) - { - _arraysToProcess.Enqueue(bytes); - _autoResetEvent.Set(); - } - - private bool IsBroadcastable(uint address) - { - var result = false; - lock (_lockListOfAddressesToBroascastObject) - { - if (_listOfAddressesToBroascast.Any(u => u == address)) - { - result = true; - } - } - return result; - } - - internal void ProcessByte(byte b) - { - try - { - switch (_state) - { - case DCSBiosStateEnum.WAIT_FOR_SYNC: - /* do nothing */ - break; - case DCSBiosStateEnum.ADDRESS_LOW: - _address = b; - _state = DCSBiosStateEnum.ADDRESS_HIGH; - break; - case DCSBiosStateEnum.ADDRESS_HIGH: - _address = (uint)(b << 8) | _address; - _state = _address != 0x5555 ? DCSBiosStateEnum.COUNT_LOW : DCSBiosStateEnum.WAIT_FOR_SYNC; - break; - case DCSBiosStateEnum.COUNT_LOW: - _count = b; - _state = DCSBiosStateEnum.COUNT_HIGH; - break; - case DCSBiosStateEnum.COUNT_HIGH: - _count = (uint)(b << 8) | _count; - _state = DCSBiosStateEnum.DATA_LOW; - break; - case DCSBiosStateEnum.DATA_LOW: - _data = b; - _count--; - _state = DCSBiosStateEnum.DATA_HIGH; - break; - case DCSBiosStateEnum.DATA_HIGH: - _data = (uint)(b << 8) | _data; - _count--; - - if (IsBroadcastable(_address)) - { - try - { - BIOSEventHandler.DCSBIOSDataAvailable(this, _address, _data); - - /*if (OnDcsDataAddressValue != null) - { - Debug.WriteLine("OnDcsDataAddressValue : " + OnDcsDataAddressValue.GetInvocationList().Length); - }*/ - } - catch (Exception ex) - { - if (!_errorsLogged.Contains(ex.Message)) - { - logger.Error(ex, "Error in DCS-BIOS stream. This error will be logged *just once*."); - _errorsLogged.Add(ex.Message); - } - } - } - _address += 2; - if (_count == 0) - _state = DCSBiosStateEnum.ADDRESS_LOW; - else - _state = DCSBiosStateEnum.DATA_LOW; - break; - } - - if (b == 0x55) - { - //Console.WriteLine(Environment.TickCount - ticks); - //ticks = Environment.TickCount; - _syncByteCount++; - } - else - { - _syncByteCount = 0; - } - - if (_syncByteCount == 4) - { - _state = DCSBiosStateEnum.ADDRESS_LOW; - _syncByteCount = 0; - } - } - catch (Exception ex) - { - logger.Error(ex, "DCSBIOSProtocolParser.ProcessByte()"); - } - } - } -} diff --git a/src/DCS-BIOS/EventArgs/BIOSEventHandler.cs b/src/DCS-BIOS/EventArgs/BIOSEventHandler.cs deleted file mode 100644 index 8ae71f33e..000000000 --- a/src/DCS-BIOS/EventArgs/BIOSEventHandler.cs +++ /dev/null @@ -1,136 +0,0 @@ -using System.Threading.Tasks; -using DCS_BIOS.Interfaces; - -namespace DCS_BIOS.EventArgs -{ - public static class BIOSEventHandler - { - /* - * Source of data from DCS-BIOS, parsed by ProtocolParser - */ - public delegate void DcsDataAddressValueEventHandler(object sender, DCSBIOSDataEventArgs e); - public static event DcsDataAddressValueEventHandler OnDcsDataAddressValue; - - public static bool OnDcsDataAddressValueEventSubscribed() - { - return OnDcsDataAddressValue != null && OnDcsDataAddressValue.GetInvocationList().Length > 0; - } - - public static void AttachDataListener(IDcsBiosDataListener dcsBiosDataListener) - { - OnDcsDataAddressValue += dcsBiosDataListener.DcsBiosDataReceived; - } - - public static void DetachDataListener(IDcsBiosDataListener dcsBiosDataListener) - { - OnDcsDataAddressValue -= dcsBiosDataListener.DcsBiosDataReceived; - } - - public static void DCSBIOSDataAvailable(object sender, uint address, uint data) - { - OnDcsDataAddressValue?.Invoke(sender, new DCSBIOSDataEventArgs { Address = address, Data = data }); - } - - /* - * Source of data from DCS-BIOS, this is not parsed by ProtocolParser, instead - * passed on as is. - */ - public delegate void DcsBulkDataEventHandler(object sender, DCSBIOSBulkDataEventArgs e); - public static event DcsBulkDataEventHandler OnDcsBulkData; - - public static bool OnDcsBulkDataEventSubscribed() - { - return OnDcsBulkData != null && OnDcsBulkData.GetInvocationList().Length > 0; - } - - public static void AttachBulkDataListener(IDcsBiosBulkDataListener biosBulkDataListener) - { - OnDcsBulkData += biosBulkDataListener.DcsBiosBulkDataReceived; - } - - public static void DetachBulkDataListener(IDcsBiosBulkDataListener biosBulkDataListener) - { - OnDcsBulkData -= biosBulkDataListener.DcsBiosBulkDataReceived; - } - - public static void DCSBIOSBulkDataAvailable(object sender, byte[] data) - { - OnDcsBulkData?.Invoke(sender, new DCSBIOSBulkDataEventArgs { Data = data }); - } - - public delegate Task AsyncDcsBulkDataEventHandler(object sender, DCSBIOSBulkDataEventArgs e); - public static event AsyncDcsBulkDataEventHandler AsyncOnDcsBulkData; - - public static bool OnAsyncDcsBulkDataEventSubscribed() - { - return AsyncOnDcsBulkData != null && AsyncOnDcsBulkData.GetInvocationList().Length > 0; - } - - public static void AttachAsyncBulkDataListener(IAsyncDcsBiosBulkDataListener asyncBulkDataListener) - { - AsyncOnDcsBulkData += asyncBulkDataListener.AsyncDcsBiosBulkDataReceived; - } - - public static void DetachAsyncBulkDataListener(IAsyncDcsBiosBulkDataListener asyncBulkDataListener) - { - AsyncOnDcsBulkData -= asyncBulkDataListener.AsyncDcsBiosBulkDataReceived; - } - - public static void AsyncDCSBIOSBulkDataAvailable(object sender, byte[] data) - { - AsyncOnDcsBulkData?.Invoke(sender, new DCSBIOSBulkDataEventArgs { Data = data }); - } - - /* - * Used for listening whether data comes from DCS-BIOS (UI spinning cog wheel for example) - */ - public delegate void DcsConnectionActiveEventHandler(object sender, DCSBIOSConnectionEventArgs e); - public static event DcsConnectionActiveEventHandler OnDcsConnectionActive; - - public static bool OnDcsConnectionActiveEventSubscribed() - { - return OnDcsConnectionActive != null && OnDcsConnectionActive.GetInvocationList().Length > 0; - } - - public static void AttachConnectionListener(IDcsBiosConnectionListener connectionListener) - { - OnDcsConnectionActive += connectionListener.DcsBiosConnectionActive; - } - - public static void DetachConnectionListener(IDcsBiosConnectionListener connectionListener) - { - OnDcsConnectionActive -= connectionListener.DcsBiosConnectionActive; - } - - public static void ConnectionActive(object sender) - { - OnDcsConnectionActive?.Invoke(sender, new DCSBIOSConnectionEventArgs()); // Informs main UI that data is coming - } - /* - * - */ - - public delegate void DCSBIOSStringReceived(object sender, DCSBIOSStringDataEventArgs e); - public static event DCSBIOSStringReceived OnDCSBIOSStringReceived; - - public static bool OnDCSBIOSStringReceivedEventSubscribed() - { - return OnDCSBIOSStringReceived != null && OnDCSBIOSStringReceived.GetInvocationList().Length > 0; - } - - public static void AttachStringListener(IDCSBIOSStringListener stringListener) - { - OnDCSBIOSStringReceived += stringListener.DCSBIOSStringReceived; - } - - public static void DetachStringListener(IDCSBIOSStringListener stringListener) - { - OnDCSBIOSStringReceived -= stringListener.DCSBIOSStringReceived; - } - - public static void DCSBIOSStringAvailable(object sender, uint address, string data) - { - OnDCSBIOSStringReceived?.Invoke(sender, new DCSBIOSStringDataEventArgs { Address = address, StringData = data }); - } - } -} diff --git a/src/DCS-BIOS/EventArgs/DCSBIOSBulkDataEventArgs.cs b/src/DCS-BIOS/EventArgs/DCSBIOSBulkDataEventArgs.cs deleted file mode 100644 index c0397340b..000000000 --- a/src/DCS-BIOS/EventArgs/DCSBIOSBulkDataEventArgs.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace DCS_BIOS.EventArgs -{ - public class DCSBIOSBulkDataEventArgs : System.EventArgs - { - public byte[] Data { get; init; } - } -} diff --git a/src/DCS-BIOS/EventArgs/DCSBIOSConnectionEventArgs.cs b/src/DCS-BIOS/EventArgs/DCSBIOSConnectionEventArgs.cs deleted file mode 100644 index b0a19f5cd..000000000 --- a/src/DCS-BIOS/EventArgs/DCSBIOSConnectionEventArgs.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace DCS_BIOS.EventArgs -{ - public class DCSBIOSConnectionEventArgs : System.EventArgs - { - // ignore - } -} diff --git a/src/DCS-BIOS/EventArgs/DCSBIOSDataEventArgs.cs b/src/DCS-BIOS/EventArgs/DCSBIOSDataEventArgs.cs deleted file mode 100644 index b7cb5f7fd..000000000 --- a/src/DCS-BIOS/EventArgs/DCSBIOSDataEventArgs.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace DCS_BIOS.EventArgs -{ - public class DCSBIOSDataEventArgs : System.EventArgs - { - public uint Address { get; init; } - - public uint Data { get; init; } - } -} diff --git a/src/DCS-BIOS/EventArgs/DCSBIOSStringDataEventArgs.cs b/src/DCS-BIOS/EventArgs/DCSBIOSStringDataEventArgs.cs deleted file mode 100644 index 4f50aaea8..000000000 --- a/src/DCS-BIOS/EventArgs/DCSBIOSStringDataEventArgs.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace DCS_BIOS.EventArgs -{ - public class DCSBIOSStringDataEventArgs : System.EventArgs - { - public uint Address { get; init; } - - public string StringData { get; init; } - } -} diff --git a/src/DCS-BIOS/Interfaces/IAsyncDcsBiosBulkDataListener.cs b/src/DCS-BIOS/Interfaces/IAsyncDcsBiosBulkDataListener.cs deleted file mode 100644 index b2d02e185..000000000 --- a/src/DCS-BIOS/Interfaces/IAsyncDcsBiosBulkDataListener.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Threading.Tasks; - -namespace DCS_BIOS.Interfaces -{ - using EventArgs; - - public interface IAsyncDcsBiosBulkDataListener - { - Task AsyncDcsBiosBulkDataReceived(object sender, DCSBIOSBulkDataEventArgs e); - } -} diff --git a/src/DCS-BIOS/Interfaces/IDCSBIOSStringListener.cs b/src/DCS-BIOS/Interfaces/IDCSBIOSStringListener.cs deleted file mode 100644 index 4341363ce..000000000 --- a/src/DCS-BIOS/Interfaces/IDCSBIOSStringListener.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace DCS_BIOS.Interfaces -{ - using EventArgs; - - public interface IDCSBIOSStringListener - { - void DCSBIOSStringReceived(object sender, DCSBIOSStringDataEventArgs e); - } -} diff --git a/src/DCS-BIOS/Interfaces/IDcsBiosBulkDataListener.cs b/src/DCS-BIOS/Interfaces/IDcsBiosBulkDataListener.cs deleted file mode 100644 index 4a1554f7c..000000000 --- a/src/DCS-BIOS/Interfaces/IDcsBiosBulkDataListener.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Threading.Tasks; - -namespace DCS_BIOS.Interfaces -{ - using EventArgs; - - public interface IDcsBiosBulkDataListener - { - void DcsBiosBulkDataReceived(object sender, DCSBIOSBulkDataEventArgs e); - } -} diff --git a/src/DCS-BIOS/Interfaces/IDcsBiosConnectionListener.cs b/src/DCS-BIOS/Interfaces/IDcsBiosConnectionListener.cs deleted file mode 100644 index 3a5a873f5..000000000 --- a/src/DCS-BIOS/Interfaces/IDcsBiosConnectionListener.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace DCS_BIOS.Interfaces -{ - using EventArgs; - - public interface IDcsBiosConnectionListener - { - void DcsBiosConnectionActive(object sender, DCSBIOSConnectionEventArgs e); - } -} diff --git a/src/DCS-BIOS/Interfaces/IDcsBiosListener.cs b/src/DCS-BIOS/Interfaces/IDcsBiosListener.cs deleted file mode 100644 index 05c37dccc..000000000 --- a/src/DCS-BIOS/Interfaces/IDcsBiosListener.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace DCS_BIOS.Interfaces -{ - using EventArgs; - - public interface IDcsBiosDataListener - { - void DcsBiosDataReceived(object sender, DCSBIOSDataEventArgs e); - } -} diff --git a/src/DCS-BIOS/Json/DCSBIOSControl.cs b/src/DCS-BIOS/Json/DCSBIOSControl.cs deleted file mode 100644 index 0f22757ad..000000000 --- a/src/DCS-BIOS/Json/DCSBIOSControl.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using DCS_BIOS.Serialized; -using Newtonsoft.Json; - -namespace DCS_BIOS.Json -{ - /// - /// This is a base class for the DCS-BIOS Control as specified in lua / JSON. - /// This class is used when reading the JSON. - /// - public class DCSBIOSControl - { - [JsonProperty("category", Required = Required.Default)] - public string Category { get; set; } - - [JsonProperty("control_type", Required = Required.Default)] - public string ControlType { get; set; } - - [JsonProperty("description", Required = Required.Default)] - public string Description { get; set; } - - [JsonProperty("identifier", Required = Required.Default)] - public string Identifier { get; set; } - - [JsonProperty("inputs", Required = Required.Default)] - public List Inputs { get; set; } - - [JsonProperty("outputs", Required = Required.Default)] - public List Outputs { get; set; } - - - public bool HasOutput() - { - return Outputs.Count > 0; - } - - public bool HasStringInput() - { - var dcsbiosInput = new DCSBIOSInput(); - dcsbiosInput.Consume(this); - return dcsbiosInput.DCSBIOSInputInterfaces.Any(o => o.Interface == DCSBIOSInputType.SET_STRING); - } - - public DCSBIOSOutput GetUIntOutput() - { - foreach (var dcsbiosControlOutput in Outputs) - { - if (dcsbiosControlOutput.OutputDataType == DCSBiosOutputType.IntegerType) - { - var dcsbiosOutput = new DCSBIOSOutput(); - dcsbiosOutput.Consume(this, DCSBiosOutputType.IntegerType); - return dcsbiosOutput; - } - } - - throw new Exception($"Control {Identifier} did not have uint output."); - } - - public DCSBIOSOutput GetStringOutput() - { - foreach (var dcsbiosControlOutput in Outputs) - { - if (dcsbiosControlOutput.OutputDataType == DCSBiosOutputType.StringType) - { - var dcsbiosOutput = new DCSBIOSOutput(); - dcsbiosOutput.Consume(this, DCSBiosOutputType.StringType); - return dcsbiosOutput; - } - } - - throw new Exception($"Control {Identifier} did not have string output."); - } - } -} diff --git a/src/DCS-BIOS/Json/DCSBIOSControlInput.cs b/src/DCS-BIOS/Json/DCSBIOSControlInput.cs deleted file mode 100644 index ff1434ec6..000000000 --- a/src/DCS-BIOS/Json/DCSBIOSControlInput.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Newtonsoft.Json; - -namespace DCS_BIOS.Json -{ - /// - /// Used when reading the JSON to create list of the inputs - /// that a DCS-BIOS Control has. - /// - public class DCSBIOSControlInput - { - - [JsonProperty("description", Required = Required.Default)] - public string Description { get; set; } - - [JsonProperty("interface", Required = Required.Default)] - public string ControlInterface { get; set; } - - [JsonProperty("max_value", Required = Required.Default)] - public int? MaxValue { get; set; } - - [JsonProperty("suggested_step", Required = Required.Default)] - public int? SuggestedStep { get; set; } - - [JsonProperty("argument", Required = Required.Default)] - public string Argument { get; set; } - } -} diff --git a/src/DCS-BIOS/Json/DCSBIOSControlOutput.cs b/src/DCS-BIOS/Json/DCSBIOSControlOutput.cs deleted file mode 100644 index b6b337dba..000000000 --- a/src/DCS-BIOS/Json/DCSBIOSControlOutput.cs +++ /dev/null @@ -1,58 +0,0 @@ -using DCS_BIOS.Serialized; -using Newtonsoft.Json; - -namespace DCS_BIOS.Json -{ - public class DCSBIOSControlOutput - { - private string _type; - - [JsonProperty("address", Required = Required.Default)] - public uint Address { get; set; } - - [JsonProperty("description", Required = Required.Default)] - public string Description { get; set; } - - [JsonProperty("mask", Required = Required.Default)] - public uint Mask { get; set; } - - [JsonProperty("max_value", Required = Required.Default)] - public int MaxValue { get; set; } - - [JsonProperty("shift_by", Required = Required.Default)] - public int ShiftBy { get; set; } - - [JsonProperty("suffix", Required = Required.Default)] - public string Suffix { get; set; } - - [JsonProperty("max_length", Required = Required.Default)] - public int MaxLength { get; set; } - - [JsonProperty("address_identifier", Required = Required.Default)] - public string AddressIdentifier { get; set; } - - [JsonProperty("address_mask_identifier", Required = Required.Default)] - public string AddressMaskIdentifier { get; set; } - - [JsonProperty("address_mask_shift_identifier", Required = Required.Default)] - public string AddressMaskShiftIdentifier { get; set; } - - [JsonProperty("type", Required = Required.Default)] - public string Type - { - get => _type; - set - { - _type = value; - OutputDataType = _type switch - { - "string" => DCSBiosOutputType.StringType, - "integer" => DCSBiosOutputType.IntegerType, - _ => DCSBiosOutputType.None - }; - } - } - - public DCSBiosOutputType OutputDataType { get; private set; } - } -} diff --git a/src/DCS-BIOS/Serialized/DCSBIOSInput.cs b/src/DCS-BIOS/Serialized/DCSBIOSInput.cs deleted file mode 100644 index 7597f1f52..000000000 --- a/src/DCS-BIOS/Serialized/DCSBIOSInput.cs +++ /dev/null @@ -1,283 +0,0 @@ -/* - * naming of all variables can not be changed because these classes are instantiated from Json based on DCS-BIOS naming standard. * - */ - -using DCS_BIOS.Json; - -namespace DCS_BIOS.Serialized -{ - using System; - using System.Collections.Generic; - using System.Linq; - using ClassLibraryCommon; - using ControlLocator; - using Newtonsoft.Json; - using NLog; - - /// - /// These are used when manipulating a DCS-BIOS Control with Increase or Decrease. - /// - public enum DCSBIOSFixedStepInput - { - INC, - DEC - } - - /// - /// Type of manipulation for a DCS-BIOS Control. - /// Fixed shifts (+/-) the control using a fixed value. - /// Set State sets the control to a specific value. - /// Action, e.g. TOGGLE - /// Variable Step, you set a step value first and then shifts the control using that. - /// - public enum DCSBIOSInputType - { - FIXED_STEP, - SET_STATE, - ACTION, - VARIABLE_STEP, - SET_STRING - } - - - /// - /// This class is a holder for all input information for a DCSBIOSControl. - /// They are used for manipulating a specific cockpit control. - /// See DCSBIOSInputType for the input types. - /// When the user specifies a DCS-BIOS Control they also select a specific input type. - /// - [Serializable] - [SerializeCritical] - public class DCSBIOSInput - { - internal static Logger Logger = LogManager.GetCurrentClassLogger(); - - /// - /// All the interfaces this particular DCSBIOSInput offers. - /// - private List _dcsbiosInputInterfaces = new(); - - /// - /// The interface the user has chosen. - /// - [JsonProperty("SelectedDCSBIOSInterface", Required = Required.Default)] - public DCSBIOSInputInterface SelectedDCSBIOSInterface { get; set; } - - [JsonProperty("ControlId", Required = Required.Default)] - public string ControlId { get; set; } - - [JsonProperty("Delay", Required = Required.Default)] - public int Delay { get; set; } - - [Obsolete] - [JsonProperty("Debug", Required = Required.Default)] - public bool Debug { get; set; } - - [JsonProperty("ControlDescription", Required = Required.Default)] - public string ControlDescription { get; set; } - - [Obsolete] - [JsonIgnore] - public string ControlType { get; set; } - - public string GetDescriptionForInterface(DCSBIOSInputType dcsbiosInputType) - { - var dcsbiosInputInterface = _dcsbiosInputInterfaces.FirstOrDefault(x => x.Interface == dcsbiosInputType); - - return dcsbiosInputInterface != null ? dcsbiosInputInterface.Description : string.Empty; - } - - public int GetMaxValueForInterface(DCSBIOSInputType dcsbiosInputType) - { - if (dcsbiosInputType == DCSBIOSInputType.SET_STRING) - { - return 0; - } - - var searched = _dcsbiosInputInterfaces.FirstOrDefault(x => x.Interface == dcsbiosInputType); - - return searched?.MaxValue ?? 0; - } - - public void Consume(DCSBIOSControl dcsbiosControl) - { - ControlId = dcsbiosControl.Identifier; - ControlDescription = dcsbiosControl.Description; - - try - { - foreach (var dcsbiosControlInput in dcsbiosControl.Inputs) - { - DCSBIOSInputInterface inputInterface = new(); - inputInterface.Consume(ControlId, dcsbiosControlInput); - _dcsbiosInputInterfaces.Add(inputInterface); - } - - if (_dcsbiosInputInterfaces.Count == 1) - { - SelectedDCSBIOSInterface = _dcsbiosInputInterfaces[0]; - } - } - catch (Exception) - { - throw new Exception($"Failed to copy control {ControlId}. Control input is missing.{Environment.NewLine}"); - } - } - - - public List DCSBIOSInputInterfaces - { - get => _dcsbiosInputInterfaces; - set => _dcsbiosInputInterfaces = value; - } - - public void SetSelectedInterface(DCSBIOSInputType dcsbiosInputType) - { - foreach (var dcsbiosInputInterface in DCSBIOSInputInterfaces) - { - if (dcsbiosInputInterface.Interface == dcsbiosInputType) - { - SelectedDCSBIOSInterface = dcsbiosInputInterface; - break; - } - } - } - - public override string ToString() - { - /* - * fixed_step = - * set_state = - * action = TOGGLE - */ - try - { - return SelectedDCSBIOSInterface.Interface switch - { - DCSBIOSInputType.FIXED_STEP => "DCSBIOSInput{" + ControlId + "|FIXED_STEP|" + SelectedDCSBIOSInterface.SpecifiedFixedStepArgument + "|" + SelectedDCSBIOSInterface.Delay + "}", - DCSBIOSInputType.SET_STATE => "DCSBIOSInput{" + ControlId + "|SET_STATE|" + SelectedDCSBIOSInterface.SpecifiedSetStateArgument + "|" + SelectedDCSBIOSInterface.Delay + "}", - DCSBIOSInputType.ACTION => "DCSBIOSInput{" + ControlId + "|ACTION|" + SelectedDCSBIOSInterface.SpecifiedActionArgument + "|" + SelectedDCSBIOSInterface.Delay + "}", - DCSBIOSInputType.VARIABLE_STEP => "DCSBIOSInput{" + ControlId + "|VARIABLE_STEP|" + SelectedDCSBIOSInterface.SpecifiedVariableStepArgument + "|" + SelectedDCSBIOSInterface.Delay + "}", - DCSBIOSInputType.SET_STRING => "DCSBIOSInput{" + ControlId + "|SET_STRING|" + SelectedDCSBIOSInterface.SpecifiedSetStringArgument + "|" + SelectedDCSBIOSInterface.Delay + "}", - _ => throw new Exception() - }; - } - catch (Exception ex) - { - Logger.Error(ex, $"Error in DCSBIOSInput.ToString(), ControlId = {ControlId}"); - throw; - } - } - - public void ImportString(string str) - { - // DCSBIOSInput{AAP_EGIPWR|FIXED_STEP|INC|0} - // DCSBIOSInput{AAP_EGIPWR|SET_STATE|65535|0} - // DCSBIOSInput{AAP_EGIPWR|ACTION|TOGGLE|0} - var value = str; - if (string.IsNullOrEmpty(str)) - { - throw new Exception("DCSBIOSInput cannot import null string."); - } - - if (!str.StartsWith("DCSBIOSInput{") || !str.EndsWith("}")) - { - throw new Exception($"DCSBIOSInput cannot import string : {str}"); - } - - value = value[(value.IndexOf("{", StringComparison.InvariantCulture) + 1)..]; - - // AAP_EGIPWR|FIXED_STEP|INC} - // AAP_EGIPWR|SET_STATE|65535} - // AAP_EGIPWR|ACTION|TOGGLE} - value = value.Substring(0, value.Length - 1); - - // AAP_EGIPWR|FIXED_STEP|INC - // AAP_EGIPWR|SET_STATE|65535 - // AAP_EGIPWR|ACTION|TOGGLE - var entries = value.Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries); - ControlId = entries[0]; - Delay = entries.Length == 4 ? int.Parse(entries[3]) : 0; - - var dcsBIOSControl = DCSBIOSControlLocator.GetControl(ControlId); - Consume(dcsBIOSControl); - - var type = Enum.Parse(entries[1]); - switch (type) - { - case DCSBIOSInputType.FIXED_STEP: - { - foreach (var dcsbiosInputInterface in _dcsbiosInputInterfaces.Where(dcsbiosInputInterface => dcsbiosInputInterface.Interface == DCSBIOSInputType.FIXED_STEP)) - { - dcsbiosInputInterface.SpecifiedFixedStepArgument = (DCSBIOSFixedStepInput)Enum.Parse(typeof(DCSBIOSFixedStepInput), entries[2]); - SelectedDCSBIOSInterface = dcsbiosInputInterface; - SelectedDCSBIOSInterface.Delay = entries.Length == 4 ? int.Parse(entries[3]) : 0; - break; - } - - break; - } - - case DCSBIOSInputType.SET_STATE: - { - foreach (var dcsbiosInputInterface in _dcsbiosInputInterfaces.Where(dcsbiosInputInterface => dcsbiosInputInterface.Interface == DCSBIOSInputType.SET_STATE)) - { - dcsbiosInputInterface.SpecifiedSetStateArgument = uint.Parse(entries[2]); - SelectedDCSBIOSInterface = dcsbiosInputInterface; - SelectedDCSBIOSInterface.Delay = entries.Length == 4 ? int.Parse(entries[3]) : 0; - break; - } - - break; - } - - case DCSBIOSInputType.ACTION: - { - foreach (var dcsbiosInputInterFace in _dcsbiosInputInterfaces.Where(dcsbiosInputInterFace => dcsbiosInputInterFace.Interface == DCSBIOSInputType.ACTION)) - { - dcsbiosInputInterFace.SpecifiedActionArgument = entries[2]; - SelectedDCSBIOSInterface = dcsbiosInputInterFace; - SelectedDCSBIOSInterface.Delay = entries.Length == 4 ? int.Parse(entries[3]) : 0; - break; - } - - break; - } - - case DCSBIOSInputType.VARIABLE_STEP: - { - foreach (var dcsbiosInputInterface in _dcsbiosInputInterfaces) - { - if (dcsbiosInputInterface.Interface == DCSBIOSInputType.VARIABLE_STEP) - { - dcsbiosInputInterface.SpecifiedVariableStepArgument = int.Parse(entries[2]); - SelectedDCSBIOSInterface = dcsbiosInputInterface; - SelectedDCSBIOSInterface.Delay = entries.Length == 4 ? int.Parse(entries[3]) : 0; - break; - } - } - break; - } - - case DCSBIOSInputType.SET_STRING: - { - foreach (var dcsbiosInputInterface in _dcsbiosInputInterfaces) - { - if (dcsbiosInputInterface.Interface == DCSBIOSInputType.SET_STRING) - { - dcsbiosInputInterface.SpecifiedSetStringArgument = entries[2]; - SelectedDCSBIOSInterface = dcsbiosInputInterface; - SelectedDCSBIOSInterface.Delay = entries.Length == 4 ? int.Parse(entries[3]) : 0; - break; - } - } - break; - } - default: - { - throw new Exception($"Failed to determine input interface type {type}."); - } - } - } - } -} diff --git a/src/DCS-BIOS/Serialized/DCSBIOSInputInterface.cs b/src/DCS-BIOS/Serialized/DCSBIOSInputInterface.cs deleted file mode 100644 index 04a775f1a..000000000 --- a/src/DCS-BIOS/Serialized/DCSBIOSInputInterface.cs +++ /dev/null @@ -1,160 +0,0 @@ -using System; -using ClassLibraryCommon; -using DCS_BIOS.Json; - -namespace DCS_BIOS.Serialized -{ - - /// - /// This class takes care of a DCS-BIOS Control Input and also - /// provides the command string and or sends the command - /// that is sent to DCS-BIOS when it should trigger (e.g. user switches a switch). - /// - [Serializable] - [SerializeCritical] - public class DCSBIOSInputInterface - { - private string _specifiedActionArgument; - private uint _specifiedSetStateArgument; - private int _specifiedVariableStepArgument; - private DCSBIOSFixedStepInput _specifiedFixedStepArgument; - private string _specifiedSetStringArgument; - - public void Consume(string controlId, DCSBIOSControlInput dcsbiosControlInput) - { - ControlId = controlId; - Description = dcsbiosControlInput.Description; - - Interface = dcsbiosControlInput.ControlInterface switch - { - "fixed_step" => DCSBIOSInputType.FIXED_STEP, - "set_state" => DCSBIOSInputType.SET_STATE, - "action" => DCSBIOSInputType.ACTION, - "variable_step" => DCSBIOSInputType.VARIABLE_STEP, - "set_string" => DCSBIOSInputType.SET_STRING, - _ => throw new SystemException($"Unexpected ControlInterface value [{dcsbiosControlInput.ControlInterface}]") - }; - MaxValue = dcsbiosControlInput.MaxValue.GetValueOrDefault(); - SuggestedStep = dcsbiosControlInput.SuggestedStep.GetValueOrDefault(); - SpecifiedActionArgument = dcsbiosControlInput.Argument; - } - - public string GetDCSBIOSCommand() - { - var command = Interface switch - { - DCSBIOSInputType.FIXED_STEP => $"{ControlId} {SpecifiedFixedStepArgument}\n", - DCSBIOSInputType.SET_STATE => $"{ControlId} {SpecifiedSetStateArgument}\n", - DCSBIOSInputType.ACTION => $"{ControlId} {SpecifiedActionArgument}\n", - DCSBIOSInputType.VARIABLE_STEP => - SpecifiedVariableStepArgument > 0 ? - $"{ControlId} +{SpecifiedVariableStepArgument}\n" - : $"{ControlId} {SpecifiedVariableStepArgument}\n", - DCSBIOSInputType.SET_STRING => $"{ControlId} {SpecifiedSetStringArgument}\n", - _ => throw new Exception("Unexpected DCSBIOSInputType value") - }; - - if (string.IsNullOrWhiteSpace(command)) - { - throw new Exception($"Error getting DCS-BIOSInput command. ControlId = {ControlId} Interface = {Interface}"); - } - return command; - } - - public void SendCommand() - { - DCSBIOS.Send(GetDCSBIOSCommand()); - } - - public int Delay { get; set; } - - public string ControlId { get; set; } - - /// - /// e.g. "description": "switch to previous or next state", - /// - public string Description { get; set; } - - public DCSBIOSInputType Interface { get; set; } - - /// - /// Relevant when _interface = set_state - /// - public int MaxValue { get; set; } - - /// - /// Relevant when _interface = variable_step - /// - public int SuggestedStep { get; set; } - - /// - /// e.g. TOGGLE - /// - public string SpecifiedActionArgument - { - get => _specifiedActionArgument; - set - { - SelectedArgumentValue = value; - _specifiedActionArgument = value; - } - } - - /// - /// set_state = integer - /// - public uint SpecifiedSetStateArgument - { - get => _specifiedSetStateArgument; - set - { - SelectedArgumentValue = value.ToString(); - _specifiedSetStateArgument = value; - } - } - - /// - /// variable_step = new_value|-decrease_by|+increase_by - /// - public int SpecifiedVariableStepArgument - { - get => _specifiedVariableStepArgument; - set - { - SelectedArgumentValue = value.ToString(); - _specifiedVariableStepArgument = value; - } - } - - /// - /// fixed_step = INC/DEC - /// - public DCSBIOSFixedStepInput SpecifiedFixedStepArgument - { - get => _specifiedFixedStepArgument; - set - { - SelectedArgumentValue = value.ToString(); - _specifiedFixedStepArgument = value; - } - } - - /// - /// set_string = some string - /// - public string SpecifiedSetStringArgument - { - get => _specifiedSetStringArgument; - set - { - SelectedArgumentValue = value; - _specifiedSetStringArgument = value; - } - } - - /// - /// Shows selected argument regardless which interface was chosen. - /// - public string SelectedArgumentValue { get; private set; } - } -} diff --git a/src/DCS-BIOS/Serialized/DCSBIOSOutput.cs b/src/DCS-BIOS/Serialized/DCSBIOSOutput.cs deleted file mode 100644 index 9af35c018..000000000 --- a/src/DCS-BIOS/Serialized/DCSBIOSOutput.cs +++ /dev/null @@ -1,406 +0,0 @@ -using DCS_BIOS.Json; -using DCS_BIOS.StringClasses; - - -namespace DCS_BIOS.Serialized -{ - using System; - using System.ComponentModel; - using ClassLibraryCommon; - using DCS_BIOS; - using ControlLocator; - using Newtonsoft.Json; - - public enum DCSBiosOutputType - { - StringType, - IntegerType, - LED, - ServoOutput, - FloatBuffer, - None - } - - public enum DCSBiosOutputComparison - { - [Description("Equals")] - Equals, - [Description("Less than")] - LessThan, - [Description("Bigger than")] - BiggerThan, - [Description("Not equals")] - NotEquals - } - - /// - /// This class represents the output sent from DCS-BIOS. - /// When a DCS-BIOS Control value has been sent each class - /// listening for specific DCS-BIOS value(s) (Address & Data) - /// can check via the Address part whether it was a match and if - /// it was then extract the Data part. Data is bit shifted so it can't be - /// read directly. This class holds the information on how much to shift - /// and with what. - /// - [Serializable] - [SerializeCritical] - public class DCSBIOSOutput - { - // The target value used for comparison as chosen by the user - private uint _specifiedValueUInt; - - private uint _address; - private volatile uint _lastUIntValue = uint.MaxValue; - private volatile string _lastStringValue = ""; - private bool _uintValueHasChanged; - - [NonSerialized] private object _lockObject = new(); - - public static DCSBIOSOutput CreateCopy(DCSBIOSOutput dcsbiosOutput) - { - var tmp = new DCSBIOSOutput - { - DCSBiosOutputType = dcsbiosOutput.DCSBiosOutputType, - ControlId = dcsbiosOutput.ControlId, - Address = dcsbiosOutput.Address, - ControlDescription = dcsbiosOutput.ControlDescription, - DCSBiosOutputComparison = dcsbiosOutput.DCSBiosOutputComparison, - Mask = dcsbiosOutput.Mask, - MaxLength = dcsbiosOutput.MaxLength, - MaxValue = dcsbiosOutput.MaxValue, - ShiftValue = dcsbiosOutput.ShiftValue - }; - - switch (tmp.DCSBiosOutputType) - { - case DCSBiosOutputType.IntegerType: - tmp.SpecifiedValueUInt = dcsbiosOutput.SpecifiedValueUInt; - break; - } - - return tmp; - } - - public void Copy(DCSBIOSOutput dcsbiosOutput) - { - DCSBiosOutputType = dcsbiosOutput.DCSBiosOutputType; - ControlId = dcsbiosOutput.ControlId; - Address = dcsbiosOutput.Address; - ControlDescription = dcsbiosOutput.ControlDescription; - DCSBiosOutputComparison = dcsbiosOutput.DCSBiosOutputComparison; - Mask = dcsbiosOutput.Mask; - MaxLength = dcsbiosOutput.MaxLength; - MaxValue = dcsbiosOutput.MaxValue; - ShiftValue = dcsbiosOutput.ShiftValue; - AddressIdentifier = dcsbiosOutput.AddressIdentifier; - AddressMaskIdentifier = dcsbiosOutput.AddressMaskIdentifier; - AddressMaskShiftIdentifier = dcsbiosOutput.AddressMaskShiftIdentifier; - - if (DCSBiosOutputType == DCSBiosOutputType.IntegerType) - { - SpecifiedValueUInt = dcsbiosOutput.SpecifiedValueUInt; - } - } - public void Consume(DCSBIOSControl dcsbiosControl, DCSBiosOutputType dcsBiosOutputType) - { - ControlId = dcsbiosControl.Identifier; - ControlDescription = dcsbiosControl.Description; - try - { - if (!dcsbiosControl.HasOutput()) - { - DCSBiosOutputType = DCSBiosOutputType.None; - return; - } - - foreach (var dcsbiosControlOutput in dcsbiosControl.Outputs) - { - if (dcsbiosControlOutput.OutputDataType == dcsBiosOutputType) - { - DCSBiosOutputType = dcsbiosControlOutput.OutputDataType; - _address = dcsbiosControlOutput.Address; - Mask = dcsbiosControlOutput.Mask; - MaxValue = dcsbiosControlOutput.MaxValue; - MaxLength = dcsbiosControlOutput.MaxLength; - ShiftValue = dcsbiosControlOutput.ShiftBy; - - AddressIdentifier = dcsbiosControlOutput.AddressIdentifier; - AddressMaskIdentifier = dcsbiosControlOutput.AddressMaskIdentifier; - AddressMaskShiftIdentifier = dcsbiosControlOutput.AddressMaskShiftIdentifier; - - if (dcsBiosOutputType == DCSBiosOutputType.StringType) - { - DCSBIOSStringManager.AddListeningAddress(this); - } - - DCSBIOSProtocolParser.RegisterAddressToBroadCast(_address); - } - } - } - catch (Exception) - { - throw new Exception($"Failed to copy control {ControlId}. Control output is missing.{Environment.NewLine}"); - } - } - - /// - /// Checks : - /// * if there is a there is a change in the value since last comparison - /// * test is true using chosen comparison operator with new value and reference value - /// - /// - /// - /// - /// - public bool UIntConditionIsMet(uint address, uint data) - { - _lockObject ??= new object(); - var result = false; - - lock (_lockObject) - { - if (Address != address) - { - return false; - } - - var newValue = (data & Mask) >> ShiftValue; - - var resultComparison = DCSBiosOutputComparison switch - { - DCSBiosOutputComparison.BiggerThan => newValue > _specifiedValueUInt, - DCSBiosOutputComparison.LessThan => newValue < _specifiedValueUInt, - DCSBiosOutputComparison.NotEquals => newValue != _specifiedValueUInt, - DCSBiosOutputComparison.Equals => newValue == _specifiedValueUInt, - _ => throw new Exception("Unexpected DCSBiosOutputComparison value") - }; - - result = resultComparison && !newValue.Equals(LastUIntValue); - //Debug.WriteLine($"(EvaluateUInt) Result={result} Target={_specifiedValueUInt} Last={LastUIntValue} New={newValue}"); - LastUIntValue = newValue; - } - - return result; - } - - /// - /// Checks : - /// for address match - /// that new value differs from previous - /// stores new value - /// - /// - /// - /// - /// Returns true when all checks are true. - public bool UIntValueHasChanged(uint address, uint data) - { - _lockObject ??= new object(); - - lock (_lockObject) - { - if (address != Address) - { - // Not correct control - return false; - } - - if (GetUIntValue(data) == LastUIntValue && !_uintValueHasChanged) - { - // Value hasn't changed - return false; - } - - _uintValueHasChanged = false; - LastUIntValue = GetUIntValue(data); - } - - return true; - } - - /// - /// Checks : - /// for address match - /// that new string value differs from previous - /// stores new value - /// - /// - /// - /// - /// Returns true when all checks are true. - public bool StringValueHasChanged(uint address, string stringData) - { - _lockObject ??= new object(); - - lock (_lockObject) - { - if (address != Address) - { - // Not correct control - return false; - } - - if ((_lastStringValue ?? string.Empty) != (stringData ?? string.Empty)) - { - _lastStringValue = stringData; - return true; - } - } - - return false; - } - - public uint GetUIntValue(uint data) - { - /* - * Fugly workaround, side effect of using deep clone DCSBIOSDecoder is that this is null - */ - _lockObject ??= new object(); - - lock (_lockObject) - { - LastUIntValue = (data & Mask) >> ShiftValue; - return LastUIntValue; - } - } - - public override string ToString() - { - if (DCSBiosOutputType == DCSBiosOutputType.StringType) - { - return ""; - } - - return "DCSBiosOutput{" + ControlId + "|" + DCSBiosOutputComparison + "|" + _specifiedValueUInt + "}"; - } - - public void ImportString(string str) - { - // DCSBiosOutput{AAP_EGIPWR|Equals|0} - var value = str; - if (string.IsNullOrEmpty(str)) - { - throw new Exception("DCSBiosOutput cannot import null string."); - } - - if (!str.StartsWith("DCSBiosOutput{") || !str.EndsWith("}")) - { - throw new Exception($"DCSBiosOutput cannot import string : {str}"); - } - - value = value.Replace("DCSBiosOutput{", string.Empty).Replace("}", string.Empty); - - // AAP_EGIPWR|Equals|0 - var entries = value.Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries); - ControlId = entries[0]; - var dcsBIOSControl = DCSBIOSControlLocator.GetControl(ControlId); - Consume(dcsBIOSControl, DCSBiosOutputType.IntegerType); - DCSBiosOutputComparison = (DCSBiosOutputComparison)Enum.Parse(typeof(DCSBiosOutputComparison), entries[1]); - _specifiedValueUInt = (uint)int.Parse(entries[2]); - } - - [JsonProperty("ControlId", Required = Required.Default)] - public string ControlId { get; set; } - - [JsonProperty("Address", Required = Required.Default)] - public uint Address - { - get => _address; - set - { - _address = value; - DCSBIOSProtocolParser.RegisterAddressToBroadCast(_address); - } - } - - [JsonProperty("Mask", Required = Required.Default)] - public uint Mask { get; set; } - - [JsonProperty("Shiftvalue", Required = Required.Default)] - public int ShiftValue { get; set; } - - [JsonProperty("DCSBiosOutputType", Required = Required.Default)] - public DCSBiosOutputType DCSBiosOutputType { get; set; } = DCSBiosOutputType.None; - - [JsonProperty("DCSBiosOutputComparison", Required = Required.Default)] - public DCSBiosOutputComparison DCSBiosOutputComparison { get; set; } = DCSBiosOutputComparison.Equals; - - [JsonIgnore] - public uint SpecifiedValueUInt - { - get => _specifiedValueUInt; - set - { - if (DCSBiosOutputType != DCSBiosOutputType.IntegerType) - { - throw new Exception($"Invalid DCSBiosOutput. Specified value (trigger value) set to [int] but DCSBiosOutputType set to {DCSBiosOutputType}"); - } - - _specifiedValueUInt = value; - } - } - - [JsonProperty("ControlDescription", Required = Required.Default)] - public string ControlDescription { get; set; } - - [JsonProperty("MaxValue", Required = Required.Default)] - public int MaxValue { get; set; } - - [JsonIgnore] - public string AddressIdentifier { get; set; } - - [JsonIgnore] - public string AddressMaskIdentifier { get; set; } - - [JsonIgnore] - public string AddressMaskShiftIdentifier { get; set; } - - [JsonProperty("MaxLength", Required = Required.Default)] - public int MaxLength { get; set; } - - [Obsolete] - [JsonIgnore] - public string ControlType { get; set; } - - [JsonIgnore] - public uint LastUIntValue - { - get => _lastUIntValue; - set - { - if (value != _lastUIntValue) - { - _uintValueHasChanged = true; - } - _lastUIntValue = value; - } - } - - [JsonIgnore] - public string LastStringValue - { - get => _lastStringValue; - set => _lastStringValue = value; - } - - public static DCSBIOSOutput GetUpdateCounter() - { - var counter = DCSBIOSControlLocator.GetUIntDCSBIOSOutput("_UPDATE_COUNTER"); - return counter; - } - - public string GetOutputType() - { - return DCSBiosOutputType switch - { - DCSBiosOutputType.IntegerType => "integer", - DCSBiosOutputType.StringType => "string", - DCSBiosOutputType.None => "none", - DCSBiosOutputType.FloatBuffer => "float", - DCSBiosOutputType.LED => "led", - DCSBiosOutputType.ServoOutput => "servo output", - _ => throw new Exception($"GetOutputType() : Failed to identify {DCSBiosOutputType} output type.") - }; - } - } -} diff --git a/src/DCS-BIOS/Serialized/DCSBIOSOutputFormula.cs b/src/DCS-BIOS/Serialized/DCSBIOSOutputFormula.cs deleted file mode 100644 index 92b6a41d6..000000000 --- a/src/DCS-BIOS/Serialized/DCSBIOSOutputFormula.cs +++ /dev/null @@ -1,213 +0,0 @@ -using Newtonsoft.Json; - -namespace DCS_BIOS.Serialized -{ - using System; - using System.Collections.Generic; - using ClassLibraryCommon; - using ControlLocator; - using misc; - using NLog; - - /// - /// Handles user specified formula and DCSBIOSOutput(s) - /// to produce a result based on DCS-BIOS value(s). - /// - [Serializable] - [SerializeCritical] - public class DCSBIOSOutputFormula - { - [NonSerialized] - internal static Logger Logger = LogManager.GetCurrentClassLogger(); - private readonly List _dcsbiosOutputs = new(); - private readonly Dictionary _variables = new(); - - [NonSerialized] - private readonly JaceExtended _jaceExtended = new(); - private string _formula; - - [NonSerialized] - private readonly object _jaceLockObject = new(); - - public double FormulaResult { get; set; } - - public DCSBIOSOutputFormula() - { - } - - public DCSBIOSOutputFormula(string formula) - { - _formula = formula; - ExtractDCSBIOSOutputsInFormula(); - } - - - public List DCSBIOSOutputs() - { - return _dcsbiosOutputs; - } - - private void ExtractDCSBIOSOutputsInFormula() - { - try - { - _dcsbiosOutputs.Clear(); - var controls = DCSBIOSControlLocator.GetControls(); - foreach (var dcsbiosControl in controls) - { - if (_formula.Contains(dcsbiosControl.Identifier)) - { - // Console.WriteLine("Variable " + dcsbiosControl.identifier + " set to 0"); - _variables.Add(dcsbiosControl.Identifier, 0); - var dcsbiosOutput = DCSBIOSControlLocator.GetUIntDCSBIOSOutput(dcsbiosControl.Identifier); - _dcsbiosOutputs.Add(dcsbiosOutput); - DCSBIOSProtocolParser.RegisterAddressToBroadCast(dcsbiosOutput.Address); - } - } - - } - catch (Exception ex) - { - Logger.Error(ex, "ExtractDCSBIOSOutputsInFormula() function"); - throw; - } - } - - - /// - /// Loops all dcs-bios outputs and checks for address match and that dcs-bios value has changed - /// and also that the comparison operator test is true against dcs-bios value. - /// Evaluates formula if all matches OK. - /// Get result via FormulaResult. - /// - /// - public bool Evaluate(uint address, uint data) - { - try - { - var result = false; - lock (_jaceLockObject) - { - foreach (var dcsbiosOutput in _dcsbiosOutputs) - { - if (!dcsbiosOutput.UIntValueHasChanged(address, data)) - { - continue; - } - - _variables[dcsbiosOutput.ControlId] = dcsbiosOutput.LastUIntValue; - result = true; - } - - if (result) - { - Evaluate(false); - } - } - - return result; - } - catch (Exception ex) - { - Logger.Error(ex, "CheckForMatch() function"); - throw; - } - } - - - /// - /// Returns true if address was found in formula - /// and that the value has changed. - /// If true do a subsequent call to Evaluate() to get new value - /// - /// - public bool CheckForMatch(uint address, uint data) - { - try - { - var result = false; - lock (_jaceLockObject) - { - foreach (var dcsbiosOutput in _dcsbiosOutputs) - { - if (dcsbiosOutput.UIntValueHasChanged(address, data)) - { - result = true; - _variables[dcsbiosOutput.ControlId] = dcsbiosOutput.LastUIntValue; - } - } - } - - return result; - } - catch (Exception ex) - { - Logger.Error(ex, "CheckForMatch() function"); - throw; - } - } - - public double Evaluate(bool throwException) - { - try - { - lock (_jaceLockObject) - { - FormulaResult = _jaceExtended.CalculationEngine.Calculate(_formula, _variables); - return FormulaResult; - } - } - catch (Exception ex) - { - Logger.Error(ex, "Evaluate() function"); - if (throwException) - { - throw; - } - } - - return double.MinValue; - } - - public void ImportString(string str) - { - ////DCSBiosOutputFormula{(AAP_EGIPWR+1)/2} - var value = str; - if (string.IsNullOrEmpty(str)) - { - throw new Exception("DCSBiosOutputFormula cannot import null string."); - } - - if (!str.StartsWith("DCSBiosOutputFormula{") || !str.EndsWith("}")) - { - throw new Exception("DCSBiosOutputFormula cannot import string : " + str); - } - - value = value.Replace("DCSBiosOutputFormula{", string.Empty).Replace("}", string.Empty); - - // (AAP_EGIPWR+1)/2 - _formula = value; - - ExtractDCSBIOSOutputsInFormula(); - } - - [JsonProperty("Formula", Required = Required.Default)] - public string Formula - { - get => _formula; - set - { - _formula = value; - if (!string.IsNullOrEmpty(_formula)) - { - ExtractDCSBIOSOutputsInFormula(); - } - } - } - - public override string ToString() - { - return "DCSBiosOutputFormula{" + _formula + "}"; - } - } -} diff --git a/src/DCS-BIOS/StringClasses/DCSBIOSString.cs b/src/DCS-BIOS/StringClasses/DCSBIOSString.cs deleted file mode 100644 index 7ed852fd1..000000000 --- a/src/DCS-BIOS/StringClasses/DCSBIOSString.cs +++ /dev/null @@ -1,102 +0,0 @@ -using System.Collections.Generic; - -namespace DCS_BIOS.StringClasses -{ - /// - /// Wrapper for DCS-BIOS strings which has to be constructed - /// from several packets sent from DCS-BIOS. - /// - public class DCSBIOSString - { - /// - /// Use this, some strings need to be fully constructed before being broadcast. - /// Once it has once been complete no further checks is made that all the addresses - /// has been received. It will be sent regardless. - /// Only the first "build up" of the string uses this. - /// - private readonly List _receivedAddresses = new(); - private readonly string[] _internalBuffer; - private readonly int _length; - private readonly uint _address; - - //private readonly uint _debugAddress = 10244; //->10251 Mi-8MT R863, Frequency - public bool IsComplete => _receivedAddresses.Count == 0; - - public string StringValue => string.Join(string.Empty, _internalBuffer); - public uint Address - { - get => _address; - } - - public DCSBIOSString(uint address, int length) - { - _address = address; - for (var i = _address; i < _address + length; i += 2) - { - DCSBIOSProtocolParser.RegisterAddressToBroadCast(i); - _receivedAddresses.Add(i); - } - _length = length; - _internalBuffer = new string[_length]; - } - - /// - /// Addresses received containing empty payload to be - /// considered as unnecessary, for example a string has too - /// big memory reserved and the last addresses contain nothing. - /// - /// - public void RemoveAddress(uint address) - { - _receivedAddresses.Remove(address); - } - - public bool IsMatch(uint address) - { - if (address >= _address && address <= _address + _length) - { - return true; - } - return false; - } - - public void Add(uint address, string str1, string str2) - { - if (address < _address || address >= _address + _length) - { - return; - } - - _receivedAddresses.Remove(address); - - var offset = address - _address; - - if (!string.IsNullOrEmpty(str1)) - { - _internalBuffer[offset] = str1; - } - - if (offset + 1 < _internalBuffer.Length && str2 != null) - { - // index = 5, length = 6 - // For example odd length strings. Only first endian byte should then be read. - _internalBuffer[offset + 1] = str2; - } - } - - public void Add(uint address, string str2) - { - if (address >= _address && address < _address + _length) - { - _receivedAddresses.Remove(address); - - var offset = address - _address; - - if (!string.IsNullOrEmpty(str2)) - { - _internalBuffer[offset] = str2; - } - } - } - } -} diff --git a/src/DCS-BIOS/StringClasses/DCSBIOSStringListener.cs b/src/DCS-BIOS/StringClasses/DCSBIOSStringListener.cs deleted file mode 100644 index c23d2c3b8..000000000 --- a/src/DCS-BIOS/StringClasses/DCSBIOSStringListener.cs +++ /dev/null @@ -1,186 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using DCS_BIOS.EventArgs; -using DCS_BIOS.Interfaces; -using NLog; - -namespace DCS_BIOS.StringClasses -{ - /// - /// Classes reports which strings they want to get updates for. - /// This class handles the listening and broadcasts the strings - /// once they are fully received. - /// Used by DCSBIOSStringManager. - /// - internal class DCSBIOSStringListener : IDcsBiosDataListener, IDisposable - { - private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - - private readonly List> _dcsBiosStrings = new(); - private readonly object _lockObject = new(); - private readonly Encoding _iso88591 = Encoding.GetEncoding("ISO-8859-1"); - //private readonly uint _debugAddress = 10244; //->10251 Mi-8MT R863, Frequency - - public DCSBIOSStringListener() - { - BIOSEventHandler.AttachDataListener(this); - } - - public void Dispose() - { - BIOSEventHandler.DetachDataListener(this); - GC.SuppressFinalize(this); - } - - public void AddStringAddress(uint address, int length) - { - var found = false; - lock (_lockObject) - { - foreach (var dcsBiosString in _dcsBiosStrings) - { - if (dcsBiosString.Key == address) - { - found = true; - } - } - if (!found) - { - _dcsBiosStrings.Add(new KeyValuePair(address, new DCSBIOSString(address, length))); - } - } - } - - public void RemoveStringAddress(uint address) - { - var dcsBiosStringToRemove = new KeyValuePair(); - var found = false; - foreach (var dcsBiosString in _dcsBiosStrings) - { - if (dcsBiosString.Key == address) - { - dcsBiosStringToRemove = dcsBiosString; - found = true; - break; - } - } - if (found) - { - _dcsBiosStrings.Remove(dcsBiosStringToRemove); - } - } - - private void UpdateStrings(uint address, uint data) - { - lock (_lockObject) - { - if (data == 0x55) - { - //start of update cycle - return; - } - - if (address == 0xfffe) - { - //end of update cycle, clear all existing values. - //broadcast every string now - foreach (var kvp in _dcsBiosStrings) - { - //kvp.Value.Address == start address for the string - if (kvp.Value.IsComplete) - { - //Once it has been "complete" one time then just keep sending it each time, do not reset it as there will be no updates from DCS-BIOS unless cockpit value changes. - BIOSEventHandler.DCSBIOSStringAvailable(this, kvp.Value.Address, kvp.Value.StringValue); - } - } - } - else - { - foreach (var kvp in _dcsBiosStrings) - { - if (kvp.Value.IsMatch(address)) - { - try - { - //Send "AB" - //0x4241 - //41 = A - //42 = B - var hex = Convert.ToString(data, 16); - - //Debug.WriteLine(hex); - //See comment below. - if (hex.Length < 2) - { - /* - * Remove address as it doesn't contain data. Maybe a dynamic string and right now the string is shorter - * than the memory space reserved. - * Now if the string - */ - kvp.Value.RemoveAddress(address); - return; - } - - //Little Endian ! - byte[] secondByte; - byte[] firstByte; - var secondChar = string.Empty; - var firstChar = string.Empty; - - switch (hex.Length) - { - case 2: - { - secondByte = new[] { Convert.ToByte(hex.Substring(0, 2), 16) }; - secondChar = _iso88591.GetString(secondByte); - firstChar = ""; - break; - } - case 3: - { - //this is really ugly, will it work ?? keep getting 0x730 from MI-8 R863 where I would except last digit (uneven 7 long frequency) - //so let's try and just ignore the for number, in this case the 7. - //28.04.2020 JDA - secondByte = new[] { Convert.ToByte(hex.Substring(0, 2), 16) }; - secondChar = _iso88591.GetString(secondByte); - firstByte = new[] { Convert.ToByte(hex.Substring(1, 2), 16) }; - firstChar = _iso88591.GetString(firstByte); - break; - } - case 4: - { - secondByte = new[] { Convert.ToByte(hex.Substring(0, 2), 16) }; - secondChar = _iso88591.GetString(secondByte); - firstByte = new[] { Convert.ToByte(hex.Substring(2, 2), 16) }; - firstChar = _iso88591.GetString(firstByte); - break; - } - } - - - if (!string.IsNullOrEmpty(firstChar)) - { - kvp.Value.Add(address, firstChar, secondChar); - } - else - { - kvp.Value.Add(address, secondChar); - } - } - catch (Exception ex) - { - Logger.Error(ex, $"**********Received (0x{data:X}"); - } - } - } - } - } - } - - public void DcsBiosDataReceived(object sender, DCSBIOSDataEventArgs e) - { - UpdateStrings(e.Address, e.Data); - } - } -} diff --git a/src/DCS-BIOS/StringClasses/DCSBIOSStringManager.cs b/src/DCS-BIOS/StringClasses/DCSBIOSStringManager.cs deleted file mode 100644 index d0c2df9c6..000000000 --- a/src/DCS-BIOS/StringClasses/DCSBIOSStringManager.cs +++ /dev/null @@ -1,34 +0,0 @@ -using DCS_BIOS.Serialized; - -namespace DCS_BIOS.StringClasses -{ - /// - /// Easy wrapper for listening to DCS-BIOS strings. - /// - public static class DCSBIOSStringManager - { - private static DCSBIOSStringListener _dcsbiosStringListener; - - private static void AddAddress(uint address, int length) - { - CheckInstance(); - _dcsbiosStringListener.AddStringAddress(address, length); - } - - public static void AddListeningAddress(DCSBIOSOutput dcsbiosOutput) - { - CheckInstance(); - AddAddress(dcsbiosOutput.Address, dcsbiosOutput.MaxLength); - } - - private static void CheckInstance() - { - _dcsbiosStringListener ??= new DCSBIOSStringListener(); - } - - public static void Close() - { - _dcsbiosStringListener?.Dispose(); - } - } -} diff --git a/src/DCS-BIOS/app.config b/src/DCS-BIOS/app.config deleted file mode 100644 index 3a4995dfd..000000000 --- a/src/DCS-BIOS/app.config +++ /dev/null @@ -1,235 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/DCS-BIOS/icon_image.ico b/src/DCS-BIOS/icon_image.ico deleted file mode 100644 index 278e67cbc3b2b3e5e39e063c44e12f31afe7f99e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 370070 zcmeIb52y|M|NrY;vzLz~KS`3@{gLD=$xo6b`MPpXk|arzT*-AMSCT79K9VF!k|aqd z>0C*YBuSEVl3YoWq@5&5k|ar|b05!{_1=5dteIIevu4(swf1}0bH8Wa^ZxUCzy7`d z&a5Frej8F5@<0B^5dQu>6R~|0VwaBkq6x&+7e@Aw&M3u|tOZ_kVl$ z|MkBO8S=l*A2Q@W|Eb>p>$f5Q`+i;P@83iI>)+0h|NHQ7L;j09Rq=1|oBN+KC^z`` z&p-eC7KVRSoaO%-)^h|Lk^qe3( z2UNx%;4WAOLg^rWBzOisgMa=t%sEPUjdIQqo~_3JBzz90`0Ld*al^q&KwcM536BBM zakCnyazAlBx-NgEXT?C8{xVEi!Ej4m{$V})s`-Bq?u70`gnw7#4!d!~dcIfh&xYhb z7<@(<_ldi2(sC_ch?dJHP9gW=`$_MabHx`Yeu`f%&j}?<<-b~&ztZy;@!~Jf9i_YD zUAyV;pc5vq@;~OjMvl;Wi+HtD&tu?R;`uRu{Z)FEzZdxH36}GK=TpFmko;SSSN-C} zR@(5E(BzlQ4}f7nX_kfL*Rw}pag`pGGYP1^o@(3@uJ3`Gwwtnup8y_$Jz!*ie8m~X z{azrxO)&9cA!$U1+9H13hOc+Yqd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4uVaQuL?8pscP!yib8tuIK&1NqN)_|*f1lYrgJ zx3*tu+YkDJ>bPJDx_b`1z#nLyZv8+s5A-drPv9<8+wVHt5BdUcZs49HSc(mtMelX)_Z`>m-d`)y5ApjN?zfgS20F}q zXhs-cY@9u>GnjNheIB+jfp96%{?;|@MC0LZ@CA%-+;@C05NiIj5ZLoNwvQhaeSBI! zhHWrMaCELk GetInformation(DCSBIOSControl dcsbiosControl) - { - var result = new List(); - if (dcsbiosControl == null) return result; - - if (dcsbiosControl.Inputs.Count > 0) { result.Add("Input"); } - - var fixedStepInputInfo = new List(); - var integerOutputInfo = new List(); - - foreach (var input in dcsbiosControl.Inputs) - { - var interfaceType = new DCSBIOSInputInterface(); - interfaceType.Consume(dcsbiosControl.Identifier, input); - switch (interfaceType.Interface) - { - case DCSBIOSInputType.FIXED_STEP: - { - //RotaryEncoder_fixed_step - result.Add(RotaryEncoderFixedStep(dcsbiosControl, interfaceType)); - break; - } - case DCSBIOSInputType.SET_STATE: - { - if (fixedStepInputInfo.Count == 0) fixedStepInputInfo.Add(CommonInputData(dcsbiosControl, interfaceType)); - - if (interfaceType.MaxValue < 33) - { - //SwitchMultiPos PIN0 Template - fixedStepInputInfo.Add(SwitchMultiPos(dcsbiosControl, interfaceType)); - } - - if (interfaceType.MaxValue == 1) - { - fixedStepInputInfo.Add(Switch2Pos(dcsbiosControl, interfaceType)); - fixedStepInputInfo.Add(Matrix2Pos(dcsbiosControl, interfaceType)); - //Switch2Pos - //Matrix2Pos - } - - if (interfaceType.MaxValue == 2) - { - fixedStepInputInfo.Add(Switch3Pos(dcsbiosControl, interfaceType)); - fixedStepInputInfo.Add(Matrix3Pos(dcsbiosControl, interfaceType)); - //Switch3Pos - //Matrix3Pos - } - - if (interfaceType.MaxValue < 20) - { - fixedStepInputInfo.Add(AnalogMultiPos(dcsbiosControl, interfaceType)); - //AnalogMultiPos - } - - if (interfaceType.MaxValue == DCSBIOSConstants.MAX_VALUE) - { - fixedStepInputInfo.Add(Potentiometer(dcsbiosControl, interfaceType)); - //Potentiometer - } - - break; - } - case DCSBIOSInputType.ACTION: - { - result.Add(ActionButton(dcsbiosControl, interfaceType)); - //ActionButton - break; - } - case DCSBIOSInputType.VARIABLE_STEP: - { - result.Add(RotaryEncoderVariableStep(dcsbiosControl, interfaceType)); - //RotaryEncoder_variable_step - break; - } - case DCSBIOSInputType.SET_STRING: - { - result.Add(StringInput(dcsbiosControl, interfaceType)); - break; - } - } - } - - - if (fixedStepInputInfo.Count > 0) - { - //Can have many so coalesce them with one banner. Banner is in [0]. - for (var i = 0; i < fixedStepInputInfo.Count; i++) - { - if (i == 0) continue; - fixedStepInputInfo[0] += "\n\n" + fixedStepInputInfo[i]; - } - - result.Add(fixedStepInputInfo[0]); - } - - if (dcsbiosControl.Outputs.Count > 0) { result.Add("Output"); } - - - foreach (var output in dcsbiosControl.Outputs) - { - - switch (output.OutputDataType) - { - case DCSBiosOutputType.IntegerType: - { - if (integerOutputInfo.Count == 0) integerOutputInfo.Add(CommonOutputData(dcsbiosControl, output)); - - integerOutputInfo.Add(IntegerOutput(dcsbiosControl, output)); - - if (output.MaxValue == 1) - { - integerOutputInfo.Add(LEDOutput(dcsbiosControl, output, false)); - } - if (output.MaxValue == DCSBIOSConstants.MAX_VALUE) - { - integerOutputInfo.Add(ServoOutput(dcsbiosControl, output)); - } - break; - } - case DCSBiosOutputType.StringType: - { - result.Add(StringOutput(dcsbiosControl, output)); - break; - } - case DCSBiosOutputType.LED: - { - result.Add(LEDOutput(dcsbiosControl, output, true)); - break; - } - case DCSBiosOutputType.FloatBuffer: // does this still exist? - { - result.Add(FloatOutput(dcsbiosControl, output)); - break; - } - case DCSBiosOutputType.ServoOutput: - { - result.Add(ServoOutput(dcsbiosControl, output)); - break; - } - } - } - - if (integerOutputInfo.Count > 0) - { - //Can have many so coalesce them with one banner. Banner is in [0]. - for (var i = 0; i < integerOutputInfo.Count; i++) - { - if (i == 0) continue; - integerOutputInfo[0] += "\n\n" + integerOutputInfo[i]; - } - - result.Add(integerOutputInfo[0]); - } - - return result; - - } - - private static string MakeCamelCase(string str) - { - var returnValue = ""; - var capitalize = false; - foreach (var c in str) - { - if (c == '_') - { - capitalize = true; - } - else - { - if (capitalize) - { - returnValue += char.ToUpperInvariant(c); - capitalize = false; - } - else - { - returnValue += char.ToLowerInvariant(c); - } - } - } - - return returnValue; - } - - private static string RotaryEncoderFixedStep(DCSBIOSControl dcsbiosControl, DCSBIOSInputInterface inputInterface) - { - //code.append($("").text('DcsBios::RotaryEncoder '+idCamelCase(cid)+'("'+cid+'", "-'+io.suggested_step.toString()+'", "+'+io.suggested_step.toString()+'", ')); - var str = CommonInputData(dcsbiosControl, inputInterface); - str += $"DcsBios::RotaryEncoder {MakeCamelCase(dcsbiosControl.Identifier)}(\"{dcsbiosControl.Identifier}\", \"DEC\", \"INC\", PIN_A, PIN_B);"; - return str; - } - - private static string RotaryEncoderVariableStep(DCSBIOSControl dcsbiosControl, DCSBIOSInputInterface inputInterface) - { - //code.append($("").text('DcsBios::RotaryEncoder '+idCamelCase(cid)+'("'+cid+'", "-'+io.suggested_step.toString()+'", "+'+io.suggested_step.toString()+'", ')); - var str = CommonInputData(dcsbiosControl, inputInterface); - str += $"DcsBios::RotaryEncoder {MakeCamelCase(dcsbiosControl.Identifier)}(\"{dcsbiosControl.Identifier}\", \"-{inputInterface.SuggestedStep}\", \"+{inputInterface.SuggestedStep}\", PIN_A, PIN_B);"; - return str; - } - - private static string SwitchMultiPos(DCSBIOSControl dcsbiosControl, DCSBIOSInputInterface inputInterface) - { - //code.append($("").text('DcsBios::SwitchMultiPos '+idCamelCase(cid)+'("'+cid+'", '+idCamelCase(cid+'_PINS')+', '+(io.max_value+1).toString()+');')); - var pins = ""; - var valuePossibilities = inputInterface.MaxValue + 1; - for (var i = 0; i < valuePossibilities; i++) - { - if (i > 0) pins += ", "; - pins += $"PIN_{i}"; - } - - var str = $"const byte {MakeCamelCase(dcsbiosControl.Identifier)}Pins[{valuePossibilities}] = {{{pins}}};\n"; - str += $"DcsBios::SwitchMultiPos {MakeCamelCase(dcsbiosControl.Identifier)}(\"{dcsbiosControl.Identifier}\", {MakeCamelCase(dcsbiosControl.Identifier)}Pins, {valuePossibilities});"; - return str; - } - - private static string Switch2Pos(DCSBIOSControl dcsbiosControl, DCSBIOSInputInterface inputInterface) - { - //code.append($("").text('DcsBios::Switch2Pos '+idCamelCase(cid)+'("'+cid+'", ')); - - var str = $"DcsBios::Switch2Pos {MakeCamelCase(dcsbiosControl.Identifier)}(\"{dcsbiosControl.Identifier}\", PIN);"; - return str; - } - - private static string Switch3Pos(DCSBIOSControl dcsbiosControl, DCSBIOSInputInterface inputInterface) - { - //code.append($("").text('DcsBios::Switch3Pos '+idCamelCase(cid)+'("'+cid+'", ')); - - var str = $"DcsBios::Switch3Pos {MakeCamelCase(dcsbiosControl.Identifier)}(\"{dcsbiosControl.Identifier}\", PIN_A, PIN_B);"; - return str; - } - - private static string Matrix2Pos(DCSBIOSControl dcsbiosControl, DCSBIOSInputInterface inputInterface) - { - //code.append($("").text('DcsBios::Matrix2Pos '+idCamelCase(cid)+'("'+cid+'", ')); - - var str = $"DcsBios::Matrix2Pos {MakeCamelCase(dcsbiosControl.Identifier)}(\"{dcsbiosControl.Identifier}\", ROW, COL);"; - return str; - } - - private static string Matrix3Pos(DCSBIOSControl dcsbiosControl, DCSBIOSInputInterface inputInterface) - { - //code.append($("").text('DcsBios::Matrix3Pos '+idCamelCase(cid)+'("'+cid+'", ')); - - var str = $"DcsBios::Matrix3Pos {MakeCamelCase(dcsbiosControl.Identifier)}(\"{dcsbiosControl.Identifier}\", ROW_A, COL_A, ROW_B, COL_B);"; - return str; - } - - private static string AnalogMultiPos(DCSBIOSControl dcsbiosControl, DCSBIOSInputInterface inputInterface) - { - //code.append($("").text('DcsBios::AnalogMultiPos '+idCamelCase(cid)+'("'+cid+'", ')); - - var str = $"DcsBios::AnalogMultiPos {MakeCamelCase(dcsbiosControl.Identifier)}(\"{dcsbiosControl.Identifier}\", PIN, STEPS);"; - return str; - } - - private static string Potentiometer(DCSBIOSControl dcsbiosControl, DCSBIOSInputInterface inputInterface) - { - //code.append($("").text('DcsBios::Potentiometer '+idCamelCase(cid)+'("'+cid+'", ')); - - var str = $"DcsBios::Potentiometer {MakeCamelCase(dcsbiosControl.Identifier)}(\"{dcsbiosControl.Identifier}\", PIN);"; - return str; - } - - private static string ActionButton(DCSBIOSControl dcsbiosControl, DCSBIOSInputInterface inputInterface) - { - //code.append($("").text("DcsBios::ActionButton "+idCamelCase(cid+"_"+io.argument)+'("'+cid+'", "'+io.argument+'", ')); - var str = CommonInputData(dcsbiosControl, inputInterface); - str += $"DcsBios::ActionButton {MakeCamelCase(dcsbiosControl.Identifier + "_" + inputInterface.SpecifiedActionArgument)}(\"{dcsbiosControl.Identifier}\", \"{inputInterface.SpecifiedActionArgument}\", PIN);"; - return str; - } - - private static string StringInput(DCSBIOSControl dcsbiosControl, DCSBIOSInputInterface inputInterface) - { - var functionName = MakeCamelCase(dcsbiosControl.Identifier) + "FreqSetFreq"; - var str = CommonInputData(dcsbiosControl, inputInterface); - str += $"void {functionName}(\"{dcsbiosControl.Identifier}\", FREQUENCY, PIN);\n"; - return str; - } - - private static string IntegerOutput(DCSBIOSControl dcsbiosControl, DCSBIOSControlOutput output) - { - var functionName = MakeCamelCase("ON_" + dcsbiosControl.Identifier + "_CHANGE"); - - //code.append($("").text('void '+idCamelCase("ON_"+cid+"_CHANGE")+'(unsigned int newValue) {')); - var str = $"void {functionName}(unsigned int newValue) \n{{\n"; - - str += $"\t\t/* your code here */\n}}\n"; - - //code.append($("").text("DcsBios::IntegerBuffer "+idCamelCase(cid+"_BUFFER")+'('+io.address_identifier+', '+idCamelCase("ON_"+cid+"_CHANGE")+');')); - //str += $"DcsBios::IntegerBuffer {MakeCamelCase(dcsbiosControl.Identifier + "_BUFFER")}({Common.GetHex(output.Address)}, {Common.GetHex(output.Mask)}, {output.ShiftBy}, {functionName});"; - str += $"DcsBios::IntegerBuffer {MakeCamelCase(dcsbiosControl.Identifier + "_BUFFER")}({output.AddressMaskShiftIdentifier}, {functionName});"; - return str; - } - - private static string LEDOutput(DCSBIOSControl dcsbiosControl, DCSBIOSControlOutput output, bool addBanner) - { - var functionName = MakeCamelCase(dcsbiosControl.Identifier); - var str = ""; - if (addBanner) str += CommonOutputData(dcsbiosControl, output); - //code.append($("").text('DcsBios::LED '+idCamelCase(cid)+'('+io.address_identifier+', ')); - //str += $"DcsBios::LED {functionName}({Common.GetHex(output.Address)}, PIN);"; - str += $"DcsBios::LED {functionName}({output.AddressMaskIdentifier}, PIN);"; - - return str; - } - - private static string StringOutput(DCSBIOSControl dcsbiosControl, DCSBIOSControlOutput output) - { - var functionName = MakeCamelCase("ON_" + dcsbiosControl.Identifier + "_CHANGE"); - var str = CommonOutputData(dcsbiosControl, output); - //code.append($("").text('void '+idCamelCase("ON_"+cid+"_CHANGE")+'(char* newValue) {')); - str += $"void {functionName}((char* newValue)) \n{{\n"; - - str += $"\t\t/* your code here */\n}}\n"; - - //code.append($("").text("DcsBios::StringBuffer<" + io.max_length.toString() + "> " + idCamelCase(cid + io.suffix + "_BUFFER") + '(' + io.address_identifier + ', ' + idCamelCase("ON_" + cid + "_CHANGE") + ');')); - //str += $"DcsBios::StringBuffer<{output.MaxLength}> {MakeCamelCase(dcsbiosControl.Identifier + output.Suffix + "_BUFFER")}(\"{Common.GetHex(output.Address)}\", {functionName});"; - str += $"DcsBios::StringBuffer<{output.MaxLength}> {MakeCamelCase(dcsbiosControl.Identifier + output.Suffix + "_BUFFER")}({output.AddressIdentifier}, {functionName});"; - return str; - } - - private static string ServoOutput(DCSBIOSControl dcsbiosControl, DCSBIOSControlOutput output) - { - var functionName = MakeCamelCase(dcsbiosControl.Identifier); - var str = CommonOutputData(dcsbiosControl, output); - //code.append($("").text('DcsBios::ServoOutput ' + idCamelCase(cid) + '(' + io.address_only_identifier + ', ')); - str += $"DcsBios::ServoOutput {functionName}({output.AddressIdentifier}, PIN, 544, 2400);"; - - return str; - } - private static string FloatOutput(DCSBIOSControl dcsbiosControl, DCSBIOSControlOutput output) - { - var functionName = MakeCamelCase(dcsbiosControl.Identifier + output.Suffix + "_BUFFER"); - var str = CommonOutputData(dcsbiosControl, output); - //code.append($("").text("DcsBios::FloatBuffer "+idCamelCase(cid+io.suffix+"_BUFFER")+'('+io.address_identifier+', '+io.value_range[0].toFixed()+', '+io.value_range[1]+ending+');')); - //str += $"DcsBios::FloatBuffer {functionName}({Common.GetHex(output.Address)}, 0, {output.MaxLength});"; - str += $"DcsBios::FloatBuffer {functionName}({output.AddressMaskShiftIdentifier}, 0, {output.MaxLength});"; - - return str; - } - - private static string CommonInputData(DCSBIOSControl dcsbiosControl, DCSBIOSInputInterface inputInterface)//DCSBIOSInputInterface inputInterface) - { - var str = $"Interface : {inputInterface.Interface}\n"; - switch (inputInterface.Interface) - { - case DCSBIOSInputType.ACTION: - { - str += $"Message : {dcsbiosControl.Identifier} TOGGLE\n"; - break; - } - case DCSBIOSInputType.VARIABLE_STEP: - { - str += $"Message : {dcsbiosControl.Identifier} |-|+\n"; - str += $"Suggested Step : {inputInterface.SuggestedStep}\n"; - str += $"Value Range : 0-{inputInterface.MaxValue}\n"; - break; - } - case DCSBIOSInputType.FIXED_STEP: - { - str += $"Message : {dcsbiosControl.Identifier} \n"; - break; - } - case DCSBIOSInputType.SET_STATE: - { - str += $"Message : {dcsbiosControl.Identifier} \n"; - str += $"Value Range : 0-{inputInterface.MaxValue}\n"; - - break; - } - case DCSBIOSInputType.SET_STRING: - { - str += $"Message : {dcsbiosControl.Identifier} set frequency\n"; - - break; - } - } - - str += $"Description : {inputInterface.Description}\n"; - - str += "\n"; - return str; - } - - private static string CommonOutputData(DCSBIOSControl dcsbiosControl, DCSBIOSControlOutput output) - { - var str = ""; - if (output.OutputDataType != DCSBiosOutputType.StringType) - { - str = $"Type : {output.Type}\n"; - str += $"Address : {Common.GetHex(output.Address)}\n"; - str += $"Mask : {Common.GetHex(output.Mask)}\n"; - str += $"ShiftBy : {output.ShiftBy}\n"; - str += $"Max Value : {output.MaxValue}\n"; - str += $"Description : {output.Description}\n"; - str += "\n"; - } - else - { - str = $"Type : {output.Type}\n"; - str += $"Address : {Common.GetHex(output.Address)}\n"; - str += $"Max Length : {output.MaxLength}\n"; - str += $"Description : {output.Description}\n"; - str += "\n"; - } - return str; - } - } -} diff --git a/src/DCS-BIOS/misc/DCSBIOSCommon.cs b/src/DCS-BIOS/misc/DCSBIOSCommon.cs deleted file mode 100644 index 2c8521495..000000000 --- a/src/DCS-BIOS/misc/DCSBIOSCommon.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; - -namespace DCS_BIOS.misc -{ - public static class DCSBIOSCommon - { - - public static string PrintBitStrings(byte[] array) - { - var result = string.Empty; - foreach (var b in array) - { - var str = Convert.ToString(b, 2).PadLeft(8, '0'); - result = result + " " + str; - } - return result; - } - } -} diff --git a/src/DCS-BIOS/misc/DCSBIOSConstants.cs b/src/DCS-BIOS/misc/DCSBIOSConstants.cs deleted file mode 100644 index 11a016ebf..000000000 --- a/src/DCS-BIOS/misc/DCSBIOSConstants.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace DCS_BIOS.misc -{ - public static class DCSBIOSConstants - { - public const int MAX_VALUE = 65535; - public const int META_MODULE_ID_START_RANGE = 500; - public const uint META_MODULE_START_ADDRESS = 0x0000; - public const uint META_MODULE_END_ADDRESS = 0xfffe; - } -} diff --git a/src/DCS-BIOS/misc/JaceExtended.cs b/src/DCS-BIOS/misc/JaceExtended.cs deleted file mode 100644 index 9ccfc152f..000000000 --- a/src/DCS-BIOS/misc/JaceExtended.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using Jace; -using NLog; - -namespace DCS_BIOS.misc -{ - public class JaceExtended - { - private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - - private readonly object _lockObject = new(); - private readonly CalculationEngine _calculationEngine = new(); - - public JaceExtended() - { - AddFunctions(); - } - - public double Evaluate(string expression) - { - try - { - lock (_lockObject) - { - return _calculationEngine.Calculate(expression); - } - } - catch (Exception ex) - { - Logger.Error(ex, "JaceExtended.Evaluate() function"); - throw; - } - } - - private static void AddFunctions() - { - //_calculationEngine.AddFunction("floor", Math.Floor); - //_calculationEngine.AddFunction("ceiling", Math.Ceiling); - //_calculationEngine.AddFunction("truncate", Math.Truncate); - } - - public CalculationEngine CalculationEngine => _calculationEngine; - } -} diff --git a/src/DCS-BIOS/misc/LuaAssistant.cs b/src/DCS-BIOS/misc/LuaAssistant.cs deleted file mode 100644 index 37d2c0e37..000000000 --- a/src/DCS-BIOS/misc/LuaAssistant.cs +++ /dev/null @@ -1,245 +0,0 @@ -using ClassLibraryCommon; -using NLog; -using System; -using System.Collections.Generic; -using System.IO; - -namespace DCS_BIOS.misc -{ - /// - /// Class for reading lua code from dcs-bios for a certain control. Can also read the signature for the function from Module.lua. - /// - internal class LuaAssistant - { - private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - private static readonly List LuaModuleSignatures = new(); - private static readonly List> LuaControls = new(); - private static DCSAircraft _dcsAircraft; - private static string _jsonDirectory; - private static string _dcsbiosAircraftLuaLocation; - private static string _dcsbiosModuleLuaFilePath; - private static readonly object LockObject = new(); - private const string DCSBIOS_LUA_NOT_FOUND_ERROR_MESSAGE = "Error loading DCS-BIOS lua."; - - - internal static DCSAircraft DCSAircraft - { - get => _dcsAircraft; - set - { - if (_dcsAircraft == value) - { - return; - } - - _dcsAircraft = value; - Reset(); - } - } - - internal static string JSONDirectory - { - get => _jsonDirectory; - set - { - _jsonDirectory = value; - _dcsbiosAircraftLuaLocation = $@"{value}\..\..\lib\modules\aircraft_modules\"; - _dcsbiosModuleLuaFilePath = $@"{value}\..\..\lib\modules\Module.lua"; - } - } - - internal static void Reset() - { - LuaModuleSignatures.Clear(); - LuaControls.Clear(); - } - - internal static string GetLuaCommand(string controlId, bool includeSignature) - { - if (_dcsAircraft == null || _dcsAircraft.IsMetaModule || string.IsNullOrEmpty(controlId)) return ""; - - if (LuaControls.Count == 0) - { - ReadLuaCommandsFromLua(); - if (LuaControls.Count == 0) return ""; - } - - var result = LuaControls.Find(o => o.Key == controlId); - - if (result.Key != controlId) return ""; - - var stringResult = result.Value; - if (!includeSignature) return stringResult; - - var signature = GetLuaCommandSignature(result.Value); - return string.IsNullOrEmpty(signature) ? result.Value : signature + "\n" + result.Value; - } - - private static string GetLuaCommandSignature(string luaCommand) - { - try - { - //A_10C:definePotentiometer("HARS_LATITUDE", 44, 3005, 271, { 0, 1 }, "HARS", "HARS Latitude Dial") - var startIndex = luaCommand.IndexOf(":", StringComparison.Ordinal); - var endIndex = luaCommand.IndexOf("(", StringComparison.Ordinal) - startIndex; - var functionName = "function Module" + luaCommand.Substring(startIndex, endIndex); - - var luaSignature = LuaModuleSignatures.Find(o => o.StartsWith(functionName + "(")); - return string.IsNullOrEmpty(luaSignature) ? "" : $"{luaSignature.Replace("function ", "")}"; - } - catch (Exception exception) - { - Common.ShowErrorMessageBox(exception); - } - - return ""; - } - - private static void ReadControlsFromLua(DCSAircraft dcsAircraft, string fileFullPath) - { - // input is a map from category string to a map from key string to control definition - // we read it all then flatten the grand children (the control definitions) - var lineArray = File.ReadAllLines(fileFullPath); - try - { - var luaBuffer = ""; - - foreach (var s in lineArray) - { - //s.StartsWith("--") - if (string.IsNullOrEmpty(s)) continue; - - if (s.StartsWith(dcsAircraft.ModuleLuaName + ":define")) - { - luaBuffer = s; - - if (CountParenthesis(true, luaBuffer) == CountParenthesis(false, luaBuffer)) - { - LuaControls.Add(CopyControlFromLuaBuffer(luaBuffer)); - luaBuffer = ""; - } - } - else if (!string.IsNullOrEmpty(luaBuffer)) - { - //We have incomplete data from previously - luaBuffer = luaBuffer + "\n" + s; - if (CountParenthesis(true, luaBuffer) == CountParenthesis(false, luaBuffer)) - { - LuaControls.Add(CopyControlFromLuaBuffer(luaBuffer)); - luaBuffer = ""; - } - } - - } - } - catch (Exception e) - { - Logger.Error(e, "ReadControlsFromLua : Failed to read DCS-BIOS lua."); - } - } - - private static List ReadModuleFunctionSignatures(string moduleFile) - { - if (LuaModuleSignatures.Count > 0) return LuaModuleSignatures; - - LuaModuleSignatures.Clear(); - - - var lineArray = File.ReadAllLines(moduleFile); - try - { - var luaBuffer = ""; - - foreach (var s in lineArray) - { - //s.StartsWith("--") - if (string.IsNullOrEmpty(s)) continue; - - if (s.StartsWith("function Module:define")) - { - luaBuffer = s; - - if (CountParenthesis(true, luaBuffer) == CountParenthesis(false, luaBuffer)) - { - LuaModuleSignatures.Add(luaBuffer); - luaBuffer = ""; - } - } - else if (!string.IsNullOrEmpty(luaBuffer)) - { - //We have incomplete data from previously - luaBuffer = luaBuffer + "\n" + s; - if (CountParenthesis(true, luaBuffer) == CountParenthesis(false, luaBuffer)) - { - LuaModuleSignatures.Add(luaBuffer); - luaBuffer = ""; - } - } - - } - } - catch (Exception e) - { - Logger.Error(e, "GetModuleFunctionSignatures : Failed to read Module.lua."); - } - - return LuaModuleSignatures; - } - - private static KeyValuePair CopyControlFromLuaBuffer(string luaBuffer) - { - // We have the whole control - // F_16C_50:define3PosTumb("MAIN_PWR_SW", 3, 3001, 510, "Electric System", "MAIN PWR Switch, MAIN PWR/BATT/OFF") - /* - A_10C:defineString("ARC210_COMSEC_SUBMODE", function() - return Functions.coerce_nil_to_string(arc_210_data["comsec_submode"]) - end, 5, "ARC-210 Display", "COMSEC submode (PT/CT/CT-TD)") - */ - var startIndex = luaBuffer.IndexOf("\"", StringComparison.Ordinal); - var endIndex = luaBuffer.IndexOf("\"", luaBuffer.IndexOf("\"") + 1); - var controlId = luaBuffer.Substring(startIndex + 1, endIndex - startIndex - 1); - - return new KeyValuePair(controlId, luaBuffer); - } - - private static int CountParenthesis(bool firstParenthesis, string s) - { - if (string.IsNullOrEmpty(s)) return 0; - var parenthesis = firstParenthesis ? '(' : ')'; - var result = 0; - var insideQuote = false; - - foreach (var c in s) - { - if (c == '"') insideQuote = !insideQuote; - - if (c == parenthesis && !insideQuote) result++; - } - - return result; - } - - /// - /// Load all lua controls - /// - /// - private static void ReadLuaCommandsFromLua() - { - LuaControls.Clear(); - LuaModuleSignatures.Clear(); - - try - { - lock (LockObject) - { - ReadControlsFromLua(_dcsAircraft, $"{_dcsbiosAircraftLuaLocation}{_dcsAircraft.LuaFilename}"); - ReadModuleFunctionSignatures(_dcsbiosModuleLuaFilePath); - } - } - catch (Exception ex) - { - throw new Exception($"{DCSBIOS_LUA_NOT_FOUND_ERROR_MESSAGE} ==>[{_jsonDirectory}]<=={Environment.NewLine}{ex.Message}{Environment.NewLine}{ex.StackTrace}"); - } - } - } -} diff --git a/src/DCSFPCommon b/src/DCSFPCommon new file mode 160000 index 000000000..122e1eacf --- /dev/null +++ b/src/DCSFPCommon @@ -0,0 +1 @@ +Subproject commit 122e1eacf47b52506a4b07059c8b8ee83d27caa8 diff --git a/src/DCSFlightpanels.sln b/src/DCSFlightpanels.sln index 8c1740c85..d50bcfdea 100644 --- a/src/DCSFlightpanels.sln +++ b/src/DCSFlightpanels.sln @@ -7,10 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DCSFlightpanels", "DCSFligh EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NonVisuals", "NonVisuals\NonVisuals.csproj", "{54C2DD8F-259C-41B7-94ED-88F51F698595}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DCS-BIOS", "DCS-BIOS\DCS-BIOS.csproj", "{6EF4492F-D4B4-42BC-B209-98783098DB22}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClassLibraryCommon", "ClassLibraryCommon\ClassLibraryCommon.csproj", "{66514CA6-6E8E-407C-8CFE-E108A95FEBC2}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SamplePanelEventPlugin1", "SamplePanelEventPlugin1\SamplePanelEventPlugin1.csproj", "{571773A4-3DDC-41CE-814E-A199A42F2FCC}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MEF", "MEF\MEF.csproj", "{0C0196B3-2442-4838-A587-C51660136F9C}" @@ -32,6 +28,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenMacroBoard.SDK", "OpenM EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StreamDeckSharp.Tests", "StreamDeckSharp.Tests\StreamDeckSharp.Tests.csproj", "{E889D653-43C1-4853-83B4-F405C393F355}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DCS-BIOS", "DCSFPCommon\src\DCS-BIOS\DCS-BIOS.csproj", "{35B2FB67-376A-454C-BDC5-BD6B1A32FEB2}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClassLibraryCommon", "DCSFPCommon\src\ClassLibraryCommon\ClassLibraryCommon.csproj", "{C28A2290-1FEC-477E-89F2-D3E0DE3D9421}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -66,30 +66,6 @@ Global {54C2DD8F-259C-41B7-94ED-88F51F698595}.Release|x64.Build.0 = Release|Any CPU {54C2DD8F-259C-41B7-94ED-88F51F698595}.Release|x86.ActiveCfg = Release|Any CPU {54C2DD8F-259C-41B7-94ED-88F51F698595}.Release|x86.Build.0 = Release|Any CPU - {6EF4492F-D4B4-42BC-B209-98783098DB22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6EF4492F-D4B4-42BC-B209-98783098DB22}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6EF4492F-D4B4-42BC-B209-98783098DB22}.Debug|x64.ActiveCfg = Debug|Any CPU - {6EF4492F-D4B4-42BC-B209-98783098DB22}.Debug|x64.Build.0 = Debug|Any CPU - {6EF4492F-D4B4-42BC-B209-98783098DB22}.Debug|x86.ActiveCfg = Debug|Any CPU - {6EF4492F-D4B4-42BC-B209-98783098DB22}.Debug|x86.Build.0 = Debug|Any CPU - {6EF4492F-D4B4-42BC-B209-98783098DB22}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6EF4492F-D4B4-42BC-B209-98783098DB22}.Release|Any CPU.Build.0 = Release|Any CPU - {6EF4492F-D4B4-42BC-B209-98783098DB22}.Release|x64.ActiveCfg = Release|Any CPU - {6EF4492F-D4B4-42BC-B209-98783098DB22}.Release|x64.Build.0 = Release|Any CPU - {6EF4492F-D4B4-42BC-B209-98783098DB22}.Release|x86.ActiveCfg = Release|Any CPU - {6EF4492F-D4B4-42BC-B209-98783098DB22}.Release|x86.Build.0 = Release|Any CPU - {66514CA6-6E8E-407C-8CFE-E108A95FEBC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {66514CA6-6E8E-407C-8CFE-E108A95FEBC2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {66514CA6-6E8E-407C-8CFE-E108A95FEBC2}.Debug|x64.ActiveCfg = Debug|Any CPU - {66514CA6-6E8E-407C-8CFE-E108A95FEBC2}.Debug|x64.Build.0 = Debug|Any CPU - {66514CA6-6E8E-407C-8CFE-E108A95FEBC2}.Debug|x86.ActiveCfg = Debug|Any CPU - {66514CA6-6E8E-407C-8CFE-E108A95FEBC2}.Debug|x86.Build.0 = Debug|Any CPU - {66514CA6-6E8E-407C-8CFE-E108A95FEBC2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {66514CA6-6E8E-407C-8CFE-E108A95FEBC2}.Release|Any CPU.Build.0 = Release|Any CPU - {66514CA6-6E8E-407C-8CFE-E108A95FEBC2}.Release|x64.ActiveCfg = Release|Any CPU - {66514CA6-6E8E-407C-8CFE-E108A95FEBC2}.Release|x64.Build.0 = Release|Any CPU - {66514CA6-6E8E-407C-8CFE-E108A95FEBC2}.Release|x86.ActiveCfg = Release|Any CPU - {66514CA6-6E8E-407C-8CFE-E108A95FEBC2}.Release|x86.Build.0 = Release|Any CPU {571773A4-3DDC-41CE-814E-A199A42F2FCC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {571773A4-3DDC-41CE-814E-A199A42F2FCC}.Debug|Any CPU.Build.0 = Debug|Any CPU {571773A4-3DDC-41CE-814E-A199A42F2FCC}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -186,6 +162,30 @@ Global {E889D653-43C1-4853-83B4-F405C393F355}.Release|x64.Build.0 = Release|Any CPU {E889D653-43C1-4853-83B4-F405C393F355}.Release|x86.ActiveCfg = Release|Any CPU {E889D653-43C1-4853-83B4-F405C393F355}.Release|x86.Build.0 = Release|Any CPU + {35B2FB67-376A-454C-BDC5-BD6B1A32FEB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {35B2FB67-376A-454C-BDC5-BD6B1A32FEB2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {35B2FB67-376A-454C-BDC5-BD6B1A32FEB2}.Debug|x64.ActiveCfg = Debug|Any CPU + {35B2FB67-376A-454C-BDC5-BD6B1A32FEB2}.Debug|x64.Build.0 = Debug|Any CPU + {35B2FB67-376A-454C-BDC5-BD6B1A32FEB2}.Debug|x86.ActiveCfg = Debug|Any CPU + {35B2FB67-376A-454C-BDC5-BD6B1A32FEB2}.Debug|x86.Build.0 = Debug|Any CPU + {35B2FB67-376A-454C-BDC5-BD6B1A32FEB2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {35B2FB67-376A-454C-BDC5-BD6B1A32FEB2}.Release|Any CPU.Build.0 = Release|Any CPU + {35B2FB67-376A-454C-BDC5-BD6B1A32FEB2}.Release|x64.ActiveCfg = Release|Any CPU + {35B2FB67-376A-454C-BDC5-BD6B1A32FEB2}.Release|x64.Build.0 = Release|Any CPU + {35B2FB67-376A-454C-BDC5-BD6B1A32FEB2}.Release|x86.ActiveCfg = Release|Any CPU + {35B2FB67-376A-454C-BDC5-BD6B1A32FEB2}.Release|x86.Build.0 = Release|Any CPU + {C28A2290-1FEC-477E-89F2-D3E0DE3D9421}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C28A2290-1FEC-477E-89F2-D3E0DE3D9421}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C28A2290-1FEC-477E-89F2-D3E0DE3D9421}.Debug|x64.ActiveCfg = Debug|Any CPU + {C28A2290-1FEC-477E-89F2-D3E0DE3D9421}.Debug|x64.Build.0 = Debug|Any CPU + {C28A2290-1FEC-477E-89F2-D3E0DE3D9421}.Debug|x86.ActiveCfg = Debug|Any CPU + {C28A2290-1FEC-477E-89F2-D3E0DE3D9421}.Debug|x86.Build.0 = Debug|Any CPU + {C28A2290-1FEC-477E-89F2-D3E0DE3D9421}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C28A2290-1FEC-477E-89F2-D3E0DE3D9421}.Release|Any CPU.Build.0 = Release|Any CPU + {C28A2290-1FEC-477E-89F2-D3E0DE3D9421}.Release|x64.ActiveCfg = Release|Any CPU + {C28A2290-1FEC-477E-89F2-D3E0DE3D9421}.Release|x64.Build.0 = Release|Any CPU + {C28A2290-1FEC-477E-89F2-D3E0DE3D9421}.Release|x86.ActiveCfg = Release|Any CPU + {C28A2290-1FEC-477E-89F2-D3E0DE3D9421}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/DCSFlightpanels/DCSFlightpanels.csproj b/src/DCSFlightpanels/DCSFlightpanels.csproj index e4e27c5d4..558e9128c 100644 --- a/src/DCSFlightpanels/DCSFlightpanels.csproj +++ b/src/DCSFlightpanels/DCSFlightpanels.csproj @@ -1,4 +1,4 @@ - + net6.0-windows en @@ -28,7 +28,7 @@ DCSFlightpanels (DCSFP) 1.0.0 - 4.11.8 + 4.11.9 Images\UI\flightpanels02_8Rc_icon.ico @@ -76,8 +76,8 @@ - - + + diff --git a/src/NonVisuals/NonVisuals.csproj b/src/NonVisuals/NonVisuals.csproj index 348288b5c..cd298e811 100644 --- a/src/NonVisuals/NonVisuals.csproj +++ b/src/NonVisuals/NonVisuals.csproj @@ -26,8 +26,8 @@ - - + + diff --git a/src/Tests/ClassLibraryCommon/CommonTests.cs b/src/Tests/ClassLibraryCommon/CommonTests.cs deleted file mode 100644 index 46efe35af..000000000 --- a/src/Tests/ClassLibraryCommon/CommonTests.cs +++ /dev/null @@ -1,145 +0,0 @@ -using System; -using System.Linq; -using ClassLibraryCommon; -using Xunit; - -namespace DCSFPTests.ClassLibraryCommon -{ - [Collection("Sequential")] // This uses EmulationMode - public class CommonTests - { - [Theory] - [InlineData("123", "123")] - [InlineData("123 ABCD", "123 ABCD")] - [InlineData("", "")] - [InlineData("RMENU + LCONTROL", "RMENU ")] - [InlineData("XxxX RMENU + LCONTROL YyY", "XxxX RMENU YyY")] - [InlineData("XxxXRMENU + LCONTROLYyY", "XxxXRMENU YyY")] - [InlineData("LCONTROL + RMENU", " RMENU")] - [InlineData("XxxX LCONTROL + RMENU YyY", "XxxX RMENU YyY")] - [InlineData("XxxXLCONTROL + RMENUYyY", "XxxX RMENUYyY")] - public void RemoveLControl_ShouldReturn_ExpectedString(string inputString, string expected) - { - Assert.Equal(expected, Common.RemoveLControl(inputString)); - } - - - [Theory] - [InlineData(@"\\testX", @"\\testX", @".\")] - [InlineData(@"\\testX\1", @"\\testX\1", @".\")] - [InlineData(@"\\testX", @"\\testY", @"file:\\testy\")] - [InlineData(@"\\testX\1", @"\\testY\1", @"file:\\testy\1")] - [InlineData(@"\\testX\1\2", @"\\testX\1", @"..\1")] - [InlineData(@"\\testX\1\2\3", @"\\testX\1", @"..\..\1")] - [InlineData(@"\\testX\1\2\3", @"\\testX\1\2", @"..\2")] - [InlineData(@"\\testX\1\2\3\", @"\\testX\1\2\", @"..\")] - [InlineData(@"\\testX\1\2\3", @"\\testX\1\2\", @".\")] - [InlineData(@"\\testX\1\2\3\", @"\\testX\1\2", @"..\..\2")] - [InlineData(@"\\testX\1\2\3\file.txt", @"\\testX\1\2\file.txt", @"..\file.txt")] - [InlineData(@"\\testX\1", @"\\testX\1\2", @"1\2")] - [InlineData(@"\\testX\1", @"\\testX\1\2\3", @"1\2\3")] - [InlineData(@"\\testX\1\2", @"\\testX\1\2\3", @"2\3")] - [InlineData(@"\\testX\1\2\file.txt", @"\\testX\1\2\3\file.txt", @"3\file.txt")] - public void GetRelativePath_ShouldReturn_ExpectedValue(string relativeTo, string path, string expected) - { - Assert.Equal(expected, Common.GetRelativePath(relativeTo, path)); - } - - [Fact] - public void EmulationModes_Set_ShouldSet_ExpectedValue() - { - try - { - Common.SetEmulationModes(EmulationMode.DCSBIOSInputEnabled); - Assert.Equal(1, Common.GetEmulationModesFlag()); - } - finally - { - Common.ResetEmulationModesFlag(); - Assert.Equal(0, Common.GetEmulationModesFlag()); - } - } - - [Fact] - private void EmulationModes_ResetStaticFlagValuesAfterTest() { - Common.ResetEmulationModesFlag(); //should always call reset after test 'cause static - Assert.Equal(0, Common.GetEmulationModesFlag()); - } - - [StaTheory] - [InlineData(new EmulationMode[] { - EmulationMode.DCSBIOSInputEnabled, - EmulationMode.DCSBIOSOutputEnabled }, 3)] - [InlineData(new EmulationMode[] { - EmulationMode.SRSEnabled, - EmulationMode.SRSEnabled }, 8)] - [InlineData(new EmulationMode[] { - EmulationMode.DCSBIOSInputEnabled, - EmulationMode.DCSBIOSOutputEnabled, - EmulationMode.SRSEnabled, - EmulationMode.NS430Enabled }, 27)] - public void EmulationModes_SetMultipleValue_ShouldSet_ExpectedValue(EmulationMode[] modes, int expectedValue) - { - try - { - Common.ResetEmulationModesFlag(); - modes.ToList().ForEach(x => Common.SetEmulationModes(x)); - Assert.Equal(expectedValue, Common.GetEmulationModesFlag()); - } - finally - { - EmulationModes_ResetStaticFlagValuesAfterTest(); - } - } - - [Theory] - [InlineData(new EmulationMode[] { - EmulationMode.KeyboardEmulationOnly, - EmulationMode.DCSBIOSOutputEnabled})] - [InlineData(new EmulationMode[] { - EmulationMode.KeyboardEmulationOnly, - EmulationMode.DCSBIOSInputEnabled})] - [InlineData(new EmulationMode[] { - EmulationMode.KeyboardEmulationOnly, - EmulationMode.DCSBIOSInputEnabled, - EmulationMode.DCSBIOSOutputEnabled,})] - public void EmulationModes_InvalidConfigs_Should_RaiseException(EmulationMode[] modes) - { - try - { - Assert.Throws( - () => modes.ToList().ForEach(x => Common.SetEmulationModes(x)) - ); - } - finally - { - EmulationModes_ResetStaticFlagValuesAfterTest(); - } - } - - [Theory] - //we want to remove SRSEnabled in those tests - [InlineData(new EmulationMode[] { - EmulationMode.DCSBIOSInputEnabled, - EmulationMode.DCSBIOSOutputEnabled, - EmulationMode.SRSEnabled, - EmulationMode.NS430Enabled }, 19)] - - [InlineData(new EmulationMode[] { - EmulationMode.SRSEnabled }, 0)] - public void EmulationModes_Clear_ShouldRemove_TheFlag(EmulationMode[] modes, int expectedValueAfterRemove) - { - try - { - modes.ToList().ForEach(x => Common.SetEmulationModes(x)); - Common.ClearEmulationModesFlag(EmulationMode.SRSEnabled); - Common.ClearEmulationModesFlag(EmulationMode.SRSEnabled); //A double clear should not affect result - Assert.Equal(expectedValueAfterRemove, Common.GetEmulationModesFlag()); - } - finally - { - EmulationModes_ResetStaticFlagValuesAfterTest(); - } - } - } -} diff --git a/src/Tests/DCSFPTests.csproj b/src/Tests/DCSFPTests.csproj index 2b8ce0b01..c21cacd38 100644 --- a/src/Tests/DCSFPTests.csproj +++ b/src/Tests/DCSFPTests.csproj @@ -34,7 +34,6 @@ - diff --git a/src/Tests/DcsBios/DCSBIOSControlLocatorTests.cs b/src/Tests/DcsBios/DCSBIOSControlLocatorTests.cs deleted file mode 100644 index ff5d73940..000000000 --- a/src/Tests/DcsBios/DCSBIOSControlLocatorTests.cs +++ /dev/null @@ -1,249 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using ClassLibraryCommon; -using DCS_BIOS.ControlLocator; -using DCS_BIOS.Serialized; -using Xunit; - -namespace DCSFPTests.DcsBios -{ - [Collection("Sequential")] // This uses EmulationMode - public class DCSBIOSControlLocatorTests - { - private readonly string _dcsbiosPath = Environment.ExpandEnvironmentVariables(@"%USERPROFILE%\Saved Games\DCS\Scripts\DCS-BIOS\doc\json"); - - private bool SetBaseParameters() - { - // !! Invalid path logs to error log but doesn't throw exception to the outside - if (!Directory.Exists(_dcsbiosPath)) - { - //No need to test as dcs-bios isn't installed - return false; - } - - DCSBIOSControlLocator.JSONDirectory = _dcsbiosPath; - Common.ResetEmulationModesFlag(); - - return true; - } - - private bool SetBaseParameters(int dcsAircraftId) - { - // !! Invalid path logs to error log but doesn't throw exception to the outside - if (!Directory.Exists(_dcsbiosPath)) - { - //No need to test as dcs-bios isn't installed - return false; - } - - DCSAircraft.FillModulesListFromDcsBios(_dcsbiosPath, true); - var dcsAircraft = DCSAircraft.GetAircraft(dcsAircraftId); - - DCSBIOSControlLocator.DCSAircraft = dcsAircraft; - DCSBIOSControlLocator.JSONDirectory = _dcsbiosPath; - Common.ResetEmulationModesFlag(); - - return true; - } - - [Theory] - [InlineData("ARC210_25KHZ_SEL", 5)] // A-10C Thunderbolt/II - public void GetControlWithValidJSONPath(string dcsbiosControlId, int dcsAircraftId) - { - if (!SetBaseParameters(dcsAircraftId)) return; - - var dcsbiosControl = DCSBIOSControlLocator.GetControl(dcsbiosControlId); - - Assert.Equal(dcsbiosControlId, dcsbiosControl.Identifier); - } - - [Theory] - [InlineData("NO_CONTROL_WITH_THIS_ID", 5)] // A-10C Thunderbolt/II - public void GetControlUsingInvalidControlIdentifierShouldThrow(string dcsbiosControlId, int dcsAircraftId) - { - if (!SetBaseParameters(dcsAircraftId)) return; - - Assert.Throws(() => DCSBIOSControlLocator.GetControl(dcsbiosControlId)); - } - - [Theory] - [InlineData("ARC210_25KHZ_SEL", 5)] // A-10C Thunderbolt/II - public void GetControlWithKeyEmulationSet(string dcsbiosControlId, int dcsAircraftId) - { - if (!SetBaseParameters(dcsAircraftId)) return; - - // Since key emulation is set DCSBIOSControlLocator shouldn't return any controls. - Common.SetEmulationModes(EmulationMode.KeyboardEmulationOnly); - - var control = DCSBIOSControlLocator.GetControl(dcsbiosControlId); - Assert.Null(control); - } - - [Theory] - [InlineData(DCSBiosOutputType.IntegerType, 5, "ARC210_25KHZ_SEL")] - [InlineData(DCSBiosOutputType.StringType, 5, "ARC210_25KHZ_SEL")] - public void GetDCSBIOSOutputBasedOnOutputTypeWithValidInputs(DCSBiosOutputType dcsBiosOutputType, int dcsAircraftId, string dcsbiosControlId) - { - if (!SetBaseParameters(dcsAircraftId)) return; - - var dcsbiosOutput = DCSBIOSControlLocator.GetDCSBIOSOutput(dcsbiosControlId, dcsBiosOutputType); - - Assert.Equal(dcsBiosOutputType, dcsbiosOutput.DCSBiosOutputType); - } - - [Theory] - [InlineData("NO_SUCH_CONTROL_ID", DCSBiosOutputType.IntegerType, 5)] - [InlineData("NO_SUCH_CONTROL_ID", DCSBiosOutputType.StringType, 5)] - public void GetDCSBIOSOutputUsingInvalidControlIdentifierShouldThrow(string dcsbiosControlId, DCSBiosOutputType dcsBiosOutputType, int dcsAircraftId) - { - if (!SetBaseParameters(dcsAircraftId)) return; - - Assert.Throws(() => DCSBIOSControlLocator.GetDCSBIOSOutput(dcsbiosControlId, dcsBiosOutputType)); - } - - [Theory] - [InlineData(DCSBiosOutputType.IntegerType, "ARC210_25KHZ_SEL", 5)] - [InlineData(DCSBiosOutputType.StringType, "ARC210_25KHZ_SEL", 5)] - public void GetDCSBIOSOutputPerOutputTypeUsingValidControlIdentifier(DCSBiosOutputType dcsBiosOutputType, string dcsbiosControlId, int dcsAircraftId) - { - if (!SetBaseParameters(dcsAircraftId)) return; - - var dcsbiosOutput = dcsBiosOutputType switch - { - DCSBiosOutputType.IntegerType => DCSBIOSControlLocator.GetUIntDCSBIOSOutput(dcsbiosControlId), - DCSBiosOutputType.StringType => DCSBIOSControlLocator.GetStringDCSBIOSOutput(dcsbiosControlId), - _ => null - }; - - Assert.NotNull(dcsbiosOutput); - Assert.Equal(dcsBiosOutputType, dcsbiosOutput.DCSBiosOutputType); - } - - [Theory] - [InlineData("NO_SUCH_CONTROL_ID", DCSBiosOutputType.IntegerType, 5)] - [InlineData("NO_SUCH_CONTROL_ID", DCSBiosOutputType.StringType, 5)] - public void GetDCSBIOSOutputPerOutputTypeUsingInvalidControlIdentifierShouldThrow(string dcsbiosControlId, DCSBiosOutputType dcsBiosOutputType, int dcsAircraftId) - { - if (!SetBaseParameters(dcsAircraftId)) return; - - switch (dcsBiosOutputType) - { - case DCSBiosOutputType.IntegerType: - Assert.Throws(() => DCSBIOSControlLocator.GetUIntDCSBIOSOutput(dcsbiosControlId)); - break; - case DCSBiosOutputType.StringType: - Assert.Throws(() => DCSBIOSControlLocator.GetStringDCSBIOSOutput(dcsbiosControlId)); - break; - } - } - - [Theory] - [InlineData("A-10C.json")] - public void GetModuleControlsFromJson(string filename) - { - if (!SetBaseParameters()) return; - - var controls = DCSBIOSControlLocator.GetModuleControlsFromJson(filename); - - Assert.NotNull(controls); - Assert.NotEmpty(controls); - } - - [Theory] - [InlineData("LON_SEC_FRAC")] // CommonData - [InlineData("_ACFT_NAME")] // MetaDataStart - [InlineData("_UPDATE_COUNTER")] // MetaDataEnd - public void GetMetaControls(string controlId) - { - if (!SetBaseParameters()) return; - - var controls = DCSBIOSControlLocator.GetMetaControls(); - - Assert.Single(controls.Where(o => o.Identifier == controlId)); - } - - [Theory] - [InlineData(DCSBiosOutputType.IntegerType, 5)] - [InlineData(DCSBiosOutputType.StringType, 5)] - public void GetOutputControls(DCSBiosOutputType dcsBiosOutputType, int dcsAircraftId) - { - if (!SetBaseParameters(dcsAircraftId)) return; - Common.SetEmulationModes(EmulationMode.DCSBIOSOutputEnabled); - - var controls = DCSBIOSControlLocator.GetOutputControls(dcsBiosOutputType); - foreach (var dcsbiosControl in controls) - { - var count = dcsbiosControl.Outputs.Count(o => o.OutputDataType == dcsBiosOutputType); - Assert.True(count > 0); - } - } - - [Theory] - [InlineData(DCSBiosOutputType.IntegerType, 5)] - [InlineData(DCSBiosOutputType.StringType, 5)] - public void GetOutputControlsDCSBIOSOutputEnabledFlagNotSet(DCSBiosOutputType dcsBiosOutputType, int dcsAircraftId) - { - if (!SetBaseParameters(dcsAircraftId)) return; - // Since Flag DCSBIOSOutputEnabled is not set DCSBIOSControlLocator returns null. - - var controls = DCSBIOSControlLocator.GetOutputControls(dcsBiosOutputType); - Assert.Null(controls); - } - - [Theory] - [InlineData(5)] - public void GetInputControls(int dcsAircraftId) - { - if (!SetBaseParameters(dcsAircraftId)) return; - Common.SetEmulationModes(EmulationMode.DCSBIOSInputEnabled); - - var controls = DCSBIOSControlLocator.GetInputControls(); - foreach (var dcsbiosControl in controls) - { - var count = dcsbiosControl.Inputs.Count; - Assert.True(count > 0); - - } - } - - [Theory] - [InlineData(5)] - public void GetOutputControlsDCSBIOSInputEnabledFlagNotSet(int dcsAircraftId) - { - if (!SetBaseParameters(dcsAircraftId)) return; - // Since Flag DCSBIOSInputEnabled is not set DCSBIOSControlLocator returns null. - - var controls = DCSBIOSControlLocator.GetInputControls(); - Assert.Null(controls); - } - - [Theory] - [InlineData("FLAPS_SWITCH", 5)] - [InlineData("SASP_MONITOR_TEST", 5)] - [InlineData("UFC_10", 5)] - public void GetLuaCommand(string controlId, int dcsAircraftId) - { - if (!SetBaseParameters(dcsAircraftId)) return; - Common.SetEmulationModes(EmulationMode.DCSBIOSInputEnabled); - - var luaCommand = DCSBIOSControlLocator.GetLuaCommand(controlId, false); - Assert.False(string.IsNullOrEmpty(luaCommand)); - - luaCommand = DCSBIOSControlLocator.GetLuaCommand(controlId, true); - Assert.False(string.IsNullOrEmpty(luaCommand)); - } - - [Theory] - [InlineData("NO_SUCH_CONTROL_ID", 5)] - public void GetLuaCommandWithInvalidControlIdentifier(string controlId, int dcsAircraftId) - { - if (!SetBaseParameters(dcsAircraftId)) return; - Common.SetEmulationModes(EmulationMode.DCSBIOSInputEnabled); - - var luaCommand = DCSBIOSControlLocator.GetLuaCommand(controlId, false); - Assert.True(string.IsNullOrEmpty(luaCommand)); - } - - } -} diff --git a/src/Tests/DcsBios/DCSBIOSInputInterfaceTests.cs b/src/Tests/DcsBios/DCSBIOSInputInterfaceTests.cs deleted file mode 100644 index 68ff3b1c9..000000000 --- a/src/Tests/DcsBios/DCSBIOSInputInterfaceTests.cs +++ /dev/null @@ -1,163 +0,0 @@ -using System; -using DCS_BIOS.Json; -using DCS_BIOS.Serialized; -using Xunit; - -namespace DCSFPTests.DcsBios -{ - public class DCSBIOSInputInterfaceTests - { - [Theory] - [InlineData("fixed_step", DCSBIOSInputType.FIXED_STEP)] - [InlineData("set_state", DCSBIOSInputType.SET_STATE)] - [InlineData("action", DCSBIOSInputType.ACTION)] - [InlineData("variable_step", DCSBIOSInputType.VARIABLE_STEP)] - [InlineData("set_string", DCSBIOSInputType.SET_STRING)] - public void Consume_ShouldSet_4_Properties(string givenControlInterface, DCSBIOSInputType expectedDCSBIOSInputType) - { - string controlId = "ThisIsAControlId"; - DCSBIOSControlInput controlInput = new() - { - Description = "Test", - ControlInterface = givenControlInterface, - MaxValue = 666, - Argument = "ThisIsAnArgument" - }; - DCSBIOSInputInterface inputInterface = new(); - inputInterface.Consume(controlId, controlInput); - - Assert.Equal(controlId, inputInterface.ControlId); - Assert.Equal(controlInput.Description, inputInterface.Description); - Assert.Equal(expectedDCSBIOSInputType, inputInterface.Interface); - Assert.Equal(controlInput.Argument, inputInterface.SpecifiedActionArgument); - } - - [Theory] - [InlineData("ThisIsAControlId", DCSBIOSFixedStepInput.INC, "ThisIsAControlId INC\n")] - [InlineData("ThisIsAControlId", DCSBIOSFixedStepInput.DEC, "ThisIsAControlId DEC\n")] - [InlineData("ThisIsAControlId", null, "ThisIsAControlId INC\n")] - [InlineData("", DCSBIOSFixedStepInput.DEC, " DEC\n")] - [InlineData(null, DCSBIOSFixedStepInput.DEC, " DEC\n")] - [InlineData(null, null, " INC\n")] - public void GetDCSBIOSCommand_FixedStep_ShouldReturn_ExpectedResult(string controlId, DCSBIOSFixedStepInput? specifiedFixedStepArgument, string expectedResult) { - DCSBIOSInputInterface inputInterface = new() - { - ControlId = controlId, - Interface = DCSBIOSInputType.FIXED_STEP - }; - if (specifiedFixedStepArgument != null) - inputInterface.SpecifiedFixedStepArgument = (DCSBIOSFixedStepInput)specifiedFixedStepArgument; - - Assert.Equal(expectedResult, inputInterface.GetDCSBIOSCommand()); - } - - [Theory] - [InlineData("ThisIsAControlId", (uint)123, "ThisIsAControlId 123\n")] - [InlineData("ThisIsAControlId", (uint)456, "ThisIsAControlId 456\n")] - [InlineData("ThisIsAControlId", null, "ThisIsAControlId 0\n")] - [InlineData("", (uint)789, " 789\n")] - [InlineData("", null, " 0\n")] - [InlineData(null, null, " 0\n")] - public void GetDCSBIOSCommand_SetState_ShouldReturn_ExpectedResult(string controlId, uint? specifiedSetStateArgument, string expectedResult) - { - DCSBIOSInputInterface inputInterface = new() - { - ControlId = controlId, - Interface = DCSBIOSInputType.SET_STATE - }; - if (specifiedSetStateArgument != null) - inputInterface.SpecifiedSetStateArgument = (uint)specifiedSetStateArgument; - - Assert.Equal(expectedResult, inputInterface.GetDCSBIOSCommand()); - } - - [Theory] - [InlineData("ThisIsAControlId", "AbC", "ThisIsAControlId AbC\n")] - [InlineData("ThisIsAControlId", "", "ThisIsAControlId \n")] - [InlineData("ThisIsAControlId", null, "ThisIsAControlId \n")] - [InlineData("", "AbC", " AbC\n")] - [InlineData(null, "AbC", " AbC\n")] - //[InlineData("", "", " \n")] - //[InlineData("", null, " 0\n")] - public void GetDCSBIOSCommand_Action_ShouldReturn_ExpectedResult(string controlId, string specifiedActionArgument, string expectedResult) - { - DCSBIOSInputInterface inputInterface = new() - { - ControlId = controlId, - Interface = DCSBIOSInputType.ACTION, - SpecifiedActionArgument = specifiedActionArgument - }; - - Assert.Equal(expectedResult, inputInterface.GetDCSBIOSCommand()); - } - - [Theory] - [InlineData("ThisIsAControlId", 1, "ThisIsAControlId +1\n")] - [InlineData("ThisIsAControlId", 0, "ThisIsAControlId 0\n")] - [InlineData("ThisIsAControlId", -1, "ThisIsAControlId -1\n")] - [InlineData("ThisIsAControlId", 123, "ThisIsAControlId +123\n")] - [InlineData("ThisIsAControlId", 456, "ThisIsAControlId +456\n")] - [InlineData("ThisIsAControlId", -123, "ThisIsAControlId -123\n")] - [InlineData("ThisIsAControlId", null, "ThisIsAControlId 0\n")] - [InlineData("", 789, " +789\n")] - [InlineData("", null, " 0\n")] - [InlineData(null, null, " 0\n")] - public void GetDCSBIOSCommand_VariableStep_ShouldReturn_ExpectedResult(string controlId, int? specifiedVariableStepArgument, string expectedResult) - { - DCSBIOSInputInterface inputInterface = new() - { - ControlId = controlId, - Interface = DCSBIOSInputType.VARIABLE_STEP - }; - if (specifiedVariableStepArgument != null) - inputInterface.SpecifiedVariableStepArgument = (int)specifiedVariableStepArgument; - - Assert.Equal(expectedResult, inputInterface.GetDCSBIOSCommand()); - } - - [Fact] - public void GetDCSBIOSCommand_WithoutAnyPropertiesSet_ReturnsDefaultValueOfFixedStep() - { - DCSBIOSInputInterface inputInterface = new(); - Assert.Equal(" INC\n", inputInterface.GetDCSBIOSCommand()); - } - - [Theory] - [InlineData("", "", DCSBIOSInputType.ACTION)] - [InlineData("", null, DCSBIOSInputType.ACTION)] - public void GetDCSBIOSCommand_ShouldThrowException_InThoseCases(string controlId, object argument, DCSBIOSInputType? inputType) - { - DCSBIOSInputInterface inputInterface = new() - { - ControlId = controlId, - }; - - if (inputType == DCSBIOSInputType.ACTION) - { - inputInterface.SpecifiedActionArgument = (string)argument; - inputInterface.Interface = DCSBIOSInputType.ACTION; - } - Assert.Throws(() => inputInterface.GetDCSBIOSCommand()); - } - - [Theory] - [InlineData("ThisIsAControlId", "1", "ThisIsAControlId 1\n")] - [InlineData("ThisIsAControlId", "0", "ThisIsAControlId 0\n")] - [InlineData("ThisIsAControlId", "-1", "ThisIsAControlId -1\n")] - [InlineData("ThisIsAControlId", "123", "ThisIsAControlId 123\n")] - [InlineData("ThisIsAControlId", "456", "ThisIsAControlId 456\n")] - [InlineData("ThisIsAControlId", "-123", "ThisIsAControlId -123\n")] - [InlineData("ThisIsAControlId", "null", "ThisIsAControlId null\n")] - public void GetDCSBIOSCommand_Set_String_ShouldReturn_ExpectedResult(string controlId, string specifiedStringArgument, string expectedResult) - { - DCSBIOSInputInterface inputInterface = new() - { - ControlId = controlId, - Interface = DCSBIOSInputType.SET_STRING, - SpecifiedSetStringArgument = specifiedStringArgument - }; - - Assert.Equal(expectedResult, inputInterface.GetDCSBIOSCommand()); - } - } -} diff --git a/src/Tests/DcsBios/DCSBIOSInputTests.cs b/src/Tests/DcsBios/DCSBIOSInputTests.cs deleted file mode 100644 index 1616da441..000000000 --- a/src/Tests/DcsBios/DCSBIOSInputTests.cs +++ /dev/null @@ -1,129 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using ClassLibraryCommon; -using DCS_BIOS.ControlLocator; -using DCS_BIOS.Json; -using DCS_BIOS.Serialized; -using Xunit; - -namespace DCSFPTests.DcsBios -{ - [Collection("Sequential")] - public class DCSBIOSInputTests - { - private readonly string _dcsbiosPath = Environment.ExpandEnvironmentVariables(@"%USERPROFILE%\Saved Games\DCS\Scripts\DCS-BIOS\doc\json"); - - private bool SetBaseParameters() - { - // !! Invalid path logs to error log but doesn't throw exception to the outside - if (!Directory.Exists(_dcsbiosPath)) - { - //No need to test as dcs-bios isn't installed - return false; - } - - DCSBIOSControlLocator.JSONDirectory = _dcsbiosPath; - Common.ResetEmulationModesFlag(); - - return true; - } - - private bool SetBaseParameters(int dcsAircraftId) - { - // !! Invalid path logs to error log but doesn't throw exception to the outside - if (!Directory.Exists(_dcsbiosPath)) - { - //No need to test as dcs-bios isn't installed - return false; - } - - DCSAircraft.FillModulesListFromDcsBios(_dcsbiosPath, true); - var dcsAircraft = DCSAircraft.GetAircraft(dcsAircraftId); - - DCSBIOSControlLocator.DCSAircraft = dcsAircraft; - DCSBIOSControlLocator.JSONDirectory = _dcsbiosPath; - Common.ResetEmulationModesFlag(); - - return true; - } - - [Theory] - [InlineData("ARC210_25KHZ_SEL", 5)] // A-10C Thunderbolt/II - [InlineData("FLAPS_SWITCH", 5)] - [InlineData("UFC_1", 5)] - public void Consume(string dcsbiosControlId, int dcsAircraftId) - { - if (!SetBaseParameters(dcsAircraftId)) return; - - var dcsbiosControl = DCSBIOSControlLocator.GetControl(dcsbiosControlId); - var dcsbiosInput = new DCSBIOSInput(); - dcsbiosInput.Consume(dcsbiosControl); - Assert.Equal(dcsbiosInput.DCSBIOSInputInterfaces.Count, dcsbiosControl.Inputs.Count); - } - - [Theory] - [InlineData(DCSBIOSInputType.ACTION, 5, "OXY_SUPPLY")] // A-10C Thunderbolt/II - [InlineData(DCSBIOSInputType.FIXED_STEP, 5, "FLAPS_SWITCH")] - [InlineData(DCSBIOSInputType.SET_STATE, 5, "UFC_1")] - [InlineData(DCSBIOSInputType.VARIABLE_STEP, 5, "ENGINE_THROTTLE_FRICTION")] - [InlineData(DCSBIOSInputType.SET_STRING, 38, "UHF_ARC51")] // UH-1H Huey - public void SetSelectedInputInterface(DCSBIOSInputType dcsbiosInputType, int dcsAircraftId, string dcsbiosControlId) - { - if (!SetBaseParameters(dcsAircraftId)) return; - - var dcsbiosControl = DCSBIOSControlLocator.GetControl(dcsbiosControlId); - var dcsbiosInput = new DCSBIOSInput(); - dcsbiosInput.Consume(dcsbiosControl); - dcsbiosInput.SetSelectedInterface(dcsbiosInputType); - Assert.Equal(dcsbiosInputType, dcsbiosInput.SelectedDCSBIOSInterface.Interface); - } - - [Theory] - [InlineData("Toggle switch state", 5, "OXY_SUPPLY", DCSBIOSInputType.ACTION)] // A-10C Thunderbolt/II - [InlineData("switch to previous or next state", 5, "FLAPS_SWITCH", DCSBIOSInputType.FIXED_STEP)] - [InlineData("set position", 5, "UFC_1", DCSBIOSInputType.SET_STATE)] - [InlineData("turn the dial left or right", 5, "ENGINE_THROTTLE_FRICTION", DCSBIOSInputType.VARIABLE_STEP)] - [InlineData("The frequency to set, with or without a decimal place", 38, "UHF_ARC51", DCSBIOSInputType.SET_STRING)] // UH-1H Huey - public void GetDescriptionForInterface(string description, int dcsAircraftId, string dcsbiosControlId, DCSBIOSInputType dcsbiosInputType) - { - if (!SetBaseParameters(dcsAircraftId)) return; - - var dcsbiosControl = DCSBIOSControlLocator.GetControl(dcsbiosControlId); - var dcsbiosInput = new DCSBIOSInput(); - dcsbiosInput.Consume(dcsbiosControl); - - Assert.Equal(description, dcsbiosInput.GetDescriptionForInterface(dcsbiosInputType)); - } - - [Theory] - [InlineData(0, 5, "OXY_SUPPLY", DCSBIOSInputType.ACTION)] // A-10C Thunderbolt/II - [InlineData(0, 5, "FLAPS_SWITCH", DCSBIOSInputType.FIXED_STEP)] - [InlineData(65535, 5, "TACAN_VOL", DCSBIOSInputType.SET_STATE)] - [InlineData(65535, 5, "ENGINE_THROTTLE_FRICTION", DCSBIOSInputType.VARIABLE_STEP)] - public void GetMaxValueInterface(int maxValue, int dcsAircraftId, string dcsbiosControlId, DCSBIOSInputType dcsbiosInputType) - { - if (!SetBaseParameters(dcsAircraftId)) return; - - var dcsbiosControl = DCSBIOSControlLocator.GetControl(dcsbiosControlId); - var dcsbiosInput = new DCSBIOSInput(); - dcsbiosInput.Consume(dcsbiosControl); - - Assert.Equal(maxValue, dcsbiosInput.GetMaxValueForInterface(dcsbiosInputType)); - } - - [Theory] - [InlineData("DCSBIOSInput{FLAPS_SWITCH|SET_STATE|0|0}", 5)] - [InlineData("DCSBIOSInput{FLAPS_SWITCH|FIXED_STEP|INC|2000}", 5)] - [InlineData("DCSBIOSInput{ENGINE_THROTTLE_FRICTION|VARIABLE_STEP|-1000|0}", 5)] - public void TestImportExportBindingSetting(string bindingCode, int dcsAircraftId) - { - if (!SetBaseParameters(dcsAircraftId)) return; - - var dcsbiosInput = new DCSBIOSInput(); - dcsbiosInput.ImportString(bindingCode); - - Assert.Equal(bindingCode, dcsbiosInput.ToString()); - } - } -} diff --git a/src/Tests/DcsBios/DCSBIOSOutputTests.cs b/src/Tests/DcsBios/DCSBIOSOutputTests.cs deleted file mode 100644 index f6480cbc0..000000000 --- a/src/Tests/DcsBios/DCSBIOSOutputTests.cs +++ /dev/null @@ -1,185 +0,0 @@ -using DCS_BIOS.Serialized; -using System; -using Xunit; - -namespace DCSFPTests.DcsBios -{ - public class DCSBIOSOutputTests - { - - [Theory] - [InlineData((uint)100, DCSBiosOutputComparison.BiggerThan, (uint)99, true)] - [InlineData((uint)99, DCSBiosOutputComparison.BiggerThan, (uint)100, false)] - [InlineData((uint)123455, DCSBiosOutputComparison.BiggerThan, (uint)123456, false)] - [InlineData((uint)100, DCSBiosOutputComparison.BiggerThan, (uint)100, false)] - - [InlineData((uint)100, DCSBiosOutputComparison.LessThan, (uint)99, false)] - [InlineData((uint)99, DCSBiosOutputComparison.LessThan, (uint)100, true)] - [InlineData((uint)123455, DCSBiosOutputComparison.LessThan, (uint)123456, true)] - [InlineData((uint)100, DCSBiosOutputComparison.LessThan, (uint)100, false)] - - [InlineData((uint)100, DCSBiosOutputComparison.Equals, (uint)99, false)] - [InlineData((uint)99, DCSBiosOutputComparison.Equals, (uint)100, false)] - [InlineData((uint)123455, DCSBiosOutputComparison.Equals, (uint)123456, false)] - [InlineData((uint)100, DCSBiosOutputComparison.Equals, (uint)100, true)] - - [InlineData((uint)100, DCSBiosOutputComparison.NotEquals, (uint)99, true)] - [InlineData((uint)99, DCSBiosOutputComparison.NotEquals, (uint)100, true)] - [InlineData((uint)123455, DCSBiosOutputComparison.NotEquals, (uint)123456, true)] - [InlineData((uint)100, DCSBiosOutputComparison.NotEquals, (uint)100, false)] - public void CheckForValueMatch_WithUint(uint valueToCompare, DCSBiosOutputComparison comparisonType, uint OriginalValue, bool expectedResult) - { - DCSBIOSOutput dcsOutput = new() - { - Address = 99, - DCSBiosOutputType = DCSBiosOutputType.IntegerType, - Mask = valueToCompare, - SpecifiedValueUInt = OriginalValue, - DCSBiosOutputComparison = comparisonType, - }; - - Assert.Equal(expectedResult, dcsOutput.UIntConditionIsMet(99, valueToCompare)); - } - - [Theory] - [InlineData("AbC", "AbC", false)] - [InlineData("AbC", "ABC", true)] - [InlineData("ABC", "AbC", true)] - [InlineData("AbC", "DeF", true)] - [InlineData("(-Something Ugly&£µLike That%$^)- ", "(-Something Ugly&£µLike That%$^)- ", false)] - [InlineData("", "", false)] - - public void CheckIfValueHasChanged_WithString(string valueToCompare, string originalValue, bool expectedResult) - { - DCSBIOSOutput dcsOutput = new() - { - Address = 99, - DCSBiosOutputType = DCSBiosOutputType.StringType, - LastStringValue = originalValue, //should set DCSBiosOutputType before assign ! - }; - - Assert.Equal(expectedResult, dcsOutput.StringValueHasChanged(99, valueToCompare)); - } - - [Theory] - [InlineData((uint)100, DCSBiosOutputComparison.BiggerThan, (uint)99, true)] - [InlineData((uint)99, DCSBiosOutputComparison.BiggerThan, (uint)100, false)] - [InlineData((uint)123455, DCSBiosOutputComparison.BiggerThan, (uint)123456, false)] - [InlineData((uint)100, DCSBiosOutputComparison.BiggerThan, (uint)100, false)] - - [InlineData((uint)100, DCSBiosOutputComparison.LessThan, (uint)99, false)] - [InlineData((uint)99, DCSBiosOutputComparison.LessThan, (uint)100, true)] - [InlineData((uint)123455, DCSBiosOutputComparison.LessThan, (uint)123456, true)] - [InlineData((uint)100, DCSBiosOutputComparison.LessThan, (uint)100, false)] - - [InlineData((uint)100, DCSBiosOutputComparison.Equals, (uint)99, false)] - [InlineData((uint)99, DCSBiosOutputComparison.Equals, (uint)100, false)] - [InlineData((uint)123455, DCSBiosOutputComparison.Equals, (uint)123456, false)] - [InlineData((uint)100, DCSBiosOutputComparison.Equals, (uint)100, false)] //<-- ?? != compared to CheckForValueMatch_WithUint - - [InlineData((uint)100, DCSBiosOutputComparison.NotEquals, (uint)99, true)] - [InlineData((uint)99, DCSBiosOutputComparison.NotEquals, (uint)100, true)] - [InlineData((uint)123455, DCSBiosOutputComparison.NotEquals, (uint)123456, true)] - [InlineData((uint)100, DCSBiosOutputComparison.NotEquals, (uint)100, false)] - public void CheckForValueMatchAndChange_WithUint_LastIntValue_Is_OriginalValue(uint valueToCompare, DCSBiosOutputComparison comparisonType, uint OriginalValue, bool expectedResult) - { - DCSBIOSOutput dcsOutput = new() - { - Address = 99, - DCSBiosOutputType = DCSBiosOutputType.IntegerType, - Mask = valueToCompare, - SpecifiedValueUInt = OriginalValue, - DCSBiosOutputComparison = comparisonType, - LastUIntValue = OriginalValue, //<-- != compared to CheckForValueMatch_WithUint - }; - - Assert.Equal(expectedResult, dcsOutput.UIntConditionIsMet(99, valueToCompare)); - Assert.Equal(valueToCompare, dcsOutput.LastUIntValue); - } - - [Theory] - [InlineData((uint)100, DCSBiosOutputComparison.BiggerThan, (uint)99)] - [InlineData((uint)99, DCSBiosOutputComparison.BiggerThan, (uint)100)] - [InlineData((uint)123455, DCSBiosOutputComparison.BiggerThan, (uint)123456)] - [InlineData((uint)100, DCSBiosOutputComparison.BiggerThan, (uint)100)] - - [InlineData((uint)100, DCSBiosOutputComparison.LessThan, (uint)99)] - [InlineData((uint)99, DCSBiosOutputComparison.LessThan, (uint)100)] - [InlineData((uint)123455, DCSBiosOutputComparison.LessThan, (uint)123456)] - [InlineData((uint)100, DCSBiosOutputComparison.LessThan, (uint)100)] - - [InlineData((uint)100, DCSBiosOutputComparison.Equals, (uint)99)] - [InlineData((uint)99, DCSBiosOutputComparison.Equals, (uint)100)] - [InlineData((uint)123455, DCSBiosOutputComparison.Equals, (uint)123456)] - [InlineData((uint)100, DCSBiosOutputComparison.Equals, (uint)100)] - - [InlineData((uint)100, DCSBiosOutputComparison.NotEquals, (uint)99)] - [InlineData((uint)99, DCSBiosOutputComparison.NotEquals, (uint)100)] - [InlineData((uint)123455, DCSBiosOutputComparison.NotEquals, (uint)123456)] - [InlineData((uint)100, DCSBiosOutputComparison.NotEquals, (uint)100)] - public void CheckForValueMatchAndChange_WithUint_LastIntValue_Is_ValueToCompare(uint valueToCompare, DCSBiosOutputComparison comparisonType, uint OriginalValue) - { - DCSBIOSOutput dcsOutput = new() - { - Address = 99, - DCSBiosOutputType = DCSBiosOutputType.IntegerType, - Mask = valueToCompare, - SpecifiedValueUInt = OriginalValue, - DCSBiosOutputComparison = comparisonType, - LastUIntValue = valueToCompare, //<-- != compared to CheckForValueMatch_WithUint - }; - //always returns false - Assert.False(dcsOutput.UIntConditionIsMet(99, valueToCompare)); - Assert.Equal(valueToCompare, dcsOutput.LastUIntValue); - } - - [Theory] - [InlineData((uint)100, DCSBiosOutputComparison.BiggerThan, (uint)99, (uint)1, true)] - [InlineData((uint)99, DCSBiosOutputComparison.BiggerThan, (uint)100, (uint)5, false)] - [InlineData((uint)123455, DCSBiosOutputComparison.BiggerThan, (uint)123456, (uint)8, false)] - [InlineData((uint)100, DCSBiosOutputComparison.BiggerThan, (uint)100, (uint)555, false)] - - [InlineData((uint)100, DCSBiosOutputComparison.LessThan, (uint)99, (uint)9991, false)] - [InlineData((uint)99, DCSBiosOutputComparison.LessThan, (uint)100, (uint)231, true)] - [InlineData((uint)123455, DCSBiosOutputComparison.LessThan, (uint)123456, (uint)1, true)] - [InlineData((uint)100, DCSBiosOutputComparison.LessThan, (uint)100, (uint)0, false)] - - [InlineData((uint)100, DCSBiosOutputComparison.Equals, (uint)99, (uint)888, false)] - [InlineData((uint)99, DCSBiosOutputComparison.Equals, (uint)100, (uint)789, false)] - [InlineData((uint)123455, DCSBiosOutputComparison.Equals, (uint)123456, (uint)12, false)] - [InlineData((uint)100, DCSBiosOutputComparison.Equals, (uint)100, (uint)99, true)] //<-- != compared to CheckForValueMatch_WithUint - [InlineData((uint)100, DCSBiosOutputComparison.Equals, (uint)100, (uint)101, true)] //<-- != compared to CheckForValueMatch_WithUint - - [InlineData((uint)100, DCSBiosOutputComparison.NotEquals, (uint)99, (uint)78121, true)] - [InlineData((uint)99, DCSBiosOutputComparison.NotEquals, (uint)100, (uint)111, true)] - [InlineData((uint)123455, DCSBiosOutputComparison.NotEquals, (uint)123456, (uint)2, true)] - [InlineData((uint)100, DCSBiosOutputComparison.NotEquals, (uint)100, (uint)55, false)] - public void CheckForValueMatchAndChange_WithUint_LastIntValue_Is_Random(uint valueToCompare, DCSBiosOutputComparison comparisonType, uint OriginalValue, uint lastIntValue, bool expectedResult) - { - DCSBIOSOutput dcsOutput = new() - { - Address = 99, - DCSBiosOutputType = DCSBiosOutputType.IntegerType, - Mask = valueToCompare, - SpecifiedValueUInt = OriginalValue, - DCSBiosOutputComparison = comparisonType, - LastUIntValue = lastIntValue, //<-- != compared to CheckForValueMatch_WithUint - }; - - Assert.Equal(expectedResult, dcsOutput.UIntConditionIsMet(99, valueToCompare)); - Assert.Equal(valueToCompare, dcsOutput.LastUIntValue); - } - - [Fact] - public void SpecifiedValueUInt_ShouldTrowIfOutputTypeNotSetToInteger() { - Assert.Throws(() => { - DCSBIOSOutput dcsOutput = new() - { - Address = 99, - DCSBiosOutputType = DCSBiosOutputType.FloatBuffer, - SpecifiedValueUInt = 6 - }; - }); - } - } -}