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

FSX Ambiguity in RequestDataOnSimObject

Messages
639
Country
panama
I think there is a lot of ambiguity in the SimConnect.RequestDataOnSimObject when it comes to periods, changes, etc. This IMHO is typical of old style C/C++ programmers :)

In particular when you look at the API method or function there are these parameters in the same call that seem to be quite ambiguous in interpretation:

  • Period
    [in] One member of the SIMCONNECT_PERIOD enumeration type, specifying how often the data is to be sent by the server and received by the client.
  • Flags
    [in, optional] A DWORD containing one or more of the following values:

    Flag value
    Description
    0
    The default, data will be sent strictly according to the defined period.
    SIMCONNECT_DATA_REQUEST_FLAG_CHANGED Data will only be sent to the client when one or more values have changed. If this is the only flag set, then all the variables in a data definition will be returned if just one of the values changes.
    SIMCONNECT_DATA_REQUEST_FLAG_TAGGED Requested data will be sent in tagged format (datum ID/value pairs). Tagged format requires that a datum reference ID is returned along with the data value, in order that the client code is able to identify the variable. This flag is usually set in conjunction with the previous flag, but it can be used on its own to return all the values in a data definition in datum ID/value pairs. See the SIMCONNECT_RECV_SIMOBJECT_DATA structure for more details.
  • origin
    [in, optional] The number of Period events that should elapse before transmission of the data begins. The default is zero, which means transmissions will start immediately.
  • interval
    [in, optional] The number of Period events that should elapse between transmissions of the data. The default is zero, which means the data is transmitted every Period.
  • limit
    [in, optional] The number of times the data should be transmitted before this communication is ended. The default is zero, which means the data should be transmitted endlessly.
Although there are several use cases there are two that can properly show where the (my?) confusion arises. Please correct my choice of parameters if I am wrong.

Use Case #1: Request data only once
The user only wants to request the data once or perhaps multiple times but in a non-periodic fashion, in other words on a need-to-know basis.

Code:
simConnect.RequestDataOnSimObject(RequestId, DefinitionId, SimConnect.SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD.ONCE, flags, 0, 0, 1);

transmission starts immediately (sort of...) and continue every period but only ONE period. In other words one shot.

Use Case #2: Request to be notified of data Change Forever
I want to be notified when one of the members of the Data Request structure changes for as long as I have a connection to the SimConnect server. Here the choice of flags is easy: CHANGED rather than DEFAULT. Same for the last three parameters (origin=now, interval=period, limit=endlessly)

Code:
simConnect.RequestDataOnSimObject(RequestId, DefinitionId, SimConnect.SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD.VISUAL_FRAME, flags, 0, 0, 0);

However, in this case the confusion arises, what is the correct value for SIMCONNECT_PERIOD? should it be NEVER? ONCE, VISUAL/SIM_FRAME or SECOND (every second).

Another question that arises is, given that you will be notified on changes, how do you cancel being notified of the changes? For example if you application has entered a context where you are no longer interested in receiving those periodical updates?
 
Back
Top