FCS Targeting and DIS entities

MicMac44
Posts: 25
Joined: Fri Feb 15, 2019 5:48 pm

FCS Targeting and DIS entities

Postby MicMac44 » Fri Oct 25, 2019 6:40 pm

Using the in-game "Weapons Gauge" window, I am able to target DIS entities. With that, it also looks like the sim is grabbing relevant spatial information about that DIS entity (LLA to calculate distance and altitude, etc...).

When I try to use the SDK to access FCS information, it seems like DIS entities do not appear. Is there a way to access the ObjectID of that DIS Entity? I am trying to use the PDK to draw a line and some other relevant information for the user.

Example code snippet:

Code: Select all

enum EVENT_ID { EVENT_RECUR_1SEC, EVENT_NEXT_TARGET, }; enum DATA_DEFINE_ID { DEFINITION_FCS, }; enum DATA_REQUEST_ID { REQUEST_FCS, }; struct Struct1 { int numTargets; }; void CALLBACK MyDispatchProc(SIMCONNECT_RECV* pData, DWORD cbData, void* pContext) { HRESULT hr; switch (pData->dwID) { case SIMCONNECT_RECV_ID_SIMOBJECT_DATA: { SIMCONNECT_RECV_SIMOBJECT_DATA* pObjData = (SIMCONNECT_RECV_SIMOBJECT_DATA*)pData; switch (pObjData->dwRequestID) { case REQUEST_FCS: Struct1* pS = (Struct1*)&pObjData->dwData; printf("Number of targets: %i", pS->numTargets); break; } break; } default: printf("\nMissed the case\n"); break; } } HANDLE mSimConnect; void StartSimConnect() { int quit = 0; if (SUCCEEDED(SimConnect_Open(&mSimConnect, ("DIS_Testing"), NULL, 0, NULL, 0))) { SimConnect_AddToDataDefinition(mSimConnect, DEFINITION_FCS, "FCS TARGET LIST COUNT", "number"); SimConnect_RequestDataOnSimObject(mSimConnect, REQUEST_FCS, DEFINITION_FCS, SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD_SECOND); SimConnect_CallDispatch(mSimConnect, MyDispatchProc, NULL); if (quit == 1) { SimConnect_Close(mSimConnect); } } else { printf("\nCouldnt open simconnect\n"); } }
Even though I can target the DIS Entity with the "Weapons Gauge", this is outputting that I have a target count of 0.

User avatar
Brady Butler
Lockheed Martin
Posts: 965
Joined: Tue May 09, 2017 5:31 pm

Re: FCS Targeting and DIS entities

Postby Brady Butler » Fri Oct 25, 2019 6:51 pm

Hello,

I believe you may be looking for GetEntityIdByObjectId() (or GetObjectIdByEntityId()) which can be found here:

https://www.prepar3d.com/SDKv4/sdk/pdk_ ... 6a41e91f21

Regards,
Brady
Brady Butler
Prepar3D® Software Engineer

MicMac44
Posts: 25
Joined: Fri Feb 15, 2019 5:48 pm

Re: FCS Targeting and DIS entities

Postby MicMac44 » Mon Nov 16, 2020 10:52 pm

Hello,

I believe you may be looking for GetEntityIdByObjectId() (or GetObjectIdByEntityId()) which can be found here:

https://www.prepar3d.com/SDKv4/sdk/pdk_ ... 6a41e91f21

Regards,
Brady
Thank you! That did the trick.

Another question:

Can SimConnect_RequestDataOnSimObject() grab DIS Entity information? Such as Title, LLA, etc... ?

Clifton Crane
Lockheed Martin
Posts: 1058
Joined: Tue Sep 25, 2012 2:34 pm

Re: FCS Targeting and DIS entities

Postby Clifton Crane » Tue Nov 17, 2020 2:10 pm

Hi MicMac44,

The entities created by DIS are SimObjects, so you should be able to access their simulation variables through SimConnect. At the moment, we do not have DIS specific simulation variables, such as site, application, or DIS entity ID. You would still need to use the PDK to get these DIS specific variables, however you should be able to access simulation variable data such as title and LLA.

