I’m a bit confused about the RequestId parameter which has to be passed to several SimConnect functions. Here are two examples from the SDK documentation:
For each call (using managed code), the argument is defined as an enum but if I would use the second definition where it says RequestId has to be unique for each call, I can not cast an integer to System.Enum in C#. Here are the definitions of the two functions:
public unsafe void RequestDataOnSimObject(Enum RequestID, Enum DefineID, uint ObjectID, SIMCONNECT_PERIOD Period, SIMCONNECT_DATA_REQUEST_FLAG Flags, uint origin, uint interval, uint limit)
public unsafe void RequestDataOnSimObjectType(Enum RequestID, Enum DefineID, uint dwRadiusMeters, SIMCONNECT_SIMOBJECT_TYPE type)
I think the second definition would be the best now when I have learnt that all calls are put into a queue but since there are two different definitions for this RequestId, I’m very confused .
Actually, both those descriptions are swapped.
In the case of RequestDataOnSimObject, as you can request to receive the data every frame or second using SIMCONNECT_PERIOD, the server will map your RequestID to your last received DefineID.
So in the case of 2 calls with identical RequestID but different DefineID, the second call will overwrite the first one.
We will fix this in the documentation.
Thank you for bringing our attention to this.
Sounds great!! One issue though with having the RequestId defined as a System.Enum in the function prototype, I’m not able to cast an integer to System.Enum using Visual Studio. For example (int)123 wont work nor will 123 as int. Some C# examples below:
For C++ there seems to be no problem passing integers since the definition of SIMCONNECT_DATA_REQUEST_ID is a DWORD and not an Enum.
SIMCONNECTAPI SimConnect_RequestFacilityData_EX1(HANDLE hSimConnect, SIMCONNECT_DATA_DEFINITION_ID DefineID, SIMCONNECT_DATA_REQUEST_ID RequestID, const char * ICAO, const char * Region = “”, char Type = 0);
SIMCONNECT_USER_ENUM SIMCONNECT_DATA_REQUEST_ID; //client-defined request data ID
#define SIMCONNECT_USER_ENUM typedef DWORD
It is also doable in C# but you have to create an enum first, then you can cast an int to this enum
For instance, this code works
public enum DefineId
Test = 123
public enum TestEnum
A = 0,
B = 79,
private void TestFunction()
TestEnum e = (TestEnum)258;
TestEnum a = TestEnum.A;
m_oSimConnect.RequestDataOnSimObjectType(TestEnum.A, DefineId.Test, 0, SIMCONNECT_SIMOBJECT_TYPE.ALL);
m_oSimConnect.RequestDataOnSimObjectType(a, DefineId.Test, 0, SIMCONNECT_SIMOBJECT_TYPE.ALL);
m_oSimConnect.RequestDataOnSimObjectType(e, DefineId.Test, 0, SIMCONNECT_SIMOBJECT_TYPE.ALL);
Maxime / Asobo
Ok, it is doable as a work around even if it is a bit dirty. If you ever in the future do some refactoring of SimConnect, maybe you can consider changing the type .