Jump to content
Sign in to follow this  
Lorby_SI

AxisAndOhs V2 and the Majestic Q400

Recommended Posts

Hello @ll,

a customer was just asking about how to access the buttons and knobs in the Majestic Q400 with AxisAndOhs (Version 2 is required)

That is a little bit tricky. Just using LVars or events is not enough with the Q400 custom switches. You need to follow a procedure that involves two calls to local variables to trigger one event or read a value.

As an example I made an RPN script that reads the state of the Autofeather switch and another script that toggles the switch:

This reads the state of the switch and writes it to an AAO local variable. I run it as an automated script for the Q400 in AAO every 200ms:
68825·(>L:MJC_VAR_READ_CODE,·Number)·(L:MJC_VAR_READ_VALUE,·Number)·(>L:Q400AFState)

And this is the script that I assigned to a joystick button to toggle Autofeather:
1·(L:Q400AFState)·-·(>L:MJC_VAR_WRITE_VALUE,·Number)·68825·(>L:MJC_VAR_WRITE_CODE,·Number)

“68825” is the Majestic code for the Autofeather switch. The trick is to find those codes, I’m not entirely sure how to do that, since I couldn't find an online resource listing them. If you have the LINDA scripts for the Q400 you may find a lot of those codes in there. But if you have LINDA, you don't need AAO for this, so...

 

Edit: If you never use the button in the VC, then you could do it with only one script that is assigned to the joystick button:
1·(L:Q400AFState)·-·(>L:Q400AFState)·(L:Q400AFState)·(>L:MJC_VAR_WRITE_VALUE,·Number)·68825·(>L:MJC_VAR_WRITE_CODE,·Number)

Best regards
 

 

Edited by Lorby_SI
  • Like 1

LORBY-SI

Share this post


Link to post
Share on other sites
On 1/2/2021 at 4:38 AM, Lorby_SI said:

Hello @ll,

a customer was just asking about how to access the buttons and knobs in the Majestic Q400 with AxisAndOhs (Version 2 is required)

That is a little bit tricky. Just using LVars or events is not enough with the Q400 custom switches. You need to follow a procedure that involves two calls to local variables to trigger one event or read a value.

As an example I made an RPN script that reads the state of the Autofeather switch and another script that toggles the switch:

This reads the state of the switch and writes it to an AAO local variable. I run it as an automated script for the Q400 in AAO every 200ms:
68825·(>L:MJC_VAR_READ_CODE,·Number)·(L:MJC_VAR_READ_VALUE,·Number)·(>L:Q400AFState)

And this is the script that I assigned to a joystick button to toggle Autofeather:
1·(L:Q400AFState)·-·(>L:MJC_VAR_WRITE_VALUE,·Number)·68825·(>L:MJC_VAR_WRITE_CODE,·Number)

“68825” is the Majestic code for the Autofeather switch. The trick is to find those codes, I’m not entirely sure how to do that, since I couldn't find an online resource listing them. If you have the LINDA scripts for the Q400 you may find a lot of those codes in there. But if you have LINDA, you don't need AAO for this, so...

 

Edit: If you never use the button in the VC, then you could do it with only one script that is assigned to the joystick button:
1·(L:Q400AFState)·-·(>L:Q400AFState)·(L:Q400AFState)·(>L:MJC_VAR_WRITE_VALUE,·Number)·68825·(>L:MJC_VAR_WRITE_CODE,·Number)

Best regards
 

 

Thank you for this - it lead me to what I've been searching for for days.

First - you need the variablemaps.xlsx, found here - :\Program Files\Lockheed Martin\Prepar3D v4\SimObjects\Airplanes\mjc8q400\doc\ExtInterfaces

Next - Find the variable you want to find the value for and copy the entire thing

Next - paste the variable into the utility (IntVarCRCGen.exe) found here - :\Program Files\Lockheed Martin\Prepar3D v4\SimObjects\Airplanes\mjc8q400\doc\ExtInterfaces\XML

 

"Abstract
This document is a specification for the FSX XML vars connector

