July 1, 201510 yr 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 Have a great night,everyone! Dave
July 1, 201510 yr (L:Gen1Off,bool) should be (>L:Gen1Off,bool) The best gift you can give your children is your time.
July 1, 201510 yr Author (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?
July 1, 201510 yr Moderator 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 Avsim Board of Directors | Avsim Forums Moderator
Create an account or sign in to comment