Archived

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

Guest Adrian

Changing screens with gauges

Recommended Posts

Hello my fellow AVSIMMERS,I have been recently trying to make my in-flight data gauge change screens say every 10 seconds using the same bitmap image, with little success so far. For example "Screen 1" should be displayed for 10 seconds (with 3 Element - 3 GaugeText), "Screen 2" displayed for 10 seconds (with 3 Element - 3 GaugeText) and so on... I tried using a local variable (L:ChangeScreenTimer, seconds) and the same variable with type number. Furthermore I even experimented with (E:ABSOLUTE TIME, seconds), both of my methods have not been successful so far. Also I believe my <Update> section of code (given below) might have a bug when it comes to looping the screen number back to the start.Is it even possible to do this or can I "trick" the ACE tool to come up with this effect?Could somebody help me please?ThanksAdrian

   		 <?xml version="1.0" encoding="UTF-8"?>		 		 <SimBase.Document				 Type="AceXML"				 version="1,0"				 id="InFlightData">			 <Descr>AceXML Document</Descr>			 <Filename>InFlightData.xml</Filename>			 <SimGauge.Gauge id="Gauge" ArtDirectory="C:\Documents and Settings\ADRIAN\My Documents\New Gauges\InFlightEntertainment">				 <FloatPosition>0.000,0.000</FloatPosition>				 <Update_When_Hidden>True</Update_When_Hidden>				 <Image id="InFlightDataScreen.bmp" Name="InFlightDataScreen.bmp">					 <Transparent>True</Transparent>				 </Image>				 <Macro id="Call GPS Routines" Name="c">					 <MacroValue>C:fs9gps</MacroValue>				 </Macro>				 <Macro id="TotalDistanceRem Routine" Name="TotalDistRem">					 <MacroValue>(A:GPS IS ACTIVE FLIGHT PLAN,bool) if{ (A:GPS FLIGHT PLAN WP Count,number) 1 - (>@c:FlightPlanWaypointIndex) (@c:FlightPlanWaypointRemainingTotalDistance,kilometers) }</MacroValue>				 </Macro>				 <Macro id="EstArrivalTime Routine" Name="EstArrivalTime">					 <MacroValue>(A:GPS IS ACTIVE FLIGHT PLAN,bool) if{ (A:GPS FLIGHT PLAN WP Count,number) 1 - (>@c:FlightPlanWaypointIndex) (@c:FlightPlanWaypointETA,minutes) }</MacroValue>				 </Macro>				 <Macro id="TimeSinceDepart Routine" Name="TimeSinceDepart">					 <MacroValue>(A:GPS IS ACTIVE FLIGHT PLAN,bool) if{ (A:GPS FLIGHT PLAN WP Count,number) 1 - (>@c:FlightPlanWaypointIndex) (@c:FlightPlanWaypointATE,minutes) }</MacroValue>				 </Macro>				 <Element id="Display Ground speed">					 <FloatPosition>50.000,60.000</FloatPosition>					 <Visibility>(L:ScreenNumber, number) 0 ==</Visibility>					 <GaugeText id="Ground speed">						 <Bold>True</Bold>						 <Bright>True</Bright>						 <FontColor>0x00FFFF</FontColor>						 <FontFace>Helvetica</FontFace>						 <FontHeight>20</FontHeight>						 <GaugeString>Ground speed			 %((A:GROUND VELOCITY, kph))%!3d! km/h</GaugeString>						 <Length>25</Length>						 <LineSpacing>40.000</LineSpacing>						 <Luminous>True</Luminous>						 <Size>299,40</Size>						 <Transparent>True</Transparent>						 <VerticalAlign>CENTER</VerticalAlign>					 </GaugeText>				 </Element>				 <Element id="Display Altitude">					 <FloatPosition>50.000,140.000</FloatPosition>					 <Visibility>(L:ScreenNumber, number) 0 ==</Visibility>					 <GaugeText id="Altitude">						 <Bold>True</Bold>						 <Bright>True</Bright>						 <FontColor>0x00FFFF</FontColor>						 <FontFace>Helvetica</FontFace>						 <FontHeight>20</FontHeight>						 <GaugeString>Altitude						%((A:PLANE ALTITUDE, meters))%!5d! m</GaugeString>						 <Length>27</Length>						 <LineSpacing>40.000</LineSpacing>						 <Luminous>True</Luminous>						 <Size>299,40</Size>						 <Transparent>True</Transparent>						 <VerticalAlign>CENTER</VerticalAlign>					 </GaugeText>				 </Element>				 <Element id="Display Outside air temperature">					 <FloatPosition>50.000,220.000</FloatPosition>					 <Visibility>(L:ScreenNumber, number) 0 ==</Visibility>					 <GaugeText id="Outside air temperature">						 <Bold>True</Bold>						 <Bright>True</Bright>						 <FontColor>0x00FFFF</FontColor>						 <FontFace>Helvetica</FontFace>						 <FontHeight>20</FontHeight>						 <GaugeString>Outside air\ntemperature					%((A:AMBIENT TEMPERATURE, celsius))%!3d! \{dplo= } C</GaugeString>						 <Length>31</Length>						 <LineSpacing>35.000</LineSpacing>						 <Luminous>True</Luminous>						 <Multiline>True</Multiline>						 <Size>299,80</Size>						 <Transparent>True</Transparent>						 <VerticalAlign>CENTER</VerticalAlign>					 </GaugeText>				 </Element>				 <Element id="Display Distance to destination">					 <FloatPosition>50.000,60.000</FloatPosition>					 <Visibility>(L:ScreenNumber, number) 1 ==</Visibility>					 <GaugeText id="Distance to destination">						 <Bold>True</Bold>						 <Bright>True</Bright>						 <FontColor>0x00FFFF</FontColor>						 <FontFace>Helvetica</FontFace>						 <FontHeight>20</FontHeight>						 <GaugeString>Distance to\ndestination				  %(@TotalDistRem)%!5d! km</GaugeString>						 <Length>31</Length>						 <LineSpacing>35.000</LineSpacing>						 <Luminous>True</Luminous>						 <Multiline>True</Multiline>						 <Size>299,80</Size>						 <Transparent>True</Transparent>						 <VerticalAlign>CENTER</VerticalAlign>					 </GaugeText>				 </Element>				 <Element id="Display Estimated arrival time">					 <FloatPosition>50.000,140.000</FloatPosition>					 <Visibility>(L:ScreenNumber, number) 1 ==</Visibility>					 <GaugeText id="Estimated arrival time">						 <Bold>True</Bold>						 <Bright>True</Bright>						 <FontColor>0x00FFFF</FontColor>						 <FontFace>Helvetica</FontFace>						 <FontHeight>20</FontHeight>						 <GaugeString>Estimated\narrival time					%(@EstArrivalTime)%!5d! min</GaugeString>						 <Length>27</Length>						 <LineSpacing>40.000</LineSpacing>						 <Luminous>True</Luminous>						 <Multiline>True</Multiline>						 <Size>299,80</Size>						 <Transparent>True</Transparent>						 <VerticalAlign>CENTER</VerticalAlign>					 </GaugeText>				 </Element>				 <Element id="Display Time since departure">					 <FloatPosition>50.000,235.000</FloatPosition>					 <Visibility>(L:ScreenNumber, number) 1 ==</Visibility>					 <GaugeText id="Time since departure">						 <Bold>True</Bold>						 <Bright>True</Bright>						 <FontColor>0x00FFFF</FontColor>						 <FontFace>Helvetica</FontFace>						 <FontHeight>20</FontHeight>						 <GaugeString>Time since\ndeparture					%(@TimeSinceDepart)%!5d! min</GaugeString>						 <Length>27</Length>						 <LineSpacing>40.000</LineSpacing>						 <Luminous>True</Luminous>						 <Multiline>True</Multiline>						 <Size>299,80</Size>						 <Transparent>True</Transparent>						 <VerticalAlign>CENTER</VerticalAlign>					 </GaugeText>				 </Element>				 <Update id="Update">					 <script>(L:Initialisation , number) 0 == if{ 0 (>L:ScreenNumber , number) 1 (>L:ChangeScreenTimer , number) 1 (>L:Initialisation , number) } els{ (L:ChangeScreenTimer , number) 10 div (>L:ScreenNumber , number) } (L:ChangeScreenTimer) ++ </Script>				 </Update>			 </SimGauge.Gauge>		 </SimBase.Document>

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

