Jump to content
The simFlight Network Forums

Recommended Posts

No, the PMDG offsets are read-only,

 

If you want to control the PMDG 737 from C# you need to send 'controls'. The available control numbers are listed in the PMDG SDK. Specifically, the C header file (it ends with .h).

 

To send a control via FSUIPC see the FSUIPC documentation for offset 3110.

 

 

In C# declare 2 write-only offsets in a group called "sendControl":

private Offset<int> controlParam = new Offset<int>("sendControl", 0x3114, true);
private Offset<int> sendControl = new Offset<int>("sendControl", 0x3110, true); // Must be declared AFTER 3114. 

Make a method you can call to send a control and parameter value:

private static void SendControlToFS(int controlNumber, int parameterValue)
{
       this.sendControl.Value = controlNumber;
       this.controlParam.Value = parameterValue;
       FSUIPCConnection.Process("sendControl");
}

I don't have any PMDG aircraft so I can't really help with anything specific to the 737. From memory, I think some controls need a parameter value that represents a mouse button (e.g. Left, Right). These values are also in the .h file. You may have to experiment or ask on a PMDG forum.

 

Paul

Share this post


Link to post
Share on other sites
On Monday, March 21, 2016 at 2:30 AM, Paul Henty said:

No, the PMDG offsets are read-only,

 

If you want to control the PMDG 737 from C# you need to send 'controls'. The available control numbers are listed in the PMDG SDK. Specifically, the C header file (it ends with .h).

 

To send a control via FSUIPC see the FSUIPC documentation for offset 3110.

 

 

In C# declare 2 write-only offsets in a group called "sendControl":


private Offset<int> controlParam = new Offset<int>("sendControl", 0x3114, true);
private Offset<int> sendControl = new Offset<int>("sendControl", 0x3110, true); // Must be declared AFTER 3114. 

Make a method you can call to send a control and parameter value:


private static void SendControlToFS(int controlNumber, int parameterValue)
{
       this.sendControl.Value = controlNumber;
       this.controlParam.Value = parameterValue;
       FSUIPCConnection.Process("sendControl");
}

I don't have any PMDG aircraft so I can't really help with anything specific to the 737. From memory, I think some controls need a parameter value that represents a mouse button (e.g. Left, Right). These values are also in the .h file. You may have to experiment or ask on a PMDG forum.

 

Paul

Hi Paul

Could You please writr

Write the C# Code In

Visaual Visual basic ??

 

 

Share this post


Link to post
Share on other sites

Sure, no problem.
.

Offset declarations...

   Dim controlParam As Offset(Of Integer) = New Offset(Of Integer)("sendControl", &H3114, True)
   Dim sendControl As Offset(Of Integer) = New Offset(Of Integer)("sendControl", &H3110, True) ' Must be declared AFTER 3114.

 

Helper sub to send a control and parameter...


    Private Sub SendControlToFS(controlNumber As Integer, parameterValue As Integer)
        Me.sendControl.Value = controlNumber
        Me.controlParam.Value = parameterValue
        FSUIPCConnection.Process("sendControl")
    End Sub

Paul

Share this post


Link to post
Share on other sites

I'm very thankful and appreciate your help but might be need abit further due to my limited programming level .

 

While WRITE controls to PMDG , I can use FSUIPC by (send control and parameter) using visual studio, also do I have to use Events(ID/NAME) ?

Can you make example of using PMDG EVENTS to write to PMDG ?

Which programming language is used for SimConnect SDK ?

Share this post


Link to post
Share on other sites

If you're using FSUIPC to send the controls then you just need the event ID number.

For example, let's say you want to press the VNAV switch on the MCP on the 737.

In the PMDG SDK header file it's defined like this:

#define    EVT_MCP_VNAV_SWITCH                        (THIRD_PARTY_EVENT_ID_MIN + 386)    

THIRD_PARTY_EVENT_ID_MIN is defined as:

#define THIRD_PARTY_EVENT_ID_MIN                0x00011000        // equals to 69632

So the control number for EVT_MCP_VNAV_SWITCH = 69632 + 386 = 70018.

The parameter value is usually one of the mouse buttons:

#define MOUSE_FLAG_RIGHTSINGLE   0x80000000
#define MOUSE_FLAG_MIDDLESINGLE  0x40000000
#define MOUSE_FLAG_LEFTSINGLE    0x20000000
... etc

You can put these into VB.NET to make things easier:

    Private Const MOUSE_FLAG_RIGHTSINGLE As Integer = &H80000000
    Private Const MOUSE_FLAG_MIDDLESINGLE As Integer = &H40000000
    Private Const MOUSE_FLAG_LEFTSINGLE As Integer = &H20000000
        etc..

So finally, to simulate the user clicking the VNAV button with the a single click of the left mouse button you do this:

        SendControlToFS(70018, MOUSE_FLAG_LEFTSINGLE) ' PMDG 737 VNAV

Paul

 

Share this post


Link to post
Share on other sites
Quote

Which programming language is used for SimConnect SDK ?

The SDK and samples are in C++.

There is a .NET DLL that allows .NET languages to use SimConnect. However, it is very poorly documented and what little there is is in C#.

Paul

Share this post


Link to post
Share on other sites

I would be interested to learn more about the Offset Mapping.

