Skip to content

Commit

Permalink
#31 Lower delay between DCS-BIOS commands (#32)
Browse files Browse the repository at this point in the history
Added option for user to change this delay
  • Loading branch information
jdahlblom authored Apr 24, 2024
1 parent 7544a64 commit cce8085
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 20 deletions.
3 changes: 3 additions & 0 deletions src/DCSBIOSBridge/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
<setting name="ShowInfoType" serializeAs="String">
<value>0</value>
</setting>
<setting name="DelayBetweenCommands" serializeAs="String">
<value>5</value>
</setting>
</DCSBIOSBridge.Properties.Settings>
</userSettings>
</configuration>
2 changes: 1 addition & 1 deletion src/DCSBIOSBridge/DCSBIOSBridge.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyVersion>1.1.4</AssemblyVersion>
<AssemblyVersion>1.1.5</AssemblyVersion>
</PropertyGroup>
<PropertyGroup>
<PackageId>DCSBIOSBridge</PackageId>
Expand Down
2 changes: 2 additions & 0 deletions src/DCSBIOSBridge/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,8 @@ private void CreateDCSBIOS()
{
ControlSpinningWheel.RotateGear(2000);
}

_dcsBios.DelayBetweenCommands = Settings.Default.DelayBetweenCommands;
}

private void MenuItemLogFile_OnClick(object sender, RoutedEventArgs e)
Expand Down
12 changes: 12 additions & 0 deletions src/DCSBIOSBridge/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/DCSBIOSBridge/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,8 @@
<Setting Name="ShowInfoType" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
<Setting Name="DelayBetweenCommands" Type="System.Int32" Scope="User">
<Value Profile="(Default)">5</Value>
</Setting>
</Settings>
</SettingsFile>
39 changes: 21 additions & 18 deletions src/DCSBIOSBridge/Windows/SettingsWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="Settings" Height="400" Width="300"
Title="Settings" Height="450" Width="300"
Loaded="SettingsWindow_OnLoaded"
WindowStartupLocation="CenterScreen"
KeyDown="SettingsWindow_OnKeyDown" Icon="/images/app_icon.ico">
Expand All @@ -14,32 +14,35 @@
<RowDefinition Height="2*"/>
</Grid.RowDefinitions>

<StackPanel Margin="10,5,10,0" >
<Label FontWeight="Bold">DCS-BIOS Settings</Label>
<StackPanel Orientation="Horizontal">

<StackPanel Margin="10,5,10,0" >
<Label FontWeight="Bold">DCS-BIOS Settings</Label>
<StackPanel Orientation="Horizontal">
<Label/>
<Label Name="LabelDCSBIOSNotFound" FontWeight="DemiBold" Foreground="Red"/>
<Label Name="LabelDCSBIOSNotFound" FontWeight="DemiBold" Foreground="Red"/>
</StackPanel>
<StackPanel Orientation="Horizontal"/>
<StackPanel Orientation="Horizontal"/>
<Label Content="IP address to read from" Margin="0,0,0,0" VerticalAlignment="Top"/>
<TextBox Name="TextBoxDCSBIOSFromIP" Height="23" Margin="0,0,0,0" TextWrapping="Wrap" Text="239.255.50.10"/>
<Label Content="Port to read from" Margin="0,0,0,0" VerticalAlignment="Top"/>
<TextBox Name="TextBoxDCSBIOSFromPort" Height="23" Margin="0,0,0,0" TextWrapping="Wrap" Text="5010"/>
<Label Content="IP address to write to" Margin="0,0,0,0" VerticalAlignment="Top"/>
<TextBox Name="TextBoxDCSBIOSToIP" Height="23" Margin="0,0,0,0" TextWrapping="Wrap" Text="127.0.0.1"/>
<Label Content="Port to write to " Margin="0,0,0,0" VerticalAlignment="Top"/>
<TextBox Name="TextBoxDCSBIOSToPort" Height="23" Margin="0,0,0,0" TextWrapping="Wrap" Text="7778"/>
<TextBox Name="TextBoxDCSBIOSFromIP" Height="23" Margin="0,0,0,0" TextWrapping="Wrap" Text="239.255.50.10"/>
<Label Content="Port to read from" Margin="0,0,0,0" VerticalAlignment="Top"/>
<TextBox Name="TextBoxDCSBIOSFromPort" Height="23" Margin="0,0,0,0" TextWrapping="Wrap" Text="5010"/>
<Label Content="IP address to write to" Margin="0,0,0,0" VerticalAlignment="Top"/>
<TextBox Name="TextBoxDCSBIOSToIP" Height="23" Margin="0,0,0,0" TextWrapping="Wrap" Text="127.0.0.1"/>
<Label Content="Port to write to " Margin="0,0,0,0" VerticalAlignment="Top"/>
<TextBox Name="TextBoxDCSBIOSToPort" Height="23" Margin="0,0,0,0" TextWrapping="Wrap" Text="7778"/>

