Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/Move-tests-to-own-project-DCSFP.…
Browse files Browse the repository at this point in the history
…Tests' into Move-tests-to-own-project-DCSFP.Tests
  • Loading branch information
Mutex666 committed Mar 9, 2024
2 parents 7e0c7f9 + 83f4614 commit 90e46dd
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 28 deletions.
46 changes: 24 additions & 22 deletions src/NonVisuals/Radios/RadioControls/FlightRadio.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using NonVisuals.Radios.RadioSettings;

[assembly: InternalsVisibleTo("DCSFP.Tests")]
namespace NonVisuals.Radios.RadioControls
{
public enum FlightRadioFrequencyBand
internal enum FlightRadioFrequencyBand
{
HF = 0,
VHF1 = 1,
VHF2 = 2,
UHF = 3
}

public class FlightRadio
internal class FlightRadio
{
private uint _integerFrequencyStandby;
private uint _decimalFrequencyStandby;
Expand All @@ -28,12 +30,12 @@ public class FlightRadio
private readonly FlightRadioSettings _settings;
private bool _isInitialized;

public FlightRadio(FlightRadioSettings flightRadioSettings)
internal FlightRadio(FlightRadioSettings flightRadioSettings)
{
_settings = flightRadioSettings;
}

public void InitRadio()
internal void InitRadio()
{
_isInitialized = true;
_settings.VerifySettings();
Expand All @@ -55,7 +57,7 @@ private void VerifyIsInitialized()
/// Move up whole number part of standby frequency
/// </summary>
/// <param name="changeFaster"></param>
public void IntegerFrequencyUp(bool changeFaster = false)
internal void IntegerFrequencyUp(bool changeFaster = false)
{
VerifyIsInitialized();

Expand All @@ -75,7 +77,7 @@ public void IntegerFrequencyUp(bool changeFaster = false)
/// Move down whole number part of standby frequency
/// </summary>
/// <param name="changeFaster"></param>
public void IntegerFrequencyDown(bool changeFaster = false)
internal void IntegerFrequencyDown(bool changeFaster = false)
{
VerifyIsInitialized();

Expand All @@ -95,7 +97,7 @@ public void IntegerFrequencyDown(bool changeFaster = false)
/// Move up decimal part of standby frequency
/// </summary>
/// <param name="changeFaster"></param>
public void DecimalFrequencyUp(bool changeFaster = false)
internal void DecimalFrequencyUp(bool changeFaster = false)
{
VerifyIsInitialized();

Expand All @@ -113,7 +115,7 @@ public void DecimalFrequencyUp(bool changeFaster = false)
/// Move down decimal part of standby frequency
/// </summary>
/// <param name="changeFaster"></param>
public void DecimalFrequencyDown(bool changeFaster = false)
internal void DecimalFrequencyDown(bool changeFaster = false)
{
VerifyIsInitialized();

Expand All @@ -127,17 +129,17 @@ public void DecimalFrequencyDown(bool changeFaster = false)
SubtractDecimalFrequencyStandby(changeFaster ? _settings.DecimalHighChangeRates[(int)_activeFrequencyBand] : _settings.DecimalChangeRates[(int)_activeFrequencyBand]);
}

public string StandbyFrequency => GetIntegerFrequencyStandby() + "." + GetDecimalFrequencyStandby().ToString().PadLeft(3, '0').Trim();
internal string StandbyFrequency => GetIntegerFrequencyStandby() + "." + GetDecimalFrequencyStandby().ToString().PadLeft(3, '0').Trim();

public string CockpitFrequency => _cockpitFrequency.Trim();
internal string CockpitFrequency => _cockpitFrequency.Trim();

public string ActiveFrequencyBandId => ((int)_activeFrequencyBand).ToString();
internal string ActiveFrequencyBandId => ((int)_activeFrequencyBand).ToString();

public string TemporaryFrequencyBandId => ((int)_tempFrequencyBand).ToString();
internal string TemporaryFrequencyBandId => ((int)_tempFrequencyBand).ToString();

public FlightRadioFrequencyBand TemporaryFrequencyBand => _tempFrequencyBand;
internal FlightRadioFrequencyBand TemporaryFrequencyBand => _tempFrequencyBand;

public void SetCockpitFrequency(string frequency)
internal void SetCockpitFrequency(string frequency)
{
VerifyIsInitialized();

Expand Down Expand Up @@ -166,7 +168,7 @@ public void SetCockpitFrequency(string frequency)
Debug.WriteLine(LastFrequencies());
}

public void SwitchFrequencyBand()
internal void SwitchFrequencyBand()
{
VerifyIsInitialized();

Expand All @@ -192,7 +194,7 @@ private void SetStandbyFrequency(string frequency)
SetDecimalFrequencyStandby(uint.Parse(array[1]));
}

public string GetDCSBIOSCommand()
internal string GetDCSBIOSCommand()
{
return $"{_settings.DCSBIOSIdentifier} {StandbyFrequency}\n";
}
Expand Down Expand Up @@ -224,7 +226,7 @@ private FlightRadioFrequencyBand GetFrequencyBand(string frequency)
throw new Exception("FlightRadio : Frequency not matching any frequency bands.");
}

public void TemporaryFrequencyBandUp()
internal void TemporaryFrequencyBandUp()
{
VerifyIsInitialized();

Expand Down Expand Up @@ -257,7 +259,7 @@ public void TemporaryFrequencyBandUp()
}
}

public void TemporaryFrequencyBandDown()
internal void TemporaryFrequencyBandDown()
{
VerifyIsInitialized();

Expand Down Expand Up @@ -410,15 +412,15 @@ private bool IsFrequencyBandSupported(string frequency)
return _settings.SupportedFrequencyBands.Any(supportedBand => GetFrequencyBand(frequency) == supportedBand);
}

public FlightRadioFrequencyBand[] SupportedFrequencyBands()
internal FlightRadioFrequencyBand[] SupportedFrequencyBands()
{
return _settings.SupportedFrequencyBands;
}

public FlightRadioFrequencyBand ActiveFrequencyBand => _activeFrequencyBand;
internal FlightRadioFrequencyBand ActiveFrequencyBand => _activeFrequencyBand;


public string GetLastStandbyFrequency(FlightRadioFrequencyBand frequencyBand)
internal string GetLastStandbyFrequency(FlightRadioFrequencyBand frequencyBand)
{
return _savedIntegerFrequencyPerBand[(int)frequencyBand] + "." + _savedDecimalFrequencyPerBand[(int)frequencyBand].ToString().PadLeft(3, '0');
}
Expand All @@ -437,7 +439,7 @@ private void PopulateSavedValues()
}
}

public string LastFrequencies()
internal string LastFrequencies()
{
var stringBuilder = new StringBuilder();
stringBuilder.AppendLine("\nStandby :");
Expand Down
4 changes: 3 additions & 1 deletion src/NonVisuals/Radios/RadioSettings/ARC164Settings.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using NonVisuals.Helpers;
using NonVisuals.Interfaces;
using NonVisuals.Radios.RadioControls;
using System.Runtime.CompilerServices;


namespace NonVisuals.Radios.RadioSettings
{
public class ARC164Settings : IFlightRadioSettings
internal class ARC164Settings : IFlightRadioSettings
{
public FlightRadioSettings RadioSettings { get; init; }

Expand Down
2 changes: 1 addition & 1 deletion src/NonVisuals/Radios/RadioSettings/ARC210Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace NonVisuals.Radios.RadioSettings
/// <summary>
/// Emulates the ARC-210 radio with 4 different bands.
/// </summary>
public class ARC210Settings : IFlightRadioSettings
internal class ARC210Settings : IFlightRadioSettings
{
public void VerifySettings()
{
Expand Down
2 changes: 1 addition & 1 deletion src/NonVisuals/Radios/RadioSettings/ARC222Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace NonVisuals.Radios.RadioSettings
{
public class ARC222Settings : IFlightRadioSettings
internal class ARC222Settings : IFlightRadioSettings
{
public FlightRadioSettings RadioSettings { get; init; }

Expand Down
2 changes: 1 addition & 1 deletion src/NonVisuals/Radios/RadioSettings/FlightRadioSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace NonVisuals.Radios.RadioSettings
{
public class FlightRadioSettings
internal class FlightRadioSettings
{
private const int ARRAY_LENGTH = 4;
private FlightRadioFrequencyBand _initialFrequencyBand;
Expand Down
2 changes: 1 addition & 1 deletion src/NonVisuals/Radios/RadioSettings/JF17ComSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace NonVisuals.Radios.RadioSettings
/// <summary>
/// Emulates the radio found in JF-17.
/// </summary>
public class JF17ComSettings : IFlightRadioSettings
internal class JF17ComSettings : IFlightRadioSettings
{
public void VerifySettings()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace NonVisuals.Radios.RadioSettings
/// <summary>
/// Single Band radio configuration for the FlightRadio class.
/// </summary>
public class SingleBandRadioSettings : IFlightRadioSettings
internal class SingleBandRadioSettings : IFlightRadioSettings
{
public void VerifySettings()
{
Expand Down

0 comments on commit 90e46dd

Please sign in to comment.