In the Mapping from PMDG to FSUIPC PDF for the 737 it is mentioned:

"The list here is simply a version of the full list in the PMDG_NGX_SDK.h file with the hexadecimal offset (6420-661F inclusive), size in bytes, and type of value added."

Where is (6420-661F inclusive) coming from?
My example uses the LTS_AntiCollisionSw that is defined in the PMDG SDK struct "PMDG_NGX_Control" with the value 0x6501
So if I want to write a proper mapping and would not have the PDF available, how would I correctly map the values instead? Is this a random number selected for this switch?

Share this post


Link to post
Share on other sites

Hi,

9 hours ago, sesc360 said:

Where is (6420-661F inclusive) coming from?

the Offsets 0x6420 - 0x661F are defined/ reserved by Pete Dowson in FSUIPC and are READ ONLY as described in the corresponding document in FSUIPC Documents folder, Offset Mapping for PMDG 737NGX.pdf. There are also documents for PMDG 777X and PMDG 747 QOTSII.

For Controls like switches you need to the way via FSUIPC as described above already by Paul Henty.

Thomas

Share this post


Link to post
Share on other sites

The thread is already old but my question goes in the same direction. How can I read the content of the CDU screen?
In the FSUIPC documents stands
 

"This is the raw matrix provided by PMDG, in offsets 0x5400-0x57FF (for CDU 0) and 0x5800-0x5BFF (for CDU1). "

But I get no or meaningless data. How can I do that in VB?
I'm grateful for any help.

Share this post


Link to post
Share on other sites

Hi,

Quote

But I get no or meaningless data.

did you activate the SDK in PMDG, if not no data will be provided and FSUIPC can not read anything.

Thomas

Share this post


Link to post
Share on other sites

Thank you for the fast answer.
You mean the broadcast entry in the Options.Ini? He is active. The entries for both FMCs are also in the Ini.

Share this post


Link to post
Share on other sites
Quote

But I get no or meaningless data. How can I do that in VB?

Are you using version 3 of the DLL with NuGet?

If so, I'm adding support for the PMDG CDUs in the DLL. They are a bit complicated to use because of the way the the data is stored (3 bytes per character). The dll will simplify things and give you a nice .net array for the cells.

I'll let you know when it's released (probably late tonight or tomorrow), but you'll need to be getting the dll from NuGet.

Paul

  • Thanks 1

Share this post


Link to post
Share on other sites

The new version is now live on NuGet.

It's 3.1.4-beta so you'll need to make sure you have "Include Prerelease" checked.

To access the screen data for a CDU, declare an instance of PMDG_NGX_CDU_Screen:

    ' Declare a PMDG_NGX_CDU_Screen variable for the CDU
    ' Pass the base offset address to the contructor
    Private cdu0 As PMDG_NGX_CDU_Screen = New PMDG_NGX_CDU_Screen(&H5400)

This example code shows a number of different ways to access the text and other info:

    Private Sub CDUExampleCode()
        ' Call RefreshData to get the latest screen contents
        ' (Connection must already be open)
        cdu0.RefreshData()

        ' Use Powered property to know if CDU is on
        If (cdu0.Powered) Then
            ' Use the ToString() method to get a string of the whole screen.
            ' Use the optional overload to pass a dilimiter for the rows.
            ' E.g. Here we pass CRLF so we can display the screen in a text box:
            '      (Use a fixed size font like 'Consolas' or 'Courier New')
            Me.txtCDU.Text = cdu0.ToString(vbCrLf)
        Else
            Me.txtCDU.Text = "No Power"
        End If

        ' To get a single row of text use the Rows array:
        ' e.g. Row 3 (Index 2 - Arrays are 0 based)
        Dim row3Text As String = cdu0.Rows(2).ToString()

        ' To get a the data in single cell of the CDU use the Cells array on the row
        ' e.g. Row 3 (Index 2), First Character (Index 0):
        Dim R3C1Char As Char = cdu0.Rows(2).Cells(0).Symbol
        ' Or as a string:
        Dim R3C1String As String = cdu0.Rows(2).Cells(0).ToString()

        ' You can also find other data about the cell:
        Dim R3C1Colour As PMDG_NGX_CDU_COLOR = cdu0.Rows(2).Cells(0).Color
        Dim R3C1Flags As PMDG_NGX_CDU_FLAG = cdu0.Rows(2).Cells(0).Flags

        ' To avoid accessing the row everytime, you can hold a reference to the row:
        Dim row3 As PMDG_NGX_CDU_Row = cdu0.Rows(2)

        ' The same for cells:
        Dim R3C1Cell As PMDG_NGX_CDU_Cell = cdu0.Rows(2).Cells(0)

        ' Example of iterating through all rows:
        For Each row As PMDG_NGX_CDU_Row In cdu0.Rows
            Dim rowText As String = row.ToString()
            ' do more work
        Next

        ' Example of iterating through all cells in a row:
        For Each cell As PMDG_NGX_CDU_Cell In row3.Cells
            Dim cellChar As Char = cell.Symbol
            ' do more work
        Next

    End Sub

Let me know if you need any more help with this, or if there are any problems.

Paul

  • Thanks 2

Share this post


Link to post
Share on other sites

32619416zt.jpg

Works perfect. An absolutely perfect piece of software. Thank you so much.

  • Like 2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.