There is no problem with getting True Air Speed or Indicated Air Speed, but does anyone know how to get reference speeds with simconnect? I mean speeds, that are described by colored stripes on the speed meter (like Vr, Vx, Vy if I think correctly )
Isn’t there any info here? I’d like to create a speed indicator, that looks like one from G1000…
Have a look at the flight model variables - lots of reference data there: Aircraft Flight Model Variables
I think not all of [REFERENCE SPEEDS] are accessible through SimConnect. Does that mean I will need to browse aircraft files to process those speeds?
Hello, you can get them in a sort of “tricky” way. I have done it in my FSAutomator application I released some minutes ago. Let me describe how I achieved it.
- Get the aircraft loaded via the SimConnect API:
Connection.OnRecvSystemState += new SimConnect.RecvSystemStateEventHandler(GetAirCraftCfgPath);
Connection.RequestSystemState(DATA_REQUESTS.REQUEST_1, "AircraftLoaded");
- On you method “GetAirCraftCfgPath”, do:
- Get all airplanes dfg files installed in the official and the community folders. These files are “aircraft.cfg”. This way you get the full path to them.
- Get the correct “aircraft.cfg” file path by matching the end of the file paths. In my case, I keep the first one and it has always worked.
- Now that you have the file path, you can get the “flight_model.cfg” and read it as an INI file.
This is my code:
public class FlightModel
{
private string flightModelPath;
public ReferenceSpeeds ReferenceSpeeds { get; set; }
public FlightModel(SimConnect Connection)
{
if (Connection != null)
{
Connection.OnRecvSystemState += new SimConnect.RecvSystemStateEventHandler(GetAirCraftCfgPath);
Connection.RequestSystemState(DATA_REQUESTS.REQUEST_1, "AircraftLoaded");
}
}
private void GetAirCraftCfgPath(SimConnect Connection, SIMCONNECT_RECV_SYSTEM_STATE data)
{
var baseFSPathOfficial = @"C:\Users\Albert\AppData\Roaming\Microsoft Flight Simulator\Packages\Official";
var baseFSPathCommunity = @"C:\Users\Albert\AppData\Roaming\Microsoft Flight Simulator\Packages\Community";
List<string> installedAircrafts = SearchFileInAllDirectories(baseFSPathOfficial, "aircraft.cfg");
installedAircrafts.AddRange(SearchFileInAllDirectories(baseFSPathCommunity, "aircraft.cfg"));
var currentAircraftCfgPath = installedAircrafts.Where(z => z.EndsWith(data.szString, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault().ToString();
if (currentAircraftCfgPath != "")
{
this.flightModelPath = Path.Combine(Path.GetDirectoryName(currentAircraftCfgPath), "flight_model.cfg");
IniFile ini = new IniFile(flightModelPath);
this.ReferenceSpeeds = new ReferenceSpeeds(ini);
}
}
private List<string> SearchFileInAllDirectories(string parentDirectory, string filename)
{
return Directory.GetFiles(parentDirectory, filename, SearchOption.AllDirectories).ToList();
}
}
And my ReferenceSpeeds class looks something like:
public class ReferenceSpeeds
{
public ReferenceSpeeds(IniFile ini)
{
this.FullFlapsStallSpeed = ini.Read("full_flaps_stall_speed", "REFERENCE SPEEDS").Split(';')[0].Trim();
this.FlapsUpStallSpeed = ini.Read("flaps_up_stall_speed", "REFERENCE SPEEDS").Split(';')[0].Trim();
this.CruiseSpeed = ini.Read("cruise_speed", "REFERENCE SPEEDS").Split(';')[0].Trim();
this.MaxMach = ini.Read("max_mach", "REFERENCE SPEEDS").Split(';')[0].Trim();
this.MaxIndicatedSpeed = ini.Read("max_indicated_speed", "REFERENCE SPEEDS").Split(';')[0].Trim();
this.MaxFlapsExtended = ini.Read("max_flaps_extended", "REFERENCE SPEEDS").Split(';')[0].Trim();
this.NormalOperatingSpeed = ini.Read("normal_operating_speed", "REFERENCE SPEEDS").Split(';')[0].Trim();
this.AirspeedIndicatorMax = ini.Read("airspeed_indicator_max", "REFERENCE SPEEDS").Split(';')[0].Trim();
this.RotationSpeedMin = ini.Read("rotation_speed_min", "REFERENCE SPEEDS").Split(';')[0].Trim();
this.ClimbSpeed = ini.Read("climb_speed", "REFERENCE SPEEDS").Split(';')[0].Trim();
this.CruiseAlt = ini.Read("cruise_alt", "REFERENCE SPEEDS").Split(';')[0].Trim();
this.TakeoffSpeed = ini.Read("takeoff_speed", "REFERENCE SPEEDS").Split(';')[0].Trim();
this.SpawnCruiseAltitude = ini.Read("spawn_cruise_altitude", "REFERENCE SPEEDS").Split(';')[0].Trim();
this.SpawnDescentAltitude = ini.Read("spawn_descent_altitude", "REFERENCE SPEEDS").Split(';')[0].Trim();
this.BestAngleClimbSpeed = ini.Read("best_angle_climb_speed", "REFERENCE SPEEDS").Split(';')[0].Trim();
this.ApproachSpeed = ini.Read("approach_speed", "REFERENCE SPEEDS").Split(';')[0].Trim();
this.BestGlide = ini.Read("best_glide", "REFERENCE SPEEDS").Split(';')[0].Trim();
this.BestSingleEngineRateOfClimbSpeed = ini.Read("best_single_engine_rate_of_climb_speed", "REFERENCE SPEEDS").Split(';')[0].Trim();
this.MinimumControlSpeed = ini.Read("minimum_control_speed", "REFERENCE SPEEDS").Split(';')[0].Trim();
}
public string FullFlapsStallSpeed { get; set; }
public string FlapsUpStallSpeed { get; set; }
public string CruiseSpeed { get; set; }
public string MaxMach { get; set; }
public string MaxIndicatedSpeed { get; set; }
public string MaxFlapsExtended { get; set; }
public string NormalOperatingSpeed { get; set; }
public string AirspeedIndicatorMax { get; set; }
public string RotationSpeedMin { get; set; }
public string ClimbSpeed { get; set; }
public string CruiseAlt { get; set; }
public string TakeoffSpeed { get; set; }
public string SpawnCruiseAltitude { get; set; }
public string SpawnDescentAltitude { get; set; }
public string BestAngleClimbSpeed { get; set; }
public string ApproachSpeed { get; set; }
public string BestGlide { get; set; }
public string BestSingleEngineRateOfClimbSpeed { get; set; }
public string MinimumControlSpeed { get; set; }
}