<Label Content="Delay between DCS-BIOS commands (>0)" Margin="0,0,0,0" VerticalAlignment="Top"/>
<TextBox Name="TextBoxDCSBIOSCommandDelay" Height="23" Margin="0,0,0,0" TextWrapping="Wrap" Text="5"/>

<TextBlock FontSize="25" HorizontalAlignment="Center" Margin="5,15,5,0" >Problems?</TextBlock>
<TextBlock TextWrapping="Wrap" Margin="5,5,5,0" FontSize="14" Background="AliceBlue" HorizontalAlignment="Center">
<TextBlock FontSize="25" HorizontalAlignment="Center" Margin="5,15,5,0" >Problems?</TextBlock>
<TextBlock TextWrapping="Wrap" Margin="5,5,5,0" FontSize="14" Background="AliceBlue" HorizontalAlignment="Center">
<Hyperlink RequestNavigate="HyperlinkRequestNavigate" NavigateUri="https://github.com/DCS-Skunkworks/DCSBIOSBridge/wiki">
<Bold>
<Run FontSize="16">Check the Wiki</Run>
</Bold>
</Hyperlink>
</TextBlock>
</StackPanel>
</TextBlock>
</StackPanel>
<StackPanel Margin="0,0,0,0" Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Content="Ok" Height="23" VerticalAlignment="Bottom" Margin="10,0,0,10" x:Name="ButtonOk" Width="75" Click="ButtonOk_OnClick"/>
<Button Content="Cancel" Height="23" VerticalAlignment="Bottom" Margin="10,0,10,10" Width="75" Click="ButtonCancel_OnClick" />
Expand Down
18 changes: 18 additions & 0 deletions src/DCSBIOSBridge/Windows/SettingsWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Navigation;
using DCS_BIOS;
using DCSBIOSBridge.Properties;

namespace DCSBIOSBridge.Windows
Expand Down Expand Up @@ -56,6 +57,7 @@ private void SetEventsHandlers()
TextBoxDCSBIOSToIP.TextChanged += DcsBiosDirty;
TextBoxDCSBIOSFromPort.TextChanged += DcsBiosDirty;
TextBoxDCSBIOSToPort.TextChanged += DcsBiosDirty;
TextBoxDCSBIOSCommandDelay.TextChanged += DcsBiosDirty;
}

private void LoadSettings()
Expand All @@ -64,6 +66,7 @@ private void LoadSettings()
TextBoxDCSBIOSToIP.Text = Settings.Default.DCSBiosIPTo;
TextBoxDCSBIOSFromPort.Text = Settings.Default.DCSBiosPortFrom;
TextBoxDCSBIOSToPort.Text = Settings.Default.DCSBiosPortTo;
TextBoxDCSBIOSCommandDelay.Text = Settings.Default.DelayBetweenCommands.ToString();
}

private void ButtonCancel_OnClick(object sender, RoutedEventArgs e)
Expand All @@ -84,7 +87,10 @@ private void ButtonOk_OnClick(object sender, RoutedEventArgs e)
Settings.Default.DCSBiosPortFrom = PortFromDCSBIOS;
Settings.Default.DCSBiosIPTo = IpAddressToDCSBIOS;
Settings.Default.DCSBiosPortTo = PortToDCSBIOS;
Settings.Default.DelayBetweenCommands = Convert.ToInt32(TextBoxDCSBIOSCommandDelay.Text);
Settings.Default.Save();

DCSBIOS.GetInstance().DelayBetweenCommands = Convert.ToInt32(TextBoxDCSBIOSCommandDelay.Text);
}

DialogResult = true;
Expand Down Expand Up @@ -158,6 +164,18 @@ private void CheckValuesDCSBIOS()
{
throw new Exception($"DCS-BIOS Error while Port to : {ex.Message}");
}
try
{
var delayValue = Convert.ToInt32(TextBoxDCSBIOSCommandDelay.Text);
if (delayValue == 0)
{
throw new Exception("Delay cannot be zero.");
}
}
catch (Exception ex)
{
throw new Exception($"DCS-BIOS Delay between DCS-BIOS commands : {ex.Message}");
}
}
catch (Exception ex)
{
Expand Down
2 changes: 1 addition & 1 deletion src/DCSFPCommon

0 comments on commit cce8085

Please sign in to comment.