Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

K Variables with two values #87

Open
artlazza opened this issue Apr 4, 2021 · 3 comments
Open

K Variables with two values #87

artlazza opened this issue Apr 4, 2021 · 3 comments

Comments

@artlazza
Copy link

artlazza commented Apr 4, 2021

I came across an issue while programming using the library.

The command:

event_to_trigger = Event(b'TURBINE_IGNITION_SWITCH_SET1', sm)
event_to_trigger(2)

Works fine and the switch moves accordingly. The variable is K:TURBINE_IGNITION_SWITCH_SET1 requires one value.

However, when dealing with a K variable that requires two values the program crashes, K:ELECTRICAL_BUS_TO_CIRCUIT_CONNECTION_TOGGLE variable for example.

If I try:

event_to_trigger = Event(b'ELECTRICAL_BUS_TO_CIRCUIT_CONNECTION_TOGGLE', sm)
event_to_trigger(11, 1)

It catches and exception and crashes.

Is there any way to pass two values for a K variable? Passing them in a row didn't work (two separate event_to_trigger commands with different values).

@odwdinc
Copy link
Owner

odwdinc commented Apr 4, 2021

Not 100% where you are geting the variable from, more info is needed.
You are not able to pass more then on value to any event. Though some have indexs that can be set.

Example Pseudocode:

event_to_trigger = Event(b'GENERAL_ENG_THROTTLE_LEVER_POSITION:index', sm)
# Need to set index befor read/write
event_to_trigger.setIndex(1)
# Note to set index 2 vs 1 just re-run
# event_to_trigger.setIndex(2)

event_to_trigger(1)

This is the same to SimConnect as:

event_to_trigger = Event(b'GENERAL_ENG_THROTTLE_LEVER_POSITION:1', sm)
event_to_trigger(1)

By passing in the 'index' string the lib will handle switching as need, using the setIndex()

@artlazza
Copy link
Author

artlazza commented Apr 4, 2021

Hi odwdinc, thanks for your reply. I tried your approach but I get "SIMCONNECT_EXCEPTION_NAME_UNRECOGNIZED" and "SIMCONNECT_EXCEPTION_ERROR", which is a different error (not crashing anymore). I suspect this variable doesn't accept the :1 or :2 index as you suggested. My code now is:

event_to_trigger = Event(b'ELECTRICAL_BUS_TO_CIRCUIT_CONNECTION_TOGGLE:1', sm)
event_to_trigger(11)
event_to_trigger = Event(b'ELECTRICAL_BUS_TO_CIRCUIT_CONNECTION_TOGGLE:2', sm)
event_to_trigger(1)

I attached two screenshots of my source. I'm trying to mimic the External Power Switch for the Cessna Grand Caravan EX. The standard "Toggle External Power" didn't do the trick, so I'm trying to figure out the commands of the xml file.

Any thoughts?

Captura de tela 2021-04-04 202950
Captura de tela 2021-04-04 203741

@FS2020-USER-TESTER
Copy link

A K: value is internal variable visible to WASM code. Some of them are hooked up to Simconnect external interface but unfortunately many of the most interesting new variables are not. Especially those related to modern avionics. So far the MSFS2020 developers have shown no urgency to modernize Simconnect which they consider seem to consider a legacy interface.

There are a couple of opensource projects using Simconnect to tunnel new commands into a stub running in WASM. These are all very aircraft-model specific as the K: variables are not consistent across models.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants