Setting NAV Frequency with ExternalSim

SDK supports Prepar3D’s philosophy of an open development architecture and encourages third parties to bring new innovations with improved add-ons and training content.
Post Reply
yakupc
Posts: 7
Joined: Mon Mar 16, 2015 1:09 pm

Setting NAV Frequency with ExternalSim

Post by yakupc »

I have a problem with setting NAV radio frequency over SimConnect. I created an aircraft using ExtertalSim example to run the external simulation that can be run inside of Prepar3D. Everything was good until setting navigation radio frequencies. I used SimConnect_TransmitClientEvent method to set 114.30 via event ("NAV1_RADIO_SET").

HRESULT hr = SimConnect_TransmitClientEvent(hSimConnect, SIMCONNECT_OBJECT_ID_USER, eventId, 0x11430, SIMCONNECT_GROUP_PRIORITY_HIGHEST, SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY);

I could get the response of this message (NAV1_RADIO_SET event is registered with SimConnect_AddClientEventToNotificationGroup) but frequency could not be changed on either the G1000 instrument or simconnect variable NAV ACTIVE FREQUENCY:1. It seems that something should have done at the aircraft side which is added as ExternalSim.

I develop another SimConnect application which is run as an external console application. When I select Mooney Bravo or any other aircraft from Select Vehicle window and then try to set NAV frequency from the console application. NAV frequency could be set successfully!

Since I need to control aircraft externally, I could not use an aircraft that have their model developed in P3D. So what should I do? I did not give up and found that there is another way to run an external simulation inside the P3D is the Prepar3D Development Kit.

If P3D aircraft (such as Mooney Bravo) allows me to set navigation frequencies, I should also look at PDK examples instead of SimConnect. then I started to develop an airplane by using PDK (Simple Airplane example). In this case, when this aircraft is loaded, I could not add the following client events by using the following methods in the Simconnect console application.

SimConnect_MapClientEventToSimEvent and SimConnect_AddClientEventToNotificationGroup

SimConnect generates the exception of SIMCONNECT_EXCEPTION_NAME_UNRECOGNIZED and SIMCONNECT_EXCEPTION_UNRECOGNIZED_ID for these requests. I need to add the following client events to be informed and set navigation frequency in the SimConnect console application.

NAV1_RADIO_WHOLE_DEC
NAV1_RADIO_WHOLE_INC
NAV1_RADIO_FRACT_DEC
NAV1_RADIO_FRACT_INC
NAV2_RADIO_WHOLE_DEC
NAV2_RADIO_WHOLE_INC
NAV2_RADIO_FRACT_DEC
NAV2_RADIO_FRACT_INC

With SimpleAirplane example: There is no problem to add system events to the notification group. I could be informed when SimStart and SimStop. What is missing in the PDK SimpleAirplane example to add above client events from my SimConnect console application?

By coincidence, I realized that when starting P3D with a P3D aircraft (Mooney Bravo) and then reselect My Simple Airplane, I could get client event notification for the above events without issue. This is not a good way for me because I want to run only SimpleAirplane at startup. If the console application starts when SimpleAirplane is already loaded, there will be the same problem adding client events.

Which way I should follow to have an external simulation application can be run inside of Prepar3D and set navigation data without issue?
yakupc
Posts: 7
Joined: Mon Mar 16, 2015 1:09 pm

Re: Setting NAV Frequency with ExternalSim

Post by yakupc »

I found the problem. Registering a simConnect client (see ExternalSim sample) as an external sim provider causes this problem.

SimConnect_RegisterExternalSim(g_hSimConnect, g_guidExternalSim, EXTERNAL_SIM_CALLBACK_MASK, PER_VEHICLE_SIMULATE_DEFINITION);

Problem solved.
Post Reply