Sign in to follow this  
C525B

XML script that flags a momentary event

Recommended Posts

Hey folks,

 

I'm creating some scripts that will make the systems of the Carenado Hawker 850XP *appear* to work correctly.  I'm learning XML as I go with this project, but I seem to have hit a newbie impasse.  I can't get the syntax of this one right.

 

The issue:  The engine generator on/off function of this aircraft are hard-coded to the wrong switches on the overhead in the VC mode.  What I'm trying to do is get annunciations of the "Gen 1/2 OFF" lights based on use of the actual Gen 1/2 switches so that it appears that those switches are really controlling the gens.  These are three-position switches with momentary contacts, spring loaded to the middle position: Gen Close-neutral-Gen Trip.  There is an LVar that reflects the position of these switches: 1 for close, 0 for neutral, -1 for trip.  The coding of the switch animation in the VC model has a timer that flips the switch back to neutral (value 0) after a second.

 

The logic:  I need to capture the momentary instance where the switch is pressed to Close (1) or Trip (-1) and save that in my own LVar which is used to evaluate the visibility of the Gen 1/2 Off lights.  The value of the "Gen1Off" LVar should change only if the generator switch is pressed momentarily to one of these positions.

 

I made, or tried to make, an Update object to accomplish this.  This is placed within the SimGauge tree, before any of other gauge elements:

<Update>
    <Script>
        (L:ASD_SWITCH_GEN1_850XP_DIR,number) 0 <
            if {1 (L:Gen1Off,bool)}
            els { }

        (L:ASD_SWITCH_GEN1_850XP_DIR,number) 0 >
            if {0 (L:Gen1Off,bool)}
            els { }
    </Script>
</Update>

But...the update object isn't changing Gen1Off.  Where am I going wrong?  I think I'm at that point where I'm so new that all of the documentation that might be helpful is over my head :lol:

 

Have a great night,everyone!

Dave

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

(L:Gen1Off,bool) should be (>L:Gen1Off,bool)

 

Hi, thanks for that!  Can you explain the need for the carat?

 

This seems to be getting closer...my Gen Off annunciator comes on momentarily when the gen switch is clicked to Trip, but it doesn't stay illuminated.  What's making Gen1Off revert to 0 when the switch is released?

Share this post


Link to post
Share on other sites

The purpose of the ">" symbol in this context is most easily understood as a command to "store the preceding calculated value into this variable."

 

You are missing a 'flag evaluation' in your scripts that will prevent the reversion of your Gen1Off variable after it has been set.

(L:ASD_SWITCH_GEN1_850XP_DIR,number) 0 <   
(L:Gen1Off,bool) 0 ==
and
if{ 1 (>L:Gen1Off,bool) } 
In the above script, we are evaluating two conditions before storing the results. Both must be "true" before our (L:Gen1off,bool) is made "true."

 

This additional test (flag) condition prevents the command being executed at each gauge cycle, and the removal of the unnecessary "els " prevents the reversion to zero of the Gen1Off variable.

 

Also, and absolutely critical is that we need to pay close attention to blank spaces! Both the if{ and els{ statements have invisible blank spaces that are an essential part of the syntax. To illustrate this, I'll place the entire expression in quotes so the blank spaces become apparent:

"if{ "......." }"
"els{ "......" }"

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