Jump to content
Sign in to follow this  
LKL

Reposted: Need (A:HSI CDI NEEDLE VALID,bool) to play sound only 1 time

Recommended Posts

Re-posted here, as per: Fr. Bill - MSFS Tips and Tricks ModeratorCould someone/anybody, post a gauge to do the following 4 sound triggers as suggested below:I use an AutoLand gauge that I modified for my own personal internal use years ago, but wanted to add 4 additional sounds.I have an Instrument rating, I just don't know how to design gauges....HA! Is there any literature that explains what the following characters do in a .XML gauge file? Examples { } || == ! / > < etc.I looked into the SDK but did not find anything. Some of the characters are self explanatory.Assuming a typical ILS Approach into KSFO 28R:Maintaining proper speeds and an altitude of about 3000 ft AGL, at an angle to intercept the Localizer until the Glide Slope is Captured.This is NOT to be interpreted as a tutorial, just for illustration purposes ONLY.<Comment> GlideSlope Active= The LOC (CDI) is detected -Not intercepted- and is visual on the HSI, Aircraft is about 27-28 miles out. DME1 will show this. Localizer Alive= The LOC is intercepted and GS (GSI) is visual on the HSI. Meaning, BOTH needles have been detected, Aircraft is about 22 miles out. APR HOLD should now be activated.GlideSlope Alive= The GS is intercepted and (GSI) is starting to move. Aircraft is about 14 miles out. Wait for Capture (Engaged).GlideSlope Engaged= The (GSI) is centered on the HSI, Aircraft is about 11 miles out. ALT HOLD will be deactivated IF, it was being used to intercept the GlideSlope System. </Comment><!-- SUGGESTED BARE BONES GAUGE --><!-- GlideSlope Active --><Element> <Select> <Value> (L:ILS_State,enum) 1 == if{ (A:HSI CDI NEEDLE VALID,bool) if{ 1 (> L:snd1_1, enum) } } <==I tried this but, even with excellent help I could not keep the sound from repeating. </Value> </Select></Element><!-- Localizer Alive --><Element> <Select> <Value> (L:ILS_State,enum) 2 == if{ Repeat of the above, but with a trigger to satisfy the event if{ 1 (> L:snd1_2, enum) } } </Value> </Select></Element><!-- GlideSlope Alive -->(<Element> <Select> <Value> (L:ILS_State,enum)3 == if{ Repeat of the above, but with a trigger to satisfy the event if{ 1 (> L:snd1_3, enum) } } </Value> </Select></Element><!-- GlideSlope Engaged --> <Element> <Select> <Value> (L:ILS_State,enum) 4 == if{ Repeat of the above, but with a trigger to satisfy the event if{ 1 (> L:snd1_4, enum) } } </Value> </Select></Element></Gauge>Thanks in AdvanceLKL

Edited by LKL

Share this post


