SimConnect_RequestDataOnSimObjectType

The SimConnect_RequestDataOnSimObjectType function is used to retrieve information about simulation objects of a given type that are within a specified radius of the user's aircraft.

 

Syntax
HRESULT SimConnect_RequestDataOnSimObjectType(
    HANDLE  hSimConnect,
    SIMCONNECT_DATA_REQUEST_ID  RequestID,
    SIMCONNECT_DATA_DEFINITION_ID  DefineID,
    DWORD  dwRadiusMeters,
    SIMCONNECT_SIMOBJECT_TYPE  type
    );

 

Parameters
Parameter Description Type
hSimConnect Handle to a SimConnect object. Integer
RequestID Specifies the ID of the client defined request. This is used later by the client to identify which data has been received. This value should be unique for each request, re-using a RequestID will overwrite any previous request using the same ID. Integer
DefineID Specifies the ID of the client defined data definition. Integer
dwRadiusMeters Double word containing the radius in meters. If this is set to zero only information on the user aircraft will be returned, although this value is ignored if type is set to SIMCONNECT_SIMOBJECT_TYPE_USER. The error SIMCONNECT_EXCEPTION_OUT_OF_BOUNDS will be returned if a radius is given and it exceeds the maximum allowed (200,000 meters, or 200 Km).  
type Specifies the type of object to receive information on. One member of the SIMCONNECT_SIMOBJECT_TYPE enumeration type  

 

Return Values

The function returns an HRESULT. Possible values include, but are not limited to, those in the following table.

Return value Description
S_OK The function succeeded.
E_FAIL The function failed.

 

Example
void CALLBACK dispatchEvents(SIMCONNECT_RECV*  pData, DWORD  cbData, void *  pContext)
{
HRESULT hr;
switch (pData->dwID)
    {
    case SIMCONNECT_RECV_ID_EVENT:
        {
        SIMCONNECT_RECV_EVENT *evt = (SIMCONNECT_RECV_EVENT*)pData;
        switch (evt->uEventID)
            {
            case STARTUP:
                stats.lastDeleted = 0;
                stats.nrOfDeletions = 0;
                stats.nrOfRequests = 0;
                // Now the sim is running, request information on the user aircraft
                hr = SimConnect_RequestDataOnSimObjectType(hSimConnect, R1, AIPARKDATA, conf.radius, SIMCONNECT_SIMOBJECT_TYPE_AIRCRAFT);
                ++stats.nrOfRequests;
                break;
            case R2:
                fsecCnt++;
                if (fsecCnt >= (conf.requestEveryXSec/4))
                    {
                    fsecCnt = 0;
                    if (SUCCEEDED(SimConnect_RequestDataOnSimObjectType(hSimConnect, R1, AIPARKDATA, conf.radius, SIMCONNECT_SIMOBJECT_TYPE_AIRCRAFT)))
                        {
                        ++stats.nrOfRequests;
                        }
                    }
                break;
            }
        break;
    // further cases here
    default:
        printf("\nReceived:%d", pData->dwID);
        break;
    }
}

 

See Also