plane icon Welcome to Microsoft Flight Simulator’s SDK Q&A Platform!

You have questions regarding the SDK? DevMode Tools? SimConnect? You would like to submit an idea for future improvements, seek help or exchange knowledge? You’re in the right place.


Please take a moment to read the platform’s guidelines before you get started!


question

Simbol avatar image
Simbol asked Vitus answered

[BUG] ELECTRICAL_CIRCUIT_BREAKER_TOGGLE - WASM not working

Hello,

The event ELECTRICAL_CIRCUIT_BREAKER_TOGGLE given a circuit number via WASM does nothing.. the expectations is to cause this to "pull the breaker" when a given circuit is given via WASM using the trigger_key_event (ELECTRICAL_CIRCUIT_BREAKER_TOGGLE , circuit number)..

However nothing happens..

In passing we are also still unable to use any event via WASM that requires 2 parameters, trigger_key_event only allows 1 parameter to be send..

Best,
Raul


aircraft
1 comment
10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

It wouldn't do anything, because for some weird reason you first need to set the

( > A:BUS LOOKUP INDEX, Number)


before you can toggle a breaker. It's the weirdest construct I've seen in the sim so far. Not only do they break consistency of A vars not being writable, it also makes no sense, since the breakers should be indexed outside of their buses anyway....

0 Likes 0 ·
SonantAlpaca avatar image
SonantAlpaca answered

@Arzop can you please have a look?

10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

HansHartmann avatar image
HansHartmann answered Simbol commented

Raul,

You could use execute_calculator_code instead - at least as a temporary workaround. It's required anyway for all those events that require two parameters (>K:2:SOMETHING) as these are not supported by trigger_key_event and send_key_event yet.

Hans

2 comments
10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

And we already are tracking this issue. Not fixed yet but it should be available soon enough.
1 Like 1 ·

Hi Hans,

Many thanks for the suggestion, there were some issues reported here implying that execute_calculator_code can leads to some performance issues, so I am trying to stay away from it until it is confirmed as fixed. It is a big vague if this is resolved or not to be honest: https://devsupport.flightsimulator.com/questions/4657/wasm-execute-calculator-code-leaks-memory-and-redu.html

Some clarification needed on that topic @FlyingRaccoon :).

In any case, I would rather see the WASM trigger event code to be expanded and supported correctly with multiple parameters, it would also be lovely to allow us to write A:VARS or any vars directly without the need of calculator code or SimConnect.

In the meantime I used SimConnect to pull the breakers, my hopes are, this event get's fixed with SU9 or SU10 and then I can update my code to be more efficient since I am trying to avoid Simconnect as much as possible inside WASM.

Thanks to everyone for looking into this,
Raul

0 Likes 0 ·
Arzop avatar image
Arzop answered Arzop commented

Hi,


What kind of electrical system are you using in your package?

Is it a MSFS system as you can find here (ELECTRICAL section) with circuit.N... Or is it more a FSX system?


In the second case, KEY_ELECTRICAL_CIRCUIT_BREAKER_TOGGLE didn't exist in FSX, so this is the expected behavior.

Otherwise, there is a deeper issue.


Best regards

Maxime

4 comments
10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

Hi Maxime,

Thanks for your answer, I am using the new electrical system of course.. I have my circuit numbers set correctly and sequentially.

The SDK documentation states we can call the event ELECTRICAL_CIRCUIT_BREAKER_TOGGLE with a circuit number, as you can see below:

1648044148019.png


This doesn't work, nothing happens.. the breaker is never pulled or set.. (toggle on / off)

Via WASM of course the equivalent is to use trigger_key_event (KEY_ELECTRICAL_CIRCUIT_BREAKER_TOGGLE, CIRCUIT_NUMBER), that doesn't work either.. the circuit breaker of any given circuit remains the same..

I know my electrical system is configured correctly because changing the breaker status via the SimVar watcher or via SimConnect works.. and I was able to confirm it via the electrical debug tool available via behaviours / show electrical system debug...

However attempting to do the same via the SDK documented electrical event generates zero results.

Thanks again for investigating this issue.

Regards,
Raul

0 Likes 0 ·
1648044148019.png (10.3 KiB)

Hi,


I have tested this line:

trigger_key_event(KEY_ELECTRICAL_CIRCUIT_BREAKER_TOGGLE, 1);

in one of SDK's sample (GaugeAircraft) by adding it in PANEL_SERVICE_PRE_DRAW section, and it seems to work (execution seems right and simvars watcher confirms it).


Is it possible for you to provide me your package, so I can investigate in "real" situation? If it is, you can follow this link (section 3) to help you.


Best Regards

Maxime

0 Likes 0 ·

Hi Max,

I am afraid I changed my project now far too much to be useful, since this is not working for me I changed to do this via SimConnect to do it inside my WASM modules by changing the BUS index, and then using the A:Var of breakers.


However, when I was trying to use the key even inside WASM, I was using different circuit numbers from 1, can you test different circuit numbers indexes? for example, a circuit index located on a different BUS from BUS number one and bigger numbers? it is posible the bug is related to a circuit number different from 1, I never tried to disconnect my starter.

The other alternative is that your version of MSFS has this fixed while SU8 in our side is not.. this is the difficulty for 3rd party devs like us when reporting issues, many times we are several version behind of what you guys have..

I was trying several circuits some of them on BUS 2.. I was also trying the circuits attached to my navigation lights, this is my electrical section:

