Sign in to follow this  
martinlest2

XML Gauge help please. Default gauge positions?

Recommended Posts

Hi.. I am still trying to work out what defines the default gauge state when a panel opens.

For instance, with a simple seat belt switch... This code will open with the sign off:

<Gauge Name="Seat Belts" Version="1.0">
<Element>
<Visible>(A:Circuit general panel on, bool)</Visible>
<Select>
<Value>(L:Seat_belts,bool)</Value>
<Case Value="1">
<Image Name="push_on.bmp" ImageSizes="31,31" Bright="Yes"/>
</Case>
</Select>
</Element>
<Element>
<Select>
<Value>(A:G force,G force) 0.8 < (A:G force,G force) 1.2 > or (A:Turn coordinator ball,part) abs 0.2 > or (A:Sim On Ground,bool) (A:Ground Velocity,meter/second) 0.5 > and or if{ 0 (>L:Seat_belts,bool) }</Value>
</Select>
</Element>
<Mouse>
<Tooltip>Seat Belts</Tooltip>
<Cursor Type="Hand"/>
<Click>(L:Seat_belts,bool) ! (>L:Seat_belts,bool) 1 (>L:Switch_Sound,bool)</Click>
</Mouse>
</Gauge>

whereas, in line 13, changing the 0 to a 1 will load the panel with the sign on:
 

<Value>(A:G force,G force) 0.8 < (A:G force,G force) 1.2 > or (A:Turn coordinator ball,part) abs 0.2 > or (A:Sim On Ground,bool) (A:Ground Velocity,meter/second) 0.5 > and or if{ 1 (>L:Seat_belts,bool) }</Value>

But with many gauges I am struggling to find what is defining the state of the gauge at startup. I'd be really grateful for some pointers.

