Set Latitude, Longitude and altitude -- one example

Discuss on the SimConnect SDK can be used by programmers to write add-on components for Prepar3D
Post Reply
caymo04
Posts: 2
Joined: Mon Jun 21, 2021 10:00 pm

Set Latitude, Longitude and altitude -- one example

Post by caymo04 »

Hello everyone!

I am trying to send latitude, longitude and altitude parameters from Visual .NET to P3D v4 but I can't it.

I don't untherstand how setting the structure. The result of:
p3d_simconnect.SetDataOnSimObject(StructDefinitions.PLANE_ALTITUDE, SimConnect.SIMCONNECT_OBJECT_ID_USER, LockheedMartin.Prepar3D.SimConnect.SIMCONNECT_DATA_SET_FLAG.DEFAULT, objv)

is allways 19.

I think that I am setting structure wrong.

Where I can find one example where this parameters will set it in P3D.

My project is send a lot of parameters from "Flight Data Monitoring" (FDM) [Real parameters from aircraft] to P3D.

Best regards,

Acaymo
caymo04
Posts: 2
Joined: Mon Jun 21, 2021 10:00 pm

Re: Set Latitude, Longitude and altitude -- one example

Post by caymo04 »

Hello everyone!

Done!

I share the VS .NET code step by step:

1) The main StructureDefinition:

Enum StructDefinitions

PLANE_ALT_ABOVE_GROUND
PLANE_LATITUDE
PLANE_LONGITUDE
PLANE_ALTITUDE
PLANE_PITCH_DEGREES
PLANE_BANK_DEGREES
PLANE_HEADING_DEGREES_TRUE
PLANE_HEADING_DEGREES_MAGNETIC
AIRSPEED_INDICATED

End Enum


2) One Structure for each parameters to send from client to SIM. For Example:

Structure AIRSPEED_INDICATED
Public IAS As Integer
End Structure


3) Add to Data Definition:

p3d_simconnect.AddToDataDefinition(StructDefinitions.AIRSPEED_INDICATED, "AIRSPEED INDICATED", "knots", LockheedMartin.Prepar3D.SimConnect.SIMCONNECT_DATATYPE.INT32, 0, SimConnect.SIMCONNECT_UNUSED)

NOTE: Allways "SimConnect.SIMCONNECT_UNUSED" in each DataDefinition

4) Register Data Definition Struct

p3d_simconnect.RegisterDataDefineStruct(Of AIRSPEED_INDICATED)(StructDefinitions.AIRSPEED_INDICATED)

5) Variable as parameter structure:

Dim ias As AIRSPEED_INDICATED

6) Save the data in variable:
ias.IAS = CInt(TablaDatos.Rows(row_tabla).Cells("IAS_C").Value.ToString().Replace(".", ","))

NOTE: Convert correctly. In this case, the variable is converted to CInt() because, check structure, the IAS parameter is the type Integer

7) Send data to SIM:

p3d_simconnect.SetDataOnSimObject(StructDefinitions.AIRSPEED_INDICATED, SimConnect.SIMCONNECT_OBJECT_ID_USER, LockheedMartin.Prepar3D.SimConnect.SIMCONNECT_DATA_SET_FLAG.DEFAULT, CObj(ias))

NOTE: The variable will be convert to OBJET --> CObj(ias)

-------------------------------

Best regards!

Acaymo.
Post Reply