Setting the simulation time of day, date of year

Discuss on the SimConnect SDK can be used by programmers to write add-on components for Prepar3D
Locked
DevSim
Posts: 141
Joined: Thu Jul 07, 2011 12:45 pm

Post by DevSim »

Dear Support Forum,



I am having troubles setting the simulation time via SimConnect from a remote machine. I am using the SDK 1.2. I send those values and the time of day is not changing at all.



Code snippet:



int todHours = 23;

int todMinutes = 59:

hr = SimConnect_TransmitClientEvent( _simHandle.simConnectHandle, 1, EVENT_KEY_CLOCK_HOURS_SET, todHours, GROUP_1, SIMCONNECT_EVENT_FLAG_DEFAULT);

hr = SimConnect_TransmitClientEvent( _simHandle.simConnectHandle, 1, EVENT_KEY_CLOCK_MINUTES_SET, todMinutes, GROUP_1, SIMCONNECT_EVENT_FLAG_DEFAULT);



Can I debug this somehow on the machine where P3D is running?



Regards,



DevSim



DevSim
Posts: 141
Joined: Thu Jul 07, 2011 12:45 pm

Post by DevSim »

From the SimConnect.log debug output on the Prepar3d machine, I get:



> 1853.50712 [ 0, 1394]TransmitClientEvent:ObjectID=1, EventID=10, dwData=23, GroupID=0, Flags=0

< 1853.50732 [0] >>>>> EXCEPTION=1, SendID=1394, Index=2 <<<<<

> 1853.50740 [ 0, 1395]TransmitClientEvent:ObjectID=1, EventID=11, dwData=59, GroupID=0, Flags=0

< 1853.50762 [0] >>>>> EXCEPTION=1, SendID=1395, Index=2 <<<<<



So the new time of day is obviously causing exceptions.

DevSim
Posts: 141
Joined: Thu Jul 07, 2011 12:45 pm

Post by DevSim »

And I figured out why the exceptions occured - the mapping of the event was wrong (forgot to omit the KEY_ prefix):



With:

hr = SimConnect_MapClientEventToSimEvent(_simHandle.simConnectHandle, EVENT_KEY_CLOCK_HOURS_SET, "CLOCK_HOURS_SET" );



I don't get exceptions during the mapping of the client to sim event.

I also don't get exceptions during transmiting the client event.



The time of day, however, doesn't change.



Regards,

DevSim

DevSim
Posts: 141
Joined: Thu Jul 07, 2011 12:45 pm

Post by DevSim »

Does anyone have a recommendation how to set the time via SimConnect?



Thanks,

DevSim
DevSim
Posts: 141
Joined: Thu Jul 07, 2011 12:45 pm

Post by DevSim »

Looks like the culprit was the '1' within TransmitClientEvent() instead of 0. With zero, it works with ZULU_HOURS_SET. However, once the hour is changed, the "Loading..." dialog appears and the scenery reloads.



Better ideas, anyone?



Regards,

DevSim
N4GIX
Posts: 617
Joined: Wed Dec 08, 2010 6:52 pm

Post by N4GIX »

That is normal behavior. Whenever the time changes +/- a certain few minutes, the entire scenery needs to reload/refresh.
Bill Leaming
Modeler and Programmer
Military Visualizations
Adam Breed
Lockheed Martin
Posts: 1382
Joined: Mon Sep 20, 2010 6:17 pm

Post by Adam Breed »

Hi DevSim,



N4GIX is correct. Whenever the time is changed using SimConnect you will end up experiencing the ‘Loading…’ screen for a brief moment. This is the same functionality that occurs when you change the time using the ‘Time and Seasons’ settings in application.
Prepar3D® Engineering Project Manager
DevSim
Posts: 141
Joined: Thu Jul 07, 2011 12:45 pm

Post by DevSim »

Thanks Adam,



For the record: The same behaviour applies for the day of the year.

"Brief moment" is of course dependant on your scenery complexity and your hardware configuration and available powert ;)



Regards,

DevSim
Locked