[ELECTRICAL]
max_battery_voltage = 12.7
bus.1 = Name:MAIN_BUS
bus.2 = Connections:bus.1#Name:AVIONICS_BUS
battery.1 = Connections:bus.1#Capacity:24#Voltage:curve.1#Name:MAIN_BATTERY ; Main Battery
alternator.1 = Connections:bus.1#iEng:0#RatedVoltage:14#Load:curve.2
curve.1 = 0:10.5, 0.1:11.31, 0.2:11.58, 0.3:11.75, 0.4:11.9, 0.5:12.06, 0.9:12.5, 1:12.7; Battery voltage for capacity %
curve.2 = 0.1:0, 0.15:30, 0.30:55, 0.8:60 ; Load from RPM table 30A at idle speed & 60 at 90%rpm
circuit.1 = Type:CIRCUIT_STARTER#Connections:bus.1#Power:1000, 1500, 11.5#Name:Starter_1 ; Starter 3500W
circuit.2 = Type:CIRCUIT_GENERAL_PANEL#Connections:bus.1#Power:0.5,1,10.5#Name:General_Panel ; General panel
circuit.3 = Type:CIRCUIT_FUEL_PUMP#Connections:bus.1#Power:20, 24, 11.3#Name:Fuel_Pump ; Fuel pump 12V DC @ 2A
circuit.4 = Type:CIRCUIT_FLAP_MOTOR#Connections:bus.1#Power:90, 100, 11.3#Name:Flaps_Motor ; Flaps motor
circuit.5 = Type:CIRCUIT_DIRECTIONAL_GYRO#Connections:bus.2#Power:10, 15, 11.3#Name:Directional_Gyro ; directional gyro 15W
circuit.6 = Type:CIRCUIT_STANDBY_VACUUM#Connections:bus.1#Power:5,10,11.3#Name:STBY_Vacuum ; stby vacuum
circuit.7 = Type:CIRCUIT_AUTOPILOT#Connections:bus.2#Power:10, 15, 11.3#Name:Autopilot ; Autopilot 15W
circuit.8 = Type:CIRCUIT_XPNDR#Connections:bus.2#Power:10, 18, 11.3#Name:Transponder ; Transponder 18W
circuit.9 = Type:CIRCUIT_ADF_DME#Connections:bus.2#Power:28, 35, 11.3#Name:ADF_DME ; ADF/DME 35W
circuit.10 = Type:CIRCUIT_GPS#Connections:bus.2#Power:30, 45, 11.3#Name:GPS ; AS530 45W
circuit.11 = Type:CIRCUIT_AVIONICS#Connections:bus.2#Power:20,25,10.8#Name:Avionics_1 ; avionics 1
circuit.12 = Type:CIRCUIT_AUDIO#Connections:bus.2#Power:10, 15, 11.1#Name:Audio ; Audio 15W
circuit.13 = Type:CIRCUIT_PITOT_HEAT#Connections:bus.1#Power:30, 40, 11.8#Name:Pitot_Heat ; pitot_heat 40W
circuit.14 = Type:CIRCUIT_NAV:1#Connections:bus.2#Power:4, 5, 11.0#Name:NAV1 ; NAV 1 5W
circuit.15 = Type:CIRCUIT_COM:1#Connections:bus.2#Power:4, 5, 11.0#Name:COM1 ; COM 1 5W
circuit.16 = Type:CIRCUIT_NAV:2#Connections:bus.2#Power:4, 5, 11.0#Name:NAV2 ; NAV 2 5W
circuit.17 = Type:CIRCUIT_COM:2#Connections:bus.2#Power:4, 5, 11.0#Name:COM2 ; COM 2 5W
circuit.18 = Type:CIRCUIT_LIGHT_LANDING#Connections:bus.1#Power:35, 40, 11.3#Name:Landing_Light ; Landing LEDs light 20W x 2
circuit.19 = Type:CIRCUIT_LIGHT_BEACON#Connections:bus.1#Power:6, 8, 11.3#Name:Beacon_Light ; 8W
circuit.20 = Type:CIRCUIT_LIGHT_PANEL#Connections:bus.1#Power:2, 5, 11.3#Name:Instruments_Lights ; panel lights 5W
circuit.21 = Type:CIRCUIT_LIGHT_NAV#Connections:bus.1#Power:10, 15, 11.3#Name:Nav_Light_1 ; nav 1 light 15W
circuit.22 = Type:CIRCUIT_LIGHT_STROBE#Connections:bus.1#Power:20, 25, 11.3#Name:Strobe_Light_1 ; strobe light 25W
circuit.23 = Type:CIRCUIT_XML:1#Connections:bus.1#Power:16, 50, 11.8#Name:SEAT_HEAT_1 ; Heated Seat 50W
circuit.24 = Type:CIRCUIT_XML:2#Connections:bus.1#Power:16, 50, 11.8#Name:SEAT_HEAT_2 ; Heated Seat 50W
0 Likes 0 ·
Show more comments
Vitus avatar image
Vitus answered

I think a big issue with this will be that to toggle the breakers, you need to also set the:

( > A:BUS LOOKUP INDEX, Number)

(Which makes no sense to begin with, but here we are....)

So it will probably not be enough to simply add the event for toggling the breaker, because we also need some way to "set" this Simvar with the right bus.

10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 5 attachments (including images) can be used with a maximum of 19.1 MiB each and 23.8 MiB total.