Hi,
(Sorry for my english in advance)
I have a little issue with retrieving some FSX variables.
I have a c++ project where I would like to retrieve some variables accorded to the user's aircraft currently playing, such as the speed/acceleration - longitude/latitude/altitude - pitch/roll/heading.
According to this very complete source : https://msdn.microsoft.com/en-us/library/cc526983.aspx ,
I had first, to use the funtion -SimConnect_AddToDataDefinition() in order to "build" a data group definition to be able, to successfuly use the SimConnect_RequestDataOnSimObject() funtion in order to get the wanted variables accessible in my project.
But after this last funtion, it appears (everywhere), that the data requested are present in the c++ project but are still in a "cache zone" which I have to take in charge.
I have readen that I need to use one of these 2 groups of funtion, in order to get those datas which are still inavailable because of the "cache zone" :
-SimConnect_GetNextDispatch()
OR
-SimConnect_CallDispatch()
AND
-DispatchProc()
So, I was going for the first funtion (SimConnect_GetNextDispatch()) because I believe that it may work.
The thing is, I really don't understand how it works :
This is the syntaxe (more like the declaring prototype) of the SimConnect_GetNextDispatch() funtion :
HRESULT SimConnect_GetNextDispatch(
HANDLE hSimConnect,
SIMCONNECT_RECV** ppData,
DWORD* pcbData
);
So it appears that we have to give the funtion a ppData which is SIMCONNECT_RECV** type.
What is this ppData in this case ? Is it the actual structure which is still in the inaccessible "Cache zone" ? Or is it a new SIMCONNECT_RECV** type that we must create just before calling the funtion ?
Because in both cases, I don't understand how to process.
I though I had to create (declare) my own SIMCONNECT_RECV** ppData2 for example, and then give it to the SimConnect_GetNextDispatch() funtion ; But then, looking for informations about this ppData type, I came to this :
SIMCONNECT_RECV_SIMOBJECT_DATA
"The SIMCONNECT_RECV_SIMOBJECT_DATA structure will be received by the client after a successful call to SimConnect_RequestDataOnSimObject or SimConnect_RequestDataOnSimObjectType."
So, where will it be received ? How can we get it ? Do we have to get it, or create our own and then use an other funtion to fil it with the real actual "received" structure ?
This is the head prototype of the structure :
struct SIMCONNECT_RECV_SIMOBJECT_DATA : public SIMCONNECT_RECV {
DWORD dwRequestID;
DWORD dwObjectID;
DWORD dwDefineID;
DWORD dwFlags;
DWORD dwentrynumber;
DWORD dwoutof;
DWORD dwDefineCount;
DWORD dwData;
};
And "the dwData[0] member will contain your struct as System.Object. This should be cast to the proper type."
What does that mean ?
I was looking for an example of using, and I came to that :
------------------------------
hr = SimConnect_RequestDataOnSimObject(hSimConnect, REQUEST_1, DEFINITION_1, SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD_ONCE);
....
// When the data is received - cast it to the correct structure type
case SIMCONNECT_RECV_ID_SIMOBJECT_DATA:
{
SIMCONNECT_RECV_SIMOBJECT_DATA *pObjData = (SIMCONNECT_RECV_SIMOBJECT_DATA*)pData;
switch(pObjData->dwRequestID)
{
case REQUEST_1:
Struct1 *pS = (Struct1*)&pObjData->dwData;
// Add code to process the structure appropriately
break;
}
break;
}
------------------------------
And this is the Struct1 definition :
struct Struct1
{
double kohlsmann;
double altitude;
double latitude;
double longitude;
};
------------------------------
So, what are *pobjData and pData ? Are those created variables which where created/declared at the same line they are used ?
What is Struct1 in this case ? Is it the created "empty/not felt" structure which will receive the actual dwData we are looking for ?
And why is there even a "case" without any switch before ?
I don't even understand why is there a :
static enum DATA_DEFINE_ID {
DEFINITION_1,
DEFINITION_2
};
to use with the AddToDataDefinition() like that : hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_1, "Kohlsman setting hg", "inHg");
When this funtion actually needs a "SIMCONNECT_DATA_DEFINITION_ID" type for the def_ID, which isn't the same thing as DATA_DEFINE_ID.
I'm getting really lost now. This was all really clear at the beining, but now, there is some lack of detailled information in this doc, and it makes it really hard for me, as I don't have the reals big definitions of each funtions (and that's normal, I don't disagree that).
So if you can give me some answer or some other webSite/documentation to share me with more or differents details, I'll be glad to take them all.
Thanks in advance for your answers.
Regards,
bas-tiras@hotmail.fr
(Sorry for my english in advance)
I have a little issue with retrieving some FSX variables.
I have a c++ project where I would like to retrieve some variables accorded to the user's aircraft currently playing, such as the speed/acceleration - longitude/latitude/altitude - pitch/roll/heading.
According to this very complete source : https://msdn.microsoft.com/en-us/library/cc526983.aspx ,
I had first, to use the funtion -SimConnect_AddToDataDefinition() in order to "build" a data group definition to be able, to successfuly use the SimConnect_RequestDataOnSimObject() funtion in order to get the wanted variables accessible in my project.
But after this last funtion, it appears (everywhere), that the data requested are present in the c++ project but are still in a "cache zone" which I have to take in charge.
I have readen that I need to use one of these 2 groups of funtion, in order to get those datas which are still inavailable because of the "cache zone" :
-SimConnect_GetNextDispatch()
OR
-SimConnect_CallDispatch()
AND
-DispatchProc()
So, I was going for the first funtion (SimConnect_GetNextDispatch()) because I believe that it may work.
The thing is, I really don't understand how it works :
This is the syntaxe (more like the declaring prototype) of the SimConnect_GetNextDispatch() funtion :
HRESULT SimConnect_GetNextDispatch(
HANDLE hSimConnect,
SIMCONNECT_RECV** ppData,
DWORD* pcbData
);
So it appears that we have to give the funtion a ppData which is SIMCONNECT_RECV** type.
What is this ppData in this case ? Is it the actual structure which is still in the inaccessible "Cache zone" ? Or is it a new SIMCONNECT_RECV** type that we must create just before calling the funtion ?
Because in both cases, I don't understand how to process.
I though I had to create (declare) my own SIMCONNECT_RECV** ppData2 for example, and then give it to the SimConnect_GetNextDispatch() funtion ; But then, looking for informations about this ppData type, I came to this :
SIMCONNECT_RECV_SIMOBJECT_DATA
"The SIMCONNECT_RECV_SIMOBJECT_DATA structure will be received by the client after a successful call to SimConnect_RequestDataOnSimObject or SimConnect_RequestDataOnSimObjectType."
So, where will it be received ? How can we get it ? Do we have to get it, or create our own and then use an other funtion to fil it with the real actual "received" structure ?
This is the head prototype of the structure :
struct SIMCONNECT_RECV_SIMOBJECT_DATA : public SIMCONNECT_RECV {
DWORD dwRequestID;
DWORD dwObjectID;
DWORD dwDefineID;
DWORD dwFlags;
DWORD dwentrynumber;
DWORD dwoutof;
DWORD dwDefineCount;
DWORD dwData;
};
And "the dwData[0] member will contain your struct as System.Object. This should be cast to the proper type."
What does that mean ?
I was looking for an example of using, and I came to that :
------------------------------
hr = SimConnect_RequestDataOnSimObject(hSimConnect, REQUEST_1, DEFINITION_1, SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD_ONCE);
....
// When the data is received - cast it to the correct structure type
case SIMCONNECT_RECV_ID_SIMOBJECT_DATA:
{
SIMCONNECT_RECV_SIMOBJECT_DATA *pObjData = (SIMCONNECT_RECV_SIMOBJECT_DATA*)pData;
switch(pObjData->dwRequestID)
{
case REQUEST_1:
Struct1 *pS = (Struct1*)&pObjData->dwData;
// Add code to process the structure appropriately
break;
}
break;
}
------------------------------
And this is the Struct1 definition :
struct Struct1
{
double kohlsmann;
double altitude;
double latitude;
double longitude;
};
------------------------------
So, what are *pobjData and pData ? Are those created variables which where created/declared at the same line they are used ?
What is Struct1 in this case ? Is it the created "empty/not felt" structure which will receive the actual dwData we are looking for ?
And why is there even a "case" without any switch before ?
I don't even understand why is there a :
static enum DATA_DEFINE_ID {
DEFINITION_1,
DEFINITION_2
};
to use with the AddToDataDefinition() like that : hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_1, "Kohlsman setting hg", "inHg");
When this funtion actually needs a "SIMCONNECT_DATA_DEFINITION_ID" type for the def_ID, which isn't the same thing as DATA_DEFINE_ID.
I'm getting really lost now. This was all really clear at the beining, but now, there is some lack of detailled information in this doc, and it makes it really hard for me, as I don't have the reals big definitions of each funtions (and that's normal, I don't disagree that).
So if you can give me some answer or some other webSite/documentation to share me with more or differents details, I'll be glad to take them all.
Thanks in advance for your answers.
Regards,
bas-tiras@hotmail.fr

