Jump to content
The simFlight Network Forums

interfacing pmdg aircraft


Recommended Posts

Hi Paul,

I'm starting the somewhat ambitious project of interfacing the PMDG 737 with my flight sim accessibility add-on.

I have a list of all the offsets from the FSUIPC PMDG documentation. I have a few questions:

1. Do you, or anyone for that matter, have a class with the PMDG offsets defined? I'm going to need a lot of them, and would rather not define over 100 offsets if someone has already done it. Long shot, I know. Is there an efficient way of defining a large amount of offsets like this, or just one line per offset like I've always done?

2. Do you have any experience reading the CDU displays? I have already verified that I can get the text, but wondering if I need to worry about detecting which line is selected on the screen, etc. This is tricky, since I don't know what the CDU visually looks like, since I'm totally blind. Related to this, what is the best way to detect which LSK key is needed to select a particular item on the display?

 

I hope this makes some sense.

 

 

 

 

Link to comment
Share on other sites

I can just throw in one idea. If the language you are using supports structures, then you could make structures based on the one supplied by PMDG in their SDK (installed with your aircraft). It's in the .h file.

Then you could read all the offsets in a few blocks, directly into the structures. You can then just refer to them by name.

Pete

 

Link to comment
Share on other sites

Hi Jason,

Pete's idea might work. I've never tried it though. It should be possible to define a single offset of type Byte[]. Then use that value to populate a predefined structure. I'll give it a go here with a small struct and see if I can get it working. You'll need to define the entire PMDG structure though, converting it from the C definition, so I'm not sure if it will save you much time. Reading one offset will likely perform better than reading 100 though.

For the CDU display, there isn't a 'selected' line, so I don't think you need to worry about that. The LSK keys are just lined up to the left and right of a particular row of text of the CDU. You can get an array of rows from the Rows property.

The keys are lined up as follows:

Starting at the top with LSK 1, this lines up with the Row with index 2.(The third row). The other keys are as follows:

  • LSK 2 is lined up with Row with index 4.
  • LSK 3 is Row 6
  • LSK 4 is Row 8
  • LSK 5 is Row 10
  • LSK 6 is Row 12

There are keys on both sides of the screen. Each row will have two options. The left option will be in the first half of the row text, the right option in the second half.

You need push the LSK button that is aligned with the instruction on the same row. E.g. 

Row index 12 might be showing '<index' on the left and 'Pos Init>' on the right. So to activate 'Pos Init' this would be LSK R6 (Right hand side, 6th button down).

For data entry, the keyboard below the screen is used to enter the data into the bottom row of the screen (left side). Then you press the relevant LSK key to move that data into the correct field. The field name is usually on the row above where the data is shown.

For example, the field name for the transition altitude will be on the right hand side of row index 9. The data for this is displayed under it on the right side of row 10. You would type in the transition altitude and then press the LSK 5 (on the right) to enter the data. 

I'm pretty sure that all the data and commands on a page appear in the same place every time. So you won't need to work that out in real time. Pos Init for example is always on LSK R6 when that particular page is active.(Indent page 1/2). The page title is always on the first row (index 0).

Paul

Link to comment
Share on other sites

Hi Jason,

I've tried to automatically create a class for the 737 offsets by writing a program to generate it from the PMDG header file. Unfortunately, the layout of the FSUIPC offsets doesn't match the header file, so that doesn't work. 

I can't think of any other easy ways to do this. Unless someone else has already done this and wants to share, you'll have to declare the offsets you want manually.

Paul

Link to comment
Share on other sites

31 minutes ago, Paul Henty said:

Unfortunately, the layout of the FSUIPC offsets doesn't match the header file, so that doesn't work. 

Can you explain this please?  By email petedowson@btconnect.com. Unless the following explains your problem:

The structure is read directly into the FSUIPC offset area. BUT it may be split. There were a number of developments of the PMDG aircraft in which their structure was extended.  That would be okay - it would be split into a different offset area. But, worse, it had more data inserted in the middle. That meant some manipulations to retain compatibility -- moving those additions to the end of the extension area.

There have been at least three different layouts for the PMDG 737 if you include the NGu and NG3 versions and the updates.

A structural approach can still work, but not just in one structure as in the PMDG SDK. It has to be split into the separate ones matching where the data had to be split.

FSUIPC is all about compatibility. That's its purpose, its raison d'etre. And it takes a lot of effort!

Pete

 

 

Link to comment
Share on other sites

  • 1 month later...

Hi Jason,

I've just released V3.1.24 which has helper classes for the PMDG 737, 747 and 777 offsets, and adds enums for the 747 and 777 Controls.