Link to post
Share on other sites
Re-posted here, as per: Fr. Bill - MSFS Tips and Tricks ModeratorCould someone/anybody, post a gauge to do the following 4 sound triggers as suggested below:I use an AutoLand gauge that I modified for my own personal internal use years ago, but wanted to add 4 additional sounds.I have an Instrument rating, I just don't know how to design gauges....HA! Is there any literature that explains what the following characters do in a .XML gauge file? Examples { } || == ! / > < etc.I looked into the SDK but did not find anything. Some of the characters are self explanatory.Assuming a typical ILS Approach into KSFO 28R:Maintaining proper speeds and an altitude of about 3000 ft AGL, at an angle to intercept the Localizer until the Glide Slope is Captured.This is NOT to be interpreted as a tutorial, just for illustration purposes ONLY.<Comment> GlideSlope Active= The LOC (CDI) is detected -Not intercepted- and is visual on the HSI, Aircraft is about 27-28 miles out. DME1 will show this. Localizer Alive= The LOC is intercepted and GS (GSI) is visual on the HSI. Meaning, BOTH needles have been detected, Aircraft is about 22 miles out. APR HOLD should now be activated.GlideSlope Alive= The GS is intercepted and (GSI) is starting to move. Aircraft is about 14 miles out. Wait for Capture (Engaged).GlideSlope Engaged= The (GSI) is centered on the HSI, Aircraft is about 11 miles out. ALT HOLD will be deactivated IF, it was being used to intercept the GlideSlope System. </Comment><!-- SUGGESTED BARE BONES GAUGE --><!-- GlideSlope Active --><Element> <Select> <Value> (L:ILS_State,enum) 1 == if{ (A:HSI CDI NEEDLE VALID,bool) if{ 1 (> L:snd1_1, enum) } } <==I tried this but, even with excellent help I could not keep the sound from repeating. </Value> </Select></Element><!-- Localizer Alive --><Element> <Select> <Value> (L:ILS_State,enum) 2 == if{ Repeat of the above, but with an event to satisfy the sound trigger if{ 1 (> L:snd1_2, enum) } } </Value> </Select></Element><!-- GlideSlope Alive -->(<Element> <Select> <Value> (L:ILS_State,enum)3 == if{ Repeat of the above, but with an event to satisfy the sound trigger if{ 1 (> L:snd1_3, enum) } } </Value> </Select></Element><!-- GlideSlope Engaged --> <Element> <Select> <Value> (L:ILS_State,enum) 4 == if{ Repeat of the above, but with an event to satisfy the sound trigger if{ 1 (> L:snd1_4, enum) } } </Value> </Select></Element></Gauge>Thanks in AdvanceLKL
I could not get in to EDIT my post, so I will add it here.The "Repeat of the above, but with a trigger to satisfy the event" should read as"Repeat of the above, but with an event to satisfy the sound trigger"LKL Edited by LKL

Share this post


Link to post
Share on other sites

Hi, Assuming you have Doug Dawson's xml-sound gauge working...Try this scheme for your sound section:

event 1 (P:ACTIVE VIEW MODE,enum) 1 == andif{  (L:event 1,number) 0 == if{  1 (>L:event 1,number)  1 (>L:sound 1,number)  }  }els{  0 (>L:event 1,number)  }event 2 (P:ACTIVE VIEW MODE,enum) 1 == andif{  (L:event 2,number) 0 == if{  1 (>L:event 2,number)  1 (>L:sound 2,number)  }  }els{  0 (>L:event 2,number)  }etc.

It works flawless for me, hope it helps you,

Edited by phjvh

Share this post


Link to post
Share on other sites

From what I gather, your basic problem is not to play the sound, but to play it only once. Right ?Your code:

<Element><Select><Value>(L:ILS_State,enum) 1 ==if{(A:HSI CDI NEEDLE VALID,bool)if{ 1 (> L:snd1_1, enum) } } <==I tried this but, even with excellent help I could not keep the sound from repeating.</Value></Select></Element>

basically forces the sound variable to "1" as long as the needle is valid; so it keeps repeating,You need another variable that keeps track of the previous state of the needle, so the sound is only played once when the needle variable goes from "false" to 'true".Such a state-transition is what Jan calls "event" in his reply above (neem ik aan, Jan ..LoL)Like in :

<Element>  <Select>	<Value>	  (A:HSI CDI NEEDLE VALID,bool) (L:Previous_CDI_Needle,number) !  &&	  if{		1 (>L:snd1_1,enum)	  }	  (A:HSI CDI NEEDLE VALID,bool) (>L:Previous_CDI_Needle,number)	</Value>  </Select></Element>Tip: use indentation in the code; makes it much more readable, and also prevents youfrom making errors in the code by missing spaces. Like there needs to be a space between ")" and "}"Furthermore, I'm of the "old" school :), so I always use escaped sequences.Like ">" instead of ">". The first syntax always works; the latter sometimes.Like using "<" instead of "<" gives unexpected result sometimes, depending where you use it ...

RobPS-1: Unfortunately, this forum messes up the display of the "two-space-character" indentation I always use.But you get the idea, I assume :)PS-2: Should you ever need it:Doug's (great !!) soundgauge sets a sound L:variable to "0" when the sound has finished playing (when started as a single-play with "1").You can even use this feature to detect possible incorrect installation of gauges, sound .ini files, or wrong panel.cfg definitions; because if the sound can't be played for whatever reason, the variable won't go to "0".I'm using this feature actively in a lot of my gauges, for debugging purposes; e.g. by displaying a "Installation error" bitmap when a sound L:Var doesn't go to "0" after the soundfile duration has elapsed. Has helped me a lot in supporting "User Installation Error" problems ...

