diff --git a/src/DCSFPCommon b/src/DCSFPCommon index 29b6342cb..1687d481c 160000 --- a/src/DCSFPCommon +++ b/src/DCSFPCommon @@ -1 +1 @@ -Subproject commit 29b6342cbc86388097324976c368b1b3cd12fcdf +Subproject commit 1687d481c5d2e27df31000d1d849ff19a1bb798d diff --git a/src/NonVisuals/Radios/RadioPanelPZ69P51D.cs b/src/NonVisuals/Radios/RadioPanelPZ69P51D.cs index 139d8e891..416f46289 100644 --- a/src/NonVisuals/Radios/RadioPanelPZ69P51D.cs +++ b/src/NonVisuals/Radios/RadioPanelPZ69P51D.cs @@ -47,19 +47,19 @@ private enum CurrentP51DRadioMode // Large dial : Radio Mode // Small dial : Channel private readonly object _lockVhf1DialObject1 = new(); - private DCSBIOSOutput _vhf1DcsbiosOutputPresetButton0; - private DCSBIOSOutput _vhf1DcsbiosOutputPresetButton1; - private DCSBIOSOutput _vhf1DcsbiosOutputPresetButton2; - private DCSBIOSOutput _vhf1DcsbiosOutputPresetButton3; - private DCSBIOSOutput _vhf1DcsbiosOutputPresetButton4; - private volatile uint _vhf1CockpitPresetActiveButton; - private const string VHF1_VOLUME_KNOB_COMMAND_INC = "RADIO_VOLUME +2000\n"; - private const string VHF1_VOLUME_KNOB_COMMAND_DEC = "RADIO_VOLUME -2000\n"; + private DCSBIOSOutput _vhfOffOutput; + private DCSBIOSOutput _vhfChannelAOutput; + private DCSBIOSOutput _vhfChannelBOutput; + private DCSBIOSOutput _vhfChannelCOutput; + private DCSBIOSOutput _vhfChannelDOutput; + private volatile uint _vhfCockpitPresetActiveButton; + private DCSBIOSOutput _vhfVolumeOutput; + private const int VHF_VOLUME_CHANGE_VALUE = 2000; private readonly object _lockVHFRadioModeDialObject1 = new(); - private volatile uint _vhfRadioModeCockpitDial1Position = 1; - private DCSBIOSOutput _vhf1RadioModeDial1PresetDcsbiosOutput; - private volatile uint _vhfRadioModeCockpitDial2Position = 1; - private DCSBIOSOutput _vhf1RadioModeDial2PresetDcsbiosOutput; + private DCSBIOSOutput _vhfMode2Output; + private volatile uint _vhfMode2CockpitDialPosition = 1; + private DCSBIOSOutput _vhfMode3Output; + private volatile uint _vhfMode3CockpitDialPosition = 1; private readonly ClickSkipper _vhfRadioDialSkipper = new(2); private const string VHF_RADIO_LIGHT_SWITCH_COMMAND = "RADIO_LIGHTS_DIMMER TOGGLE\n"; @@ -111,13 +111,15 @@ public override void InitPanel() CreateRadioKnobs(); // VHF - _vhf1DcsbiosOutputPresetButton0 = DCSBIOSControlLocator.GetUIntDCSBIOSOutput("VHF_RADIO_ON_OFF"); - _vhf1DcsbiosOutputPresetButton1 = DCSBIOSControlLocator.GetUIntDCSBIOSOutput("VHF_RADIO_CHAN_A"); - _vhf1DcsbiosOutputPresetButton2 = DCSBIOSControlLocator.GetUIntDCSBIOSOutput("VHF_RADIO_CHAN_B"); - _vhf1DcsbiosOutputPresetButton3 = DCSBIOSControlLocator.GetUIntDCSBIOSOutput("VHF_RADIO_CHAN_C"); - _vhf1DcsbiosOutputPresetButton4 = DCSBIOSControlLocator.GetUIntDCSBIOSOutput("VHF_RADIO_CHAN_D"); - _vhf1RadioModeDial1PresetDcsbiosOutput = DCSBIOSControlLocator.GetUIntDCSBIOSOutput("RADIO_MODE2"); - _vhf1RadioModeDial2PresetDcsbiosOutput = DCSBIOSControlLocator.GetUIntDCSBIOSOutput("RADIO_MODE3"); + _vhfOffOutput = DCSBIOSControlLocator.GetUIntDCSBIOSOutput("VHF_RADIO_ON_OFF"); + _vhfChannelAOutput = DCSBIOSControlLocator.GetUIntDCSBIOSOutput("VHF_RADIO_CHAN_A"); + _vhfChannelBOutput = DCSBIOSControlLocator.GetUIntDCSBIOSOutput("VHF_RADIO_CHAN_B"); + _vhfChannelCOutput = DCSBIOSControlLocator.GetUIntDCSBIOSOutput("VHF_RADIO_CHAN_C"); + _vhfChannelDOutput = DCSBIOSControlLocator.GetUIntDCSBIOSOutput("VHF_RADIO_CHAN_D"); + _vhfMode2Output = DCSBIOSControlLocator.GetUIntDCSBIOSOutput("RADIO_MODE2"); + _vhfMode3Output = DCSBIOSControlLocator.GetUIntDCSBIOSOutput("RADIO_MODE3"); + _vhfVolumeOutput = DCSBIOSControlLocator.GetUIntDCSBIOSOutput("RADIO_VOLUME"); + // LF DETROLA _lfRadioFrequencyDcsbiosOutput = DCSBIOSControlLocator.GetUIntDCSBIOSOutput("DETROLA_FREQUENCY"); _lfRadioVolumeDcsbiosOutput = DCSBIOSControlLocator.GetUIntDCSBIOSOutput("DETROLA_VOLUME"); @@ -141,91 +143,91 @@ public override void DcsBiosDataReceived(object sender, DCSBIOSDataEventArgs e) */ // VHF On Off - if (_vhf1DcsbiosOutputPresetButton0.UIntValueHasChanged(e.Address, e.Data)) + if (_vhfOffOutput.UIntValueHasChanged(e.Address, e.Data)) { lock (_lockVhf1DialObject1) { - if (_vhf1DcsbiosOutputPresetButton0.LastUIntValue == 1) + if (_vhfOffOutput.LastUIntValue == 1) { // Radio is off - _vhf1CockpitPresetActiveButton = 0; + _vhfCockpitPresetActiveButton = 0; } Interlocked.Increment(ref _doUpdatePanelLCD); } } // VHF A - if (_vhf1DcsbiosOutputPresetButton1.UIntValueHasChanged(e.Address, e.Data)) + if (_vhfChannelAOutput.UIntValueHasChanged(e.Address, e.Data)) { lock (_lockVhf1DialObject1) { - if (_vhf1DcsbiosOutputPresetButton1.LastUIntValue == 1) + if (_vhfChannelAOutput.LastUIntValue == 1) { // Radio is on A - _vhf1CockpitPresetActiveButton = 1; + _vhfCockpitPresetActiveButton = 1; } Interlocked.Increment(ref _doUpdatePanelLCD); } } // VHF B - if (_vhf1DcsbiosOutputPresetButton2.UIntValueHasChanged(e.Address, e.Data)) + if (_vhfChannelBOutput.UIntValueHasChanged(e.Address, e.Data)) { lock (_lockVhf1DialObject1) { - if (_vhf1DcsbiosOutputPresetButton2.LastUIntValue == 1) + if (_vhfChannelBOutput.LastUIntValue == 1) { // Radio is on A - _vhf1CockpitPresetActiveButton = 2; + _vhfCockpitPresetActiveButton = 2; } Interlocked.Increment(ref _doUpdatePanelLCD); } } // VHF C - if (_vhf1DcsbiosOutputPresetButton3.UIntValueHasChanged(e.Address, e.Data)) + if (_vhfChannelCOutput.UIntValueHasChanged(e.Address, e.Data)) { lock (_lockVhf1DialObject1) { - if (_vhf1DcsbiosOutputPresetButton3.LastUIntValue == 1) + if (_vhfChannelCOutput.LastUIntValue == 1) { // Radio is on A - _vhf1CockpitPresetActiveButton = 3; + _vhfCockpitPresetActiveButton = 3; } Interlocked.Increment(ref _doUpdatePanelLCD); } } // VHF D - if (_vhf1DcsbiosOutputPresetButton4.UIntValueHasChanged(e.Address, e.Data)) + if (_vhfChannelDOutput.UIntValueHasChanged(e.Address, e.Data)) { lock (_lockVhf1DialObject1) { - if (_vhf1DcsbiosOutputPresetButton4.LastUIntValue == 1) + if (_vhfChannelDOutput.LastUIntValue == 1) { // Radio is on A - _vhf1CockpitPresetActiveButton = 4; + _vhfCockpitPresetActiveButton = 4; } Interlocked.Increment(ref _doUpdatePanelLCD); } } // VHF MODE 1 - if (_vhf1RadioModeDial1PresetDcsbiosOutput.UIntValueHasChanged(e.Address, e.Data)) + if (_vhfMode2Output.UIntValueHasChanged(e.Address, e.Data)) { lock (_lockVhf1DialObject1) { - _vhfRadioModeCockpitDial1Position = _vhf1RadioModeDial1PresetDcsbiosOutput.LastUIntValue; + _vhfMode2CockpitDialPosition = _vhfMode2Output.LastUIntValue; Interlocked.Increment(ref _doUpdatePanelLCD); } } // VHF MODE 2 - if (_vhf1RadioModeDial2PresetDcsbiosOutput.UIntValueHasChanged(e.Address, e.Data)) + if (_vhfMode3Output.UIntValueHasChanged(e.Address, e.Data)) { lock (_lockVhf1DialObject1) { - _vhfRadioModeCockpitDial2Position = _vhf1RadioModeDial2PresetDcsbiosOutput.LastUIntValue; + _vhfMode3CockpitDialPosition = _vhfMode3Output.LastUIntValue; Interlocked.Increment(ref _doUpdatePanelLCD); } } @@ -357,7 +359,7 @@ protected override void PZ69KnobChanged(IEnumerable hashSet) { if (!_upperButtonPressedAndDialRotated) { - // Do not synch if user has pressed the button to configure the radio + // Do not sync if user has pressed the button to configure the radio // Do when user releases button DCSBIOS.Send(VHF_RADIO_LIGHT_SWITCH_COMMAND); } @@ -377,7 +379,7 @@ protected override void PZ69KnobChanged(IEnumerable hashSet) { if (!_lowerButtonPressedAndDialRotated) { - // Do not synch if user has pressed the button to configure the radio + // Do not sync if user has pressed the button to configure the radio // Do when user releases button DCSBIOS.Send(VHF_RADIO_LIGHT_SWITCH_COMMAND); } @@ -465,7 +467,7 @@ private void AdjustFrequency(IEnumerable hashSet) if (_upperButtonPressed) { _upperButtonPressedAndDialRotated = true; - DCSBIOS.Send(VHF1_VOLUME_KNOB_COMMAND_INC); + DCSBIOS.Send(_vhfVolumeOutput.GetVariableCommand(VHF_VOLUME_CHANGE_VALUE)); } else if (!_vhfRadioDialSkipper.ShouldSkip()) { @@ -491,7 +493,7 @@ private void AdjustFrequency(IEnumerable hashSet) if (_upperButtonPressed) { _upperButtonPressedAndDialRotated = true; - DCSBIOS.Send(VHF1_VOLUME_KNOB_COMMAND_DEC); + DCSBIOS.Send(_vhfVolumeOutput.GetVariableCommand(VHF_VOLUME_CHANGE_VALUE * -1)); } else if (!_vhfRadioDialSkipper.ShouldSkip()) { @@ -553,7 +555,7 @@ private void AdjustFrequency(IEnumerable hashSet) if (_lowerButtonPressed) { _lowerButtonPressedAndDialRotated = true; - DCSBIOS.Send(VHF1_VOLUME_KNOB_COMMAND_INC); + DCSBIOS.Send(_vhfVolumeOutput.GetVariableCommand(VHF_VOLUME_CHANGE_VALUE)); } else if (!_vhfRadioDialSkipper.ShouldSkip()) { @@ -579,7 +581,7 @@ private void AdjustFrequency(IEnumerable hashSet) if (_lowerButtonPressed) { _lowerButtonPressedAndDialRotated = true; - DCSBIOS.Send(VHF1_VOLUME_KNOB_COMMAND_DEC); + DCSBIOS.Send(_vhfVolumeOutput.GetVariableCommand(VHF_VOLUME_CHANGE_VALUE * -1)); } else if (!_vhfRadioDialSkipper.ShouldSkip()) { @@ -643,10 +645,10 @@ private void ShowFrequenciesOnPanel() string channelAsString; lock (_lockVhf1DialObject1) { - channelAsString = _vhf1CockpitPresetActiveButton.ToString(); + channelAsString = _vhfCockpitPresetActiveButton.ToString(); } - SetPZ69DisplayBytesUnsignedInteger(ref bytes, _vhfRadioModeCockpitDial1Position, PZ69LCDPosition.UPPER_ACTIVE_LEFT); + SetPZ69DisplayBytesUnsignedInteger(ref bytes, _vhfMode2CockpitDialPosition, PZ69LCDPosition.UPPER_ACTIVE_LEFT); SetPZ69DisplayBytesUnsignedInteger(ref bytes, Convert.ToUInt32(channelAsString), PZ69LCDPosition.UPPER_STBY_RIGHT); break; } @@ -681,10 +683,10 @@ private void ShowFrequenciesOnPanel() string channelAsString; lock (_lockVhf1DialObject1) { - channelAsString = _vhf1CockpitPresetActiveButton.ToString(); + channelAsString = _vhfCockpitPresetActiveButton.ToString(); } - SetPZ69DisplayBytesUnsignedInteger(ref bytes, _vhfRadioModeCockpitDial1Position, PZ69LCDPosition.LOWER_ACTIVE_LEFT); + SetPZ69DisplayBytesUnsignedInteger(ref bytes, _vhfMode2CockpitDialPosition, PZ69LCDPosition.LOWER_ACTIVE_LEFT); SetPZ69DisplayBytesUnsignedInteger(ref bytes, Convert.ToUInt32(channelAsString), PZ69LCDPosition.LOWER_STBY_RIGHT); break; } @@ -721,29 +723,29 @@ private void SendIncVHFPresetCommand() Interlocked.Increment(ref _doUpdatePanelLCD); lock (_lockVhf1DialObject1) { - switch (_vhf1CockpitPresetActiveButton) + switch (_vhfCockpitPresetActiveButton) { case 0: { - DCSBIOS.Send("VHF_RADIO_CHAN_A 1\n"); + DCSBIOS.Send(_vhfChannelAOutput.GetIncCommand()); break; } case 1: { - DCSBIOS.Send("VHF_RADIO_CHAN_B 1\n"); + DCSBIOS.Send(_vhfChannelBOutput.GetIncCommand()); break; } case 2: { - DCSBIOS.Send("VHF_RADIO_CHAN_C 1\n"); + DCSBIOS.Send(_vhfChannelCOutput.GetIncCommand()); break; } case 3: { - DCSBIOS.Send("VHF_RADIO_CHAN_D 1\n"); + DCSBIOS.Send(_vhfChannelDOutput.GetIncCommand()); break; } @@ -755,7 +757,45 @@ private void SendIncVHFPresetCommand() } } + private void SendDecVHFPresetCommand() + { + Interlocked.Increment(ref _doUpdatePanelLCD); + lock (_lockVhf1DialObject1) + { + switch (_vhfCockpitPresetActiveButton) + { + case 0: + { + break; + } + + case 1: + { + DCSBIOS.Send(_vhfOffOutput.GetIncCommand()); + break; + } + + case 2: + { + DCSBIOS.Send(_vhfChannelAOutput.GetIncCommand()); + break; + } + + case 3: + { + DCSBIOS.Send(_vhfChannelBOutput.GetIncCommand()); + break; + } + case 4: + { + DCSBIOS.Send(_vhfChannelCOutput.GetIncCommand()); + break; + } + } + } + } + private void SendLFFrequencyCommand(bool increase) { DCSBIOS.Send(GetDetrolaFrequencyStringCommand(increase, _lfFrequencyDialChangeMonitor.ClickAndCheck() ? _lfFrequencyChangeValue * 10 : _lfFrequencyChangeValue)); @@ -813,64 +853,25 @@ private string GetHFRadioModeStringCommand(bool moveUp) */ if (moveUp) { - return _vhfRadioModeCockpitDial1Position switch + return _vhfMode2CockpitDialPosition switch { - 0 => "RADIO_MODE3 DEC\n", - 1 => "RADIO_MODE2 INC\n", + 0 => _vhfMode3Output.GetDecCommand(), + 1 => _vhfMode2Output.GetIncCommand(), 2 => null, _ => null }; } - return _vhfRadioModeCockpitDial1Position switch + return _vhfMode2CockpitDialPosition switch { 0 => null, - 1 => "RADIO_MODE3 DEC\n", - 2 => "RADIO_MODE3 DEC\n RADIO_MODE3 DEC\n", + 1 => _vhfMode3Output.GetDecCommand(), + 2 => _vhfMode3Output.GetDecCommand() + _vhfMode3Output.GetDecCommand(), _ => null }; } } - private void SendDecVHFPresetCommand() - { - Interlocked.Increment(ref _doUpdatePanelLCD); - lock (_lockVhf1DialObject1) - { - switch (_vhf1CockpitPresetActiveButton) - { - case 0: - { - break; - } - - case 1: - { - DCSBIOS.Send("VHF_RADIO_ON_OFF 1\n"); - break; - } - - case 2: - { - DCSBIOS.Send("VHF_RADIO_CHAN_A 1\n"); - break; - } - - case 3: - { - DCSBIOS.Send("VHF_RADIO_CHAN_B 1\n"); - break; - } - - case 4: - { - DCSBIOS.Send("VHF_RADIO_CHAN_C 1\n"); - break; - } - } - } - } - public override void ClearSettings(bool setIsDirty = false) { } public override DcsOutputAndColorBinding CreateDcsOutputAndColorBinding(SaitekPanelLEDPosition saitekPanelLEDPosition, PanelLEDColor panelLEDColor, DCSBIOSOutput dcsBiosOutput) @@ -910,28 +911,11 @@ private void SetLowerRadioMode(CurrentP51DRadioMode currentP51DRadioMode) } } - public override void RemoveSwitchFromList(object controlList, PanelSwitchOnOff panelSwitchOnOff) - { - } - - public override void AddOrUpdateKeyStrokeBinding(PanelSwitchOnOff panelSwitchOnOff, string keyPress, KeyPressLength keyPressLength) - { - } - - public override void AddOrUpdateSequencedKeyBinding(PanelSwitchOnOff panelSwitchOnOff, string description, SortedList keySequence) - { - } - - public override void AddOrUpdateDCSBIOSBinding(PanelSwitchOnOff panelSwitchOnOff, List dcsbiosInputs, string description, bool isSequenced) - { - } - - public override void AddOrUpdateBIPLinkBinding(PanelSwitchOnOff panelSwitchOnOff, BIPLinkBase bipLink) - { - } - - public override void AddOrUpdateOSCommandBinding(PanelSwitchOnOff panelSwitchOnOff, OSCommand operatingSystemCommand) - { - } + public override void RemoveSwitchFromList(object controlList, PanelSwitchOnOff panelSwitchOnOff) { } + public override void AddOrUpdateKeyStrokeBinding(PanelSwitchOnOff panelSwitchOnOff, string keyPress, KeyPressLength keyPressLength) { } + public override void AddOrUpdateSequencedKeyBinding(PanelSwitchOnOff panelSwitchOnOff, string description, SortedList keySequence) { } + public override void AddOrUpdateDCSBIOSBinding(PanelSwitchOnOff panelSwitchOnOff, List dcsbiosInputs, string description, bool isSequenced) { } + public override void AddOrUpdateBIPLinkBinding(PanelSwitchOnOff panelSwitchOnOff, BIPLinkBase bipLink) { } + public override void AddOrUpdateOSCommandBinding(PanelSwitchOnOff panelSwitchOnOff, OSCommand operatingSystemCommand) { } } }