Applicability
Applies to every edition of the MJC8Q400 since version 1.008

Description
The XML based access to MJC8Q400 systems can be used to read and write most of the numerical variables within the MJC8Q400

Access is performed in a request/response sequences via 4 dedicated XML variables:

MJC_VAR_READ_CODE
MJC_VAR_READ_VALUE
MJC_VAR_WRITE_CODE
MJC_VAR_WRITE_VALUE

Interface contains 2 special return codes, which are returned in the MJC_VAR_READ_CODE/MJC_VAR_WRITE_CODE:
9991999 // Acknowledge success
9992999 // Acknowledge variable not found


READING THE VARIABLES

To read a variable from MJC, a requestor would perform the following steps:

Design time
1. Identify the variable name in the varlist.xlsx located under \SimObjects\Airplanes\mjc8q400\doc\scripts
2. Derive the 32 bit var name hash using the IntVarCRCGen.exe utility

Run time
3. Write the var name hash into MJC_VAR_READ_CODE
4. Wait for MJC_VAR_READ_CODE to indicate one of the Acknowledge codes (success, or var not found)
5. If Ack is success, the variable value is in the MJC_VAR_READ_VALUE

WRITING THE VARIABLES

To write a variable to MJC, the following steps are performed

Design time
1. Identify the variable name in the varlist.xlsx located under \SimObjects\Airplanes\mjc8q400\doc\scripts
2. Derive the 32 bit var name hash using the IntVarCRCGen.exe utility

Run time
3. Write the desired variable value into MJC_VAR_WRITE_VALUE
4. Write the var name hash into MJC_VAR_WRITE_CODE
5. Wait for MJC_VAR_WRITE_CODE to indicate one of the Acknowledge codes (success, or var not found)
6. If Ack is success, the variable was written

Considerations:
+ Only the numerical variables can be accessed by the XML interface
+ A Read and a Write operation can be executed concurrently
+ The response time of the interface equals to a single FSX visual frame. Due to this fact, the interface might be blocked during aircraft repositions or while the blocking FSX dialogs, such as select flight, or weather setting are shown


Copyright (c) 2013-2016 Majestic Software"

Edited by B1900
minor

http://www.ruscool.co.nzBanner_MJC5.png05_10_2012_14_25_54_C-GLXV_New_Paint_Apr

P3D 4.5:), X-Plane 11.55:(, MSFS 2020:), MJC Q400, Saab 340A, CRJ550, B1900, X-Crafts ERJ/EMB; Win 10x64, 32GB Ram, Samsung drives, RTX 3070 GPU, 5.3 Ghz Intel 1200. Turboprops and RJ's only.

Share this post


Link to post
Share on other sites

Now if you would show me how to make just a single button in Stream Deck - APU, START etc I would be forever in your debt

Jon


http://www.ruscool.co.nzBanner_MJC5.png05_10_2012_14_25_54_C-GLXV_New_Paint_Apr

P3D 4.5:), X-Plane 11.55:(, MSFS 2020:), MJC Q400, Saab 340A, CRJ550, B1900, X-Crafts ERJ/EMB; Win 10x64, 32GB Ram, Samsung drives, RTX 3070 GPU, 5.3 Ghz Intel 1200. Turboprops and RJ's only.

Share this post


Link to post
Share on other sites
22 hours ago, B1900 said:

Now if you would show me how to make just a single button in Stream Deck - APU, START etc I would be forever in your debt

Sorry, but at the moment I don't have access to the Majestic plane. I can only refer to the example from above.

1. Create a script group in AAO for your MJC scripts (so you can distinguish them from the others). Let us call that one "mjcscripts"

2. Create an RPN script that operates the aircraft system in that group. In my example from above, I would create a script called "autofeather" in the "mjcscripts" group with this content:

Quote

1·(L:Q400AFState)·-·(>L:Q400AFState)·(L:Q400AFState)·(>L:MJC_VAR_WRITE_VALUE,·Number)·68825·(>L:MJC_VAR_WRITE_CODE,·Number)

3. Create an "Event" action on the StreamDeck and call the script:
- Write event: "K:" - "mjcscripts-autofeather"
- Send value: 1

Etc.

Every AAO RPN script can be called as "K:scriptgroup-scriptname"

The group and script names are case sensitive. As is everything else in AAO!

 

 

 

Edited by Lorby_SI

LORBY-SI

Share this post


Link to post
Share on other sites

Another example: the APU power switch in the current implementation of the AAO StreamDeck plugin (5.03)

Create a new "OnOffEvent" Action

First Write Event is "S:" "1 (>L:MJC_VAR_WRITE_VALUE, Number) 53623 (>L:MJC_VAR_WRITE_CODE, Number)", On value is 1

Second Write Event is "S:" "0 (>L:MJC_VAR_WRITE_VALUE, Number) 53623 (>L:MJC_VAR_WRITE_CODE, Number)", Off value is 0

 

 

Edited by Lorby_SI

LORBY-SI

Share this post


Link to post
Share on other sites
24 minutes ago, Lorby_SI said:

Another example: the APU power switch in the current implementation of the AAO StreamDeck plugin (5.03)

Create a new "OnOffEvent" Action

First Write Event is "S:" "1 (>L:MJC_VAR_WRITE_VALUE, Number) 53623 (>L:MJC_VAR_WRITE_CODE, Number)", On value is 1

Second Write Event is "S:" "0 (>L:MJC_VAR_WRITE_VALUE, Number) 53623 (>L:MJC_VAR_WRITE_CODE, Number)", Off value is 0

 

To do the same with a proper "OnOff" Action the setup is the same, except that there is an additional read variable that is supposed to contain the actual state of the switch:

You have to create an RPN script in AAO that continuously writes the current state of the APU PWR switch into an LVar, then use that LVar as "Read variable" in the action.

Autoscript:
53623·(>L:MJC_VAR_READ_CODE,·Number)·(L:MJC_VAR_READ_VALUE,·Number)·(>L:MJC_APU_PWR)
this has to be run as an "Aircraft automated script", repeating every 200ms or more (= you don't need that live, IMHO it is enough if it is updated every now and then).

Then in the StreamDeck "OnOff" Action the Read Variable is simply "L:" "MJC_APU_PWR" with the "On value" set to "1"

Edited by Lorby_SI

LORBY-SI

Share this post


Link to post
Share on other sites

I managed to fairly easily make the Nav lights go on and off with AAO button but I tried every (AAO) button on SD and nothing?

I have all the codes from the HC MJCQ400 profile from Dedarian

I'll give this a try 


http://www.ruscool.co.nzBanner_MJC5.png05_10_2012_14_25_54_C-GLXV_New_Paint_Apr

P3D 4.5:), X-Plane 11.55:(, MSFS 2020:), MJC Q400, Saab 340A, CRJ550, B1900, X-Crafts ERJ/EMB; Win 10x64, 32GB Ram, Samsung drives, RTX 3070 GPU, 5.3 Ghz Intel 1200. Turboprops and RJ's only.

Share this post


Link to post
Share on other sites
34 minutes ago, B1900 said:

I tried every (AAO) button on SD and nothing?

"I tried" - well, AAO is not forgiving in the least. Either you get everything exactly right or it won't work. I would need specifics to have an opinion about what you might have done wrong. 

Before I posted the instructions above, I downloaded the Q400 and installed it into P3D V5. The procedures are definitely working, I have tested them.

Edited by Lorby_SI

LORBY-SI

Share this post


Link to post
Share on other sites

Thanks

 I am going to start with a simple switch on a simple plane to make sure SD is talking to P3D\


http://www.ruscool.co.nzBanner_MJC5.png05_10_2012_14_25_54_C-GLXV_New_Paint_Apr

P3D 4.5:), X-Plane 11.55:(, MSFS 2020:), MJC Q400, Saab 340A, CRJ550, B1900, X-Crafts ERJ/EMB; Win 10x64, 32GB Ram, Samsung drives, RTX 3070 GPU, 5.3 Ghz Intel 1200. Turboprops and RJ's only.

