Jump to content
Sign in to follow this  
dalugoga

How to Read AI Aircraft List of Waypoints with Simconnect?

Recommended Posts

Hello everyone,
I want to read the list of waypoints that an AI aircraft is currently following. The "AI WAYPOINT LIST" seems to be what I want but I don't understand how to extract information from it using managed C#.
I have a definition with a bunch of other variable that work, only this is giving me trouble. Some of the code im using to request the data:

simConnect.AddToDataDefinition(DEFINITIONS.DATA_DEFINITION, "AI WAYPOINT LIST", "", SIMCONNECT_DATATYPE.FLOAT64, 0.0f, SimConnect.SIMCONNECT_UNUSED);

simConnect.RegisterDataDefineStruct<Data_Definition>(DEFINITIONS.DATA_DEFINITION);

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct Data_Definition
{
<other data variables>
public SIMCONNECT_DATA_WAYPOINT waypoint;
};

Thank you in advance,
Daniel

Share this post


Link to post
Share on other sites

Hi, 

You don't need a data structure for this, but a callback instead

  1. Create a definition enum value and a data request enum only for the waypoint list 
  2. Create the callback method to receive the waypoint list data (simconnect.OnRecvWaypointList += new SimConnect.RecvWaypointListEventHandler(simconnect_OnRecvWaypointList);)
  3. drop in the AddToDataDefinition - a single one for the waypoint list (simconnect.AddToDataDefinition(DEFINITIONS.AIWAYPOINTS, "AI WAYPOINT LIST", "number", SIMCONNECT_DATATYPE.WAYPOINT, 0.0f, SimConnect.SIMCONNECT_UNUSED);)
  4. Now just request the data (simconnect.RequestDataOnSimObject(DATA_REQUESTS.AI_WAYPOINTS, DEFINITIONS.AIWAYPOINTS, ObjectID, SIMCONNECT_PERIOD.ONCE, SIMCONNECT_DATA_REQUEST_FLAG.DEFAULT, 0, 0, 0);)
    The result will be transmitted to you in repeated callbacks to your simconnect_OnRecvWaypointList method.

This principle is applicable to all data requests that result in something "special", most importantly lists of any kind. First thing to do is check for an OnRecv… callback pertaining to your data request.

(not sure where I got the "number" part as DatumName from. It works for setting the waypoint list, but you may want to change it to an empty string or null).

Best regards

 

Edited by Lorby_SI

LORBY-SI

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...