I also need a gauge to give callouts at a certain altitude. For example at around 2,000 feet to hear a flight attendant say something like '
It is now safe to use your electronic devices... etc'. Will this work:
XML:
<Element>
<Select>
<Value>
(* Arming Lvar when reaching 2000 feet *)
(A:Radio Height, feet) 2000 > = (L:Altitude, number) 2000 < &&
if{ 1 (>L:ARMED,bool) }
(A:Radio Height, feet) (>L:Altitude, number)
(* Play the sound when ARMED *)
(L:ARMED,bool)
if{
1 (>L:FAMessages,number)
0 (>L:ARMED,bool) (* Lvar Reset *)
}
</Value>
</Select>
</Element>
Could I combine it with the previous gauge or better make a separate?
Any help appreciated.
You don't need an ARMED state here, because you only play the sound once when you ascend through 2000 ft
So the code:
Code:
<Element>
<Select>
<Value>
(* Play the sound when reaching 2000 feet *)
(A:Radio Height, feet) 2000 >= (L:Altitude, number) 2000 < &&
if{ 1 (>L:FAMessages,number) }
(A:Radio Height, feet) (>L:Altitude, number)
</Value>
</Select>
</Element>
Note on your code above: there should be NO spacecharacter in >= ….. You used >SPACE=
And Yes, just place all of such callouts it in the same gauge (that's what I would do anyway)
As a sidenote:
The code will work, but actually is too simple (as the other example):
- When you load a flight with the aircraft in the air above 2000 ft, the sound will play too (because the Lvar Altitude initially is 0
- When you are flying low over rough terrain during the ascend, you may hear the sound multiple times, because (even if you are in a climb), RA may drop below 2000 ft. Eg. because you climb out over a high, steep mountain.
But these problems could be solved again with another ARMED var, which is set when you are on the ground., and reset when the sound has been played once.
WIth code like:
Code:
<Element>
<Select>
<Value>
(* Arming Lvar when on the ground *)
(A:SIM ON GROUND,bool)
if{ 1 (>L:ARMED1,bool) }
(* Play sound once when armed and ascending through 2000 feet the first time *)
(L:ARMED1,bool) (A:Radio Height, feet) 2000 >= && (L:Altitude, number) 2000 < &&
if{
1 (>L:FAMessages,number)
0 (>L:ARMED1,bool) (* Lvar Reset *)
}
(* Save previous RadioHeight *)
(A:Radio Height, feet) (>L:Altitude, number)
</Value>
</Select>
</Element>
Again, like in the other Doors example, the trick is not to play a sound at the right moment in a simple flight procedure, but finding/programming the exceptions where it should NOT be played.
And if I would think about this more, I could probably find other exceptions where you don't want to play this sound.... LoL
It's just how far you want to go, and how much effort you want to spend in making it "fool-proof"
As an example: I once created a rather fancy, generic GPWS gauge, but it took me quite a few iterations to program even a simple, but fool-proof condition to establish if the aircraft (when flying) is in TakeOff mode, CruiseFLight mode or Approach/Land mode.
Using criteria like gear, flaps, thrust, altitude, Toga setting, etc... And I still know "holes" in that logic.
Almost as if are programming a FMC.
But if you are really serious about creating a lot of such automated cabin announcements: I think there are allready addons outthere that do exactly what you want.
Success with your codings ...
Cheers, Rob