• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Using FREEZE events

Messages
34
Country
canada
Hi,

Ok.. so I'm trying to use the two events FREEZE_ATTITUDE_TOGGLE and FREEZE_ALTITUDE_TOGGLE to keep an AI plane flying straight and level.

The problem I'm having is I'm not really seeing that happen, and I don't know if I'm using the events properly or at the right time.

So I have this when I'm connecting to SimConnect and setting up all my stuff:
Code:
                simconnect.MapClientEventToSimEvent(EVENTS.EVENT_FREEZE_ALT, "FREEZE_ALTITUDE_TOGGLE");
                simconnect.MapClientEventToSimEvent(EVENTS.EVENT_FREEZE_ATT, "FREEZE_ATTITUDE_TOGGLE");

                simconnect.AddClientEventToNotificationGroup(GROUPS.GROUP_FREEZE, EVENTS.EVENT_FREEZE_ALT, false);
                simconnect.AddClientEventToNotificationGroup(GROUPS.GROUP_FREEZE, EVENTS.EVENT_FREEZE_ATT, false);
                simconnect.SetNotificationGroupPriority(GROUPS.GROUP_FREEZE, SimConnect.SIMCONNECT_GROUP_PRIORITY_HIGHEST);


Later, after I get the ID of my sim object:
Code:
                        SimObjectId_AirConnectTrike = simObjectId.dwObjectID;
                        displayText("Received Air Trike id: " + SimObjectId_AirConnectTrike.ToString());

                        // now that we have the id, freeze the LLA/PBH of the plane
                        simconnect.TransmitClientEvent(SimObjectId_AirConnectTrike, EVENTS.EVENT_FREEZE_ALT, 0, GROUPS.GROUP_FREEZE, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY);
                        simconnect.TransmitClientEvent(SimObjectId_AirConnectTrike, EVENTS.EVENT_FREEZE_ATT, 0, GROUPS.GROUP_FREEZE, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY);

Am I doing this in the wrong place, or at the wrong time? Or instead of the Toggle events should I use the two Set events instead?

Thanks again!
DAvid
 
simconnect.TransmitClientEvent(SimObjectId_AirConnectTrike, EVENTS.EVENT_FREEZE_ATT, 0, GROUPS.GROUP_FREEZE, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY);

I don't know whether those controls actually work or not (I've not tried them), but I don't think you want that "SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY" flag, as you certainly aren't providing a Priority number in the Group ID parameter position. If you leave that flag out (just have zero), it will use the Priority you set for the Group. You only use the flag when you want to override the priority in this one Transmission.

It would explain why nothing happens if the GROUPS.GROUP_FREEZE value places the priority lower than STANDARD as I don't think they then get through to the right place in FSX.

Regards

Pete
 
Hi Pete,

I don't know if they work either. Since they're there, I was sort of hoping they did.

As for the GROUP_IS_PRIORITY thing. It was my understanding that the flag would tell it to use the priority set within the group. I chaned it to 0 and it didn't seem to have any different effect on what the AI plane was doing.

David
 
I don't know if they work either. Since they're there, I was sort of hoping they did.

Well, they are new to FSX, but as I had already implemented the Freeze options for FS2002 and FS2004 in FSUIPC, I continued those into FSX. It should be easy to try the new FSX freeze controls (all FSX controls are available for key/button assignment in FSUIPC4), but I've not had time, or so much interest, actually. I am going on holiday after tomorrow, but maybe it is something I should try when I return.

As for the GROUP_IS_PRIORITY thing. It was my understanding that the flag would tell it to use the priority set within the group.

Even though it is clearly named "GROUPID_IS_PRIORITY", (not "GROUP_IS_PRIORITY" as you have it, which makes no sense to me) and the description says "Indicates to the SimConnect server to treat the GroupID as a priority value. If this flag is set, and the GroupID parameter is set to SIMCONNECT_GROUP_PRIORITY_HIGHEST ..."?

Fascinating how what seems clear as day to one reader engenders the exact opposite interpretation in another. I can't see how you could interpret it the way you have done, but there you go ... ;-)

I chaned it to 0 and it didn't seem to have any different effect on what the AI plane was doing.

Shame. Are you checking error returns? If not, I assume you've checked the SimConnect log to see what it might say?

Regards

Pete
 
Curiosity got the better of me -- I tried, within FSUIPC4, assigning separate Key presses to each of

Freeze altitude toggle
Freeze attitude toggle
Freeze latitude longitude toggle

and then I slewed an aircraft up high enough to avoid mishaps, released it to do as it will, and tried each of the above, in turn and in combination. I had the Shift+Z Lat/Lon/Alt display on screen, and of course the aircraft's PFD.

I can attest to the fact that these three controls work well.

So, you need ot look to your code somewhere. First off try getting a SimConnect log so you can see what is happening. Extracting the relevant parts out of my Log I see all this:

Where I map the Sim Event to the Control number (I use the same control numbers assigned for KEY Events in the Gauges SDK).

