• 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.

MSFS20 Problem retrieving the value from the Pitot button

Messages
3
Country
france
Hello :)

I use this instruction in a VB Timer to read the "Pitot" value in the Cessna 172:

Code:
.AddToDataDefinition(EnumDefinitions.Struct1, "PITOT HEAT", "bool", Microsoft.FlightSimulator.SimConnect.SIMCONNECT_DATATYPE.INT32, 0, 0)

and

.RequestDataOnSimObjectType(DataRequests.Request_1, EnumDefinitions.Struct1, 0, SIMCONNECT_SIMOBJECT_TYPE.USER)

I use these instructions to enable or disable the "Pitot" button:

Code:
num EnumEventsID
    PITOT_HEAT_OFF = 0
    PITOT_HEAT_ON = 1
End Enum

.MapClientEventToSimEvent(EnumEventsID.PITOT_HEAT_OFF, "PITOT_HEAT_OFF")
.AddClientEventToNotificationGroup(Group_ID.Group0, EnumEventsID.PITOT_HEAT_OFF, False)

.MapClientEventToSimEvent(EnumEventsID.PITOT_HEAT_ON, "PITOT_HEAT_ON")
.AddClientEventToNotificationGroup(Group_ID.Group0, EnumEventsID.PITOT_HEAT_ON, False)

.SetNotificationGroupPriority(Group_ID.Group0, SimConnect.SIMCONNECT_GROUP_PRIORITY_STANDARD)

and

If Me.btnPitot.Valeur = True Then
    .TransmitClientEvent(SimConnect.SIMCONNECT_OBJECT_ID_USER, EnumEventsID.PITOT_HEAT_ON, 0, Group_ID.Group0, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY)
Else
    .TransmitClientEvent(SimConnect.SIMCONNECT_OBJECT_ID_USER, EnumEventsID.PITOT_HEAT_OFF, 0, Group_ID.Group0, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY)
End If

"Me.btnPitot" is a button on a VB Form.

Clicking the button in MSFS2020, changes the button's value in the Form.
(Changing the button value in the Form does not trigger an event in MSFS2020)

Clicking the button in the Form changes the button's value in MSFS2020.

Everything works. But there's a problem.

If I activate the Pitot with the button in the Form, MSFS2020 also activates its button.
But if I immediately use the button in MSFS2020 to disable the Pitot, my button on the Form remains activated.
Because in "OnRecvSimobjectDataBytype", "data" is always equal to 1.
And yet, I observe that the Pitot probe is indeed deactivated because the value of the "AMP" indicator changes.
I enable and disable the Pitot button in MSFS2020 several times, but "data" always returns 1.
I tried using the "PITOT HEAT SWITCH:index" event, but it's the same.
I don't understand.
If I do the opposite, if I first activate the Pitot with the MSFS2020 button and then deactivate the Pitot with
the button in the Form, it works.
 
I don't usually respond to MSFS questions because I don't use the sim, but in this case I think that your problem is that you are not notifying the form correctly that the MSFS button has been pressed. You should not need a timer to synchronise the events. See this for an example of how to synchronise an event between the sim (in this case P3D but the principle applies to MSFS SimConnect as well). The solution that you are interested in it the 'Client-Server Communications' topic.


Although I wrote the examples in vb.Net you should be able to use Telerik's code converter to translate it to C#.
 
Back
Top