A few examples (all from Edgar Guinart Lopez's fine Sukhoi SSJ-100, taken at random)...

First, the batteries. They have two xml files, as below. Where is the coding that has the batteries on, so powering the aircraft, at startup? How can that be changed so that the batteries are off at startup?
 

<Gauge Name="Battery" Version="1.0">
<Image Name="cover_back.bmp" ImageSizes="46,50"/>
<Element>
<Visible>(A:Circuit general panel on, bool)</Visible>
<Element>
<Position X="8" Y="10"/>
<Select>
<Value>(L:Battery_On,bool)</Value>
<Case Value="0">
<Image Name="fault-off.bmp" ImageSizes="31,31" Bright="Yes"/>
</Case>
</Select>
</Element>
<Element>
<Visible>(L:Battery_Charge,enum) 1700 <</Visible>
<Position X="8" Y="10"/>
<Image Name="box_fault.bmp" ImageSizes="31,31" Bright="Yes"/>
</Element>
</Element>
<Element>
<Select>
<Value>(G:Var1)</Value>
<Case Value="0">
<Image Name="GrayCover_Close.bmp" ImageSizes="46,50"/>
</Case>
<Case Value="1">
<Image Name="GrayCover_Open.bmp" ImageSizes="46,50"/>
</Case>
</Select>
</Element>
<Mouse>
<Tooltip>All Battery Switchs</Tooltip>
<Cursor Type="Hand"/>
<Click Kind="LeftSingle+RightSingle">(M:Event) 'RightSingle' scmp 0 == if{ (G:Var1) ! (>G:Var1) } (M:Event) 'LeftSingle' scmp 0 == (G:Var1) and if{ (L:Battery_On,bool) ! (>L:Battery_On,bool) 1 (>L:Switch_Sound,bool) }</Click>
</Mouse>
</Gauge>
<Gauge Name="Battery Display" Version="1.0">
<Image Name="black.bmp" ImageSizes="50,50"/>
<Element>
<Select>
<Value>(L:PanelLoader2,bool) ! if{ 1 (>L:PanelLoader2,bool) }</Value>
</Select>
</Element>
<Element>
<Visible>(A:Circuit general panel on, bool) (L:Battery_Test,enum) 0 != and</Visible>
<Position X="8" Y="8"/>
<Text Bright="Yes" X="28" Y="12" Length="4" Fixed="Yes" Font="Quartz" Color="#FF9030" Adjust="Center" VerticalAdjust="Center" Multiline="No">
<String>%((L:Battery_Test,enum) 1 ==)%{if}%((L:Battery_Charge,enum) 100 / 0.3 + )%!2.1f!%{end}%((L:Battery_Test,enum) 2 ==)%{if}%((L:Battery_Charge,enum) 100 / 0.1 + )%!2.1f!%{end}%((L:Battery_Test,enum) 3 ==)%{if}%((L:Battery_Charge,enum) 100 / 0.2 + )%!2.1f!%{end}%((L:Battery_Test,enum) 4 ==)%{if}%((L:Battery_Charge,enum) 100 / 0.4 + )%!2.1f!%{end}</String>
</Text>
</Element>
</Gauge>

And a second example, which I find even more bemusing, a windscreen wiper speed switch. How is the switch defined to be in "Item Value="0"" at startup, with the switch at 'off' rather than in any other of the four positions?
 

<Gauge Name="Left Wiper Speed" Version="1.0">
<Element>
<Position X="19" Y="19"/>
<Image Name="Selector1.bmp" ImageSizes="38,38">
<Axis X="19" Y="19" PointsTo="North"/>
</Image>
<Rotate>
<Value>(L:WiperSpeed01,enum)</Value>
<Nonlinearity>
<Item Value="0" Degrees="-90"/>
<Item Value="1" Degrees="-45"/>
<Item Value="2" Degrees="0"/>
<Item Value="3" Degrees="45"/>
</Nonlinearity>
<Delay DegreesPerSecond="360"/>
</Rotate>
</Element>
<Element>
<Select>
<Value>(A:Circuit general panel on, bool) if{ (L:WiperSpeed01,enum) 0 > if{ (L:L_WindClean,percent) 0 == if{ (L:WiperSpeed01,enum) 2 * (>L:LWRef,enum) } (L:L_WindClean,percent) 100 == if{ (L:WiperSpeed01,enum) -2 * (>L:LWRef,enum) } (L:L_WindClean,percent) (L:LWRef,enum) + 0 max 100 min (>L:L_WindClean,percent) } els{ (L:L_WindClean,percent) (L:LWRef,enum) abs - 0 max (>L:L_WindClean,percent) } }</Value>
</Select>
</Element>
<Mouse>
<Tooltip>Wiper Speed</Tooltip>
<Area Left="19">
<Cursor Type="UpArrow"/>
<Click>(L:WiperSpeed01,enum) ++ 3 min (>L:WiperSpeed01,enum) 1 (>L:Switch_Sound,bool)</Click>
</Area>
<Area Right="19">
<Cursor Type="DownArrow"/>
<Click>(L:WiperSpeed01,enum) -- 0 max (>L:WiperSpeed01,enum) 1 (>L:Switch_Sound,bool)</Click>
</Area>
</Mouse>
</Gauge>

Similarly/finally, how is it that the wing anti-ice switch is in the Item Value="1" position by default. How, for example, could I set it to item Value="0" (i.e. 'off') when the panel loads:
 

<Gauge Name="A-ice Wing" Version="1.0">
<Element>
<Position X="19" Y="19"/>
<Image Name="Selector1.bmp" ImageSizes="38,38">
<Axis X="19" Y="19" PointsTo="North"/>
</Image>
<Rotate>
<Value>(L:A-ice_Wing,enum)</Value>
<Nonlinearity>
<Item Value="0" Degrees="-45"/>
<Item Value="1" Degrees="0"/>
<Item Value="2" Degrees="45"/>
</Nonlinearity>
<Delay DegreesPerSecond="360"/>
</Rotate>
</Element>
<Element>
<Select>
<Value>(L:A-ice_Wing,enum) 0 != if{ (A:STRUCTURAL DEICE SWITCH,bool) ! if{ (>K:TOGGLE_STRUCTURAL_DEICE) } (A:Pitot Heat,bool) ! if{ (>K:PITOT_HEAT_TOGGLE) } } els{ (A:STRUCTURAL DEICE SWITCH,bool) if{ (>K:TOGGLE_STRUCTURAL_DEICE) } (A:Pitot Heat,bool) if{ (>K:PITOT_HEAT_TOGGLE) } }</Value>
</Select>
</Element>
<Mouse>
<Tooltip>A-ice Wing</Tooltip>
<Area Left="19">
<Cursor Type="UpArrow"/>
<Click>(L:A-ice_Wing,enum) ++ 2 min (>L:A-ice_Wing,enum) 1 (>L:Switch_Sound,bool)</Click>
</Area>
<Area Right="19">
<Cursor Type="DownArrow"/>
<Click>(L:A-ice_Wing,enum) -- 0 max (>L:A-ice_Wing,enum) 1 (>L:Switch_Sound,bool)</Click>
</Area>
</Mouse>
</Gauge>

Many thanks for any explanations that anyone can offer!!

Martin

Share this post


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

For the Sukhoi, look in OtherPrograms.xml, there's a "Vars init" element.

<Element Name="Vars init">
      <Select>
         <Value>(L:Battery_Charge,enum) 0 == if{ 2800 (>L:Battery_Charge,enum) } (L:VarsLoader,bool) 0 == if{ (A:General eng1 generator switch,bool) if{ (>K:TOGGLE_ALTERNATOR1) } (A:General eng2 generator switch,bool) if{ (>K:TOGGLE_ALTERNATOR2) } 1 (>L:Hyd1,enum) 1 (>L:Hyd2A,enum) 1 (>L:Hyd2B,enum) 1 (>L:Hyd3,enum) 1 (>L:A-ice_Wing,enum) 1 (>L:A-ice_Eng1,enum) 1 (>L:A-ice_Eng2,enum) 1 (>L:Air_Source1,bool) 1 (>L:Air_Source2,bool) 1 (>L:APU_Bleed,bool) 1 (>L:Battery_On,bool) 1 (>L:AutoBrakeSet,enum) 1 (>L:VarsLoader,bool) } (L:PanelLoader2,bool) ! if{ (>K:PANEL_2) } (L:PanelLoader3,bool) ! if{ (>K:PANEL_3) } (L:PanelLoader4,bool) ! if{ (>K:PANEL_4) }</Value>
      </Select>
   </Element>

Share this post


Link to post
Share on other sites

OMG, so there is!!! That explains why I can't get anything to work by editing code. I haven't had a look at that xml in any detail yet, but I am going to do that right now.

 

(Maybe I picked a bad example to test my 'skills' on with this panel! More complex than I thought).

 

Thanks.

Share this post


Link to post
Share on other sites

Generally speaking, L variables can be assumed to be zero, unless changed by some xml gauge.

 

Good programming practice would assign specific values to each L var in a startup routine.

Share this post


Link to post
Share on other sites

Yes, indeed...

 

To be honest I am not really all that advanced in this (which will have been obvious!!) but I am experimenting, with help of xml gauge tutorials online, with changing certain appearances of >L:  to  L:    - I am not sure I understand 100% what that is doing yet, other than having the desired result in the panel!

 

Still got to test that gauges work as before.. but all seems to be OK on the first few runs.

 

Bit of a learning curve here! Thanks again for pointing out this extra xml file!

Share this post


Link to post
Share on other sites

Now you are mucking with code...  

 

>L  is the same as >L  which means assigning a value to this L var.

 

You should not remove the >  and leave the rest behind    Shame%20On%20You.gif

Share this post


Link to post
Share on other sites

Well, in theory, maybe not. But in practice, the panel now works perfectly with the gauges off at startup and functioning exactly as they should when you switch them on. I have a backup of the original of course, but I am not sure why one "should not" do this when  the result in the sim speaks for itself. As long as the panel works perfectly, I shan't be reverting to the original coding :smile:

Share this post


Link to post
Share on other sites

If it works for you, do not fix it!

 

Removing random bits of code may work, or leave a defective gauge behind..  :wink:

 

You got lucky!

Share this post


Link to post
Share on other sites

 

 


changing certain appearances of >L: to L:

(L:Var,) reads the variable value so the gauge can use that value, (>L:Var) sets the variable value.

 

They are not interchangeable.

 

regards,

Joe

Share this post


Link to post
Share on other sites

All L:vars are initialized to zero (0) by default.

 

To assign a value to an L:variable, one must use this exact format:

 
12 (>L:MyVariable,enum)  
(* sets the value of (L:MyVariable,enum) to 12 (twelve) *)

(L:MyVariable,enum) (>L:MyNewVariable,enum) 
(* sets the value of (L:MyNewVariable,enum) to whatever is currently in (L:MyVariable,enum) which is now 12... *)
 
0 (>L:MyVariable,enum) 
(* sets the value of (L:MyVariable,enum) to 0 
(zero) *)

Share this post


Link to post
Share on other sites

I can't pretend, at my low level, to understand all the theory. As I say though, whatever the theory, changing the coding as I did has 'unlocked' the gauges and they can now be operated normally (that's to say, like the gauges in 99% of the freeware/payware aircraft I fly). And I can start a flight cold and dark if I want (as, sometimes, I do) without switches like APU Bleed or fuel pumps always being 'on' at startup (not very realistic, surely?).

 

