Skip to content

Commit

Permalink
Smaller fixes (#510)
Browse files Browse the repository at this point in the history
* Smaller fixes

ControlSpinningWheel visibility set properly
DCSBIOS.Send using concurrentqueue
Removed imports

* Fix spelling

* Update submodule
  • Loading branch information
jdahlblom authored Apr 1, 2024
1 parent 4fec2cf commit 519186d
Show file tree
Hide file tree
Showing 27 changed files with 313 additions and 336 deletions.
1 change: 1 addition & 0 deletions src/DCSFlightpanels.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OS/@EntryIndexedValue">OS</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OSCOMMANDS/@EntryIndexedValue">OSCOMMANDS</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PURPLE/@EntryIndexedValue">PURPLE</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PZ/@EntryIndexedValue">PZ</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RED/@EntryIndexedValue">RED</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=REF/@EntryIndexedValue">REF</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SA/@EntryIndexedValue">SA</s:String>
Expand Down
10 changes: 8 additions & 2 deletions src/DCSFlightpanels/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ ADF AJS ALL ALT APR BIOS BIP BIPS COM CRS DB DCS DCSBIOS DCSBIOSJSON DME DRO HDG
using NonVisuals.HID;
using DCS_BIOS.Serialized;
using DCS_BIOS.ControlLocator;
using System.Windows.Threading;

public partial class MainWindow : IGamingPanelListener, IDcsBiosConnectionListener, ISettingsModifiedListener, IProfileHandlerListener, IDisposable, IHardwareConflictResolver, IPanelEventListener, IForwardPanelEventListener, IDCSBIOSStringListener
{
Expand Down Expand Up @@ -316,13 +317,16 @@ private void CreateDCSBIOS()
return;
}

ControlSpinningWheel.Visibility = Visibility.Visible;

DCSBIOSControlLocator.DCSAircraft = _profileHandler.DCSAircraft;

_dcsBios = new DCSBIOS(Settings.Default.DCSBiosIPFrom,
Settings.Default.DCSBiosIPTo,
int.Parse(Settings.Default.DCSBiosPortFrom),
int.Parse(Settings.Default.DCSBiosPortTo),
DcsBiosNotificationMode.Parse);

if (!_dcsBios.HasLastException())
{
ControlSpinningWheel.RotateGear(2000);
Expand All @@ -331,6 +335,8 @@ private void CreateDCSBIOS()

private void StartupDCSBIOS()
{
ControlSpinningWheel.Visibility = Visibility.Visible;

if (_dcsBios.IsRunning)
{
return;
Expand Down Expand Up @@ -714,7 +720,7 @@ private void MenuItemCloseProfile_OnClick(object sender, RoutedEventArgs e)
}
finally
{
Mouse.OverrideCursor = null;
Mouse.OverrideCursor = Cursors.Arrow;
}
}
catch (Exception ex)
Expand Down Expand Up @@ -847,7 +853,7 @@ public void DcsBiosConnectionActive(object sender, DCSBIOSConnectionEventArgs e)
{
try
{
Dispatcher?.BeginInvoke((Action)(() => ControlSpinningWheel.RotateGear()));
Dispatcher?.BeginInvoke(() => ControlSpinningWheel.RotateGear());
}
catch (Exception ex)
{
Expand Down
10 changes: 2 additions & 8 deletions src/DCSFlightpanels/PanelUserControls/StreamDeck/Resources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,11 @@ internal static class Resources

public static BitmapImage GetDefaultButtonImageNamed(EnumStreamDeckButtonNames streamDeckButtonName)
{
lock (LockDefault)
{
return new BitmapImage(new Uri(StreamDeckConstants.NUMBER_BUTTON_LOCATION + StreamDeckCommon.ButtonNumber(streamDeckButtonName) + "_blue.png", UriKind.Absolute));
}
return new BitmapImage(new Uri(StreamDeckConstants.NUMBER_BUTTON_LOCATION + StreamDeckCommon.ButtonNumber(streamDeckButtonName) + "_blue.png", UriKind.Absolute));
}
public static BitmapImage GetButtonDcsBiosDecoderRule()
{
lock (LockDecoder)
{
return new BitmapImage(new Uri(StreamDeckConstants.StreamDeckGalleryPathMisc + "DcsBiosDecoderRule.png", UriKind.Absolute));
}
return new BitmapImage(new Uri(StreamDeckConstants.StreamDeckGalleryPathMisc + "DcsBiosDecoderRule.png", UriKind.Absolute));
}
}
}
351 changes: 166 additions & 185 deletions src/DCSFlightpanels/ProfileHandler.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protected override void GamingPanelKnobChanged(bool isFirstReport, IEnumerable<o
{
foreach (CDUMappedCommandKey key in hashSet)
{
_ = DCSBIOS.Send(key.MappedCommand());
DCSBIOS.Send(key.MappedCommand());
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ protected override void GamingPanelKnobChanged(bool isFirstReport, IEnumerable<o

foreach (CDUMappedCommandKey key in hashSet)
{
_ = DCSBIOS.Send(key.MappedCommand());
DCSBIOS.Send(key.MappedCommand());
}
}
catch (Exception)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ protected override void GamingPanelKnobChanged(bool isFirstReport, IEnumerable<o
{
foreach (CDUMappedCommandKey key in hashSet)
{
_ = DCSBIOS.Send(key.MappedCommand());
DCSBIOS.Send(key.MappedCommand());
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ protected override void GamingPanelKnobChanged(bool isFirstReport, IEnumerable<o
{
foreach (CDUMappedCommandKey key in hashSet)
{
_ = DCSBIOS.Send(key.MappedCommand());
DCSBIOS.Send(key.MappedCommand());
}
}
catch (Exception)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected override void GamingPanelKnobChanged(bool isFirstReport, IEnumerable<o
{
foreach (CDUMappedCommandKey key in hashSet)
{
_ = DCSBIOS.Send(key.MappedCommand());
DCSBIOS.Send(key.MappedCommand());
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected override void GamingPanelKnobChanged(bool isFirstReport, IEnumerable<o

foreach (CDUMappedCommandKey key in hashSet)
{
_ = DCSBIOS.Send(key.MappedCommand());
DCSBIOS.Send(key.MappedCommand());
}
}
catch (Exception)
Expand Down
40 changes: 20 additions & 20 deletions src/NonVisuals/Radios/RadioPanelPZ69A10C.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private enum CurrentA10RadioMode
private const string VHF_AM_FREQ_3DIAL_COMMAND = "VHFAM_FREQ3 ";
private const string VHF_AM_FREQ_4DIAL_COMMAND = "VHFAM_FREQ4 ";
private Thread _vhfAmSyncThread;
private long _vhfAmThreadNowSynching;
private long _vhfAmThreadNowSyncing;
private long _vhfAmDial1WaitingForFeedback;
private long _vhfAmDial2WaitingForFeedback;
private long _vhfAmDial3WaitingForFeedback;
Expand Down Expand Up @@ -118,7 +118,7 @@ private enum CurrentA10RadioMode
private const string UHF_FREQ_4DIAL_COMMAND = "UHF_POINT1MHZ_SEL "; // 0 1 2 3 4 5 6 7 8 9
private const string UHF_FREQ_5DIAL_COMMAND = "UHF_POINT25_SEL "; // "00" "25" "50" "75"
private Thread _uhfSyncThread;
private long _uhfThreadNowSynching;
private long _uhfThreadNowSyncing;
private long _uhfDial1WaitingForFeedback;
private long _uhfDial2WaitingForFeedback;
private long _uhfDial3WaitingForFeedback;
Expand Down Expand Up @@ -165,7 +165,7 @@ private enum CurrentA10RadioMode
private const string VHF_FM_FREQ_3DIAL_COMMAND = "VHFFM_FREQ3 ";
private const string VHF_FM_FREQ_4DIAL_COMMAND = "VHFFM_FREQ4 ";
private Thread _vhfFmSyncThread;
private long _vhfFmThreadNowSynching;
private long _vhfFmThreadNowSyncing;
private long _vhfFmDial1WaitingForFeedback;
private long _vhfFmDial2WaitingForFeedback;
private long _vhfFmDial3WaitingForFeedback;
Expand Down Expand Up @@ -203,7 +203,7 @@ private enum CurrentA10RadioMode
private const string ILS_FREQ1_DIAL_COMMAND = "ILS_MHZ ";
private const string ILS_FREQ2_DIAL_COMMAND = "ILS_KHZ ";
private Thread _ilsSyncThread;
private long _ilsThreadNowSynching;
private long _ilsThreadNowSyncing;
private long _ilsDial1WaitingForFeedback;
private long _ilsDial2WaitingForFeedback;

Expand All @@ -229,7 +229,7 @@ private enum CurrentA10RadioMode
private const string TACAN_FREQ2_DIAL_COMMAND = "TACAN_1 ";
private const string TACAN_FREQ3_DIAL_COMMAND = "TACAN_XY ";
private Thread _tacanSyncThread;
private long _tacanThreadNowSynching;
private long _tacanThreadNowSyncing;
private long _tacanDial1WaitingForFeedback;
private long _tacanDial2WaitingForFeedback;
private long _tacanDial3WaitingForFeedback;
Expand Down Expand Up @@ -828,7 +828,7 @@ private void VhfAmSynchThreadMethod(int desiredPositionDial1, int desiredPositio
* Small dial 0.00-0.95 [step of 0.05]
*/

Interlocked.Exchange(ref _vhfAmThreadNowSynching, 1);
Interlocked.Exchange(ref _vhfAmThreadNowSyncing, 1);
long dial1Timeout = DateTime.Now.Ticks;
long dial2Timeout = DateTime.Now.Ticks;
long dial3Timeout = DateTime.Now.Ticks;
Expand Down Expand Up @@ -982,7 +982,7 @@ private void VhfAmSynchThreadMethod(int desiredPositionDial1, int desiredPositio
}
finally
{
Interlocked.Exchange(ref _vhfAmThreadNowSynching, 0);
Interlocked.Exchange(ref _vhfAmThreadNowSyncing, 0);
}

Interlocked.Increment(ref _doUpdatePanelLCD);
Expand Down Expand Up @@ -1147,7 +1147,7 @@ private void UhfSynchThreadMethod(int desiredPosition1, int desiredPosition2, in
{
try
{
Interlocked.Exchange(ref _uhfThreadNowSynching, 1);
Interlocked.Exchange(ref _uhfThreadNowSyncing, 1);
long dial1Timeout = DateTime.Now.Ticks;
long dial2Timeout = DateTime.Now.Ticks;
long dial3Timeout = DateTime.Now.Ticks;
Expand Down Expand Up @@ -1378,7 +1378,7 @@ private void UhfSynchThreadMethod(int desiredPosition1, int desiredPosition2, in
}
finally
{
Interlocked.Exchange(ref _uhfThreadNowSynching, 0);
Interlocked.Exchange(ref _uhfThreadNowSyncing, 0);
}

Interlocked.Increment(ref _doUpdatePanelLCD);
Expand Down Expand Up @@ -1458,7 +1458,7 @@ private void VhfFmSynchThreadMethod(int desiredPositionDial1, int desiredPositio
{
try
{
Interlocked.Exchange(ref _vhfFmThreadNowSynching, 1);
Interlocked.Exchange(ref _vhfFmThreadNowSyncing, 1);
var dial1Timeout = DateTime.Now.Ticks;
var dial2Timeout = DateTime.Now.Ticks;
var dial3Timeout = DateTime.Now.Ticks;
Expand Down Expand Up @@ -1616,7 +1616,7 @@ private void VhfFmSynchThreadMethod(int desiredPositionDial1, int desiredPositio
}
finally
{
Interlocked.Exchange(ref _vhfFmThreadNowSynching, 0);
Interlocked.Exchange(ref _vhfFmThreadNowSyncing, 0);
}

Interlocked.Increment(ref _doUpdatePanelLCD);
Expand Down Expand Up @@ -1664,7 +1664,7 @@ private void ILSSynchThreadMethod(int position1, int position2)
{
try
{
Interlocked.Exchange(ref _ilsThreadNowSynching, 1);
Interlocked.Exchange(ref _ilsThreadNowSyncing, 1);

long dial1Timeout = DateTime.Now.Ticks;
long dial2Timeout = DateTime.Now.Ticks;
Expand Down Expand Up @@ -1767,7 +1767,7 @@ private void ILSSynchThreadMethod(int position1, int position2)
}
finally
{
Interlocked.Exchange(ref _ilsThreadNowSynching, 0);
Interlocked.Exchange(ref _ilsThreadNowSyncing, 0);
}

Interlocked.Increment(ref _doUpdatePanelLCD);
Expand Down Expand Up @@ -1810,7 +1810,7 @@ private void TacanSynchThreadMethod(int desiredPositionDial1, int desiredPositio
{
try
{
Interlocked.Exchange(ref _tacanThreadNowSynching, 1);
Interlocked.Exchange(ref _tacanThreadNowSyncing, 1);

long dial1Timeout = DateTime.Now.Ticks;
long dial2Timeout = DateTime.Now.Ticks;
Expand Down Expand Up @@ -1935,7 +1935,7 @@ private void TacanSynchThreadMethod(int desiredPositionDial1, int desiredPositio
}
finally
{
Interlocked.Exchange(ref _tacanThreadNowSynching, 0);
Interlocked.Exchange(ref _tacanThreadNowSyncing, 0);
}

Interlocked.Increment(ref _doUpdatePanelLCD);
Expand Down Expand Up @@ -4264,27 +4264,27 @@ private bool UhfPresetSelected()

private bool VhfAmNowSyncing()
{
return Interlocked.Read(ref _vhfAmThreadNowSynching) > 0;
return Interlocked.Read(ref _vhfAmThreadNowSyncing) > 0;
}

private bool UhfNowSyncing()
{
return Interlocked.Read(ref _uhfThreadNowSynching) > 0;
return Interlocked.Read(ref _uhfThreadNowSyncing) > 0;
}

private bool VhfFmNowSyncing()
{
return Interlocked.Read(ref _vhfFmThreadNowSynching) > 0;
return Interlocked.Read(ref _vhfFmThreadNowSyncing) > 0;
}

private bool IlsNowSyncing()
{
return Interlocked.Read(ref _ilsThreadNowSynching) > 0;
return Interlocked.Read(ref _ilsThreadNowSyncing) > 0;
}

private bool TacanNowSyncing()
{
return Interlocked.Read(ref _tacanThreadNowSynching) > 0;
return Interlocked.Read(ref _tacanThreadNowSyncing) > 0;
}

public override void RemoveSwitchFromList(object controlList, PanelSwitchOnOff panelSwitchOnOff)
Expand Down
Loading

0 comments on commit 519186d

Please sign in to comment.