Sign in to follow this  
Guest dirk1000

Help wanted with delay code for a XML gauge

Recommended Posts

Help AVSIM continue to serve you!
Please donate today!

Hi, You can build in a timer.May be this one works:(A:general eng2 propeller lever position,part) 0.04 + 0.75 > if{ (P:Absolute Time, seconds) 5 + (>L:timer,number) (G:Var1) 0 == if{ 1 (>G:Var1) 1 (>L:dsd_xml_sound_id_20,number) } } els{ 0 (>G:Var1) }(A:general eng2 propeller lever position,part) 0.04 + 0.90 < if{ (G:Var3) 0 == (P:Absolute Time, seconds) (L:timer,number) > and if{ 1 (>G:Var3) 0 (>L:dsd_xml_sound_id_20,number) 1 (>L:dsd_xml_sound_id_21,number) } } els{ 0 (>G:Var3) }Jan"Beatus Ille Procul Negotiis"

Share this post


Link to post
Share on other sites

Hi Dirk,If your problem is that one sound should be started when another is completed, you can solve that much simpler.If you start a sound (single shot) by setting the appropriate variable to "1", Dougs XMLsound gauge will set that variable back to "0" if the sound has completed playing. So just test for that.It's easier, and will even work OK if you decide to change the soundfiles (and duration) without the need to change the timer in the XML code.Cheers, Rob

Share this post


Link to post
Share on other sites

Hi Jan, Thanks for your help.This is jus what I was looking for.I will try your code and comment.Kind Regards.Dirk Trotteyn (SANT)

Share this post


Link to post
Share on other sites

Hi Jan, I tested your timer code. Needed change the position of '(P:Absolute Time,seconds) 5 + (>L:timer,number)', coz it was outside the (G:Var1).. 'do it once' control, and the L:timer was continued updated (in the first tag).--- (A:general eng2 propeller lever position,part) 0.04 + 0.75 > if{ (G:Var1) 0 == if{ (P:Absolute Time, seconds) 5 + (>L:timer,number) 1 (>G:Var1) 1 (>L:dsd_xml_sound_id_20,number) } } els{ 0 (>G:Var1) }------(A:general eng2 propeller lever position,part) 0.04 + 0.90 > if{ (G:Var2) 0 == (P:Absolute Time, seconds) (L:timer,number) > && if{ 1 (>G:Var2) 2 (>L:dsd_xml_sound_id_21,number) 0 (>L:dsd_xml_sound_id_20,number) } } els{ 0 (>G:Var2) }---This works OK! And do what I need to do in my gauge.Thanks again for your help and for your time.Kind Regards.Dirk Trotteyn (SANT)

Share this post


Link to post
Share on other sites

This topic appears to have been dead for a while but is exactly what I am trying to implement in my MFD.I am trying to build in the Built-In-Test function, which requires the MFD to scroll through 8 coloured screens at 1 sec intervals, then the last screen is shown for 2 seconds then returns to the original page.I am happy with setting up variables etc for it, but I am wondering if anyone can offer any light on an easy way to cycle through the images. I am NOT sure of how to use Update cycles yet - I am getting there slowly though.Thanks in advance guys.taipan

Share this post


Link to post
Share on other sites

Hi,You could experiment with:(G:Var1) 0 == if{ (P:Absolute time,seconds) 2 + (>G:Var2) 1 (>G:Var1) } (G:Var1) 1 == (P:Absolute time,seconds) (G:Var2) > and if{ (P:Absolute time,seconds) 2 + (>G:Var2) 2 (>G:Var1) } (G:Var1) 2 == (P:Absolute time,seconds) (G:Var2) > and if{ (P:Absolute time,seconds) 2 + (>G:Var2) 3 (>G:Var1) } (G:Var1) 3 == (P:Absolute time,seconds) (G:Var2) > and if{ (P:Absolute time,seconds) 2 + (>G:Var2) 4 (>G:Var1) } (G:Var1) 4 == (P:Absolute time,seconds) (G:Var2) > and if{ 5 (>G:Var1) } etc. etc.(G:Var1)etc. etc.Jan"Beatus ille qui procul negotiis..."

Share this post


Link to post
Share on other sites

Thanks Jan,I'll give it a go and get back to you with the results.Cheers.taipan

Share this post


Link to post
Share on other sites

Jan, no joy mate.If I tried to use an block here, would it simply be a case of removing the and and replacing with ?? Can I set a speed using Frequency=" " ??Cheers for your time.

Share this post


Link to post
Share on other sites

You could try:(G:Var1) 0 == if{ (P:Absolute time,seconds) 2 + (>G:Var2) 1 (>G:Var1) } (G:Var1) 1 == (P:Absolute time,seconds) (G:Var2) > and if{ (P:Absolute time,seconds) 2 + (>G:Var2) 2 (>G:Var1) } (G:Var1) 2 == (P:Absolute time,seconds) (G:Var2) > and if{ (P:Absolute time,seconds) 2 + (>G:Var2) 3 (>G:Var1) } (G:Var1) 3 == (P:Absolute time,seconds) (G:Var2) > and if{ (P:Absolute time,seconds) 2 + (>G:Var2) 4 (>G:Var1) } etc. etc.somewhere back to 0!(G:Var1)etc. etc.Jan"Beatus ille qui procul negotiis..."

Share this post


Link to post
Share on other sites