Adrian, 1st to start, I'm not totally comfortable with the FSX XML format, nor do I like it compared to FS9 format. But anyway it works just the same. :( I did notice you only have 2 elements ( so far? ) to be switched... you only have <Element><Visible> values of 0 & 1. Following is a tip for "grouping / nesting" when multiple <Elements> are controlled equally. For coding wise and such... (FS9 style )

<Element Name = "VISIBLE SECTION WHEN ZERO" ><Visible>0</Visible>              <Element Name = "My 1st part visible when zero">                   some stuff in here             </Element>              <Element Name = "My 2nd part visible when zero">                   some stuff in here             </Element> </Element><Element Name = "VISIBLE SECTION WHEN ONE" ><Visible>1</Visible>              <Element Name = "My 1st part visible when one">                   some stuff in here             </Element>              <Element Name = "My 2nd part visible when one">                   some stuff in here             </Element> </Element>

Now for the switching part in "psuedo 9 /10 " XML code. Renamed vars for clarity. CAUTION!!! on some of my old code timing structures donot work no more as FS9 absolute time seems like it's DECREASING!! ( still working, testing, verifying this when I have time, so donot quote me on this ) This code "should" handle it both ways.

<Update id="Update"><script><!-- Initialize all vars on 1st read & set INI to 1, set timer, 1st screen is already set @ 0 -->(L:INI , number) 0 == if{ 1 (>L:INI , number) 10 (P:Absolute Time, Seconds) + (>L:Timer, Seconds) }<!-- Do stuff once intialized -->(L:INI , number) 1 == if{ <!-- Trigger stuff once timer is up -->(L:Timer, Seconds) (P:Absolute Time, Seconds) - abs 10 > if{ <!-- Reset trigger timing -->10 (P:Absolute Time, Seconds) + (>L:Timer, Seconds) <!-- Increment visible values ( USING 3 visibles here ( 0-2 ) -->(L:Screen, number) 2 == if{ 0  (>L:Screen, number) } els{(L:Screen, number) ++ (>L:Screen, number) }}}</Script></Update>

There is probably a more efficient way to do this & it has not been tested fully, basic code/struture has. Anyway...Hope this helps, Roman

Share this post


Link to post
Share on other sites

Thanks Roman for the very helpful solution, much appreciated.I tried another approach to my problem and put <select> and <case> statements for each <GaugeText> item I want to display. Will try your method and mine and I will see how it goes.CheersAdrian

Share this post


Link to post
Share on other sites

Hello everybody,I am still confused as to why my gauge is not changing screens via a timer.As you explained Roman that I should use nested <Element> structures with the appropriate <Visiibility> condition and the use of an <Update> script to control the timing of screens using (P:Absolute time, seconds). Furthermore you mentioned that "trigger stuff once timer is up", do I have to write code that points to my <Element>, <GaugeText> tags or just a comment that explained the proceeding statement of code.When I tried out your solution it still stays on "Screen 0" and does not proceed to the next screen let alone loop.The (P:Absolute time, seconds) variable stays at 0 or a negative number when used :( . I then proceeded to use (E:LOCAL TIME, seconds) as it did show when testing the time incrementing.Here below is the XML code for the project. Any bugs?I experimented with some code with the <Update> script using (E:LOCAL TIME) given below in infix notation.XML code:

<?xml version="1.0" encoding="UTF-16"?><SimBase.Document        Type="AceXML"        version="1,0"        id="InFlightData">    <Descr>AceXML Document</Descr>    <Filename>InFlightData.xml</Filename>    <SimGauge.Gauge id="Gauge" ArtDirectory="C:\Documents and Settings\ADRIAN\My Documents\New Gauges\InFlightEntertainment">        <FloatPosition>0.000,0.000</FloatPosition>        <Update_When_Hidden>True</Update_When_Hidden>        <Image id="InFlightDataScreen.bmp" Name="InFlightDataScreen.bmp">            <Transparent>True</Transparent>        </Image>        <Macro id="Call GPS Routines" Name="c">            <MacroValue>C:fs9gps</MacroValue>        </Macro>        <Macro id="TotalDistanceRem Routine" Name="TotalDistRem">            <MacroValue>(A:GPS IS ACTIVE FLIGHT PLAN,bool) if{ (A:GPS FLIGHT PLAN WP Count,number) 1 - (>@c:FlightPlanWaypointIndex) (@c:FlightPlanWaypointRemainingTotalDistance,kilometers) }</MacroValue>        </Macro>        <Macro id="EstArrivalTime Routine" Name="EstArrivalTime">            <MacroValue>(A:GPS IS ACTIVE FLIGHT PLAN,bool) if{ (A:GPS FLIGHT PLAN WP Count,number) 1 - (>@c:FlightPlanWaypointIndex) (@c:FlightPlanWaypointETA,minutes) }</MacroValue>        </Macro>        <Macro id="TimeSinceDepart Routine" Name="TimeSinceDepart">            <MacroValue>(A:GPS IS ACTIVE FLIGHT PLAN,bool) if{ (A:GPS FLIGHT PLAN WP Count,number) 1 - (>@c:FlightPlanWaypointIndex) (@c:FlightPlanWaypointATE,minutes) }</MacroValue>        </Macro>        <Update id="Update">            <script>(L:Init, number) 0 == if{ 0 (>L:ScreenNumber, number) (E:LOCAL TIME, seconds) (>L:Timer, seconds) (E:LOCAL TIME, seconds) 10 + (>L:Next, seconds) 1 (>L:Init, number) } els{ (L:Next, seconds) (L:Timer, seconds) (L:Next, seconds) == (L:ScreenNumber, number) 2 == && if{ 0 -- (>L:ScreenNumber, number) (E:LOCAL TIME, seconds) 10 + (>L:Next, seconds) } els{ (L:Timer, seconds) (L:Next, seconds) == if{ (L:ScreenNumber, seconds) (E:LOCAL TIME, seconds) 10 + ++ (>L:Next, seconds) } } } </Script>        </Update>        <Element id="Screen0">            <FloatPosition>0.000,0.000</FloatPosition>            <Visibility>(L:ScreenNumber, number) 0 ==</Visibility>            <Element id="Display Ground speed">                <FloatPosition>50.000,60.000</FloatPosition>                <GaugeText id="Ground speed">                    <Bold>True</Bold>                    <Bright>True</Bright>                    <FontColor>0x00FFFF</FontColor>                    <FontFace>Helvetica</FontFace>                    <FontHeight>20</FontHeight>                    <GaugeString>Ground speed             %((A:GROUND VELOCITY, kph))%!3d! km/h</GaugeString>                    <Length>25</Length>                    <LineSpacing>40.000</LineSpacing>                    <Luminous>True</Luminous>                    <Size>299,40</Size>                    <Transparent>True</Transparent>                    <VerticalAlign>CENTER</VerticalAlign>                </GaugeText>            </Element>            <Element id="Display Altitude">                <FloatPosition>50.000,140.000</FloatPosition>                <GaugeText id="Altitude">                    <Bold>True</Bold>                    <Bright>True</Bright>                    <FontColor>0x00FFFF</FontColor>                    <FontFace>Helvetica</FontFace>                    <FontHeight>20</FontHeight>                    <GaugeString>Altitude                        %((A:PLANE ALTITUDE, meters))%!5d! m</GaugeString>                    <Length>27</Length>                    <LineSpacing>40.000</LineSpacing>                    <Luminous>True</Luminous>                    <Size>299,40</Size>                    <Transparent>True</Transparent>                    <VerticalAlign>CENTER</VerticalAlign>                </GaugeText>            </Element>            <Element id="Display Outside air temperature">                <FloatPosition>50.000,220.000</FloatPosition>                <GaugeText id="Outside air temperature">                    <Bold>True</Bold>                    <Bright>True</Bright>                    <FontColor>0x00FFFF</FontColor>                    <FontFace>Helvetica</FontFace>                    <FontHeight>20</FontHeight>                    <GaugeString>Outside air\ntemperature                    %((A:AMBIENT TEMPERATURE, celsius))%!3d! \{dplo= }C</GaugeString>                    <Length>31</Length>                    <LineSpacing>35.000</LineSpacing>                    <Luminous>True</Luminous>                    <Multiline>True</Multiline>                    <Size>299,80</Size>                    <Transparent>True</Transparent>                    <VerticalAlign>CENTER</VerticalAlign>                </GaugeText>            </Element>        </Element>        <Element id="Screen1">            <FloatPosition>0.000,0.000</FloatPosition>            <Visibility>(L:ScreenNumber, number) 1 ==</Visibility>            <Element id="Display Distance to destination">                <FloatPosition>50.000,60.000</FloatPosition>                <GaugeText id="Distance to destination">                    <Bold>True</Bold>                    <Bright>True</Bright>                    <FontColor>0x00FFFF</FontColor>                    <FontFace>Helvetica</FontFace>                    <FontHeight>20</FontHeight>                    <GaugeString>Distance to\ndestination                  %(@TotalDistRem)%!5d! km</GaugeString>                    <Length>31</Length>                    <LineSpacing>35.000</LineSpacing>                    <Luminous>True</Luminous>                    <Multiline>True</Multiline>                    <Size>299,80</Size>                    <Transparent>True</Transparent>                    <VerticalAlign>CENTER</VerticalAlign>                </GaugeText>            </Element>            <Element id="Display Estimated arrival time">                <FloatPosition>50.000,140.000</FloatPosition>                <GaugeText id="Estimated arrival time">                    <Bold>True</Bold>                    <Bright>True</Bright>                    <FontColor>0x00FFFF</FontColor>                    <FontFace>Helvetica</FontFace>                    <FontHeight>20</FontHeight>                    <GaugeString>Estimated\narrival time                    %(@EstArrivalTime)%!5d! min</GaugeString>                    <Length>27</Length>                    <LineSpacing>40.000</LineSpacing>                    <Luminous>True</Luminous>                    <Multiline>True</Multiline>                    <Size>299,80</Size>                    <Transparent>True</Transparent>                    <VerticalAlign>CENTER</VerticalAlign>                </GaugeText>            </Element>            <Element id="Display Time since departure">                <FloatPosition>50.000,235.000</FloatPosition>                <GaugeText id="Time since departure">                    <Bold>True</Bold>                    <Bright>True</Bright>                    <FontColor>0x00FFFF</FontColor>                    <FontFace>Helvetica</FontFace>                    <FontHeight>20</FontHeight>                    <GaugeString>Time since\ndeparture                    %(@TimeSinceDepart)%!5d! min</GaugeString>                    <Length>27</Length>                    <LineSpacing>40.000</LineSpacing>                    <Luminous>True</Luminous>                    <Multiline>True</Multiline>                    <Size>299,80</Size>                    <Transparent>True</Transparent>                    <VerticalAlign>CENTER</VerticalAlign>                </GaugeText>            </Element>        </Element>    </SimGauge.Gauge></SimBase.Document>

and the infix code:

if ((L:Init, number) == 0) {    (L:ScreenNumber, number) = 0;    (L:Timer, seconds) = (E:LOCAL TIME, seconds);    (L:Next, seconds) = (E:LOCAL TIME, seconds) + 10;    (L:Init, number) = 1;} else {    (L:Next, seconds)--;    if (((L:Timer, seconds) == (L:Next, seconds)) && ((L:ScreenNumber, number) == 2)) {        (L:ScreenNumber, number) = 0;        (L:Next, seconds) = (E:LOCAL TIME, seconds) + 10;    } else {        if ((L:Timer, seconds) == (L:Next, seconds)) {            (L:ScreenNumber, seconds)++;            (L:Next, seconds) = (E:LOCAL TIME, seconds) + 10;        }    }}

Is the XML code a top down language? If not, does that mean I can place my tags in any order?Does the <Update> tag run at the same time as <Element>, @Macro etc. or before?Adrian

Share this post


Link to post
Share on other sites

Adrian,

Is the XML code a top down language? If not, does that mean I can place my tags in any order?Does the <Update> tag run at the same time as <Element>, @Macro etc. or before?
This is how i do it, in general it is top --> bottom.-For general coding style it's best to have Macros the very top but just below the background image (if there). Easier to find / track. -Have the update section next. You want to update all the data before you display/control something. The order you do the coding in update is very important in complex gauges.-Element sections next, display(s), switches etc...-Area/Mouse section at the end.In the update section code I did find a few bugs, including one of my own. ( Sorry :( ) I noticed these,- (L:ScreenNumber, number) (L:ScreenNumber, seconds) might work, probably not though, better just to keep value type the same.- It's not a good idea to have a timer to equal time to trigger something. 3.1234 seconds is not the same as 3.1235. Better to find the difference and trigger when larger than a value. ( That's where I bugged it :( )- Donot know what this is or what you were trying.......... && if{ 0 -- (>L:ScreenNumber, number) ..... or (L:ScreenNumber, seconds) (E:LOCAL TIME, seconds) 10 + ++ (>L:Next, seconds)Anyway keep plugging at it, it'll come to you. :( When things donot work after many tries sometimes I get further away from the intended code. Best just start from scratch again. B) Attached is a text file with both FS9 (tested fully) and FSX (not tested) code for the update section. Should be able to just copy and paste into your gauge. I kept the variable names the same as yours. Hope it helps.UPDATE - the forum wont upload it so it's here in the codebox..Watch spaces when copiing....
<!-- FS9 --><Update>(L:Init, number) 0 == if{ (E:LOCAL TIME, seconds) (>L:Timer, seconds) 1 (>L:Init, number) } (L:Init, number) 1 == if{ (L:Timer, Seconds) (E:LOCAL TIME, seconds) - abs 10 > if{ (L:ScreenNumber, number) 2 == if{ 0 (>L:ScreenNumber, number) (E:LOCAL TIME, seconds) (>L:Timer, seconds) } els{ (L:ScreenNumber, number) ++ (>L:ScreenNumber, number) (E:LOCAL TIME, seconds) (>L:Timer, seconds) } } }</Update>        <!-- FSX --><Update id="Update"><script>(L:Init, number) 0 == if{ (E:LOCAL TIME, seconds) (>L:Timer, seconds) 1 (>L:Init, number) } (L:Init, number) 1 == if{ (L:Timer, Seconds) (E:LOCAL TIME, seconds) - abs 10 > if{ (L:ScreenNumber, number) 2 == if{ 0 (>L:ScreenNumber, number) (E:LOCAL TIME, seconds) (>L:Timer, seconds) } els{ (L:ScreenNumber, number) ++ (>L:ScreenNumber, number) (E:LOCAL TIME, seconds) (>L:Timer, seconds) } } }</Script></Update>        

Roman

Share this post


Link to post
Share on other sites

Thanks again Roman for the tips and the words of encouragement :( . I probably a real pest to everybody with these posts. It's lucky that I have'nt gone nuts over this part of the project. I am hoping when I get this changing of screens going ok, then I can proceed into using a 2D map of the world to map the flight plan, which I think it would be cool. :( . When this project is hopefully done i will release it to download.Does anybody do any beta testing on gauges? I might scare people off because it took me ages to get to this stage :( .Adrian

Share this post


Link to post
Share on other sites

That was the functionality I needed to change screens thats a million. Now I can generalise the code to any number of screens.Now no more blisters on my brain :)Adrian

Share this post


Link to post
Share on other sites

Adrain, Glad it worked ! If you noticed though I forgot to change the timing back to 10 seconds :( Roman

Share this post


Link to post
Share on other sites

RomanIs this what you meant about the timing resetting back to 10 seconds, after (L:Init, number) == 1 always?10 (E:LOCAL TIME, seconds) + (>L:Timer, seconds)Adrian

Share this post


Link to post
Share on other sites

Adrian, No I had posted my test code where i reduced the timing to 3 seconds before a switch..... (L:Timer, Seconds) (E:LOCAL TIME, seconds) - abs 3 > ....I edited the post to put it back to 10.... (L:Timer, Seconds) (E:LOCAL TIME, seconds) - abs 10 > .... Hope I didn't confuse you.Roman

Share this post


Link to post
Share on other sites