Share this post


Link to post
Share on other sites
7 minutes ago, B1900 said:

Thanks

 I am going to start with a simple switch on a simple plane to make sure SD is talking to P3D\

The basic test is the "Button" Action. Create one, open the "Add Button" dialog in AAO and check if AAO can pick it up.

I thought that you had the SD working for the MSFS version? There is no difference here. Did you make sure that the port is the same in both AAOs? Running P3D AAO "As Administrator"? 
Also don't use the MSFS and the P3D versions at the same time or in quick succession, Windows might decide to block that port for a while.


LORBY-SI

Share this post


Link to post
Share on other sites

Its works perfectly in MSFS

Hot key works

 

Edited by B1900

http://www.ruscool.co.nzBanner_MJC5.png05_10_2012_14_25_54_C-GLXV_New_Paint_Apr

P3D 4.5:), X-Plane 11.55:(, MSFS 2020:), MJC Q400, Saab 340A, CRJ550, B1900, X-Crafts ERJ/EMB; Win 10x64, 32GB Ram, Samsung drives, RTX 3070 GPU, 5.3 Ghz Intel 1200. Turboprops and RJ's only.

Share this post


Link to post
Share on other sites
1 minute ago, B1900 said:

Its works perfectly in MSFS

Compare the two and make sure that in the P3D AAO the WebAPI is enabled, that it is using the same port and that the app is run "As Administrator".

Also check if you made the port exception in your firewall specifically for MSFS AAO or if it is free for all programs.

On another note, also double check that the AAO hook DLL is active in P3D (P3D top menu -> Options -> Add-ons -> Lorby AxisAndOhs should be enabled)


LORBY-SI

Share this post


Link to post
Share on other sites
6 hours ago, Lorby_SI said:

Another example: the APU power switch in the current implementation of the AAO StreamDeck plugin (5.03)

Create a new "OnOffEvent" Action

First Write Event is "S:" "1 (>L:MJC_VAR_WRITE_VALUE, Number) 53623 (>L:MJC_VAR_WRITE_CODE, Number)", On value is 1

Second Write Event is "S:" "0 (>L:MJC_VAR_WRITE_VALUE, Number) 53623 (>L:MJC_VAR_WRITE_CODE, Number)", Off value is 0

 

 

 

6 hours ago, Lorby_SI said:

To do the same with a proper "OnOff" Action the setup is the same, except that there is an additional read variable that is supposed to contain the actual state of the switch:

You have to create an RPN script in AAO that continuously writes the current state of the APU PWR switch into an LVar, then use that LVar as "Read variable" in the action.

Autoscript:
53623·(>L:MJC_VAR_READ_CODE,·Number)·(L:MJC_VAR_READ_VALUE,·Number)·(>L:MJC_APU_PWR)
this has to be run as an "Aircraft automated script", repeating every 200ms or more (= you don't need that live, IMHO it is enough if it is updated every now and then).

Then in the StreamDeck "OnOff" Action the Read Variable is simply "L:" "MJC_APU_PWR" with the "On value" set to "1"

FS | Flickr

Piece of cake

Thanks

Edited by B1900
update

http://www.ruscool.co.nzBanner_MJC5.png05_10_2012_14_25_54_C-GLXV_New_Paint_Apr

P3D 4.5:), X-Plane 11.55:(, MSFS 2020:), MJC Q400, Saab 340A, CRJ550, B1900, X-Crafts ERJ/EMB; Win 10x64, 32GB Ram, Samsung drives, RTX 3070 GPU, 5.3 Ghz Intel 1200. Turboprops and RJ's only.

Share this post


Link to post
Share on other sites

Ok. So I’m not a programmer, but I do have the Q400, AAO and an X-touch mini. If I parse the above, can I program a few knobs and keys, such as altitude? Or is there something simpler I can do?

I did manage to get FSL and PMDG planes working. Not so much with the Maddog. 

Edited by Iadbound

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