From 9dddf6d4d8b55c64a03f704bca8c57489c39091b Mon Sep 17 00:00:00 2001 From: Jerker Dahlblom Date: Sat, 21 Oct 2023 12:30:58 +0300 Subject: [PATCH] Server and client changes. Not show errors or nil results in range testing (#35) * Server : Error messages are returned in its own field now with a field indicating whether error was thrown * Client : Possibility to not show error messages or nil results during range testing. This is useful if you are doing testing large ranges. --- src/client/DCSInsight/DCSInsight.csproj | 2 +- .../DCSInsight/DCSInsight.sln.DotSettings | 1 + src/client/DCSInsight/JSON/DCSAPI.cs | 6 + src/client/DCSInsight/MainWindow.xaml.cs | 24 ++-- .../DCSInsight/Misc/ResultComparator.cs | 17 ++- .../UserControls/UserControlAPI.xaml.cs | 6 +- .../DCSInsight/Windows/WindowRangeTest.xaml | 20 ++- .../Windows/WindowRangeTest.xaml.cs | 127 +++++++++++++++--- .../Scripts/DCS-INSIGHT/lib/APIHandler.lua | 12 +- .../lib/commands/GetArgumentValue.lua | 6 +- .../DCS-INSIGHT/lib/commands/GetFrequency.lua | 6 +- .../lib/commands/ListIndicationAPI.lua | 3 +- .../lib/commands/LoGetADIPitchBankYawAPI.lua | 3 +- .../commands/LoGetAccelerationUnitsAPI.lua | 3 +- .../LoGetAircraftDrawArgumentValueAPI.lua | 3 +- .../LoGetAltitudeAboveGroundLevelAPI.lua | 3 +- .../LoGetAltitudeAboveSeaLevelAPI.lua | 3 +- .../lib/commands/LoGetAngleOfAttackAPI.lua | 3 +- .../LoGetBasicAtmospherePressureAPI.lua | 3 +- .../commands/LoGetControlPanel_HSI_API.lua | 3 +- .../lib/commands/LoGetEngineInfoAPI.lua | 3 +- .../lib/commands/LoGetGlideDeviationAPI.lua | 3 +- .../commands/LoGetIndicatedAirSpeedAPI.lua | 3 +- .../lib/commands/LoGetMCPStateAPI.lua | 3 +- .../lib/commands/LoGetMachNumberAPI.lua | 3 +- .../lib/commands/LoGetMagneticYawAPI.lua | 3 +- .../lib/commands/LoGetMechInfoAPI.lua | 3 +- .../lib/commands/LoGetMissionStartTimeAPI.lua | 3 +- .../lib/commands/LoGetModelTimeAPI.lua | 3 +- .../lib/commands/LoGetNavigationInfoAPI.lua | 3 +- .../lib/commands/LoGetPayloadInfoAPI.lua | 3 +- .../lib/commands/LoGetPilotNameAPI.lua | 3 +- .../lib/commands/LoGetSelfDataAPI.lua | 3 +- .../lib/commands/LoGetSideDeviationAPI.lua | 3 +- .../lib/commands/LoGetSlipBallPositionAPI.lua | 3 +- .../lib/commands/LoGetSnaresAPI.lua | 3 +- .../lib/commands/LoGetTWSInfoAPI.lua | 3 +- .../lib/commands/LoGetTrueAirSpeedAPI.lua | 3 +- .../lib/commands/LoGetVerticalVelocityAPI.lua | 3 +- .../commands/LoIsOwnshipExportAllowedAPI.lua | 3 +- .../lib/commands/PerformClickableAction.lua | 6 +- .../lib/commands/SetArgumentValue.lua | 6 +- .../DCS-INSIGHT/lib/commands/SetCommand.lua | 6 +- .../DCS-INSIGHT/lib/commands/SetFrequency.lua | 6 +- .../lib/commands/common/APIInfo.lua | 8 +- 45 files changed, 253 insertions(+), 93 deletions(-) diff --git a/src/client/DCSInsight/DCSInsight.csproj b/src/client/DCSInsight/DCSInsight.csproj index 4546402..f468465 100644 --- a/src/client/DCSInsight/DCSInsight.csproj +++ b/src/client/DCSInsight/DCSInsight.csproj @@ -6,7 +6,7 @@ true dcs-insight 1.0.0 - 1.7.4 + 1.7.5 Images\Magnifier_icon.ico diff --git a/src/client/DCSInsight/DCSInsight.sln.DotSettings b/src/client/DCSInsight/DCSInsight.sln.DotSettings index ffa9e19..4901df7 100644 --- a/src/client/DCSInsight/DCSInsight.sln.DotSettings +++ b/src/client/DCSInsight/DCSInsight.sln.DotSettings @@ -10,4 +10,5 @@ API True True + True True \ No newline at end of file diff --git a/src/client/DCSInsight/JSON/DCSAPI.cs b/src/client/DCSInsight/JSON/DCSAPI.cs index 03124c7..4ea113d 100644 --- a/src/client/DCSInsight/JSON/DCSAPI.cs +++ b/src/client/DCSInsight/JSON/DCSAPI.cs @@ -28,6 +28,12 @@ public class DCSAPI [JsonProperty("parameter_defs", Required = Required.Default)] public List Parameters { get; set; } + [JsonProperty("error_thrown", Required = Required.Default)] + public bool ErrorThrown { get; set; } + + [JsonProperty("error_message", Required = Required.Default)] + public string ErrorMessage { get; set; } + [JsonProperty("result", Required = Required.Default)] public string Result { get; set; } } diff --git a/src/client/DCSInsight/MainWindow.xaml.cs b/src/client/DCSInsight/MainWindow.xaml.cs index 3daa19d..ccd91ee 100644 --- a/src/client/DCSInsight/MainWindow.xaml.cs +++ b/src/client/DCSInsight/MainWindow.xaml.cs @@ -33,8 +33,7 @@ public partial class MainWindow : Window, IErrorListener, IConnectionListener, I private bool _formLoaded; private TCPClientHandler _tcpClientHandler; private bool _isConnected; - private bool _rangeTesting; - + private WindowRangeTest _windowRangeTest; public MainWindow() { @@ -46,6 +45,7 @@ public MainWindow() public void Dispose() { + _windowRangeTest?.Close(); ICEventHandler.DetachErrorListener(this); ICEventHandler.DetachConnectionListener(this); ICEventHandler.DetachDataListener(this); @@ -145,12 +145,12 @@ public void ConnectionStatus(ConnectionEventArgs args) Dispatcher?.BeginInvoke((Action)(() => Common.ShowErrorMessageBox(ex))); } } - + public void ErrorMessage(ErrorEventArgs args) { try { - if (_rangeTesting) return; + if (_windowRangeTest != null) return; Logger.Error(args.Ex); Dispatcher?.BeginInvoke((Action)(() => TextBlockMessage.Text = $"{args.Message}. See log file.")); @@ -165,7 +165,7 @@ public void DataReceived(DataEventArgs args) { try { - if (_rangeTesting) return; + if (_windowRangeTest != null) return; if (args.DCSAPIS != null) { @@ -224,7 +224,7 @@ private void HandleAPIMessage(List dcsApis) Dispatcher?.BeginInvoke((Action)(() => Common.ShowErrorMessageBox(ex))); } } - + private void ButtonConnect_OnClick(object sender, RoutedEventArgs e) { try @@ -487,16 +487,8 @@ private void ButtonRangeTest_OnClick(object sender, RoutedEventArgs e) { try { - try - { - _rangeTesting = true; - var windowRangeTest = new WindowRangeTest(_dcsAPIList); - windowRangeTest.ShowDialog(); - } - finally - { - _rangeTesting = false; - } + _windowRangeTest = new WindowRangeTest(_dcsAPIList); + _windowRangeTest.Show(); } catch (Exception ex) { diff --git a/src/client/DCSInsight/Misc/ResultComparator.cs b/src/client/DCSInsight/Misc/ResultComparator.cs index eb0d6fc..32c10a6 100644 --- a/src/client/DCSInsight/Misc/ResultComparator.cs +++ b/src/client/DCSInsight/Misc/ResultComparator.cs @@ -92,12 +92,27 @@ public string GetResultString() currentTestString.Append($"{dcsApiParameter.ParameterName} [{dcsApiParameter.Value}], "); } - currentTestString.Append($" result : {_dcsApi.Result}\n"); + currentTestString.Append($" result : {(string.IsNullOrEmpty(_dcsApi.Result) ? "nil" : _dcsApi.Result)}"); return currentTestString.ToString(); } } + public static string GetResultString(DCSAPI dcsApi) + { + var currentTestString = new StringBuilder(); + + foreach (var dcsApiParameter in dcsApi.Parameters) + { + currentTestString.Append($"{dcsApiParameter.ParameterName} [{dcsApiParameter.Value}], "); + } + + currentTestString.Append($" result : {dcsApi.Result}"); + + return currentTestString.ToString(); + } + + public static void SetDecimals(bool limitDecimals, int decimalPlaces) { _limitDecimals = limitDecimals; diff --git a/src/client/DCSInsight/UserControls/UserControlAPI.xaml.cs b/src/client/DCSInsight/UserControls/UserControlAPI.xaml.cs index d130574..4323a24 100644 --- a/src/client/DCSInsight/UserControls/UserControlAPI.xaml.cs +++ b/src/client/DCSInsight/UserControls/UserControlAPI.xaml.cs @@ -242,13 +242,15 @@ public void SetResult(DCSAPI dcsApi) { try { + var result = dcsApi.ErrorThrown ? dcsApi.ErrorMessage : (string.IsNullOrEmpty(dcsApi.Result) ? "nil" : dcsApi.Result); + if (_keepResults) { Dispatcher?.BeginInvoke((Action)(() => TextBoxResult.Text = TextBoxResult.Text.Insert(0, "\n-----------\n"))); - Dispatcher?.BeginInvoke((Action)(() => TextBoxResult.Text = TextBoxResult.Text.Insert(0, dcsApi.Result))); + Dispatcher?.BeginInvoke((Action)(() => TextBoxResult.Text = TextBoxResult.Text.Insert(0, result))); return; } - Dispatcher?.BeginInvoke((Action)(() => TextBoxResult.Text = dcsApi.Result)); + Dispatcher?.BeginInvoke((Action)(() => TextBoxResult.Text = result)); } catch (Exception ex) { diff --git a/src/client/DCSInsight/Windows/WindowRangeTest.xaml b/src/client/DCSInsight/Windows/WindowRangeTest.xaml index 443ebdc..c4ce2e7 100644 --- a/src/client/DCSInsight/Windows/WindowRangeTest.xaml +++ b/src/client/DCSInsight/Windows/WindowRangeTest.xaml @@ -12,6 +12,7 @@ + @@ -23,11 +24,16 @@ + + + + + - + diff --git a/src/client/DCSInsight/Windows/WindowRangeTest.xaml.cs b/src/client/DCSInsight/Windows/WindowRangeTest.xaml.cs index d813da4..e2b1c49 100644 --- a/src/client/DCSInsight/Windows/WindowRangeTest.xaml.cs +++ b/src/client/DCSInsight/Windows/WindowRangeTest.xaml.cs @@ -3,6 +3,7 @@ using System.ComponentModel; using System.Globalization; using System.Linq; +using System.Text; using System.Threading; using System.Windows; using System.Windows.Controls; @@ -30,10 +31,13 @@ public partial class WindowRangeTest : Window, IErrorListener, IConnectionListen private bool _isRunning; private bool _stopRunning; private bool _doLoop; + private readonly int _longPulse = 10000000; private bool _showChangesOnly; + private bool _showErrors; + private bool _showNilResults; private static readonly AutoResetEvent AutoResetEvent1 = new(false); private Thread _thread; - private readonly int _threadLoopSleep = 50; + private readonly int _threadLoopSleep = 20; private readonly List _resultComparatorList = new(); private readonly object _lockObject = new(); @@ -60,7 +64,9 @@ private void WindowRangeTest_OnLoaded(object sender, RoutedEventArgs e) try { if (_formLoaded) return; - + + CheckBoxShowErrors.IsChecked = true; + CheckBoxShowNilResults.IsChecked = true; CheckBoxTop.IsChecked = true; PopulateAPIComboBox(); SetFormState(); @@ -134,8 +140,21 @@ public void DataReceived(DataEventArgs args) { if (!_isConnected || !_isRunning) return; + if (args.DCSApi.ErrorThrown) + { + if(_showErrors) Dispatcher?.BeginInvoke((Action)(() => AddResultText(GetResultString(args.DCSApi)))); + AutoResetEvent1.Set(); + return; + } + + if (string.IsNullOrEmpty(args.DCSApi.Result) && !_showNilResults) + { + AutoResetEvent1.Set(); + return; + } + var hasChanged = _resultComparatorList.First(o => o.IsMatch(args.DCSApi)).SetResult(args.DCSApi); - + if (_showChangesOnly && !hasChanged) { AutoResetEvent1.Set(); @@ -143,7 +162,6 @@ public void DataReceived(DataEventArgs args) else { Dispatcher?.BeginInvoke((Action)(() => AddResultText(_resultComparatorList.First(o => o.IsMatch(args.DCSApi)).GetResultString()))); - ; AutoResetEvent1.Set(); } } @@ -154,13 +172,30 @@ public void DataReceived(DataEventArgs args) } } + private string GetResultString(DCSAPI dcsApi) + { + var currentTestString = new StringBuilder(); + + foreach (var dcsApiParameter in dcsApi.Parameters) + { + currentTestString.Append($"{dcsApiParameter.ParameterName} [{dcsApiParameter.Value}], "); + } + + currentTestString.Append($" result : {(dcsApi.ErrorThrown ? dcsApi.ErrorMessage : (string.IsNullOrEmpty(dcsApi.Result) ? "nil" : dcsApi.Result))}"); + + return currentTestString.ToString(); + } + private void StartTesting() { _stopRunning = false; try { - _resultComparatorList.Clear(); + lock (_lockObject) + { + _resultComparatorList.Clear(); + } TextBoxResults.Text = ""; var dynamicCount = _textBoxParameterList.Count(o => o.RangeLimit == RangeLimitsEnum.From); if (dynamicCount == 0) return; @@ -217,12 +252,12 @@ private void Loop1(int i, int x) { do { - PulseLed.Pulse(); - Dispatcher?.BeginInvoke((Action)(() => Mouse.OverrideCursor = Cursors.Wait)); + PulseLed.Pulse(_doLoop ? 300 : _longPulse); + for (var b = i; b <= x; b++) { if (_stopRunning) return; - + _dcsAPI.Parameters[0].Value = b.ToString(); SetCurrentTestStructure(_dcsAPI); @@ -237,8 +272,8 @@ private void Loop1(int i, int x) { Thread.Sleep(500); _isRunning = false; - Dispatcher?.BeginInvoke((Action)(() => Mouse.OverrideCursor = Cursors.Arrow)); Dispatcher?.BeginInvoke((Action)(SetFormState)); + PulseLed.Pulse(); } } catch (Exception ex) @@ -254,23 +289,24 @@ private void Loop2(int i, int x, int j, int y) _isRunning = true; try { - Dispatcher?.BeginInvoke((Action)(() => Mouse.OverrideCursor = Cursors.Wait)); - do { - PulseLed.Pulse(); + PulseLed.Pulse(_doLoop ? 300 : _longPulse); for (var b = i; b <= x; b++) { for (var c = j; c <= y; c++) { if (_stopRunning) return; - + _dcsAPI.Parameters[0].Value = b.ToString(); _dcsAPI.Parameters[1].Value = c.ToString(); - if(_resultComparatorList.Count > 0) _resultComparatorList[0].GetResultString(); - SetCurrentTestStructure(_dcsAPI); - _resultComparatorList[0].GetResultString(); + lock (_lockObject) + { + if (_resultComparatorList.Count > 0) _resultComparatorList[0].GetResultString(); + SetCurrentTestStructure(_dcsAPI); + _resultComparatorList[0].GetResultString(); + } ICEventHandler.SendCommand(_dcsAPI); AutoResetEvent1.WaitOne(); Thread.Sleep(_threadLoopSleep); @@ -283,8 +319,8 @@ private void Loop2(int i, int x, int j, int y) { Thread.Sleep(500); _isRunning = false; - Dispatcher?.BeginInvoke((Action)(() => Mouse.OverrideCursor = Cursors.Arrow)); Dispatcher?.BeginInvoke((Action)(SetFormState)); + PulseLed.Pulse(); } } catch (Exception ex) @@ -300,10 +336,9 @@ private void Loop3(int i, int x, int j, int y, int k, int z) _isRunning = true; try { - Dispatcher?.BeginInvoke((Action)(() => Mouse.OverrideCursor = Cursors.Wait)); do { - PulseLed.Pulse(); + PulseLed.Pulse(_doLoop ? 300 : _longPulse); for (var b = i; b <= x; b++) { @@ -312,7 +347,7 @@ private void Loop3(int i, int x, int j, int y, int k, int z) for (var d = k; d <= z; d++) { if (_stopRunning) return; - + _dcsAPI.Parameters[0].Value = b.ToString(); _dcsAPI.Parameters[1].Value = c.ToString(); _dcsAPI.Parameters[2].Value = d.ToString(); @@ -331,8 +366,8 @@ private void Loop3(int i, int x, int j, int y, int k, int z) { Thread.Sleep(500); _isRunning = false; - Dispatcher?.BeginInvoke((Action)(() => Mouse.OverrideCursor = Cursors.Arrow)); Dispatcher?.BeginInvoke((Action)(SetFormState)); + PulseLed.Pulse(); } } catch (Exception ex) @@ -630,7 +665,7 @@ private void CheckBoxShowChangesOnly_OnUnchecked(object sender, RoutedEventArgs private void AddResultText(string text) { - TextBoxResults.Text += text; + TextBoxResults.Text += text + "\n"; TextBoxResults.ScrollToEnd(); } @@ -652,5 +687,53 @@ private void ComboBoxDecimals_OnSelectionChanged(object sender, SelectionChanged Common.ShowErrorMessageBox(ex); } } + + private void CheckBoxShowErrors_OnChecked(object sender, RoutedEventArgs e) + { + try + { + _showErrors = true; + } + catch (Exception ex) + { + Common.ShowErrorMessageBox(ex); + } + } + + private void CheckBoxShowErrors_OnUnchecked(object sender, RoutedEventArgs e) + { + try + { + _showErrors = false; + } + catch (Exception ex) + { + Common.ShowErrorMessageBox(ex); + } + } + + private void CheckBoxShowNilResults_OnChecked(object sender, RoutedEventArgs e) + { + try + { + _showNilResults = true; + } + catch (Exception ex) + { + Common.ShowErrorMessageBox(ex); + } + } + + private void CheckBoxShowNilResults_OnUnchecked(object sender, RoutedEventArgs e) + { + try + { + _showNilResults = false; + } + catch (Exception ex) + { + Common.ShowErrorMessageBox(ex); + } + } } } diff --git a/src/server/Scripts/DCS-INSIGHT/lib/APIHandler.lua b/src/server/Scripts/DCS-INSIGHT/lib/APIHandler.lua index 9bbee76..d62a20c 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/APIHandler.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/APIHandler.lua @@ -212,15 +212,21 @@ function APIHandler:execute(api) if api.id == v.id then local result_code, result = pcall(v.execute, v, api) -- = v:execute(api) if result_code == true then + result.error_thrown = false + result.error_message = "" return result else if result == nil then - api.result = "Error but no error message" + api.error_thrown = true + api.error_message = "Error but no error message" + api.result = nil return api else local path = v:script_path():gsub("%-", "%%-") -- escape any hyphen otherwise next gsub won't work - Log:log(result:gsub(path, "")) - api.result = result:gsub(path, "") + --Log:log(result:gsub(path, "")) + api.error_thrown = true + api.result = nil + api.error_message = result:gsub(path, "") return api end end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/GetArgumentValue.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/GetArgumentValue.lua index 00d2689..9429167 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/GetArgumentValue.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/GetArgumentValue.lua @@ -33,7 +33,8 @@ function GetArgumentValue:init() end function GetArgumentValue:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end @@ -48,7 +49,8 @@ function GetArgumentValue:execute(api) end if self:verify_device(param0) == false then - api.result = "Device not found" + api.error_thrown = true + api.error_message = "Device not found" return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/GetFrequency.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/GetFrequency.lua index 94d7640..3930721 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/GetFrequency.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/GetFrequency.lua @@ -34,7 +34,8 @@ function GetFrequency:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end @@ -45,7 +46,8 @@ function GetFrequency:execute(api) end if self:verify_device(param0) == false then - api.result = "Device not found" + api.error_thrown = true + api.error_message = "Device not found" return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/ListIndicationAPI.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/ListIndicationAPI.lua index 1d56a33..779d7f9 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/ListIndicationAPI.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/ListIndicationAPI.lua @@ -31,7 +31,8 @@ function ListIndicationAPI:init() end function ListIndicationAPI:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetADIPitchBankYawAPI.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetADIPitchBankYawAPI.lua index 0c895e0..a9a19d5 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetADIPitchBankYawAPI.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetADIPitchBankYawAPI.lua @@ -27,7 +27,8 @@ function LoGetADIPitchBankYawAPI:init() end function LoGetADIPitchBankYawAPI:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetAccelerationUnitsAPI.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetAccelerationUnitsAPI.lua index 617c3e7..de9035e 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetAccelerationUnitsAPI.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetAccelerationUnitsAPI.lua @@ -27,7 +27,8 @@ function LoGetAccelerationUnitsAPI:init() end function LoGetAccelerationUnitsAPI:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetAircraftDrawArgumentValueAPI.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetAircraftDrawArgumentValueAPI.lua index 28dd8c1..c66d7b8 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetAircraftDrawArgumentValueAPI.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetAircraftDrawArgumentValueAPI.lua @@ -31,7 +31,8 @@ function LoGetAircraftDrawArgumentValueAPI:init() end function LoGetAircraftDrawArgumentValueAPI:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetAltitudeAboveGroundLevelAPI.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetAltitudeAboveGroundLevelAPI.lua index 3093be6..83eaf15 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetAltitudeAboveGroundLevelAPI.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetAltitudeAboveGroundLevelAPI.lua @@ -27,7 +27,8 @@ function LoGetAltitudeAboveGroundLevelAPI:init() end function LoGetAltitudeAboveGroundLevelAPI:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetAltitudeAboveSeaLevelAPI.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetAltitudeAboveSeaLevelAPI.lua index b49af19..47a3a63 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetAltitudeAboveSeaLevelAPI.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetAltitudeAboveSeaLevelAPI.lua @@ -27,7 +27,8 @@ function LoGetAltitudeAboveSeaLevelAPI:init() end function LoGetAltitudeAboveSeaLevelAPI:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetAngleOfAttackAPI.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetAngleOfAttackAPI.lua index 334925a..a3567fb 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetAngleOfAttackAPI.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetAngleOfAttackAPI.lua @@ -27,7 +27,8 @@ function LoGetAngleOfAttackAPI:init() end function LoGetAngleOfAttackAPI:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetBasicAtmospherePressureAPI.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetBasicAtmospherePressureAPI.lua index 8f279c0..920b73b 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetBasicAtmospherePressureAPI.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetBasicAtmospherePressureAPI.lua @@ -27,7 +27,8 @@ function LoGetBasicAtmospherePressureAPI:init() end function LoGetBasicAtmospherePressureAPI:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetControlPanel_HSI_API.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetControlPanel_HSI_API.lua index 7bcac37..52dc7c6 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetControlPanel_HSI_API.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetControlPanel_HSI_API.lua @@ -27,7 +27,8 @@ function LoGetControlPanel_HSI_API:init() end function LoGetControlPanel_HSI_API:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetEngineInfoAPI.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetEngineInfoAPI.lua index dff5314..e1edef8 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetEngineInfoAPI.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetEngineInfoAPI.lua @@ -27,7 +27,8 @@ function LoGetEngineInfoAPI:init() end function LoGetEngineInfoAPI:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetGlideDeviationAPI.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetGlideDeviationAPI.lua index 9a63807..c5ad6f6 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetGlideDeviationAPI.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetGlideDeviationAPI.lua @@ -27,7 +27,8 @@ function LoGetGlideDeviationAPI:init() end function LoGetGlideDeviationAPI:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetIndicatedAirSpeedAPI.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetIndicatedAirSpeedAPI.lua index 95a90e2..5141d93 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetIndicatedAirSpeedAPI.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetIndicatedAirSpeedAPI.lua @@ -27,7 +27,8 @@ function LoGetIndicatedAirSpeedAPI:init() end function LoGetIndicatedAirSpeedAPI:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetMCPStateAPI.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetMCPStateAPI.lua index ccfd97c..09d7d71 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetMCPStateAPI.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetMCPStateAPI.lua @@ -27,7 +27,8 @@ function LoGetMCPStateAPI:init() end function LoGetMCPStateAPI:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetMachNumberAPI.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetMachNumberAPI.lua index 3d72747..65703a9 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetMachNumberAPI.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetMachNumberAPI.lua @@ -27,7 +27,8 @@ function LoGetMachNumberAPI:init() end function LoGetMachNumberAPI:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetMagneticYawAPI.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetMagneticYawAPI.lua index 7ba2957..6fa9920 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetMagneticYawAPI.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetMagneticYawAPI.lua @@ -27,7 +27,8 @@ function LoGetMagneticYawAPI:init() end function LoGetMagneticYawAPI:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetMechInfoAPI.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetMechInfoAPI.lua index febd6f5..7a4a167 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetMechInfoAPI.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetMechInfoAPI.lua @@ -27,7 +27,8 @@ function LoGetMechInfoAPI:init() end function LoGetMechInfoAPI:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetMissionStartTimeAPI.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetMissionStartTimeAPI.lua index 048372c..bb4fb3e 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetMissionStartTimeAPI.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetMissionStartTimeAPI.lua @@ -27,7 +27,8 @@ function LoGetMissionStartTimeAPI:init() end function LoGetMissionStartTimeAPI:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetModelTimeAPI.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetModelTimeAPI.lua index d0af7e5..cbdbf06 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetModelTimeAPI.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetModelTimeAPI.lua @@ -27,7 +27,8 @@ function LoGetModelTimeAPI:init() end function LoGetModelTimeAPI:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetNavigationInfoAPI.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetNavigationInfoAPI.lua index c2c7b3b..baa5c73 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetNavigationInfoAPI.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetNavigationInfoAPI.lua @@ -27,7 +27,8 @@ function LoGetNavigationInfoAPI:init() end function LoGetNavigationInfoAPI:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetPayloadInfoAPI.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetPayloadInfoAPI.lua index d09fcbe..879e11d 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetPayloadInfoAPI.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetPayloadInfoAPI.lua @@ -27,7 +27,8 @@ function LoGetPayloadInfoAPI:init() end function LoGetPayloadInfoAPI:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetPilotNameAPI.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetPilotNameAPI.lua index 76a2c31..a1b7ae1 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetPilotNameAPI.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetPilotNameAPI.lua @@ -27,7 +27,8 @@ function LoGetPilotNameAPI:init() end function LoGetPilotNameAPI:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetSelfDataAPI.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetSelfDataAPI.lua index 50dac83..e9347a9 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetSelfDataAPI.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetSelfDataAPI.lua @@ -27,7 +27,8 @@ function LoGetSelfDataAPI:init() end function LoGetSelfDataAPI:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetSideDeviationAPI.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetSideDeviationAPI.lua index 34a96e5..eb87abd 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetSideDeviationAPI.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetSideDeviationAPI.lua @@ -27,7 +27,8 @@ function LoGetSideDeviationAPI:init() end function LoGetSideDeviationAPI:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetSlipBallPositionAPI.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetSlipBallPositionAPI.lua index a135630..6449ba3 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetSlipBallPositionAPI.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetSlipBallPositionAPI.lua @@ -27,7 +27,8 @@ function LoGetSlipBallPositionAPI:init() end function LoGetSlipBallPositionAPI:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetSnaresAPI.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetSnaresAPI.lua index 27d6431..9fc7e0e 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetSnaresAPI.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetSnaresAPI.lua @@ -27,7 +27,8 @@ function LoGetSnaresAPI:init() end function LoGetSnaresAPI:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetTWSInfoAPI.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetTWSInfoAPI.lua index 5eb51a0..0811843 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetTWSInfoAPI.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetTWSInfoAPI.lua @@ -27,7 +27,8 @@ function LoGetTWSInfoAPI:init() end function LoGetTWSInfoAPI:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetTrueAirSpeedAPI.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetTrueAirSpeedAPI.lua index f82e29e..706865c 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetTrueAirSpeedAPI.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetTrueAirSpeedAPI.lua @@ -27,7 +27,8 @@ function LoGetTrueAirSpeedAPI:init() end function LoGetTrueAirSpeedAPI:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetVerticalVelocityAPI.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetVerticalVelocityAPI.lua index 247ccfb..a96f068 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetVerticalVelocityAPI.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoGetVerticalVelocityAPI.lua @@ -27,7 +27,8 @@ function LoGetVerticalVelocityAPI:init() end function LoGetVerticalVelocityAPI:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoIsOwnshipExportAllowedAPI.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoIsOwnshipExportAllowedAPI.lua index 3431713..401c143 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/LoIsOwnshipExportAllowedAPI.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/LoIsOwnshipExportAllowedAPI.lua @@ -27,7 +27,8 @@ function LoIsOwnshipExportAllowedAPI:init() end function LoIsOwnshipExportAllowedAPI:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/PerformClickableAction.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/PerformClickableAction.lua index 7a85e17..915ec1b 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/PerformClickableAction.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/PerformClickableAction.lua @@ -37,7 +37,8 @@ function PerformClickableAction:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end @@ -54,7 +55,8 @@ function PerformClickableAction:execute(api) end if self:verify_device(param0) == false then - api.result = "Device not found" + api.error_thrown = true + api.error_message = "Device not found" return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/SetArgumentValue.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/SetArgumentValue.lua index 8c7671b..8f30909 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/SetArgumentValue.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/SetArgumentValue.lua @@ -37,7 +37,8 @@ function SetArgumentValue:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end @@ -54,7 +55,8 @@ function SetArgumentValue:execute(api) end if self:verify_device(param0) == false then - api.result = "Device not found" + api.error_thrown = true + api.error_message = "Device not found" return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/SetCommand.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/SetCommand.lua index 477bb9c..d6d5b8e 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/SetCommand.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/SetCommand.lua @@ -37,7 +37,8 @@ function SetCommand:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end @@ -54,7 +55,8 @@ function SetCommand:execute(api) end if self:verify_device(param0) == false then - api.result = "Device not found" + api.error_thrown = true + api.error_message = "Device not found" return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/SetFrequency.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/SetFrequency.lua index 49b2bcf..1d9d36b 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/SetFrequency.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/SetFrequency.lua @@ -36,7 +36,8 @@ function SetFrequency:execute(api) local result_code, message = self:verify_params() if result_code == 1 then - api.result = message + api.error_thrown = true + api.error_message = message return api end @@ -50,7 +51,8 @@ function SetFrequency:execute(api) end if self:verify_device(param0) == false then - api.result = "Device not found" + api.error_thrown = true + api.error_message = "Device not found" return api end diff --git a/src/server/Scripts/DCS-INSIGHT/lib/commands/common/APIInfo.lua b/src/server/Scripts/DCS-INSIGHT/lib/commands/common/APIInfo.lua index 1b25221..2a20ec1 100644 --- a/src/server/Scripts/DCS-INSIGHT/lib/commands/common/APIInfo.lua +++ b/src/server/Scripts/DCS-INSIGHT/lib/commands/common/APIInfo.lua @@ -8,12 +8,13 @@ local Parameter = require("Scripts.DCS-INSIGHT.lib.commands.common.Parameter") --- @field api_syntax string --- @field parameter_count number --- @field parameter_defs table ---- @field value any +--- @field error_thrown boolean +--- @field error_message string --- @field result any local APIInfo = {} --- Constructs a new APIInfo -function APIInfo:new(id, returns_data, api_syntax, parameter_count, parameter_defs, value, result) +function APIInfo:new(id, returns_data, api_syntax, parameter_count, parameter_defs, error_thrown, error_message, result) --- @type APIInfo local o = { id = id, @@ -21,7 +22,8 @@ function APIInfo:new(id, returns_data, api_syntax, parameter_count, parameter_de api_syntax = api_syntax, parameter_count = parameter_count, parameter_defs = parameter_defs or {}, - value = value, + error_thrown = false, + error_message = "", result = result, } setmetatable(o, self)