1
0
Fork 0
mirror of https://github.com/hawkeye-stan/msfs-popout-panel-manager.git synced 2024-11-22 05:40:11 +00:00
msfs-popout-panel-manager/DomainModel/SimConnect/HudBarData737.cs

95 lines
2.5 KiB
C#
Raw Normal View History

2023-07-12 22:41:31 +00:00
using MSFSPopoutPanelManager.DomainModel.Profile;
using MSFSPopoutPanelManager.Shared;
using System;
namespace MSFSPopoutPanelManager.DomainModel.SimConnect
{
public class HudBarData737 : ObservableObject, IHudBarData
{
public HudBarType HudBarType => HudBarType.PMDG_737;
public double ElevatorTrim { get; set; }
public double AileronTrim { get; set; }
public double RudderTrim { get; set; }
public double Flap { get; set; }
public double ParkingBrake { get; set; }
public double GearLeft { get; set; }
public double GearCenter { get; set; }
public double GearRight { get; set; }
public double SimRate { get; set; }
public string ElevatorTrimFormatted => Math.Round(ElevatorTrim / 10, 2).ToString("F2");
public string AileronTrimFormatted => Math.Round(AileronTrim / 16384 * 57, 2).ToString("F2");
public string RudderTrimFormatted => Math.Round(RudderTrim * 2 * 10, 2).ToString("F2");
public string FlapFormatted => MapFlap(Flap);
public string ParkingBrakeFormatted => ParkingBrake > 0 ? "Engaged" : "Disengaged";
public string GearLeftFormatted => MapGear(GearLeft);
public string GearCenterFormatted => MapGear(GearCenter);
public string GearRightFormatted => MapGear(GearRight);
private string MapFlap(double flap)
{
switch (Convert.ToInt32(flap))
{
case 0:
return "0";
case 1:
return "1";
case 2:
return "2";
case 3:
return "5";
case 4:
return "10";
case 5:
return "15";
case 6:
return "25";
case 7:
return "30";
case 8:
return "40";
default:
return "5";
}
}
private string MapGear(double gear)
{
2024-02-28 02:44:21 +00:00
if (Convert.ToInt32(gear) == 100)
2023-07-12 22:41:31 +00:00
return "DOWN";
2024-02-28 02:44:21 +00:00
2023-07-12 22:41:31 +00:00
if (gear == 0)
return "UP";
return "MOVING";
}
public void Clear()
{
2024-02-28 02:44:21 +00:00
var type = this.GetType();
var properties = type.GetProperties();
foreach (var property in properties)
2023-07-12 22:41:31 +00:00
{
2024-02-28 02:44:21 +00:00
if (property.SetMethod != null)
property.SetValue(this, 0);
2023-07-12 22:41:31 +00:00
}
}
}
}