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

MSFS 2D gauges conversion by Legacy Importer

Greetings. I am Legacy Importer tool developer and apparently reached the point where I need some help. Working on gauges conversion now, get some result but its really far away from the finish line.

As you know, 2D gauges does not work in legacy cockpits (because of bug probably and maybe will be fixed some day, but who knows). I see some mentions that XML gauge format still supported by engine, but I have decided to avoid it (we know that devs does not care about legacy stuff so it can be broken with any future update) and move to native gauges format - HTML.

I've started 2D gauges experiments about 2 weeks ago. For some reason, VCockpit method did not work for me. Maybe it's another legacy bug, or I did something wrong, tell me if you made it work. But VPainting did work - it is not supposed to be used for needles control, but it does use JS and have access to all sim variables, so good enough for my goal.

dg808_1.jpg

So I moved on and made HTML/CSS generator. That was easy part actually. Most problematic is JS code generator - complicated animation, FSX and MSFS sim variables differences, and especially expressions parsing - these things makes me dizzy.

conversion.jpg

Animation itself quite tricky, on top of that FSX and FS9 has has different XML formats. Currently only rotate/shift elements processed, but that enough for initial testing.

Linking variables not so simple task as it should be. If I use transformation solution like this one:
(A:Wiskey compass indication degrees,degrees) -> SimVar.GetSimVarValue("Wiskey compass indication degrees", "degrees")
at least 50% of variables will be not read properly.

So I had to build a table of known variables which works fine but will take a lot of time until it will be completed:
Code:
                case string hn when hn.Equals("(A:Delta Heading Rate,rpm)", StringComparison.InvariantCultureIgnoreCase):
                    return "parseFloat(-SimVar.GetSimVarValue(\"TURN INDICATOR RATE\", \"degree per second\")) * 60 / 360";
                case string hn when hn.Equals("(A:Variometer rate,knots)", StringComparison.InvariantCultureIgnoreCase):
                    return "parseFloat(SimVar.GetSimVarValue(\"AIRCRAFT WIND Y\", \"knots\"))"; // TODO: fix rate
                case string hn when hn.Equals("(A:Wiskey compass indication degrees,degrees)", StringComparison.InvariantCultureIgnoreCase):
                    return "parseFloat(SimVar.GetSimVarValue(\"PLANE HEADING DEGREES MAGNETIC\", \"degrees\"))";
Any thoughts how to make it more flexible, or maybe full list of available variables exists?

Last one is postfix expression parsing. Simple arithmetics like +-/* is not a problem. Expression with single argument (sin abs if-else) a bit complicated, 2-3 - haven't even tried to make it work so converter returns 0 in this case and gauge does not work.This Expression Operators table really helps.

So, this method looks promising even if doesn't work in 80% of cases =) I will continue on it and hope to reach at least 50% success level. You can test it in latest Legacy Importer version, any imported plane can be loaded - it's not required to use any other program functions like CFG split or AIR import. If some/all of gauges does not appear you may check JS files first - if at least single error happen, whole panel will be black out.

Desktop Screenshot 2020.10.03 - 12.52.51.51.png
Desktop Screenshot 2020.10.02 - 23.10.46.83.png
 

Attachments

  • dg808_1.jpg
    dg808_1.jpg
    113.3 KB · Views: 64
  • conversion.jpg
    conversion.jpg
    608.6 KB · Views: 64
  • Desktop Screenshot 2020.10.04 - 18.25.29.31.png
    Desktop Screenshot 2020.10.04 - 18.25.29.31.png
    3.2 MB · Views: 68
Last edited:

WebSimConnect

Resource contributor
Nice work. I did couple of years ago similar XML gauges conversion into HTML to be used within my framework for P3D/X-plane. Now as the HTML renderer is out of box built-in MSFS it makes sense for me to come back to this project.

I managed to migrate all XML elements and their properties (shift, rotation, etc) however I failed to convert RPN code especially with those IFs, CASE statements etc. This is a nightmare to build proper parser as RPN is one thing and FSX specific parser implementation is another (e.g. stack operations, loop etc), so I skipped that and produced kind of warnings logs to modify manually particular RPN statements. I was happy enough to parse +- 80% of RPN statements without errors for complex PFD gauges.

What was a challenge is that XML gauges philosophy is different from JS programming, XML gauges are responsive to variable changes, so I need to apply same philosophy in kind of watch variable framework. I have not yet analysed HTML-JS framework for MSFS integration, but it might be this can be achieved in another way...

Anyway, good luck in your project.
 
Hi!

Expressions parsing is a headache indeed. I've reach some success by simulating stack manipulator - most commands supported (except case mentioned by you, bitwise, string operators, and some uncommon for JS lang commands), but I am going to finish at least most of them. Planning to make full report for everyone who interested with detailed description and code examples.
Unfortunately, I'm getting challenges from each direction so my current goal is make ~50% of gauges work. Amount of time required for single improvement will increase dramatically with each step, so at some point it will not worth it.
 
Hey, fellow FS developers. I wish to share some information on FSX expressions parsing (which in Reverse Polish notation form, or just Postfix) that implemented in latest Legacy Importer (on post publish moment - in future 0.0.4.10 update).

If some of you would like to test conversion process and debug it - two instruments available:
1. Test expression converter button will open form where you can past expression and get conversion result
2. When you converting aircraft panel, log file created next to XML file (in example picture below - fragment of ".panel.log.txt" file of DG808S). Log contain detailed information about stack state (records divided by | ), condition logic state, and conversion results. You can see that variables replaced with random numbers for simplification process - once parsing finished, they moved back into final script.
parser.jpg

You can check table in attachments with all available operators, their conversion replacements (in final JS script) and examples. Original data was copied from here.

Color labels:
white - not implemented yet
green - native JS operator user
blue - custom functions used as workaround
yellow - works but probably wrong

Feel free to report about any issues you will find. I am still working on scripts so maybe this table will updated soon.
 

Attachments

  • expression_parsing.pdf
    76.1 KB · Views: 30
Hi,

While manipulating on a great number of planes, we noticed that the transcription maded by LegacyImporter went better when certain precautions had been taken in the writing of the panel.cfg:
- no blank between commas and numbers: example "gauge, 3, 3, 3" becoming "gauge,3,3,3,3"
- no white in the gauge's names, it is better to replace them with underscores
 
Thanks for the tip, will check it out.

I've made significant improvement lately by adding support of nested Elements, so now a lot of digital instruments details pop up (even if animation does not work properly most of the time). but it cause some problems with cockpits that did work fine before, trying to solve it and push new update soon.
 
MSFS Legacy Importer 0.0.5.0

List of changes:

* Discord link fixed
* missing aircraft.cfg values fix for all liveries
* fix for invalid ui_typerole value (to make aircraft visible in main menu list)
* real time status for textures conversion, CAB extraction, panels import
* JSON generation result message
* panel import log improved
* gauge string data import (static styles only, no formatting or if/else parsing)
* expression if/else issues fixed
* most expressions operators added (except case and labels)
* nested gauge elements support (infinity depth)
* gauge string with single dimension (width) supported
* gauges IDs sanitizing
* numeric gauge ID fix
* some sizing issues fixed
* macro data reading
* gauge image load without extension
 
Top