The offset helper classes are called:

  • PMDG_737_NGX_Offsets
  • PMDG_747QOTSII_Offsets
  • PMDG_777X_Offsets

These all work the same way - Examples below are for the 737

First declare a new instance of the helper class. This is best done at the class or form level like normal offsets.

C#

private PMDG_737_NGX_Offsets pmdg737 = new PMDG_737_NGX_Offsets();

VB.NET

Private pmdg737 As PMDG_737_NGX_Offsets = New PMDG_737_NGX_Offsets()

With the connection open, call the RefreshData() method to get the latest data. The class contains all the known offsets for the aircraft. The names are the same as in the supplied FSUIPC Documentation. Where there are multiple values (e.g. The pilot and co-pilot MCP values) these are arrays of Offsets.  

The example below shows getting the state of the left-hand wiper switch and the EFIS mode selector switch on the pilot and co-pilot side:

 C#

            // Get latest data
            pmdg737.RefreshData();
            
            // Get left wiper switch. Single offset 
            int leftWiper = pmdg737.OH_WiperLSelector.Value;

            // Get EIFS Mode selectors (array of 2 offsets, Pilot and Co-Pilot)
            int pilotEFISMode = pmdg737.EFIS_ModeSel[0].Value;
            int copilotEFISMode = pmdg737.EFIS_ModeSel[1].Value;

VB.NET

        ' Get latest data
        pmdg737.RefreshData()

        ' Get left wiper switch. Single offset 
        Dim leftWiper As Integer = pmdg737.OH_WiperLSelector.Value

        ' Get EIFS Mode selectors (array of 2 offsets, Pilot And Co-Pilot)
        Dim pilotEFISMode As Integer = pmdg737.EFIS_ModeSel(0).Value
        Dim copilotEFISMode As Integer = pmdg737.EFIS_ModeSel(1).Value

Paul

 

Link to comment
Share on other sites

  • 2 months later...

Paul,

  Thanks so much for adding the Helper classes, just what I'm looking for in fact, and I'd not noticed them or the update you pushed, have it now, thanks.

One question/comment/what-have-you, one of the things I've been struggling with is that the offsets are different between the earlier 737NGX and the 737NGXu.

 Would it be possible to create/add the NGXu helper class also? I've attached the NGXu header file in case you don't have it available...

Ian.

PMDG_NG3_SDK.h

Link to comment
Share on other sites

11 hours ago, IanAbel said:

One question/comment/what-have-you, one of the things I've been struggling with is that the offsets are different between the earlier 737NGX and the 737NGXu.

We updated FSUIPC so that the values in common between the NGX and NGXu were in the very same offsets, with the new ones added at the end. Your reference is NOT the PMDG SDK but the FSUIPC PMDG offsets documentation:

Offset Mapping for PMDG 737NGX and 737NGXu.pdf

Dated December 2019.

Pete

 

Link to comment
Share on other sites

Thanks for clarifying Pete.

I've found the updated PDF with the extra NGXu offsets. I will add those to the DLL helper class. 

I will also check the list of controls (events) to see if there are any changes/additions there and bring those into line.

I expect to release a new version early next week.

Paul

Link to comment
Share on other sites

5 hours ago, Pete Dowson said:

Your reference is NOT the PMDG SDK but the FSUIPC PMDG offsets documentation:

Sorry Pete, my mistake.

I don't own the NGXu so asked one of the BAVirtual members to send the header file. He supposedly sent the one in the SDK folder from PMDG.

Link to comment
Share on other sites

Paul,

 Question regarding the helper classes, is there any indication available that the data is unavailable if the appropriate "EnableDataBroadcast" is not set in the _options.ini file for the aircraft?

Just wondering what is returned if that's not set.

Link to comment
Share on other sites

Hi Ian,

All offsets will just return 0, but that's a valid value for most of them.

You could try looking for an offset which can never be 0 under normal operation and test that. 

Something else you can try is writing an out-of-range value to one of the offsets and then read it back after a second or so and see if it's a correct value. This could be 0 but that's okay if you wrote 0xFF. If the connection to PMDG isn't working you'll read your original 0xFF back.

Paul

Link to comment
Share on other sites

Version 3.1.27 is now available with the updated PMDG 737 offsets and controls.

Quote

as it is tedious work, which I am sure you can attest to. 

Well I didn't do it by hand, I cheated a bit. I wrote a program that pulled the information from the .pdf and the .h file and wrote the classes for me. 

Paul

Link to comment
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
×
×
  • Create New...

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.