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

Flysimware avatar image
Flysimware asked FlyingRaccoon answered

Need better way to pull a breaker for a pre defined circuit type

I am trying to disable a circuit for the starters and since the starter is already defined as a circuit called CIRCUIT_STARTER:1 and CIRCUIT_STARTER:2 the circuit is off when not used. And on when triggered. So when I trigger an event to toggle off when this circuit is on, it's already too late as it's not actually on for a few seconds. So the only way to get this to work is to use an update section and flood the circuit off. I am hopping there is a better solution or maybe new code coming in the future that can always pull any circuit off when pulled. Toggles are the worst kind of event triggers. Set is much better for this exact reason.


Here is the logic I normally use for a breaker switch.

<LEFT_SINGLE_CODE_CALLBACKCODE> 
(L:GENERIC_CIRCUIT_START) 1 == (A:CIRCUIT ON:2, Bool) 1 == and if{ 2 (>K:ELECTRICAL_CIRCUIT_TOGGLE) }  
</LEFT_SINGLE_CODE_CALLBACKCODE>

Here is my update section that works but I am flooding.

                <UseTemplate Name="ASOBO_GT_Update">
                    <FREQUENCY>18</FREQUENCY>
                    <UPDATE_CODE>
                        (L:GENERIC_CIRCUIT_START) 1 == (A:CIRCUIT ON:2, Bool) 1 == and if{ 2 (>K:ELECTRICAL_CIRCUIT_TOGGLE) }    
                    </UPDATE_CODE>
                </UseTemplate>
circuit.2 = Type:CIRCUIT_STARTER:1#Connections:bus.3:-1#Power:400,496,20#Name:Starter_LH ; Starter 3500W
aircraft
10 |10000

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

davux3 avatar image
davux3 answered Flysimware edited

For every electrical circuit in the sim, there is a breaker defined for you. (There's actually a breaker for each bus which the circuit is connected to). That's in addition to the normal on/off switch. For things like gear and the starter, the sim seems to essentially manage that switch state for you. All other circuits are on by default. You can see both the switch status and the breaker status in the Electrical debug, under Behaviors -> Systems -> Electrical Debug.


ELECTRICAL_CIRCUIT_BREAKER_TOGGLE

[0] Source bus index

[1] Target circuit index


So this can be used to pull a breaker between bus 3 and circuit index 2:

2 3 (>K:2:ELECTRICAL_CIRCUIT_BREAKER_TOGGLE )


Of course as you point out, with only a TOGGLE type event, we are usually forced to check the state first.

3 (>A:BUS LOOKUP INDEX, Number) (A:CIRCUIT BREAKER PULLED:2, Bool)

This will put a number in the stack that is the status of the breaker that connects bus 3 to circuit 2 (0:in/on 1:pulled/off).

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.

Flysimware avatar image Flysimware commented ·

Unfortunately all this I already know. Yes with a toggle event we are forced to check the state. And that is ok as it's not really an issue. But since these breakers are already off my breaker switch is not seeing the state as on. And since the sim auto controls these breakers when it does turn on it's too late. I was forced to flood as this is a conflict and works but like a band aid. But is working.

Asobo could make it so that any auto controlled breaker will have a master parent breaker switch that completely turns off as that is how breakers work. The auto on/off control should be a child to the parent master breaker. This is vital and needed. Please use this suggestion Asobo!

0 Likes 0 ·
FlyingRaccoon avatar image
FlyingRaccoon answered

Hello @Flysimware

By default, the starter circuit state is handled on the sim side and as you saw, it is temporarily switched on when the starter is on regardless of what state it was set to previously.

As @davux3 indicated, rather than constantly checking and toggling the circuit when it's on in an update component, you can just pull its corresponding breaker with ELECTRICAL_CIRCUIT_BREAKER_TOGGLE.

There's also a second option, which is to switch off the connection between the bus and the circuit with ELECTRICAL_BUS_TO_CIRCUIT_CONNECTION_TOGGLE.

Regards,
Sylvain

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.