MobiFlight Community Support

Welcome to the forum for MobiFlight! Feel free to reach out to the community in case you have questions, issues or just want to share great ideas or details about your latest home cockpit project.

You like MobiFlight? Donate via PayPal and support the MobiFlight development. Thanks! 

05/03/2024 - This forum is read-only

The community support for MobiFlight has moved exclusively over to our Discord server. Register for free and enjoy more interactive functions like image and video upload, voice chat. More than 7,000 registered users around the world make it a great experience!

See you on our MobiFlight Community Discord server.

A HUGE Thank You to everyone who participated in the forum, especially obviously to Pizman and Stephan who did an outstanding job over so many years providing an incredible service to the MobiFlight community.

The forum is still providing a lot of good content, hence we keep this information accessible.

icon
Avatar
AndrewZAP1977
Posts: 8
Hello!
I am sorry about my English!
Sorry if I posted this thread in the wrong section!

I have just begun to study MF and its use in MFS2020.
In MFS2020, in developer mode, I found that when i press the APR autopilot button on the screen, the command
should be executed:
(A:AUTOPILOT APPROACH HOLD, Bool) (A:AUTOPILOT GLIDESLOPE HOLD, Bool) ! and if{ (>K:AP_APR_HOLD) } (>K:AP_APR_HOLD).
If I understand correctly, is this written on the RPN (please correct me if I'm wrong)?
I read on the MFS2020 SDK page about the RPN syntax. But I have some questions.
If I understood everything correctly, then it can be interpreted as follows:

IF (A:AUTOPILOT APPROACH HOLD, Bool) (A:AUTOPILOT GLIDESLOPE HOLD, Bool) is not equal to "1"
(in other words, equal to "0", "false". If I understand correctly, the "!" means "not equal").
THEN { (>K:AP_APR_HOLD) }
ELSE (>K:AP_APR_HOLD)

But I can't figure out what the "and" operator means? I did not find a similar combination like "! and" in the RPN.
Or does it mean
IF (A:AUTOPILOT APPROACH HOLD, Bool) and (A:AUTOPILOT GLIDESLOPE HOLD, Bool) is not equal to "1"

And why are the commands executed after "then" and "else" the same?

And the most important thing!
How I can interpret this entry in MobiFlight syntax? If it's possible of course! Or will it be exactly the same for MF?

Please excuse me for the stupid question!

With all respect,
Andrew!
[Last edited by AndrewZAP1977, 2022-10-22 17:54]
2022-10-22 17:44
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
Hi

this is a RPN Code.

When you talk about "mobiflight Syntax" you mean pretty sure the NCALC Syntax we use in transform/Compare.
Thats different.
Within Mobiflight this Ncalc Stuff is our way..... But commands we send via WASM Module must be done in RPN.
Whatever you not have to learn RPN cause those premade PRESET from our HupHop database "should" work fine.
So in MF you just choose for them and the code do the work within the sim.

About your question:

(A:AUTOPILOT APPROACH HOLD, Bool) (A:AUTOPILOT GLIDESLOPE HOLD, Bool) ! and if{ (>K:AP_APR_HOLD) } (>K:AP_APR_HOLD)

This basically means.....
At first READ (A:AUTOPILOT APPROACH HOLD, Bool) and also read (A:AUTOPILOT GLIDESLOPE HOLD, Bool)
Now ! and if means .... If first value is True AND Second Value is ! (not True)
Behind comes the THEN .... if{ (>K:AP_APR_HOLD) }
Means when IF Condition is TRUE THEN send this Command.

This Code have no Else included !!! The code at the End is a own command .... (>K:AP_APR_HOLD)
So this is send once whatever the IF was True or False.

Summary:
We say something like If Approach is True AND Glideslope is FALSE THEN Send Command (>K:AP_APR_HOLD) and at the end send again the same (>K:AP_APR_HOLD)
If condition is not True ( E.g. if Approach is False or if Approach is true but Glideslope is also True, Then "ignore" the THEN part and only send the last Command (>K:AP_APR_HOLD) only one time this moment.

**********
Let me say.... i not know what aircraft you use.... And i also not knwo why the user who create this make it in that difficult way.....
If it work.... Use it. If not request to us so we can maybe find a better one.

But i hope your question is answerd , what the code means.
Good Luck !
2022-10-23 00:43
Avatar
AndrewZAP1977
Posts: 8
pizman82, Thanks for the fast and quality answer!

iconQuote:

When you talk about "mobiflight Syntax" you mean pretty sure the NCALC Syntax we use in transform/Compare.
Thats different.


Thanks, now I know what it's called! And I will study it!
iconQuote:

But commands we send via WASM Module must be done in RPN.
Whatever you not have to learn RPN cause those premade PRESET from our HupHop database "should" work fine.
So in MF you just choose for them and the code do the work within the sim.


Using ready-made PRESETS from HupHop is very good! But I want to understand myself what I require from the computer when executing different commands! I really don't want to use the stupid "copy/paste" principle! Therefore, I will continue to study the documentation on the RPN and begin to study the NCALC Syntax.
iconQuote:

About your question:

(A:AUTOPILOT APPROACH HOLD, Bool) (A:AUTOPILOT GLIDESLOPE HOLD, Bool) ! and if{ (>K:AP_APR_HOLD) } (>K:AP_APR_HOLD)

This basically means.....


Thanks for the detailed explanation! In general, my assumptions were correct.
iconQuote:

**********
Let me say....


TBM 930 Improvements Mod :blush:

Thank you very much again!!!
With all respect,
Andrew!
2022-10-23 06:57
Avatar
AndrewZAP1977
Posts: 8
pizman82, Hello!

With your hint, I managed to assign the APR button the way I wanted!
May I ask you one more question? I'm sorry!

There is a (A:AUTOPILOT MAX BANK ID, Number) variable that shows the state of the BANK button in the SIM. I can read it in MF.
I change the value of this variable by pressing a BANK button on the screen (for experiment).

I send: 1 (>K:AP_MAX_BANK_SET) when the value of (A:AUTOPILOT MAX BANK ID, Number) is "0". Then value of (A:AUTOPILOT MAX BANK ID, Number) changes to "1" and the button on the screen is "ON"
And vice versa...
When the value of (A:AUTOPILOT MAX BANK ID, Number) is "1" and I send: 0 (>K:AP_MAX_BANK_SET) . Then value of (A:AUTOPILOT MAX BANK ID, Number) changes to "0" and the button on the screen is "OFF"
Everything is working!

I wanted to use its value and created the following construction:
(A:AUTOPILOT MAX BANK ID, Number) ! if{ 0 (>K:AP_MAX_BANK_SET) } els{ 1 (>K:AP_MAX_BANK_SET) }
And I tried to send it through the WASM module.
But am I doing something wrong again? This does not work!
pizman82, tell me please, what am I doing wrong?
Or am I wrong again and this shouldn't work at all?

I'll attach a picture from developer mode:


Respectfully,
Andrew.

Question removed!!! I figured it out and found the error!
[Last edited by AndrewZAP1977, 2022-10-24 15:18]
2022-10-23 10:28
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
Hi again

I need to say.... I´m not the Pro User for that RPN Stuff.
Also yesterday i need to also ask myself a other user (Jaime, our RPN Specialist ) to be able to awnser your question :blush:

Means.... Best way to awnser your Coding Questions would be our DISCORD https://discord.gg/99vHbK7
Its more logical to direct talk to these guys as using me as "transmitter" ...... Whatever its cool cause also i learn myself a lot by those request :thumbup:

About your Problem....
I see 2 spots that are wrong.... ( But again i not have a lot experience and this time i not ask the other guys and just tell you my own idea)

(A:AUTOPILOT MAX BANK ID, Number) ! if{ 0 (>K:AP_MAX_BANK_SET) } els{ 1 (>K:AP_MAX_BANK_SET) }

Issue 1 ( not sure if correct!!) You use "!" as operator. This work fine if the Readed Variable is BOOLEAN .... So True or not True.
But the Variable occure in a "Number"
I´m not sure if these ( if 0 or 1) is in code also show as Bool OR If we need here something like =0 instead of ! (NOT)

Issue 2 If it would work that way your logic is inverted .... You say If NOT ( Means if Variable is 0 at the moment) THEN send the 0 ELSE send the 1
So you SET to 0 if 0 and set to 1 if 1 .... Make no sense!

Solution:
I would try at first..... (A:AUTOPILOT MAX BANK ID, Number) if{ 0 (>K:AP_MAX_BANK_SET) } els{ 1 (>K:AP_MAX_BANK_SET) }
By remove the ! we say now if True ( so Var =1) then send a 0 else a 1
If this not work you need to google for correct operator ( i not sure what it is... Maybe == ) .....
(A:AUTOPILOT MAX BANK ID, Number) ==1 if{ 0 (>K:AP_MAX_BANK_SET) } els{ 1 (>K:AP_MAX_BANK_SET) }
Good Luck !
2022-10-24 15:24
Avatar
erjdriver
Posts: 3
For people not familiar - RPN stands for Reverse polish notation.

Normally we write A + B = C i.e. first operand, the operator and then the second operand. Operations are performed left to right with a precedence order e.g. () over */ over +- etc.

RPN places the two operands and then the operator. Operations are performed left to right - but there's no precedence - first come first served. So the above would be written.

A B + C =

So getting back to `(A:AUTOPILOT APPROACH HOLD, Bool) (A:AUTOPILOT GLIDESLOPE HOLD, Bool) ! and if{ (>K:AP_APR_HOLD) } (>K:AP_APR_HOLD)`

simplifying it

A B ! and if {X} Y

Little bit more complicated because ! is an unary operator like -5

so take A

and then B and apply the complement - i.e. not B. iow you've got

A (not B) and

that's a binary operator (e.g A and not B) - so A would have to be true AND B would have to be false, the the result to be true

if true, then the if statement is executed - that's not true RPN but some sort of an extension.
2023-06-06 23:51
icon