• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

One off variable

Messages
7
Country
newzealand
I am trying to get a payload weight for my program but only want to get it once at a certain point.
I understand that I have to read the payload station count and then go through each of the stations to add them all up for the combined weight.
I was just wondering which call do I use to get data once only? I already have a loop that is running reading a set of data every second for fuel weight.

I would like to call the routine to first read the count of stations and then another call to read the correct amount of station weights. Dont want to read more than needed.
 
I am trying to get a payload weight for my program but only want to get it once at a certain point.

Look up the SimConnect_RequestDataOnSimObject call and check the SIMCONNECT_PERIOD enumeration type -- just set it to SIMCONNECT_PERIOD_ONCE. It is all clear in the documentation.

I understand that I have to read the payload station count and then go through each of the stations to add them all up for the combined weight.

Might be easier and quicker to simply compute it from TOTAL WEIGHT - (EMPTY WEIGHT + TOTAL FUEL QUANTITY WEIGHT).

Regards

Pete
 
The easiest way I think would be something like this:

static int trigger = 0;


static int totalWeight = 0;

if (trigger != 0)
{
for (int i = 0; i < numStations; i++)
{
totalWeight += aircraft_varget( get_aircraft_var_enum("PAYLOAD STATION WEIGHT"), get_units_enum("pounds"), i);
}
trigger = 0;
}

Somewhere elsewhere in your code you just need to set trigger to non-zero and that code above will then execute once only.

Si
 
Look up the SimConnect_RequestDataOnSimObject call and check the SIMCONNECT_PERIOD enumeration type -- just set it to SIMCONNECT_PERIOD_ONCE. It is all clear in the documentation.



Might be easier and quicker to simply compute it from TOTAL WEIGHT - (EMPTY WEIGHT + TOTAL FUEL QUANTITY WEIGHT).

Regards

Pete

Thanks, Have got it all working now. I tried your second suggestion before I asked and found that the answer varied all the time. It seems as the fuel and total weight drops it is not the same number (ie dont change the same time) so they get out and you see a number going up and down by a few kgs each second.

Now I calculate it once and display it and if it changes for any reason (ie XPax) then it gets updated like it should.
 
Back
Top