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

Use SimIn SDK to query facilities

fs1

Messages
301
Country
brazil
Hi All,


We are posting a quick example (6 Step setup only!) on how to use the SimIn SDK to query facility data.


Save the SimIn (x32 or x64) DLL in the same path of where your project DLL will be deployed.

Step 1

Set Up the Project Preprocessor defines.

Right click on your project. Select Properties. You should see the below menu where you can navigate to Configuration Properties > C/C++ > Preprocessor. In this case we need to define SIMINDLL to tell the .h header we will be loading a DLL.






Step 2

Include the .h files, in this case the ISimInSDK.h is necessary for all the services and we are going to include the IFacilitiesService.h in this example






Then define a Global ISimInSDK *pointer, and a facilities IFacilitiesServiceV1 *pointer as well.

These two are the only ones you need to retrieve facility data.




Step 3

In you void __stdcall module_init(void) (or DLLStart or gauge init function) function, define our GetSimInSDK function typedef and define a function pointer with this type so as to load dynamically the GetSimInSDK function:

C:
typedef SIMINCALL SIMINSDKHANDLE(WINAPI *GetSimInSDKPtr)(VOID);
GetSimInSDKPtr GetSimInSDKCall;

Then go ahead and use LoadLibrary and GetProcAddress so load it.

Call GetSimInSDKCall() and the result assign it to the ISimSDK pointer:

C:
sdk = GetSimInSDKCall();

Then query the SERVICE_IFacilitiesServiceV1, and assign it to your IFacilitiesServiceV1 pointer:

C:
sdk->GetService(SERVICE_IFacilitiesServiceV1, reinterpret_cast<void**>(&facilities));




In this case (and you don't need to), we are using here a function from the core service to create a callback from the sim so we can go ahead and do our calls while the sim is running. You can use your regular gauge or SimConnect callbacks to call this code.

Step 4

We are going to query facilities in the KJFK area, with the grid/rectangle function call. You can do:

C:
facilities->QueryFacilitiesRectangleAsync(41, -74, 40, -72, &facilitiesCallback);

This will process your query and call your callback routine to query all facilities in the the KJFK area defined in the the Lat/Lon grid: Lat 41, Lon -74, Lat 40, Lon -72.




Step 5

We are defining a callback function called facilitiesCallback, which has the following prototype:

C:
HRESULT SIMINAPI facilitiesCallback(FacilityData* data)

This function will be hit async, when query is done.






Step 6

Don’t forget to release our pointer once we are done. In module_deinit(void) (or DLLStop or whatever terminate function), call sdk->Release();

Step 7

So let’s Go! Let’s do our request call and expect an Async callback to our function




Step 8

We receive the callback and loop through the results. To see what objects are retrieved refer to the SimIn SDK. All objects and the object count are retrieved in the FacilityData* data object - you will need to loop through them to get all the data. After processing all data call facilities->ReleaseFacilityData(&data); to free all data.




The source code for this example is available here

Thanks
 
Back
Top