• 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.

SimConnect_AddToDataDefinition fEpsilon and DatumID

Messages
17
Country
spain
I write from my island called "ignorance".
I'm trying to understand how SimConnect_AddToDataDefinition works.
I don't understand the use of fEpsilon and DatumID.
As well as the union with SimConnect_RequestDataOnSimObject
I intend to use it to receive notifications, example ALTITUDE value, which does not change constantly during the flight.
I don't see any point in getting the same value over and over for minutes / hours.
Being notified only when the exchange value exceeds 1 seems like the right thing to do.
I can't find anything from the SDK (FSX or P3D) examples that clears my doubts.

Someone can light a coastal lighthouse to get off my island.
An explanation and an example would be perfect.
Thank you.
 
Messages
1,243
Country
canada
Do you have the P3D SDK chm help file.

Look there at the taggeddata example. It shows how to use DatumID. It have fEpsilon = 0. You can use either scenario or both. You can set the datumID of what you want or not and/or you can set the fEpsilon delta value to send the change when the change in value is > your fEpsilon value.

the DatumIDs are set here, - an enum is a list of integer numbers starting at zero in this case - DATA_VERTICAL_SPEED = 0 and DATA_PITOT_HEAT = 1

static enum DATA_NAMES {
DATA_VERTICAL_SPEED,
DATA_PITOT_HEAT,
};

this shows the datadef for getting "Vertical Speed", "Feet per second" uses ID = 0 (DATA_VERTICAL_SPEED) and simlarly pitot is ID=1
Sample: TaggedData.cpp
// Set up the data definition, ensuring that all the elements are in Float32 units, to
// match the StructDatum structure
// The number of entries in the DEFINITION_PDR definition should be equal to
// the maxReturnedItems define

hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_PDR, "Vertical Speed", "Feet per second",
SIMCONNECT_DATATYPE_FLOAT32, 0, DATA_VERTICAL_SPEED);
hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_PDR, "Pitot Heat", "Bool",
SIMCONNECT_DATATYPE_FLOAT32, 0, DATA_PITOT_HEAT);

You make the system request this data in this manner. SIMCONNECT_PERIOD_SECOND - every second it will SIMCONNECT_DATA_REQUEST_FLAG_CHANGED | SIMCONNECT_DATA_REQUEST_FLAG_TAGGED send the data if it changes (fEpsilon=0 - so any change) and give it a ref datumID.
Sample: TaggedData.cpp
// Make the call for data every second, but only when it changes and
// only that data that has changed
hr = SimConnect_RequestDataOnSimObject(hSimConnect, REQUEST_PDR, DEFINITION_PDR,
SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD_SECOND,
SIMCONNECT_DATA_REQUEST_FLAG_CHANGED | SIMCONNECT_DATA_REQUEST_FLAG_TAGGED );

The structure of your data record is this and it has the datumID and the value. You also have a structure of datum structures - kind of a list with a max of two.
Sample: TaggedData.cpp
// A basic structure for a single item of returned data
struct StructOneDatum {
int id;
float value;
};

// maxReturnedItems is 2 in this case, as the sample only requests
// vertical speed and pitot heat switch data
#define maxReturnedItems 2

// A structure that can be used to receive Tagged data
struct StructDatum {
StructOneDatum datum[maxReturnedItems];
};

You are asking for, in this example, a maximum of two items of data, but anywhere from 1 to a max of 2 can appear because you asked for data every second (period) and if it changed. Since fEpsilon is zero you get data all the time.

Now if you set fEpsilon to say 10 for vertical speed and keep pitot heat fEpsilon = zero. You will get one StructDatum record but will only be Pitot heat if it changed and VS did not change. You will get one StructDatum record if pitot heat did not change but VS did change by more than 10 feet/min. You will get two StructDatum records if both change. All this happens every second because Period = 1 sec.

HTH
 
Messages
17
Country
spain
Thankful for your reply. [ronh]
Do you have the chm help file for the P3D SDK? P3d = NO that of Fsx YES.
I'm going to work on your input and the taggeddata example in FSX.
With what I had done before your answer, I lose intermediate values.
Thank you
 

Attachments

  • Result.txt
    413 bytes · Views: 121
Messages
17
Country
spain
Do you have the P3D SDK chm help file.

Look there at the taggeddata example. It shows how to use DatumID. It have fEpsilon = 0. You can use either scenario or both. You can set the datumID of what you want or not and/or you can set the fEpsilon delta value to send the change when the change in value is > your fEpsilon value.

the DatumIDs are set here, - an enum is a list of integer numbers starting at zero in this case - DATA_VERTICAL_SPEED = 0 and DATA_PITOT_HEAT = 1

static enum DATA_NAMES {
DATA_VERTICAL_SPEED,
DATA_PITOT_HEAT,
};


this shows the datadef for getting "Vertical Speed", "Feet per second" uses ID = 0 (DATA_VERTICAL_SPEED) and simlarly pitot is ID=1


You make the system request this data in this manner. SIMCONNECT_PERIOD_SECOND - every second it will SIMCONNECT_DATA_REQUEST_FLAG_CHANGED | SIMCONNECT_DATA_REQUEST_FLAG_TAGGED send the data if it changes (fEpsilon=0 - so any change) and give it a ref datumID.


The structure of your data record is this and it has the datumID and the value. You also have a structure of datum structures - kind of a list with a max of two.


You are asking for, in this example, a maximum of two items of data, but anywhere from 1 to a max of 2 can appear because you asked for data every second (period) and if it changed. Since fEpsilon is zero you get data all the time.

Now if you set fEpsilon to say 10 for vertical speed and keep pitot heat fEpsilon = zero. You will get one StructDatum record but will only be Pitot heat if it changed and VS did not change. You will get one StructDatum record if pitot heat did not change but VS did change by more than 10 feet/min. You will get two StructDatum records if both change. All this happens every second because Period = 1 sec.

HTH
Report: Thankful for your help .. It has put me on the right path, not only to solve the problem, but also to learn.
 
Top