Regards,
Clifton
Clifton Crane
Prepar3D® Software Engineer Sr.

MicMac44
Posts: 25
Joined: Fri Feb 15, 2019 5:48 pm

Re: FCS Targeting and DIS entities

Postby MicMac44 » Tue Nov 17, 2020 4:11 pm

Hi MicMac44,

The entities created by DIS are SimObjects, so you should be able to access their simulation variables through SimConnect. At the moment, we do not have DIS specific simulation variables, such as site, application, or DIS entity ID. You would still need to use the PDK to get these DIS specific variables, however you should be able to access simulation variable data such as title and LLA.

Regards,
Clifton
Clifton,

Thank you for the response. I keep having my SimConnect_RequestDataOnSimObject() fail when calling it from an “ObjectAdded” event. Since i know now it is possible to grab data on DIS entities this gives me something else to look for for why it is failing.

As for the PDK services, is there a way to Init() PDKServices outside the DLLStart? From searching this forum it appears that it is not possible but maybe you have an alternative? I created the callbacks to receive DIS packets and read their appropriate IDs in order to grab the P3D objectID, but I am trying to connect 2 simulations together so my current plugin does not start in the DLLStart call.

Thank you,
MicMac44

Clifton Crane
Lockheed Martin
Posts: 1058
Joined: Tue Sep 25, 2012 2:34 pm

Re: FCS Targeting and DIS entities

Postby Clifton Crane » Tue Nov 17, 2020 4:39 pm

Hi MicMac44,

I believe calling PdkServices::Init outside of DLLStart will work as long as you have a valid IPdk pointer to provide it. PdkServices is essentially a wrapper class that queries and provides getters for the various PDK services. As long as the IPdk pointer is valid I think it should work.

Regards,
Clifton
Clifton Crane
Prepar3D® Software Engineer Sr.

MicMac44
Posts: 25
Joined: Fri Feb 15, 2019 5:48 pm

Re: FCS Targeting and DIS entities

Postby MicMac44 » Tue Nov 17, 2020 4:53 pm

Hi MicMac44,

I believe calling PdkServices::Init outside of DLLStart will work as long as you have a valid IPdk pointer to provide it. PdkServices is essentially a wrapper class that queries and provides getters for the various PDK services. As long as the IPdk pointer is valid I think it should work.

Regards,
Clifton
Do you have/can you provide an example of getting a valid IPdk pointer? The only place I’ve seen a valid pointer is from the DLLStart() call. I have seen some GetPdk() references but I think that has been depreciated?

Any help is appreciated!

MicMac44
Posts: 25
Joined: Fri Feb 15, 2019 5:48 pm

Re: FCS Targeting and DIS entities

Postby MicMac44 » Tue Nov 24, 2020 6:36 pm

So after some digging I found this topic: https://www.prepar3d.com/forum/viewtopic.php?t=131939

They initialized the PDK by including "gauges.h" and the following code

Code: Select all

P3D::IPdk* pIPdk = nullptr; query_pdk(P3D::IID_IPdkV01, (void **)&pIPdk);
I got my code to compile but crashes when it hits the query_pdk() line. I have yet to find any other way to grab a valid pointer to the PDK.

Is this the correct way to go about this?

Clifton Crane
Lockheed Martin
Posts: 1058
Joined: Tue Sep 25, 2012 2:34 pm

Re: FCS Targeting and DIS entities

Postby Clifton Crane » Mon Nov 30, 2020 2:54 pm

Hi MicMac44,

The gauges.h query_pdk function is intended to be used by C-Gauges to gain access to the PDK.
I created the callbacks to receive DIS packets and read their appropriate IDs in order to grab the P3D objectID, but I am trying to connect 2 simulations together so my current plugin does not start in the DLLStart call.
Could you expand on how your DLL's are being started? It sounds as if your PDK plugin is delay loading another DLL. If so, is there a reason why the second DLL can't be loaded by P3D and implement the DLLStart function to gain access to the PDK pointer?

Regards,
Clifton
Clifton Crane
Prepar3D® Software Engineer Sr.


Return to “Software Development Kit (SDK) Questions”

Who is online

Users browsing this forum: No registered users and 14 guests