- Messages
- 639
- Country

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:
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.
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)
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?
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.
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?