> 14.13580 [ 0, 2282]MapClientEventToSimEvent:EventID=66827, EventName="FREEZE_ATTITUDE_TOGGLE"
> 14.13582 [ 0, 2283]MapClientEventToSimEvent:EventID=66828, EventName="FREEZE_ATTITUDE_SET"
> 14.13584 [ 0, 2284]MapClientEventToSimEvent:EventID=66829, EventName="FREEZE_LATITUDE_LONGITUDE_TOGGLE"
> 14.13586 [ 0, 2285]MapClientEventToSimEvent:EventID=66830, EventName="FREEZE_LATITUDE_LONGITUDE_SET"
> 14.13587 [ 0, 2286]MapClientEventToSimEvent:EventID=66831, EventName="FREEZE_LATITUDE_LONGITUE_TOGGLE"
> 14.13590 [ 0, 2287]MapClientEventToSimEvent:EventID=66832, EventName="FREEZE_LATITUDE_LONGITUE_SET"
> 14.13591 [ 0, 2288]MapClientEventToSimEvent:EventID=66833, EventName="FREEZE_ALTITUDE_TOGGLE"
> 14.13593 [ 0, 2289]MapClientEventToSimEvent:EventID=66834, EventName="FREEZE_ALTITUDE_SET"

and later, when I used these controls, isolated log entries like this one (66827 = Attitude Freeze):

> 340.37475 [ 0, 2575]TransmitClientEvent:ObjectID=0, EventID=66827, dwData=0, GroupID=1, Flags=16

> 347.41075 [ 0, 2590]TransmitClientEvent:ObjectID=0, EventID=66829, dwData=0, GroupID=1, Flags=16

etc

Note that for the majority of Events FSUIPC4 never uses "AddClientEventToNotificationGroup" or "SetNotificationGroupPriority" -- you only really need those if you are wanting to RECEIVE the events for some reason. In my code there's just the MapClientEventToSimEvent, and the TransmitClientEvent -- yes, with the "GROUPID_IS_PRIORITY", because there is no group in my case, and as you see the Priority is set to "1", which is SIMCONNECT_GROUP_PRIORITY_HIGHEST.

Maybe you should simplify your code a little and try this?

Regards

Pete
 
I started testing them out more carefully too, and it does work.

Part of the strange behavior of the AI plane that I was seeing I discovered is that after it's created, the speed of the AI plane is decreasing. This is why it was dropping relative to my own plane.

I started looking around to see if there were any events similar to freeze for the plane's airspeed, and I stumbled on some simulation variables, AI desired speed and AI unit Mode.

I tried setting the speed I wanted the plane to stay at with the AI desired speed, and it still seemed to slow down.

I'll try out these unit modes, but I'm not sure about the meaning of a few of them. The doc lists:
0: Sleep
1: Zombie
2: Waypoint
3: Takeoff
4: Landing
5: Taxi
6: Working
7: Waiting.

But doesn't give any explanation about what they do or how they affect the AI plane. Does anyone know?

Thanks,
David
 
I'll try out these unit modes, but I'm not sure about the meaning of a few of them. The doc lists:
0: Sleep
1: Zombie
2: Waypoint
3: Takeoff
4: Landing
5: Taxi
6: Working
7: Waiting.

But doesn't give any explanation about what they do or how they affect the AI plane. Does anyone know?

Actually I only just noticed this Sim Var is listed as "writeable". I've no idea what it would do -- really these are ATC-related modes, so it should be interesting to know what happens. Please do let us know!

Regards

Pete
 
Seems I'm having some trouble trying to test these out.

I created a structure with a single uint to hold the value of the AI Unit Mode I want to set. When I try to addToDataDefinition and give "Ai Unit Mode" as the parameter, I get an exception 7: name unrecognized.

I tried different data types, different spellings and spacings between the words. Nothing that I tried worked so far.
 
Ok... So I asked a contact I have with MS about this var, and what the states would do to an AI plane.

Turns out these aren't supposed to be modifiable by the user, and that they've showed up in the documentation is a mistake.

So.. pretend none of this discussion happened.
 
It doesn't look like it, unless I had something else going on screwing it up.. but I didn't get any errors or anything like that... but the plane didn't seem to be keeping up any better.

I'll test it again tomorrow and let you know.
 
For the user aircraft I can get the "FREEZE_TOGGLE" commands to work, but not the "FREEZE_SET". The user aircraft just carries on its way, no exceptions from SimConnect.

If anyone came across some particular tricks to making this work, using managed code, I'd be glad to hear about them.

Either way this is a good way of controlling the user aircraft without having to turn on slew.
 
Are you passing a 1 (or other non-zero value) as the dwData param of the TransmitClientEvent for the _SET version of those events? For all _SET events, you have to provide its new value as a param.
 
Freeze Ids

The freeze ids work well, I have tested them extensively, you DO want to use GROUPID_IS_PRIORITY and I use default priority, with good results. Set the dwData field to 1, in TransmitClientEvent. I do not use the TOGGLE versions of the Freeze Event Ids, but used the ....._SET versions with great success.
 
Back
Top