Edited by rcbarend

Share this post


Link to post
Share on other sites

BTW the info about the symbols is in the SDK under the "Creating XML Gauges" page, then click on the "Expression Operators" link to get the list.Perhaps this code will help with the problem. I have over commented it so you can tell exactly what I am trying to do.

<!-- GlideSlope Active --><Element><Select>  <Value>   (L:ILS_State,enum) 1 ==   if{	 (A:HSI CDI NEEDLE VALID,bool)	 if{		// We have a valid GS signal		 (L:GS_Sound_Triggered,bool) !		 // Check to see if we have already triggered a sound, the values are 0 = false and 1 = true the ! checks to see the GS_Sound_Triggered variable is not true. If GS_Sound_Triggered is true then nothing happens.		if{		 // We haven't triggered the sound before so trigger the sound and set the GS_sound_Triggered to true		 1 (> L:snd1_1, enum)		 1 (>L:GS_Sound_Triggered,bool)		}		}	els{		// Lost contact with the GS so reset the trigger to false.		 0 (>L:GS_Sound_Triggered,bool)	}   }     </Value></Select></Element>

Edited by anthony31

www.antsairplanes.com

Share this post


Link to post
Share on other sites
Hi,Assuming you have Doug Dawson's xml-sound gauge working...Try this scheme for your sound section:
event 1 (P:ACTIVE VIEW MODE,enum) 1 == andif{  (L:event 1,number) 0 == if{  1 (>L:event 1,number)  1 (>L:sound 1,number)  }  }els{  0 (>L:event 1,number)  }event 2 (P:ACTIVE VIEW MODE,enum) 1 == andif{  (L:event 2,number) 0 == if{  1 (>L:event 2,number)  1 (>L:sound 2,number)  }  }els{  0 (>L:event 2,number)  }etc.

It works flawless for me, hope it helps you,

JAN:I'm just now getting up to speed on xml gauge programming, and need an example of the gauge using your suggesting with the following.f{(A:HSI CDI NEEDLE VALID,bool)if{ 1 (> L:snd1_1, enum) } }In the meantime I will look into the other 2 replies to my post.

Share this post


Link to post
Share on other sites
From what I gather, your basic problem is not to play the sound, but to play it only once. Right ?Your code:
<Element><Select><Value>(L:ILS_State,enum) 1 ==if{(A:HSI CDI NEEDLE VALID,bool)if{ 1 (> L:snd1_1, enum) } } <==I tried this but, even with excellent help I could not keep the sound from repeating.</Value></Select></Element>

basically forces the sound variable to "1" as long as the needle is valid; so it keeps repeating,You need another variable that keeps track of the previous state of the needle, so the sound is only played once when the needle variable goes from "false" to 'true".Such a state-transition is what Jan calls "event" in his reply above (neem ik aan, Jan ..LoL)Like in :

<Element>  <Select>	<Value>	  (A:HSI CDI NEEDLE VALID,bool) (L:Previous_CDI_Needle,number) !  &&	  if{		1 (>L:snd1_1,enum)	  }	  (A:HSI CDI NEEDLE VALID,bool) (>L:Previous_CDI_Needle,number)	</Value>  </Select></Element>Tip: use indentation in the code; makes it much more readable, and also prevents youfrom making errors in the code by missing spaces. Like there needs to be a space between ")" and "}"Furthermore, I'm of the "old" school :), so I always use escaped sequences.Like ">" instead of ">". The first syntax always works; the latter sometimes.Like using "<" instead of "<" gives unexpected result sometimes, depending where you use it ...

RobPS-1: Unfortunately, this forum messes up the display of the "two-space-character" indentation I always use.But you get the idea, I assume :)PS-2: Should you ever need it:Doug's (great !!) soundgauge sets a sound L:variable to "0" when the sound has finished playing (when started as a single-play with "1").You can even use this feature to detect possible incorrect installation of gauges, sound .ini files, or wrong panel.cfg definitions; because if the sound can't be played for whatever reason, the variable won't go to "0".I'm using this feature actively in a lot of my gauges, for debugging purposes; e.g. by displaying a "Installation error" bitmap when a sound L:Var doesn't go to "0" after the soundfile duration has elapsed. Has helped me a lot in supporting "User Installation Error" problems ...

ROB:It WORKED just as designed. I Thank you guys very much.I feel like "OPA'' who passed away recently. THIS FLIGHT SIMMING CAN BECOME ADDICTIVE.I helped Doug test his latest gauge last year that was having a problem that me and another guy was having. His latest revision became 4.1.8 (164 KB) but I don't know if he ever released it yet.For comparison purposes, what events would YOU use to detect the 4 gauges==> GlideSlope Active, Localizer Alive, GlideSlope Alive and GlideSlope Engaged.An example like (A:HSI GSI NEEDLE,number) -20 > would be welcomed. LKL Edited by LKL

Share this post


Link to post
Share on other sites
BTW the info about the symbols is in the SDK under the "Creating XML Gauges" page, then click on the "Expression Operators" link to get the list.Perhaps this code will help with the problem. I have over commented it so you can tell exactly what I am trying to do.
<!-- GlideSlope Active --><Element><Select>  <Value>   (L:ILS_State,enum) 1 ==   if{	 (A:HSI CDI NEEDLE VALID,bool)	 if{		// We have a valid GS signal		 (L:GS_Sound_Triggered,bool) !		 // Check to see if we have already triggered a sound, the values are 0 = false and 1 = true the ! checks to see the GS_Sound_Triggered variable is not true. If GS_Sound_Triggered is true then nothing happens.		if{		 // We haven't triggered the sound before so trigger the sound and set the GS_sound_Triggered to true		 1 (> L:snd1_1, enum)		 1 (>L:GS_Sound_Triggered,bool)		}		}	els{		// Lost contact with the GS so reset the trigger to false.		 0 (>L:GS_Sound_Triggered,bool)	}   }     </Value></Select></Element>

Anthony:Thanks for your help. I tried your gauge but could not make it work. I think it has some to do with the placement of the { and } operators. What is the rule? (opens/closes a statement ??) It appears to be that if the { is used it must be followed with a } somewhere in the file and it looks like you can have extra ones on the end. I found the Expression operators, after re-installing the SDK. Have not looked at it in years because I just recently got interested in gauge creation. It must have got corrupted somehow. Here is what I tried.<Element> <Select> <Value> L:ILS_State,number) 1 ==<!-- GlideSlope Active --> if{ (A:HSI CDI NEEDLE VALID,bool) if{ (L:GS_Sound_Triggered,bool) ! if{ 1 (> L:snd1_1, enum) 1 (>L:GS_Sound_Triggered,bool) }} els{ 0 (>L:GS_Sound_Triggered,bool) } } </Value> </Select></Element> I could move the } around and got sound but it would continuously repeat.

Share this post


Link to post
Share on other sites

The { and } symbols are components of the if{ } els{ } constructs. For every open brace { there must be a closing brace }.Note that blank spaces are absolutely critical for these constructs. Any error, no matter how seemingly insignificant can cause the entire gauge to fail to load at all. It is NOT the least bit forgiving! :(

  1. Correct syntax is: if{ (xxxxx) } els{ (yyyyy) }
  2. Note there is no space between if and the opening brace. There must be a blank space following the opening brace.
  3. Note there is no space between els and the opening brace. There must be a blank space following the opening brace.
  4. Note there must be blank spaces before and after each closing brace!

XML is not a "programming language" per se, but it does follow most of the rules of any programming language. If/else constructs may be "nested" as long as the above four rules are adhered to firmly.

(Condition 1)  if{ (DoThis 1) }  els{ (Condition 2)	  if{ (DoThis 2) }	  els{ (DoThis 3) }    }


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites

You are missing an opening parentheses:L:ILS_State,number) 1 ==And your code could be simplified to something like:

<Element><Select><Value>(L:ILS_State,number) 1 == <!-- GlideSlope Active -->(A:HSI CDI NEEDLE VALID,bool) and (L:GS_Sound_Triggered,bool) ! andif{1 (> L:snd1_1, enum)1 (>L:GS_Sound_Triggered,bool)}els{0 (>L:GS_Sound_Triggered,bool)}</Value></Select></Element>

Hope this helps,

Share this post


Link to post
Share on other sites

Sorry about that, I didn't test the code before I wrote it and you are quite right it didn't work. I think all those comments caused problems somehow so I stripped them out to make the following code which I tested and does work, I am assuming that you control ILS_State somewhere else in your gauge and that this controls whether the device is working or not or something like that:

<!-- GlideSlope Active(L:ILS_State,enum) 1 ==if{  (A:HSI CDI NEEDLE VALID,bool)  if{   	 (L:GS_Sound_Triggered,bool) !		  	 if{ 1 (>L:snd1_1,enum)						 1 (>L:GS_Sound_Triggered,bool)	 }  }	  els{			  	   0 (>L:GS_Sound_Triggered,bool)	 }}els{   0 (>L:GS_Sound_Triggered,bool)}

I added another 0 (>L:GS_Sound_Triggered,bool) line to the bottom so that when ILS_State is 0 the trigger is reset to zero. Also, make sure there are no spaces in "1 (>L:snd1_1,enum)", I think your code had a space between the > and the L:snd1_1 which may not have worked.The { } were actually correct, what I recommend is that you download Notepad++. This is a fantastic free editor and one of the great things it can do is show the linked { }. For example, if you click on either a { or a } it will highlight the matching one which makes it a hell of a lot easier to write code because as you know if you get these messed up it will stop your gauge working.One thing I have is a gauge I made myself which basically displays variables, it helps an awful lot when debugging to see what variables are set to what and this gauge will display them for me. The basic gauge looks like this:<Gauge Name="radio" Version="1.0"> <Image Name="ConfigPanel.bmp"/> // Create your own simple bmp maybe 1024x256 pixels wide in a dark colour (not 0,0,0, black though) <Macro Name="c">C:fs9gps</Macro> <Macro Name="g">C:fs9gps</Macro> <Element> <Select> <Value> // Place any sort of test logic you want in here </Value> </Select> </Element> <!-- Duplicate the following Element changing the position and variable names as needed--> <Element> <Position X="0" Y="5"/> <Text X="200" Y="10" Length="30" Fixed="Yes" Font="Quartz" Adjust="Center" VerticalAdjust="Center" Color="#22FF22" Bright="Yes"> <String>N1 percent: %((A:ENG N1 RPM:1, percent))%!6.6f!</String> </Text> </Element></Gauge>BTW I don't think TGibsons code will work, The problem with his code is that when GS_sound_triggered is set to 1 his logic will immediately set it back to zero which defeats the purpose of that variable.


www.antsairplanes.com

Share this post


Link to post
Share on other sites

Hi,If his original logic wouldn't work then mine wouldn't either, since I used his code as a base. :)

