n4gix
Resource contributor
- Messages
- 11,674
- Country

I need to code alternator switches for the KA-350i. These are three position switches with the top position spring loaded, off/on/reset.
How it works is the pilot would move the switch to on, then reset. The switch springs back to the on position, and brings the alternator on-line. Should the alternator go off-line due to an overload or other problem, using reset should bring it on-line again.
I've beat my head for several days and have been unsuccessful.
The 3d switch is scripted like this:
I want to have the 'logic' in a separate XML gauge for easier development. The following is what I've tried last, and it simply will not work. The bloody toggle event keeps firing constantly despite the 'controlling variables...'
How it works is the pilot would move the switch to on, then reset. The switch springs back to the on position, and brings the alternator on-line. Should the alternator go off-line due to an overload or other problem, using reset should bring it on-line again.
I've beat my head for several days and have been unsuccessful.

The 3d switch is scripted like this:
Code:
<PartInfo>
<Name>B350i_L_Generator</Name>
<AnimLength>10</AnimLength>
<Animation>
<Parameter>
<Code>
(L:B350i_L_Generator,enum) 5 *
</Code>
</Parameter>
</Animation>
<MouseRect>
<Cursor>Hand</Cursor>
<MouseFlags>LeftSingle+LeftRelease+RightSingle+Wheel</MouseFlags>
<CallbackCode>
(M:Event) 'RightSingle' scmp 0 ==
(M:Event) 'WheelDown' scmp 0 == or
if{ (L:B350i_L_Generator, enum) -- 0 max (>L:B350i_L_Generator, enum) }
(M:Event) 'LeftSingle' scmp 0 ==
(M:Event) 'WheelUp' scmp 0 == or
if{ (L:B350i_L_Generator, enum) ++ 2 min (>L:B350i_L_Generator, enum) }
1 (>L:XMLSND1,bool)
</CallbackCode>
</MouseRect>
</PartInfo>
Code:
<!-- GENERATOR LOGIC -->
<!-- RESET LEFT -->
(L:B350i_L_Generator,enum) 2 ==
(L:B350i_L_GenReset,enum) 0 == and
if{ 1 (>L:B350i_L_GenReset,enum) 1 (>L:B350i_L_Generator,enum) }
<!-- ON LEFT -->
(L:B350i_L_Generator,enum) 1 ==
(L:B350i_L_GenReset,enum) 1 == and
(A:GENERAL ENG MASTER ALTERNATOR:1,enum) 0 == and
if{ (>K:TOGGLE_ALTERNATOR1) }
<!-- OFF LEFT -->
(L:B350i_L_Generator,enum) 0 ==
if{ 0 (>L:B350i_L_GenReset,enum) }
(L:B350i_L_Generator,enum) 0 ==
(L:B350i_L_GenReset,enum) 0 == and
(A:GENERAL ENG MASTER ALTERNATOR:1,enum) 1 == and
if{ (>K:TOGGLE_ALTERNATOR1) }
<!-- END GENERATOR LOGIC -->






