- Messages
- 158
- Country

Greetings fellow developers!
In my DLL application one of the things I need to do is load fuel tank quantities for the player's aircraft, and SimConnect ought to be able to to that easily. I can load all the payload stations just fine.
And indeed I can load any fuel tank quantity...but only one! Any attempt to load another tank fails to set the quantity. It doesn't seem to matter which one; the first one I set works and subsequent attempts to set others fail until...until I open up the fuel dialog box! Then, I can use SimConnect to set another tank.
It does not appear to be a timing issue. I can wait minutes between sets and it doesn't work on the 2nd one.
Does anyone know of any special thing that needs to be done between writes to fuel tanks so that they can be loaded?
Here's the code. Two test functions to load separate tanks, and I can call these from buttons on a gauge:
If 'TestFuelLoad1' gets called first, the center tank will have 100 gallons in it. A call to 'TestFuelLoad2' will not, however, put 200 gallons in the left main tank, it will stay zero UNTIL I manually bring up the fuel dialog box and observe the 100 gallons in the center tank. After this, the next call to 'TestFuelLoad2' will put the 200 gallons in the left main tank and leave the 100 in the center tank. Reverse the other of the calls and the opposite occurs, left main gets loaded and center won't -- it has nothing to do with which tank.
I realize that in this test I could set both of these with one call -- but the nature of the application is such that I need to be able to set tanks individually at different points without the user having to do anything.
Many thanks,
Dutch
void TestFuelLoad1()
{
double Value = 100;
HRESULT hr;
static enum DATA_DEFINE_ID21 {
FUELQTY1
};
hr = SimConnect_AddToDataDefinition(hSimConnect, FUELQTY1, "FUEL TANK CENTER QUANTITY", "gallons");
hr = SimConnect_SetDataOnSimObject(hSimConnect, FUELQTY1, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(double), &Value);
}
void TestFuelLoad2()
{
double Value = 200;
HRESULT hr;
static enum DATA_DEFINE_ID22 {
FUELQTY2
};
hr = SimConnect_AddToDataDefinition(hSimConnect, FUELQTY2, "FUEL TANK LEFT MAIN QUANTITY", "gallons");
hr = SimConnect_SetDataOnSimObject(hSimConnect, FUELQTY2, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(double), &Value);
}
In my DLL application one of the things I need to do is load fuel tank quantities for the player's aircraft, and SimConnect ought to be able to to that easily. I can load all the payload stations just fine.
And indeed I can load any fuel tank quantity...but only one! Any attempt to load another tank fails to set the quantity. It doesn't seem to matter which one; the first one I set works and subsequent attempts to set others fail until...until I open up the fuel dialog box! Then, I can use SimConnect to set another tank.
It does not appear to be a timing issue. I can wait minutes between sets and it doesn't work on the 2nd one.
Does anyone know of any special thing that needs to be done between writes to fuel tanks so that they can be loaded?
Here's the code. Two test functions to load separate tanks, and I can call these from buttons on a gauge:
If 'TestFuelLoad1' gets called first, the center tank will have 100 gallons in it. A call to 'TestFuelLoad2' will not, however, put 200 gallons in the left main tank, it will stay zero UNTIL I manually bring up the fuel dialog box and observe the 100 gallons in the center tank. After this, the next call to 'TestFuelLoad2' will put the 200 gallons in the left main tank and leave the 100 in the center tank. Reverse the other of the calls and the opposite occurs, left main gets loaded and center won't -- it has nothing to do with which tank.
I realize that in this test I could set both of these with one call -- but the nature of the application is such that I need to be able to set tanks individually at different points without the user having to do anything.
Many thanks,
Dutch
void TestFuelLoad1()
{
double Value = 100;
HRESULT hr;
static enum DATA_DEFINE_ID21 {
FUELQTY1
};
hr = SimConnect_AddToDataDefinition(hSimConnect, FUELQTY1, "FUEL TANK CENTER QUANTITY", "gallons");
hr = SimConnect_SetDataOnSimObject(hSimConnect, FUELQTY1, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(double), &Value);
}
void TestFuelLoad2()
{
double Value = 200;
HRESULT hr;
static enum DATA_DEFINE_ID22 {
FUELQTY2
};
hr = SimConnect_AddToDataDefinition(hSimConnect, FUELQTY2, "FUEL TANK LEFT MAIN QUANTITY", "gallons");
hr = SimConnect_SetDataOnSimObject(hSimConnect, FUELQTY2, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(double), &Value);
}

