Skip to content

Commit

Permalink
Small pulse sign when Range testing starts over (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdahlblom authored Oct 15, 2023
1 parent 0ade9bf commit 002ddf4
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 16 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.6.0</AssemblyVersion>
<AssemblyVersion>1.7.0</AssemblyVersion>
<ApplicationIcon>Images\Magnifier_icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
Expand Down
24 changes: 12 additions & 12 deletions src/client/DCSInsight/UserControls/UserControlAPI.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,11 @@ private void ButtonSend_OnClick(object sender, RoutedEventArgs e)
}
}

private void StopPolling()
private void StartPolling(int milliseconds)
{
try
{
_pollingTimer.Change(Timeout.Infinite, Timeout.Infinite);
_pollingTimer.Change(milliseconds, milliseconds);
SetFormState();
}
catch (Exception ex)
Expand All @@ -306,31 +306,31 @@ private void StopPolling()
}
}

private void PollingTimerCallback(object state)
private void StopPolling()
{
try
{
if (_canSend)
{
Dispatcher?.BeginInvoke((Action)(SendCommand));
}
_pollingTimer.Change(Timeout.Infinite, Timeout.Infinite);
SetFormState();
}
catch (Exception ex)
{
ICEventHandler.SendErrorMessage( "Timer Polling Error", ex);
Common.ShowErrorMessageBox(ex);
}
}

private void StartPolling(int milliseconds)
private void PollingTimerCallback(object state)
{
try
{
_pollingTimer.Change(milliseconds, milliseconds);
SetFormState();
if (_canSend)
{
Dispatcher?.BeginInvoke((Action)(SendCommand));
}
}
catch (Exception ex)
{
Common.ShowErrorMessageBox(ex);
ICEventHandler.SendErrorMessage( "Timer Polling Error", ex);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/client/DCSInsight/Windows/WindowRangeTest.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<ComboBox Width="auto" MinWidth="200" Name="ComboBoxAPI" FontFamily="Consolas" SelectionChanged="ComboBoxAPI_OnSelectionChanged" ></ComboBox>
<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>
<Label Name="LabelLoopPulse" VerticalAlignment="Center" Content=" " FontSize="16" Height="22" Margin="10,0,0,0" />
<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"/>
Expand Down
48 changes: 45 additions & 3 deletions src/client/DCSInsight/Windows/WindowRangeTest.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Diagnostics;
using System.Linq;
using System.Text;
Expand Down Expand Up @@ -37,6 +38,8 @@ public partial class WindowRangeTest : Window, IErrorListener, IConnectionListen
private readonly int _threadLoopSleep = 50;
private readonly List<ResultComparator> _resultComparatorList = new();
private readonly object _lockObject = new();
private Timer _timerLoopPulse;
private readonly int _pulseVisibilityTime = 500;

public WindowRangeTest(List<DCSAPI> dcsAPIList)
{
Expand All @@ -62,6 +65,9 @@ private void WindowRangeTest_OnLoaded(object sender, RoutedEventArgs e)
{
if (_formLoaded) return;

_timerLoopPulse = new Timer(PulseTimerCallback);
_timerLoopPulse.Change(Timeout.Infinite, Timeout.Infinite);

CheckBoxTop.IsChecked = true;
PopulateAPIComboBox();
SetFormState();
Expand All @@ -82,6 +88,7 @@ private void SetFormState()
ButtonStop.IsEnabled = _isRunning && !_stopRunning;
CheckBoxLoop.IsEnabled = _isConnected;
CheckBoxShowChangesOnly.IsEnabled = CheckBoxLoop.IsChecked == true;
LabelLoopPulse.Visibility = _isConnected && CheckBoxLoop.IsEnabled && _isRunning ? Visibility.Visible : Visibility.Collapsed;
}
catch (Exception ex)
{
Expand Down Expand Up @@ -218,11 +225,12 @@ private void Loop1(int i, int x)
{
do
{
StartPulse(_pulseVisibilityTime);
Dispatcher?.BeginInvoke((Action)(() => Mouse.OverrideCursor = Cursors.Wait));
for (var b = i; b <= x; b++)
{
if (_stopRunning) return;

_dcsAPI.Parameters[0].Value = b.ToString();

SetCurrentTestStructure(_dcsAPI);
Expand Down Expand Up @@ -258,12 +266,14 @@ private void Loop2(int i, int x, int j, int y)

do
{
StartPulse(_pulseVisibilityTime);

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();
Expand Down Expand Up @@ -301,14 +311,16 @@ private void Loop3(int i, int x, int j, int y, int k, int z)
Dispatcher?.BeginInvoke((Action)(() => Mouse.OverrideCursor = Cursors.Wait));
do
{
StartPulse(_pulseVisibilityTime);

for (var b = i; b <= x; b++)
{
for (var c = j; c <= y; c++)
{
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();
Expand Down Expand Up @@ -525,6 +537,36 @@ private void CheckBoxTop_OnUnchecked(object sender, RoutedEventArgs e)
}
}

private void StartPulse(int milliseconds)
{
try
{
Dispatcher?.BeginInvoke((Action)(() => LabelLoopPulse.Content = "*"));

_timerLoopPulse.Change(milliseconds, milliseconds);
Dispatcher?.BeginInvoke((Action)( SetFormState));
}
catch (Exception ex)
{
Common.ShowErrorMessageBox(ex);
}
}

private void PulseTimerCallback(object state)
{
try
{
Dispatcher?.BeginInvoke((Action)(() => LabelLoopPulse.Content = " "));
Dispatcher?.BeginInvoke((Action)(() => ToolBarMain.UpdateLayout()));
_timerLoopPulse.Change(Timeout.Infinite, Timeout.Infinite);
Dispatcher?.BeginInvoke((Action)(SetFormState));
}
catch (Exception ex)
{
ICEventHandler.SendErrorMessage("Timer Polling Error", ex);
}
}

private void TextBoxParameter_OnKeyDown_Number(object sender, KeyEventArgs e)
{
try
Expand Down

0 comments on commit 002ddf4

Please sign in to comment.