I’m experimenting with WASM and SimConnect. I found a lot of valuable information on this forum, and I’m getting my first results. One of these posts is started by @VFRMau an can be found here. There was also a link to some source code on github.
In the main() function, I found the following code extract:
// Map an ID to the Client Data Area.
hr = SimConnect_MapClientDataNameToID(hSimconnect, "EFIS_CDA", ClientDataID);
// Add a double to the data definition.
hr &= SimConnect_AddToClientDataDefinition(hSimconnect, DEFINITION_1, SIMCONNECT_CLIENTDATAOFFSET_AUTO, sizeof(data));
// Set up a custom Client Data Area.
hr &= SimConnect_CreateClientData(hSimconnect, ClientDataID, sizeof(data), SIMCONNECT_CLIENT_DATA_REQUEST_FLAG_CHANGED); // This should be SIMCONNECT_CREATE_CLIENT_DATA_FLAG_READ_ONLY, but has same value
// Request the client data periodically.
hr &= SimConnect_RequestClientData(hSimconnect, ClientDataID, REQUEST_1, DEFINITION_1, SIMCONNECT_CLIENT_DATA_PERIOD_SECOND, SIMCONNECT_CLIENT_DATA_REQUEST_FLAG_DEFAULT);
Based on the SimConnect SDK documentation, Events And Data, I understand most of it. Except the second line.
First line is simply mapping a Client Data Area name to an ID. ID’s are a lot more efficient to work with, so instead of using a null terminated string, we can use ClientDataID from now. In that Client Area Data I can now define several data elements (I think we can call them “variables”). In the third line, a data element is created (I spotted a mistake in the code, the flag should be …_READ_ONLY and not …_CHANGED, although they have the same values). In the fourth line, we ask the sim to give us a value of that data element every second, and REQUEST_1 can be used in the DispatchRoutine (not shown here) to identify this data element when it arrives.
But why do we need the second line? There is even not a link with my ClientDataID. In the third line, when we create the Client Area data element, we provide the “sizeof(data)”, so there it’s not relevant I guess. But we use this “DEFINITION_1” in the RequestClientData call.
Can somebody explain?