Skip to content

Commit

Permalink
Server and client changes. Not show errors or nil results in range te…
Browse files Browse the repository at this point in the history
…sting (#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.
  • Loading branch information
jdahlblom authored Oct 21, 2023
1 parent 74ad8c7 commit 9dddf6d
Show file tree
Hide file tree
Showing 45 changed files with 253 additions and 93 deletions.
2 changes: 1 addition & 1 deletion src/client/DCSInsight/DCSInsight.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<UseWPF>true</UseWPF>
<AssemblyName>dcs-insight</AssemblyName>
<Version>1.0.0</Version>
<AssemblyVersion>1.7.4</AssemblyVersion>
<AssemblyVersion>1.7.5</AssemblyVersion>
<ApplicationIcon>Images\Magnifier_icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/client/DCSInsight/DCSInsight.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/Abbreviations/=API/@EntryIndexedValue">API</s:String>
<s:Boolean x:Key="/Default/UserDictionary/Words/=consolas/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=DCSAPI/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=defs/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=SENDAPI/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
6 changes: 6 additions & 0 deletions src/client/DCSInsight/JSON/DCSAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ public class DCSAPI
[JsonProperty("parameter_defs", Required = Required.Default)]
public List<ParameterInfo> 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; }
}
Expand Down
24 changes: 8 additions & 16 deletions src/client/DCSInsight/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -46,6 +45,7 @@ public MainWindow()

public void Dispose()
{
_windowRangeTest?.Close();
ICEventHandler.DetachErrorListener(this);
ICEventHandler.DetachConnectionListener(this);
ICEventHandler.DetachDataListener(this);
Expand Down Expand Up @@ -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."));
Expand All @@ -165,7 +165,7 @@ public void DataReceived(DataEventArgs args)
{
try
{
if (_rangeTesting) return;
if (_windowRangeTest != null) return;

if (args.DCSAPIS != null)
{
Expand Down Expand Up @@ -224,7 +224,7 @@ private void HandleAPIMessage(List<DCSAPI> dcsApis)
Dispatcher?.BeginInvoke((Action)(() => Common.ShowErrorMessageBox(ex)));
}
}

private void ButtonConnect_OnClick(object sender, RoutedEventArgs e)
{
try
Expand Down Expand Up @@ -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)
{
Expand Down
17 changes: 16 additions & 1 deletion src/client/DCSInsight/Misc/ResultComparator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions src/client/DCSInsight/UserControls/UserControlAPI.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
20 changes: 16 additions & 4 deletions src/client/DCSInsight/Windows/WindowRangeTest.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="35" />
<RowDefinition Height="35" />
<RowDefinition Height="10*" />
<RowDefinition Height="25" />
Expand All @@ -23,11 +24,16 @@
<Button Content="Start" Width="50" Margin="10,0,0,0" BorderBrush="Gray" FontSize="14" Name="ButtonStart" Click="ButtonStart_OnClick"></Button>
<Button Content="Stop" Width="50" Margin="10,0,0,0" BorderBrush="Gray" FontSize="14" Name="ButtonStop" Click="ButtonStop_OnClick"></Button>
<userControls:UserControlPulseLED x:Name="PulseLed" Margin="10,0,0,0"/>
<CheckBox Name="CheckBoxTop" Content="On Top" BorderBrush="Gray" Margin="20,0,0,0" Checked="CheckBoxTop_OnChecked" Unchecked="CheckBoxTop_OnUnchecked"></CheckBox>
<Button Width="20" Content="?" Margin="10,0,0,0" BorderBrush="Black" FontSize="14" Name="ButtonInformation" Click="ButtonInformation_OnClick"></Button>
</ToolBar>

<ToolBar Height="35" HorizontalAlignment="Stretch" Name="ToolBarMain2" VerticalAlignment="Top" Grid.Column="0" Grid.Row="1">
<Label VerticalAlignment="Center" Content="Loop" Margin="10,0,0,0" />
<Label VerticalAlignment="Center" Margin="0,0,0,0" >
<CheckBox Name="CheckBoxLoop" VerticalAlignment="Center" IsChecked="False" Checked="CheckBoxLoop_OnChecked" Unchecked="CheckBoxLoop_OnUnchecked"/>
</Label>
<Label VerticalAlignment="Center" Content="Changes only" Margin="10,0,0,0" />
<Label VerticalAlignment="Center" Content="Show Changes Only" Margin="10,0,0,0" />
<Label VerticalAlignment="Center" Margin="0,0,0,0" >
<CheckBox Name="CheckBoxShowChangesOnly" VerticalAlignment="Center" IsChecked="False" Checked="CheckBoxShowChangesOnly_OnChecked" Unchecked="CheckBoxShowChangesOnly_OnUnchecked"/>
</Label>
Expand All @@ -41,11 +47,17 @@
<ComboBoxItem>4</ComboBoxItem>
<ComboBoxItem>5</ComboBoxItem>
</ComboBox>
<CheckBox Name="CheckBoxTop" Content="On Top" BorderBrush="Gray" Margin="20,0,0,0" Checked="CheckBoxTop_OnChecked" Unchecked="CheckBoxTop_OnUnchecked"></CheckBox>
<Button Width="20" Content="?" Margin="10,0,0,0" BorderBrush="Black" FontSize="14" Name="ButtonInformation" Click="ButtonInformation_OnClick"></Button>
<Label VerticalAlignment="Center" Content="Show Errors" Margin="10,0,0,0" />
<Label VerticalAlignment="Center" Margin="0,0,0,0" >
<CheckBox Name="CheckBoxShowErrors" VerticalAlignment="Center" IsChecked="False" Checked="CheckBoxShowErrors_OnChecked" Unchecked="CheckBoxShowErrors_OnUnchecked"/>
</Label>
<Label VerticalAlignment="Center" Content="Show nil Results" Margin="10,0,0,0" />
<Label VerticalAlignment="Center" Margin="0,0,0,0" >
<CheckBox Name="CheckBoxShowNilResults" VerticalAlignment="Center" IsChecked="False" Checked="CheckBoxShowNilResults_OnChecked" Unchecked="CheckBoxShowNilResults_OnUnchecked"/>
</Label>
</ToolBar>

<StackPanel Grid.Row="1" Grid.Column="0" Margin="5,5,5,5" >
<StackPanel Grid.Row="2" Grid.Column="0" Margin="5,5,5,5" >
<StackPanel Name="StackPanelParameters" ></StackPanel>
<StackPanel>
<TextBox Name="TextBoxResults" IsReadOnly="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Visible" MaxHeight="400" />
Expand Down
Loading

0 comments on commit 9dddf6d

Please sign in to comment.