Jump to content

Archived

This topic is now archived and is closed to further replies.

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

 

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


The best gift you can give your children is your time.

sigbar.gif

Share this post


Link to post
Share on other sites

(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{ "......" }"

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556

Interests: Gauge Programming - 3d Modeling for Milviz

Many Thanks to All That Donated To Our Server Drive!

Share this post


Link to post
Share on other sites

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
  • Donation Goals

    AVSIM's 2020 Fundraising Goal

    Donate to our annual general fundraising goal. This donation keeps our doors open and providing you service 24 x 7 x 365. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. We reset this goal every new year for the following year's goal.


    18%
    $4,640.00 of $25,000.00 Donate Now
×
×
  • Create New...