Jump to content
Sign in to follow this  
nas123

Assigning postfix(RPN) code to KeyPress

Recommended Posts

I just bought AxisAndOhs to check it out if it was any useful for MSFS projects.

 

My first test was to bind the RPN code that is sent when you press the APPR button in the A320 airplane.IbxV2if.png

The RPN code is the same that is documented in the ModelBehaviorDebug for the A320 when APPR is pressed.  

 

But the keypress (CTRL-SHIFT-P) does not trigger the APPR button in the airplane.

 

See attached image

 

I am probably doing something wrong.

Please advice.

 

Share this post


Link to post
Share on other sites
48 minutes ago, nas123 said:

I am probably doing something wrong.

Please advice.

Hi,

are you sure that all this is really neceassary? Not at my computer right now, but wouldn't triggering "AP_APR_HOLD" be good enough? (that is the "toggle" event as per spec). Also, please double check that the button activates when using the mouse. Just in case.

About the L: - vars in general: when you are using them in AAO RPN scripts, you have to make a decision if only AAO should see them or if they should be handled in the simulator

"(L:MysimVar)" is a local variable, it doesn't leave AAO

"(L:MySimVar, Number)" is a sim variable, and it will be sent to the simulator. The difference is supplying the unit, in this case ", Number", which is the safest bet in all cases.

In the upcoming version 2.04 you will have the option to hand over processing of the script to the sim entirely, by prefixing "SIMPROC:". This already works in the 2.03 too as a hidden option, but IIRC it is just "SIMPROC" without the ":"

If you want, please post the entire script here as text , and I will rewrite it to AAO specs. It doesn't look quite right when you just copy and paste it from the devel log.

Edited by Lorby_SI

LORBY-SI

Share this post


Link to post
Share on other sites

FmoOGhH.png

Quote

are you sure that all this is really neceassary? Not at my computer right now, but wouldn't triggering "AP_APR_HOLD" be good enough? (that is the "toggle" event as per spec). Also, please double check that the button activates when using the mouse. Just in case.

A320/32NX does not reacts to either "AP_APR_HOLD" or "AP_LOC_HOLD". That is why I have to use the same code as found in the ModelBehaviorDebug.

Both buttons reacts to mouse clicks in the virtual cockpit.

 

Sending the RPN code from my own WASM module also works fine.

 

Quote

About the L: - vars in general: when you are using them in AAO RPN scripts, you have to make a decision if only AAO should see them or if they should be handled in the simulator

"(L:MysimVar)" is a local variable, it doesn't leave AAO

"(L:MySimVar, Number)" is a sim variable, and it will be sent to the simulator. The difference is supplying the unit, in this case ", Number", which is the safest bet in all cases.

Oh, I now see why it is not working in the Sim, only local in AAO.

 

Quote

If you want, please post the entire script here as text , and I will rewrite it to AAO specs. It doesn't look quite right when you just copy and paste it from the devel log.

I wrote it down by hand, as it is not possible to copy/paste anything from ModelBehaviorDegub window. If you know how to do that, I would like to know.FmoOGhH.png

Edited by nas123

Share this post


Link to post
Share on other sites
2 hours ago, nas123 said:

it is not possible to copy/paste anything from ModelBehaviorDegub window

But it would have been possible to copy&paste it from the AAO script editor window...

AAO would expect the script to be fully qualified (=without shortcuts). And I think that there is an error in it. Or at least calling LOC_HOLD_ON and LOC_HOLD_OFF in succession doesn't make a lot of sense to me. So I took the liberty of changing that and turn off the approach mode instead. (see lower quote)

Visualized:

Quote

                (L:A32NX_AUTOPILOT_APPR_MODE, Number) 1 == if{
                    0 (>L:A32NX_AUTOPILOT_APPR_MODE, Number)
                    1 (>K:AP_LOC_HOLD_ON)
                    1 (>K:AP_LOC_HOLD_OFF)
                } els{
                    1 (>L:A32NX_AUTOPILOT_APPR_MODE, Number)
                    0 (>L:A32NX_AUTOPILOT_LOC_MODE, Number)
                    1 (>K:AP_APR_HOLD_ON)
                }

For C&P into the script editor

Quote

(L:A32NX_AUTOPILOT_APPR_MODE,·Number)·1·==·if{·0·(>L:A32NX_AUTOPILOT_APPR_MODE,·Number)·1·(>K:AP_LOC_HOLD_ON)·1·(>K:AP_APR_HOLD_OFF)·}·els{·1·(>L:A32NX_AUTOPILOT_APPR_MODE,·Number)·0·(>L:A32NX_AUTOPILOT_LOC_MODE,·Number)·1·(>K:AP_APR_HOLD_ON)·}

 

Edited by Lorby_SI

LORBY-SI

Share this post


Link to post
Share on other sites
Quote

But it would have been possible to copy&paste it from the AAO script editor window...

aargh, how stupid of me..

 

Another issue with RPN coding as you seems to have some knowledge in this area( I know it is not an AAO issue, but I try anyway):