Thanks again for the input. I need to do a proper xml programming course: I spend way more time these days on this sort of stuff (I don't just mean xml gauges of course!) than actually flying.

Share this post


Link to post
Share on other sites

As I say though, whatever the theory

 

 

It is not theory, is a fact.

If you remove the assignment char(s) -either > or > , what you are doing is obtaining the opposite of what the original author wanted in his gauge(s).

 

 

 

And I can start a flight cold and dark if I want (as, sometimes, I do) without switches like APU Bleed or fuel pumps always being 'on' at startup (not very realistic, surely?).

 

 

That was what the original author programmed (switches being ON at startup). If you prefer them OFF, it's ok to remove those characters. I hope you now understand the basics on how it works.

 

Tom

Share this post


Link to post
Share on other sites

I didn't mean 'theory' literally! :smile:  I just meant as opposed to what happens in the panel.

 

Yes, I understand better now and hopefully will know what to do in the future. Not sure I could make anything but a basic gauge from scratch yet though.... (I also have a copy of FS Panel Studio but haven't got to the bottom of how that works either. So little time...)

 

M.

Share this post


Link to post
Share on other sites

FS Panel Studio is the "cat's meow" as far as setting up panels and virtual cockpit gauge assignments is concerned.

It's fairly useless as an "XML gauge development tool" though, despite the author's well intentioned efforts. :Nerd:

Share this post


Link to post
Share on other sites

Not sure why I got it now. Probably in one of those moments of enthusiasm where I was set on becoming a panel 'guru'. Never quite happened somehow!  :hi: 

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