- Messages
- 40
- Country
Hi, ive been trying to get altitude from the simulator using data requests. I've been following the SDK example and SDK documentation but ran into a problem. My results are not the same in WPF as it is in a WinForms example. Here is my data request code:
The problem i'm having it that my result from the datarequest is : 7.8359836439297E-67
while the result should be around: 1000 feet...
The problem i'm having it that my result from the datarequest is : 7.8359836439297E-67
while the result should be around: 1000 feet...
C#:
simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "Plane Altitude", "feet", SIMCONNECT_DATATYPE.FLOAT64, 0,SimConnect.SIMCONNECT_UNUSED);
// IMPORTANT: register it with the simconnect managed wrapper marshaller
// if you skip this step, you will only receive a uint in the .dwData field.
simconnect.RegisterDataDefineStruct<Struct1>(DEFINITIONS.Struct1);
// catch a simobject data request
simconnect.OnRecvSimobjectDataBytype += new SimConnect.RecvSimobjectDataBytypeEventHandler(simconnect_OnRecvSimobjectDataBytype);
C#:
switch ((DATA_REQUESTS)data.dwRequestID)
{
case DATA_REQUESTS.REQUEST_1:
Struct1 s1 = (Struct1)data.dwData[0];
uint u = Convert.ToUInt32(s1.altitude);
AltitudeTXT.Text = s1.altitude.ToString();
break;
default:
break;
}