View Full Version : Want to set FSX time via Simconnect
veldthui
19 Jan 2008, 00:23
Okay I have Simconnect up and running fine using VB.NET and can read values I want fine.
Now as part of a program I am tinkering with I would like to be able to set the FSX current UTC time by clicking on a button on my application. I am not quite sure where to begin as the examples I have seen are a bit not that clear to me.
Any help or pointers to example code would be much appreciated.
John Veldthuis
Pete Dowson
19 Jan 2008, 06:24
I would like to be able to set the FSX current UTC
You send a Sim Event. Check these SimConnect functions:
SimConnect_MapClientEventToSimEvent
and
SimConnect_TransmitClientEvent
The events relating to Time setting are:
CLOCK_SECONDS_ZERO Zeros seconds
CLOCK_HOURS_SET Sets hour of day
CLOCK_MINUTES_SET Sets minutes of the hour
ZULU_HOURS_SET Sets hours, zulu time
ZULU_MINUTES_SET Sets minutes, in zulu time
ZULU_DAY_SET Sets day, in zulu time
ZULU_YEAR_SET
where all you need to know is ZULU = UTC.
Regards
Pete
Michael Garbers
26 Jan 2008, 18:56
Hi John and Pete,
I have the same problem.
Normal events without parameter are working. (Like PAUSE_ON)
But setting a value e.g. ZULU_HOURS_SET doesn't seem to work.
fsx_simconnect.MapClientEventToSimEvent(EVENTTIME_ ID.ZULU_HOURS_SET, "ZULU_HOURS_SET")
fsx_simconnect.AddClientEventToNotificationGroup(G ROUPTIME_ID.GROUP_TIME, EVENTTIME_ID.ZULU_HOURS_SET, False)
fsx_simconnect.SetNotificationGroupPriority(GROUPT IME_ID.GROUP_TIME, SimConnect.SIMCONNECT_GROUP_PRIORITY_STANDARD)
:
:
:
Dim uValue As UInteger
uValue = 0
fsx_simconnect.TransmitClientEvent(SimConnect.SIMC ONNECT_OBJECT_ID_USER, EVENTTIME_ID.ZULU_HOURS_SET, uValue, GROUPTIME_ID.GROUP_TIME, SIMCONNECT_EVENT_FLAG.DEFAULT)
This doesn't make any effect.
Any idea?
Micha
Pete Dowson
27 Jan 2008, 06:03
But setting a value e.g. ZULU_HOURS_SET doesn't seem to work.
Have you checked the SimConnect log? The answers are often there. The controls do work from FSUIPC4 (if you have a registered copy you can assign them, with parameter, and test them -- then compare what's in the SimConnect log with what you get).
Two other suggestions:
fsx_simconnect.SetNotificationGroupPriority(GROUPT IME_ID.GROUP_TIME, SimConnect.SIMCONNECT_GROUP_PRIORITY_STANDARD)
I found some things (not sure which) don't get to the right part of FSX unless you have a higher priority (i.e. lower number), so I send all mine with that last parameter as
SIMCONNECT_GROUP_PRIORITY_STANDARD-1.
Probably won't make any difference here, but worth a try.
fsx_simconnect.TransmitClientEvent(SimConnect.SIMC ONNECT_OBJECT_ID_USER, EVENTTIME_ID.ZULU_HOURS_SET, uValue, GROUPTIME_ID.GROUP_TIME, SIMCONNECT_EVENT_FLAG.DEFAULT)
Now here I am pretty sure you should be using
SIMCONNECT_SIMOBJECT_TYPE_USER
in place of
SIMCONNECT_OBJECT_ID_USER
The "user object" is his aircraft. Time is an environmental setting, so maybe there's the difference? I use SIMCONNECT_SIMOBJECT_TYPE_USER for all transmitted events except for those specific to AI aircraft.
This was confusing right from the start, by the way. Once finding something that worked, I stuck to it without inquiring too much deeper! ;-)
Regards
Pete
Michael Garbers
27 Jan 2008, 08:09
Hi Pete,
thank you for your help.
Your last comment on the enumberation was correct. :)
By the way, I do the same. If it is working I don't spend much care of it anymore.
Now I just have to figure out why the AIObject placement doesn't like rotorcraft but normal aircraft. Well, that's a total different story.
Best,
Micha
veldthui
09 Feb 2008, 00:32
Well I just cant get it working. The program is certainly sending data through as it appears in the debug window but the UTC time just does not change.
In my initiate section I have.
fsx_simconnect.MapClientEventToSimEvent(ZEVENTS.ZU LU_YEAR, "ZULU_YEAR_SET")
fsx_simconnect.MapClientEventToSimEvent(ZEVENTS.ZU LU_DAY, "ZULU_DAY_SET")
fsx_simconnect.MapClientEventToSimEvent(ZEVENTS.ZU LU_HOURS, "ZULU_HOURS_SET")
fsx_simconnect.MapClientEventToSimEvent(ZEVENTS.ZU LU_MINUTES, "ZULU_MINUTES_SET")
fsx_simconnect.AddClientEventToNotificationGroup(E GROUP.ZHOURS, ZEVENTS.ZULU_HOURS, False)
fsx_simconnect.AddClientEventToNotificationGroup(E GROUP.ZHOURS, ZEVENTS.ZULU_MINUTES, False)
fsx_simconnect.SetNotificationGroupPriority(EGROUP .ZHOURS, SimConnect.SIMCONNECT_GROUP_PRIORITY_DEFAULT - 1)
And to try and set the time I use
Dim mytime As Date
Dim mhours As UInteger
Dim mminutes As UInteger
mytime = Date.UtcNow
mhours = CUInt(mytime.Hour)
mminutes = CUInt(mytime.Minute)
'Set ZULU hours
fsx_simconnect.TransmitClientEvent(CUInt(SIMCONNEC T_SIMOBJECT_TYPE.USER), ZEVENTS.ZULU_HOURS, mhours, SimPri.SIMCONNECT_GROUP_PRIORITY_DEFAULT, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY)
'Set ZULU minutes
fsx_simconnect.TransmitClientEvent(CUInt(SIMCONNEC T_SIMOBJECT_TYPE.USER), ZEVENTS.ZULU_MINUTES, mminutes, SimPri.SIMCONNECT_GROUP_PRIORITY_DEFAULT, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY)
Geoff_D
09 Feb 2008, 02:14
You do not specify if you are trying to change time in a FREE FLYING session or a MULTIPLAYER session.
I am assuming you are talking FREE FLYING.
However, if you are in fact talking about changing time in a Multiplayer Session, then this is a very different thing, and setting the LOCAL or ZULU time by the methods mentioned earlier in this post will NOT effect a permanent time change.
Within a few seconds, time will be reset back to the original time, before you made the simconnect calls. :confused:
This applies to trying to set the time on either the HOSTING computer OR any of the Client computers.
If anyone has figureed ot a way to change the time of a "running" Multiplayer session, please share the information.:idea:
From what I have deduced (assumed) over the past year, there must be another SIM TIME clock running in the simulator during a Multiplayer session, that originaly gets set to the Hosts's specified Multiplayer Session time, and then "Free Runs".( possibly being constantly re-syned on Clinet compouters to the Host's computer ??) If this additional clock does really exist, I have seen no official mention of it, and there is obviouly no documented simconnect function to read or set it.
Geoff_D
veldthui
09 Feb 2008, 14:57
What I am trying to do is set the Free Flying time. I want to set it to UTC or local depending on which button is clicked. Thought I would try it with UTC first just to get it working.
I would like to be able to set it via my program just as though it was set just before the flight in the World Menu.
I have tried quite a few things. I can read all the times perfectly that I want to affect, just cant change them.
vBulletin® v3.8.3, Copyright ©2000-2013, Jelsoft Enterprises Ltd.