Crazy number outputs from simconnect, not sure where to start.

haroldFDavidson
Posts: 9
Joined: Thu Jun 01, 2017 12:24 am

Crazy number outputs from simconnect, not sure where to start.

Postby haroldFDavidson » Thu Oct 19, 2017 3:26 am

Hi, i'm working on some external gauges for Prepar3d, and i can't understand some of the values that Simconnect is outputting.
One of them is the ELECTRICAL BATTERY VOLTAGE Simulation variable, which seems to dart around numbers like 3.058675e+28, and other times it just outputs NaN. The variables unit is Volts, so obviously this number is incorrect.

Wondering if anyone has any insight into this,
Thanks

JB3DG
Posts: 494
Joined: Mon Jan 09, 2012 6:44 pm

Re: Crazy number outputs from simconnect, not sure where to start.

Postby JB3DG » Thu Oct 19, 2017 9:31 am

What do your structs look like? Are all the variables in them doubles?
Jonathan Bleeker
Milviz systems dev

Formerly known as Naruto-kun

haroldFDavidson
Posts: 9
Joined: Thu Jun 01, 2017 12:24 am

Re: Crazy number outputs from simconnect, not sure where to start.

Postby haroldFDavidson » Thu Oct 19, 2017 9:12 pm

Here is the Struct Definition:

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
struct Struct1
{
public float voltage;
public float ampPercent;
};

Here is the data going into the Struct:

simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "ELECTRICAL BATTERY VOLTAGE", "Volts", SIMCONNECT_DATATYPE.FLOAT32, 0.0f, SimConnect.SIMCONNECT_UNUSED);
simconnect.AddToDataDefinition(DEFINITIONS.Struct1, "ELECTRICAL BATTERY BUS AMPS", "Amperes", SIMCONNECT_DATATYPE.FLOAT32, 0.0f, SimConnect.SIMCONNECT_UNUSED); [/code]


The variables are using floats, as there was not supposed to be anything over 1000, and presumed that there would not be any floating point data loss.

Is there a different reason I should consider Doubles here? This program will run in Realtime, so speed is important.
Thanks,

User avatar
WarpD
Posts: 1455
Joined: Mon Feb 14, 2011 5:29 am

Re: Crazy number outputs from simconnect, not sure where to start.

Postby WarpD » Fri Oct 20, 2017 1:47 am

You absolutely must use doubles.... all variables returned are doubles, no matter their possible range.

Size of the variable cannot possibly impact performance.
Ed Wilson
Senior Developer
Mindstar Aviation

haroldFDavidson
Posts: 9
Joined: Thu Jun 01, 2017 12:24 am

Re: Crazy number outputs from simconnect, not sure where to start.

Postby haroldFDavidson » Fri Oct 20, 2017 1:56 am

Okay thanks for that..

I have converted to software to use Doubles, and the same issue persists.
I'm just going to put it down to the flight models i'm testing with (which all seem inconsistent in the variables that they output)

Thanks all for the advice.

JB3DG
Posts: 494
Joined: Mon Jan 09, 2012 6:44 pm

Re: Crazy number outputs from simconnect, not sure where to start.

Postby JB3DG » Fri Oct 20, 2017 6:31 am

Would be helpful to see your code since the changes
Jonathan Bleeker
Milviz systems dev

Formerly known as Naruto-kun


Return to “SimConnect Interface Questions”

Who is online

Users browsing this forum: No registered users and 8 guests