Jump to content
Sign in to follow this  

Using SimIn SDK to query facitities data

Recommended Posts

Hi All,

Just to follow the announcement, 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:

GetSimInSDKPtr GetSimInSDKCall;

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

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

sdk = GetSimInSDKCall();

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

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:

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:

 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


Edited by fs1

Federico Sucari

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online

  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
  • Create New...