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
Crazy number outputs from simconnect, not sure where to start.
-
- Posts: 9
- Joined: Thu Jun 01, 2017 12:24 am
Re: Crazy number outputs from simconnect, not sure where to start.
What do your structs look like? Are all the variables in them doubles?
Jonathan Bleeker
Milviz systems dev
Formerly known as Naruto-kun
Milviz systems dev
Formerly known as Naruto-kun
-
- Posts: 9
- Joined: Thu Jun 01, 2017 12:24 am
Re: Crazy number outputs from simconnect, not sure where to start.
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,
[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,
Re: Crazy number outputs from simconnect, not sure where to start.
You absolutely must use doubles.... all variables returned are doubles, no matter their possible range.
Size of the variable cannot possibly impact performance.
Size of the variable cannot possibly impact performance.
Ed Wilson
Senior Developer
Mindstar Aviation
Senior Developer
Mindstar Aviation
-
- Posts: 9
- Joined: Thu Jun 01, 2017 12:24 am
Re: Crazy number outputs from simconnect, not sure where to start.
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.
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.
Re: Crazy number outputs from simconnect, not sure where to start.
Would be helpful to see your code since the changes
Jonathan Bleeker
Milviz systems dev
Formerly known as Naruto-kun
Milviz systems dev
Formerly known as Naruto-kun