Skip to content

Commit

Permalink
Merge branch 'radios-use-output-commands' of https://github.com/jdahl…
Browse files Browse the repository at this point in the history
…blom/DCSFlightpanels into radios-use-output-commands
  • Loading branch information
jdahlblom committed Apr 3, 2024
2 parents aecbaa2 + ff060e4 commit 6106a09
Showing 1 changed file with 27 additions and 26 deletions.
53 changes: 27 additions & 26 deletions src/NonVisuals/Radios/RadioPanelPZ69A10C.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NonVisuals.BindingClasses.BIP;
using DCS_BIOS.misc;
using NonVisuals.BindingClasses.BIP;

namespace NonVisuals.Radios
{
Expand Down Expand Up @@ -935,15 +936,15 @@ private void VhfAmSyncThreadMethod(int desiredPositionDial1, int desiredPosition
if (_vhfAmCockpitFreq4DialPos < desiredPositionDial4)
{
dial4OkTime = DateTime.Now.Ticks;
str = VHF_AM_FREQ_4DIAL_COMMAND + DCSBIOS_INCREASE_COMMAND;
str = VHF_AM_FREQ_4DIAL_COMMAND + DCSBIOSCommand.DCSBIOS_INCREMENT;
DCSBIOS.Send(str);
dial4SendCount++;
Interlocked.Exchange(ref _vhfAmDial4WaitingForFeedback, 1);
}
else if (_vhfAmCockpitFreq4DialPos > desiredPositionDial4)
{
dial4OkTime = DateTime.Now.Ticks;
str = VHF_AM_FREQ_4DIAL_COMMAND + DCSBIOS_DECREASE_COMMAND;
str = VHF_AM_FREQ_4DIAL_COMMAND + DCSBIOSCommand.DCSBIOS_DECREMENT;
DCSBIOS.Send(str);
dial4SendCount++;
Interlocked.Exchange(ref _vhfAmDial4WaitingForFeedback, 1);
Expand Down Expand Up @@ -1204,14 +1205,14 @@ private void UhfSyncThreadMethod(int desiredPosition1, int desiredPosition2, int

if (_uhfCockpitFreq1DialPos < desiredPosition1)
{
const string str = UHF_FREQ_1DIAL_COMMAND + DCSBIOS_INCREASE_COMMAND;
const string str = UHF_FREQ_1DIAL_COMMAND + DCSBIOSCommand.DCSBIOS_INCREMENT;
DCSBIOS.Send(str);
dial1SendCount++;
Interlocked.Exchange(ref _uhfDial1WaitingForFeedback, 1);
}
else if (_uhfCockpitFreq1DialPos > desiredPosition1)
{
const string str = UHF_FREQ_1DIAL_COMMAND + DCSBIOS_DECREASE_COMMAND;
const string str = UHF_FREQ_1DIAL_COMMAND + DCSBIOSCommand.DCSBIOS_DECREMENT;
DCSBIOS.Send(str);
dial1SendCount++;
Interlocked.Exchange(ref _uhfDial1WaitingForFeedback, 1);
Expand All @@ -1236,14 +1237,14 @@ private void UhfSyncThreadMethod(int desiredPosition1, int desiredPosition2, int

if (_uhfCockpitFreq2DialPos < desiredPosition2)
{
const string str = UHF_FREQ_2DIAL_COMMAND + DCSBIOS_INCREASE_COMMAND;
const string str = UHF_FREQ_2DIAL_COMMAND + DCSBIOSCommand.DCSBIOS_INCREMENT;
DCSBIOS.Send(str);
dial2SendCount++;
Interlocked.Exchange(ref _uhfDial2WaitingForFeedback, 1);
}
else if (_uhfCockpitFreq2DialPos > desiredPosition2)
{
const string str = UHF_FREQ_2DIAL_COMMAND + DCSBIOS_DECREASE_COMMAND;
const string str = UHF_FREQ_2DIAL_COMMAND + DCSBIOSCommand.DCSBIOS_DECREMENT;
DCSBIOS.Send(str);
dial2SendCount++;
Interlocked.Exchange(ref _uhfDial2WaitingForFeedback, 1);
Expand All @@ -1268,14 +1269,14 @@ private void UhfSyncThreadMethod(int desiredPosition1, int desiredPosition2, int

if (_uhfCockpitFreq3DialPos < desiredPosition3)
{
const string str = UHF_FREQ_3DIAL_COMMAND + DCSBIOS_INCREASE_COMMAND;
const string str = UHF_FREQ_3DIAL_COMMAND + DCSBIOSCommand.DCSBIOS_INCREMENT;
DCSBIOS.Send(str);
dial3SendCount++;
Interlocked.Exchange(ref _uhfDial3WaitingForFeedback, 1);
}
else if (_uhfCockpitFreq3DialPos > desiredPosition3)
{
const string str = UHF_FREQ_3DIAL_COMMAND + DCSBIOS_DECREASE_COMMAND;
const string str = UHF_FREQ_3DIAL_COMMAND + DCSBIOSCommand.DCSBIOS_DECREMENT;
DCSBIOS.Send(str);
dial3SendCount++;
Interlocked.Exchange(ref _uhfDial3WaitingForFeedback, 1);
Expand All @@ -1300,14 +1301,14 @@ private void UhfSyncThreadMethod(int desiredPosition1, int desiredPosition2, int

if (_uhfCockpitFreq4DialPos < desiredPosition4)
{
const string str = UHF_FREQ_4DIAL_COMMAND + DCSBIOS_INCREASE_COMMAND;
const string str = UHF_FREQ_4DIAL_COMMAND + DCSBIOSCommand.DCSBIOS_INCREMENT;
DCSBIOS.Send(str);
dial4SendCount++;
Interlocked.Exchange(ref _uhfDial4WaitingForFeedback, 1);
}
else if (_uhfCockpitFreq4DialPos > desiredPosition4)
{
const string str = UHF_FREQ_4DIAL_COMMAND + DCSBIOS_DECREASE_COMMAND;
const string str = UHF_FREQ_4DIAL_COMMAND + DCSBIOSCommand.DCSBIOS_DECREMENT;
DCSBIOS.Send(str);
dial4SendCount++;
Interlocked.Exchange(ref _uhfDial4WaitingForFeedback, 1);
Expand All @@ -1332,14 +1333,14 @@ private void UhfSyncThreadMethod(int desiredPosition1, int desiredPosition2, int

if (_uhfCockpitFreq5DialPos < desiredPosition5)
{
const string str = UHF_FREQ_5DIAL_COMMAND + DCSBIOS_INCREASE_COMMAND;
const string str = UHF_FREQ_5DIAL_COMMAND + DCSBIOSCommand.DCSBIOS_INCREMENT;
DCSBIOS.Send(str);
dial5SendCount++;
Interlocked.Exchange(ref _uhfDial5WaitingForFeedback, 1);
}
else if (_uhfCockpitFreq5DialPos > desiredPosition5)
{
const string str = UHF_FREQ_5DIAL_COMMAND + DCSBIOS_DECREASE_COMMAND;
const string str = UHF_FREQ_5DIAL_COMMAND + DCSBIOSCommand.DCSBIOS_DECREMENT;
DCSBIOS.Send(str);
dial5SendCount++;
Interlocked.Exchange(ref _uhfDial5WaitingForFeedback, 1);
Expand Down Expand Up @@ -1568,15 +1569,15 @@ private void VhfFmSyncThreadMethod(int desiredPositionDial1, int desiredPosition
if (_vhfFmCockpitFreq4DialPos < frequencyDial4)
{
dial4OkTime = DateTime.Now.Ticks;
const string str = VHF_FM_FREQ_4DIAL_COMMAND + DCSBIOS_INCREASE_COMMAND;
const string str = VHF_FM_FREQ_4DIAL_COMMAND + DCSBIOSCommand.DCSBIOS_INCREMENT;
DCSBIOS.Send(str);
dial4SendCount++;
Interlocked.Exchange(ref _vhfFmDial4WaitingForFeedback, 1);
}
else if (_vhfFmCockpitFreq4DialPos > frequencyDial4)
{
dial4OkTime = DateTime.Now.Ticks;
const string str = VHF_FM_FREQ_4DIAL_COMMAND + DCSBIOS_DECREASE_COMMAND;
const string str = VHF_FM_FREQ_4DIAL_COMMAND + DCSBIOSCommand.DCSBIOS_DECREMENT;
DCSBIOS.Send(str);
dial4SendCount++;
Interlocked.Exchange(ref _vhfFmDial4WaitingForFeedback, 1);
Expand Down Expand Up @@ -1692,15 +1693,15 @@ private void ILSSyncThreadMethod(int position1, int position2)
if (_ilsCockpitFreq1DialPos < position1)
{
dial1OkTime = DateTime.Now.Ticks;
const string str = ILS_FREQ1_DIAL_COMMAND + DCSBIOS_INCREASE_COMMAND;
const string str = ILS_FREQ1_DIAL_COMMAND + DCSBIOSCommand.DCSBIOS_INCREMENT;
DCSBIOS.Send(str);
dial1SendCount++;
Interlocked.Exchange(ref _ilsDial1WaitingForFeedback, 1);
}
else if (_ilsCockpitFreq1DialPos > position1)
{
dial1OkTime = DateTime.Now.Ticks;
const string str = ILS_FREQ1_DIAL_COMMAND + DCSBIOS_DECREASE_COMMAND;
const string str = ILS_FREQ1_DIAL_COMMAND + DCSBIOSCommand.DCSBIOS_DECREMENT;
DCSBIOS.Send(str);
dial1SendCount++;
Interlocked.Exchange(ref _ilsDial1WaitingForFeedback, 1);
Expand All @@ -1722,15 +1723,15 @@ private void ILSSyncThreadMethod(int position1, int position2)
if (_ilsCockpitFreq2DialPos < position2)
{
dial2OkTime = DateTime.Now.Ticks;
const string str = ILS_FREQ2_DIAL_COMMAND + DCSBIOS_INCREASE_COMMAND;
const string str = ILS_FREQ2_DIAL_COMMAND + DCSBIOSCommand.DCSBIOS_INCREMENT;
DCSBIOS.Send(str);
dial2SendCount++;
Interlocked.Exchange(ref _ilsDial2WaitingForFeedback, 1);
}
else if (_ilsCockpitFreq2DialPos > position2)
{
dial2OkTime = DateTime.Now.Ticks;
const string str = ILS_FREQ2_DIAL_COMMAND + DCSBIOS_DECREASE_COMMAND;
const string str = ILS_FREQ2_DIAL_COMMAND + DCSBIOSCommand.DCSBIOS_DECREMENT;
DCSBIOS.Send(str);
dial2SendCount++;
Interlocked.Exchange(ref _ilsDial2WaitingForFeedback, 1);
Expand Down Expand Up @@ -1849,7 +1850,7 @@ private void TacanSyncThreadMethod(int desiredPositionDial1, int desiredPosition
if (_tacanCockpitFreq1DialPos != desiredPositionDial1)
{
dial1OkTime = DateTime.Now.Ticks;
var str = TACAN_FREQ1_DIAL_COMMAND + (_tacanCockpitFreq1DialPos < desiredPositionDial1 ? DCSBIOS_INCREASE_COMMAND : DCSBIOS_DECREASE_COMMAND);
var str = TACAN_FREQ1_DIAL_COMMAND + (_tacanCockpitFreq1DialPos < desiredPositionDial1 ? DCSBIOSCommand.DCSBIOS_INCREMENT : DCSBIOSCommand.DCSBIOS_DECREMENT);
DCSBIOS.Send(str);
dial1SendCount++;
Interlocked.Exchange(ref _tacanDial1WaitingForFeedback, 1);
Expand All @@ -1872,7 +1873,7 @@ private void TacanSyncThreadMethod(int desiredPositionDial1, int desiredPosition
{
dial2OkTime = DateTime.Now.Ticks;

var str = TACAN_FREQ2_DIAL_COMMAND + (_tacanCockpitFreq2DialPos < desiredPositionDial2 ? DCSBIOS_INCREASE_COMMAND : DCSBIOS_DECREASE_COMMAND);
var str = TACAN_FREQ2_DIAL_COMMAND + (_tacanCockpitFreq2DialPos < desiredPositionDial2 ? DCSBIOSCommand.DCSBIOS_INCREMENT : DCSBIOSCommand.DCSBIOS_DECREMENT);
DCSBIOS.Send(str);
dial2SendCount++;
Interlocked.Exchange(ref _tacanDial2WaitingForFeedback, 1);
Expand All @@ -1895,7 +1896,7 @@ private void TacanSyncThreadMethod(int desiredPositionDial1, int desiredPosition
{
dial3OkTime = DateTime.Now.Ticks;

var str = TACAN_FREQ3_DIAL_COMMAND + (_tacanCockpitFreq3DialPos < desiredPositionDial3 ? DCSBIOS_INCREASE_COMMAND : DCSBIOS_DECREASE_COMMAND);
var str = TACAN_FREQ3_DIAL_COMMAND + (_tacanCockpitFreq3DialPos < desiredPositionDial3 ? DCSBIOSCommand.DCSBIOS_INCREMENT : DCSBIOSCommand.DCSBIOS_DECREMENT);
DCSBIOS.Send(str);
dial3SendCount++;
Interlocked.Exchange(ref _tacanDial3WaitingForFeedback, 1);
Expand Down Expand Up @@ -4002,9 +4003,9 @@ public static string GetCommandDirectionForVhfDial1(int desiredDialPosition, uin
int shift = desiredDialPosition - (int)actualDialPosition;

if (shift > 0)
return shift <= 6 ? DCSBIOS_INCREASE_COMMAND : DCSBIOS_DECREASE_COMMAND;
return shift <= 6 ? DCSBIOSCommand.DCSBIOS_INCREMENT : DCSBIOSCommand.DCSBIOS_DECREMENT;
else
return shift < -6 ? DCSBIOS_INCREASE_COMMAND : DCSBIOS_DECREASE_COMMAND;
return shift < -6 ? DCSBIOSCommand.DCSBIOS_INCREMENT : DCSBIOSCommand.DCSBIOS_DECREMENT;
}

/// <summary>
Expand All @@ -4021,9 +4022,9 @@ public static string GetCommandDirectionForVhfDial23(int desiredDialPosition, ui
int shift = desiredDialPosition - (int)actualDialPosition;

if (shift > 0)
return shift <= 5 ? DCSBIOS_INCREASE_COMMAND : DCSBIOS_DECREASE_COMMAND;
return shift <= 5 ? DCSBIOSCommand.DCSBIOS_INCREMENT : DCSBIOSCommand.DCSBIOS_DECREMENT;
else
return shift <= -5 ? DCSBIOS_INCREASE_COMMAND : DCSBIOS_DECREASE_COMMAND;
return shift <= -5 ? DCSBIOSCommand.DCSBIOS_INCREMENT : DCSBIOSCommand.DCSBIOS_DECREMENT;
}

private void SaveCockpitFrequencyVhfAm()
Expand Down

0 comments on commit 6106a09

Please sign in to comment.