Get All Flight Plan Data with PDK(C++)

SDK supports Prepar3D’s philosophy of an open development architecture and encourages third parties to bring new innovations with improved add-ons and training content.
Post Reply
a8325811
Posts: 11
Joined: Mon Dec 16, 2019 7:25 am

Get All Flight Plan Data with PDK(C++)

Post by a8325811 »

Hi, I want to get all waypoint's data(eg. LLA...) into my program to do some custom map.

First I use the [IWaypointQueryManagerV400] class to get Waypoint Manager, but I found out these data is not for the user aircraft Flight Plane.
This manager only can get the AI waypoint data.

Then I found out I can use fs9gps's FlightPlan series variable to get data, but only have the current waypoint's data.

Is there a way to get all flight plane data once ? or only use (>C:fs9gps:FlightPlanActiveWaypoint) to change current waypoint one by one to get all data ?

If the answer is get it one by one, but in my PDK design, I will get all data in each Frame Update to get all newest data if there have something change.
And if I use (>C:fs9gps:FlightPlanActiveWaypoint) to change and get data, in the P3D I will see the waypoint's information on the gauge or map jumping everywhere.

Remarks : I use Tacpack's turtorial(https://forums.vrsimulations.com/suppor ... ia_C.2B.2B) to get/set custom varible.
a8325811
Posts: 11
Joined: Mon Dec 16, 2019 7:25 am

Re: Get All Flight Plan Data with PDK(C++)

Post by a8325811 »

I found out a solution, here it is, hope can help someone who have same problem.

Code: Select all

//Init Get Variable
double dValue;
int iValue;

//Get Total Waypoints Number
PdkServices::GetPanelSystem()->ExecuteCalculatorCode("(C:fs9gps:FlightPlanWaypointsNumber, number)", nullptr, &iValue, nullptr);
UINT _totalWaypoints = iValue;

//Get All Waypoints Data
for (UINT i = 0; i < _totalWaypoints; i++)
{
	//Combine Now Waypoint Code
	std::string _nowWPIndexCode = std::to_string(i) + " (>C:fs9gps:FlightPlanWaypointIndex, number)";

	//Get Data
	PdkServices::GetPanelSystem()->ExecuteCalculatorCode((_nowWPIndexCode + " (C:fs9gps:FlightPlanWaypointLatitude, radians)").c_str(), &dValue, nullptr, nullptr);
	/*WaypointsData[i].Pos_Latitude_Value = dValue;*/

	PdkServices::GetPanelSystem()->ExecuteCalculatorCode((_nowWPIndexCode + " (C:fs9gps:FlightPlanWaypointLongitude, radians)").c_str(), &dValue, nullptr, nullptr);
	/*WaypointsData[i].Pos_Longitude_Value = dValue;*/

	PdkServices::GetPanelSystem()->ExecuteCalculatorCode((_nowWPIndexCode + " (C:fs9gps:FlightPlanWaypointAltitude, feet)").c_str(), &dValue, nullptr, nullptr);
	/*WaypointsData[i].Pos_Baro_Altitude_Value = dValue;*/
}
Post Reply