How do I convert the BOLD lines to standard C++ code(my brain can't understand it)?

(L:A32NX_AUTOPILOT_APPR_MODE, bool) if{
(>K:AP_APR_HOLD_ON)
(>K:AP_APR_HOLD_OFF)
}

(L:A32NX_AUTOPILOT_LOC_MODE, bool) if{
(>K:AP_LOC_HOLD)


(A:AUTOPILOT DISENGAGED, Bool) ! 1 and if {
1 1 != if { 0 (>L:XMLVAR_Autopilot_1_Status) }
2 1 != if {0 (>L:XMLVAR_Autopilot_2_Status) }
(L:XMLVAR_Autopilot_1_Status) ! (>L:XMLVAR_Autopilot_1_Status)
(L:XMLVAR_Autopilot_1_Status) (L:XMLVAR_Autopilot_2_Status) or
(A:AUTOPILOT MASTER, Bool) != if {
(>K:AP_MASTER)
(A:AUTOPILOT MASTER, Bool) ! if {
0 (>L:XMLVAR_Autopilot_2_Status)
     }
  }
}

(L:A32NX_AUTOPILOT_APPR_MODE, Bool) if{
(>K:AP_APR_HOLD)
}

(L:A32NX_AUTOPILOT_LOC_MODE, Bool) if {
(>K:AP_LOC_HOLD)
}

 

 

Share this post


Link to post
Share on other sites
12 minutes ago, nas123 said:

How do I convert the BOLD lines to standard C++ code

Install a copy of the old FSX SDK or a P3D SDK and look for the "Infix2Postfix.exe" tool. But to be honest, this script doesn't make a lot of sense - see infix: (I mean the stuff like "if (1 != 1)"...waiting for that to be true is a bit of a stretch)

Quote

 
 if ( ( ! (A:AUTOPILOT DISENGAGED , Bool) ) and 1 ) 
 {     
      if ( 1 != 1 ) 
      {
         (L:XMLVAR_Autopilot_1_Status) = 0 ;  
     } 
      if ( 2 != 1 ) 
      {
         (L:XMLVAR_Autopilot_2_Status) = 0 ;  
     } (L:XMLVAR_Autopilot_1_Status) = ( ! (L:XMLVAR_Autopilot_1_Status) ) ;  
      
      if ( ( (L:XMLVAR_Autopilot_1_Status) or (L:XMLVAR_Autopilot_2_Status) ) != (A:AUTOPILOT MASTER , Bool) ) 
      {
         (K:AP_MASTER) = result ;  
          
          if ( ! (A:AUTOPILOT MASTER , Bool) ) 
          {
             (L:XMLVAR_Autopilot_2_Status) = 0 ;  
          
         } 
     } 
 } 

 

 

Edited by Lorby_SI

LORBY-SI

Share this post


Link to post
Share on other sites
Quote

(I mean the stuff like "if (1 != 1)"...waiting for that to be true is a bit of a stretch)

This is also what I don't understand, but

1 1 != if { 0 (>L:XMLVAR_Autopilot_1_Status) }
2 1 != if {0 (>L:XMLVAR_Autopilot_2_Status) }

is what is coded in by MS/ASOBO as it is taken from the A320's ModelBehaviorDebug window.

To me this is total confusing.

Edited by nas123

Share this post


Link to post
Share on other sites
28 minutes ago, nas123 said:

as it is taken from the A320's ModelBehaviorDebug window.

And that is the problem, because you are seeing code that has already been interpreted. The actual written code works based on inheritance of generic templates, using #..# tags, that are replaced with the local value at runtime.

I am assuming that this part has been constructed from the generic ASOBO_AUTOPILOT_Push_Autopilot_Template and is the interpreted version of the reset code, which is this:

						<Case Value="2">
							<RESET_CODE>
								1 #ID# != if{ 0 (&gt;L:XMLVAR_Autopilot_1_Status) }
								2 #ID# != if{ 0 (&gt;L:XMLVAR_Autopilot_2_Status) }
							</RESET_CODE>
						</Case>
					</Switch>

So they want to make sure that with this generic code, only the autopilot status variable pertaining to the actual knob is changed.

There is bound to be another knob, maybe in another aircraft, where it says "2 2 !="

That being said - it can just as well be a simple programming error, because it definitely looks wrong. I would understand it if it would say "if (1 == 1)" . There are a few errors in the native code, don't just take it as gospel.

Edited by Lorby_SI

LORBY-SI

Share this post


Link to post
Share on other sites

In which MSFS file did you find the 

Quote

<Case Value="2">
							<RESET_CODE>
								1 #ID# != if{ 0 (&gt;L:XMLVAR_Autopilot_1_Status) }
								2 #ID# != if{ 0 (&gt;L:XMLVAR_Autopilot_2_Status) }
							</RESET_CODE>
						</Case>
					</Switch>

 

Share this post


Link to post
Share on other sites
2 hours ago, nas123 said:

In which MSFS file did you find the 

I am using Notepad++ -> Search -> Find in files, filtered for *.xml, *.html. *.js in the entire \Packages\ folder of MSFS. In this case I searched for the L-Vars that are in your script, then threaded my way through the Template hierarchy, assembling the code until I found the relevant bits. 


LORBY-SI

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
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...