Share this post


Link to post
Share on other sites
Hi,If his original logic wouldn't work then mine wouldn't either, since I used his code as a base. :)
Thanks I will try it. I was actually trying to create a standalone gauge (containing the 4 items) that I described in my original post, but have decided to just use it in my Autoland gauge that I have been messing with for years. I got it working the other day using the sounds, and it was easier then trying to make it a separate gauge.How do you close this post? or can you.Thank to everyone for their help. I have learned a lot.LKL

Share this post


Link to post
Share on other sites
hi,did you see my pm?
JAN:FIRST OFF I USE ALL CAPS BECAUSE OF HOW MY KEY BOARD IS SET UP. MY JOY STICKS ARE IN FRONT OF MY FIRST MONITOR AND THE KEY BOARD IS AT AN ANGLE OF ABOUT 75 DEGREES IN FRONT THE SECOND RIGHT MONITOR. THEREFORE I 'HAVE' TO 1 FINGER TYPE. SORRY IF ANYBODY TAKES OFFENSE, BUT THAT'S JUST THE WAY IT IS.I SAW THE FEB 18 POST AND RESPONDED WITH 'COULD YOU INCLUDE THE ACTUAL EVENTS' BECAUSE I DID NOT UNDERSTAND SOME OF THE STATEMENTS.I JUST STARTED TO TAKE AN INTEREST IN PANEL AND GAUGE DESIGN, AND STILL GETTING UP TO SPEED. IT'S MY FAVORITE AREA IN FSX.SO FAR I TAKE SOMEONE'S GAUGE AND MODIFY IT TO MY OWN PERSONAL USE. I THINK I HAVE SOME NICE ONES. (FOR ME THAT IS)THANKS

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  

  • 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.
×
×
  • Create New...