Hi Jan,This works, but only displays the first image. I can't be sure, but I don't think the gauge is even acknowledging the block, and it is just going straight to the block for (G:Var8) = 0.Here is my code. The first is the overarching page in the MFD, the next one is the MFD background for the Built In Test page, and the next Element, which we are dealing with, it for the MFD test function, which is activated using the L varb (L:Lbit_MFD, bool) being 1.Any thoughts? I am probably doing something obviously wrong!(L:Lpage_select, enum) 1100 >= (L:Lpage_select, enum) 1199 <= &&(L:Lbit_MFD, bool) 0 ==(L:Lbit_MFD, bool) 1 ==(G:Var8) 0 == if{ (P:Absolute time, seconds) 2 + (>G:Var9) 1 (>G:Var8) } (G:Var8) 1 == (P:Absolute time, seconds) (G:Var9) > && if{ (P:Absolute time, seconds) 2 + (>G:Var9) 2 (>G:Var8) } (G:Var8) 2 == (P:Absolute time, seconds) (G:Var9) > && if{ (P:Absolute time, seconds) 2 + (>G:Var9) 3 (>G:Var8) } (G:Var8) 3 == (P:Absolute time, seconds) (G:Var9) > && if{ (P:Absolute time, seconds) 2 + (>G:Var9) 4 (>G:Var8) } (G:Var8) 4 == (P:Absolute time, seconds) (G:Var9) > && if{ (P:Absolute time, seconds) 2 + (>G:Var9) 5 (>G:Var8) } (G:Var8) 5 == (P:Absolute time, seconds) (G:Var9) > && if{ (P:Absolute time, seconds) 2 + (>G:Var9) 6 (>G:Var8) } (G:Var8) 6 == (P:Absolute time, seconds) (G:Var9) > && if{ (P:Absolute time, seconds) 2 + (>G:Var9) 7 (>G:Var8) } (G:Var8) 7 == (P:Absolute time, seconds) (G:Var9) > && if{ (P:Absolute time, seconds) 2 + (>G:Var9) 0 (>G:Var8) 0 (>L:Lbit_MFD, bool) } (G:Var8)and so on up to Case Value = 7..Any thoughts?

Share this post


Link to post
Share on other sites

Hi,Put the update section at the top of the gauge, not in an element.(Didn't check the code)So:(G:Var8) 0 == if{ (P:Absolute time, seconds) 2 + (>G:Var9) 1 (>G:Var8) } (G:Var8) 1 == (P:Absolute time, seconds) (G:Var9) >&& if{ (P:Absolute time, seconds) 2 + (>G:Var9) 2 (>G:Var8) } (G:Var8) 2 == (P:Absolute time, seconds) (G:Var9) >&& if{ (P:Absolute time, seconds) 2 + (>G:Var9) 3 (>G:Var8) } (G:Var8) 3 == (P:Absolute time, seconds) (G:Var9) >&& if{ (P:Absolute time, seconds) 2 + (>G:Var9) 4 (>G:Var8) } (G:Var8) 4 == (P:Absolute time, seconds) (G:Var9) >&& if{ (P:Absolute time, seconds) 2 + (>G:Var9) 5 (>G:Var8) } (G:Var8) 5 == (P:Absolute time, seconds) (G:Var9) >&& if{ (P:Absolute time, seconds) 2 + (>G:Var9) 6 (>G:Var8) } (G:Var8) 6 == (P:Absolute time, seconds) (G:Var9) >&& if{ (P:Absolute time, seconds) 2 + (>G:Var9) 7 (>G:Var8) } (G:Var8) 7 == (P:Absolute time, seconds) (G:Var9) >&& if{ (P:Absolute time, seconds) 2 + (>G:Var9) 0 (>G:Var8) 0(>L:Lbit_MFD, bool) } Codeetc.Jan"Beatus ille qui procul negotiis..."

Share this post


Link to post
Share on other sites

Hey Jan, it worked!Sorry, I should have told you the layout before hand. I probably also could have solved that myself looking at the DTD couldn't I.Thanks again mate, I am really indebted to you.taipan_daz.

Share this post


Link to post
Share on other sites

XML Gods...Guys I want to use this sort of loop to install a "reversion" - if a button is pressed but after two seconds there has been no entry made, the system reverts to its previous state.Is there a key trap I can use? Maybe something like an 'if no event then' type loop?Cheers.

Share this post


Link to post
Share on other sites

Hi,If what you want is to detect if a key is pressed like when entering data on the GPS, or a specific is executed,it would be simple. Now, if the reversion must be canceled upon ANY event or keypress is done, it would be a tough work :-)Tom

Share this post


Link to post
Share on other sites

Hi Tom,I feared as much. Situation is this: In my PFD page on my MFD, five of the buttons allow input (CRS, ADF, bearing 1 and 2, heading bug, etc). If one of these buttons is pressed a submenu appears. If, however, after two seconds, nothing is entered, the submenu disappears and the original page is restored.I know this would be tough work - the company I'm building this for may just have to settle for my work around of click once to change, click again to cancel.Cheers.

Share this post


Link to post
Share on other sites

If you are checking for character typing, this could be an approach (pseudocode)In Mouse section :Button1 --> CRSClick= 1(>LSbMenuActive) (PAbsoluteTime) (>LTime)Button2 --> ADFClick= 1(>LSbMenuActive) (PAbsoluteTime) (>LTime)etcIn Update section: (LTime) 0 != if{ (LTime) 2 + (PAbsoluteTime) < if{ 0 (>LSbMenuActive) 0 (>LTime) } }In Element section (SubMenu):Visible = (LSbMenuActive)In Keys section:On Key (alphanumeric, etc)Process the key (PAbsoluteTime) (>LTime)Tom

Share this post


Link to post
Share on other sites

Yeah, I guess that could work. Because I have a few buttons that do it I could turn the initial couple of lines into a Macro and call it on each click.... hmm, plan forming in head...Thanks Tom, I'll let you know.Daz.

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