• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FSX Gauge Default Settings

Paul Domingue

Resource contributor
Messages
1,532
Country
us-california
Is it possible to set the default startup of a gauge on aircraft load so it will reflect what the visual portion of the gauge is showing? I have two 3d gauges with custom code that while working properly default to uncoded settings on aircraft load. The gauges in question are the magneto switch and the fuel valve and both have 75 frames and 4 positions.
Examples;
Fuel valve frame 0 is set to tank 7
frame 25 tank 6
frame 50 tank 8
frame 75 tank 0
On aircraft load the gauge is pointing to 0, tank 7 but the sim is using tank 1 (All). I have to cycle the valve once for it to work correctly.

Similarly the magneto switch starts frame 0 = BOTH then LEFT, RIGHT and OFF. If I save a flight with the mag switch turned off, then on saved flight load the switch will be in the BOTH position but retain the OFF setting from the saved flight. It also needs cycling to return to its proper function.

What's the work around? How do I tell the sim what the correct setting is for these gauges on load and what frame they should start with?

Code:
 	<PartInfo>
		<Name>j2f-5_switch_mag</Name>
		<!-- CCW - BOTH - LEFT - RIGHT - OFF -->
		<AnimLength>75</AnimLength>
		<Animation>
			<Parameter>
				<Code>
					(L:SelectMagneto, enum)
				</Code>
			<Lag>100</Lag>
			</Parameter>
		</Animation>
		<MouseRect>
			<Cursor>Hand</Cursor>
			<TooltipText>Magneto Switch</TooltipText>
			<MouseFlags>LeftSingle+RightSingle+WheelUp+WheelDown</MouseFlags>
			<CallbackCode>
				(M:Event) 'RightSingle' scmp 0 ==
				(M:Event) 'WheelDown' scmp 0 == or
				if{ (L:SelectMagneto, enum) 25 + (>L:SelectMagneto, enum) }
				(M:Event) 'LeftSingle' scmp 0 ==
				(M:Event) 'WheelUp' scmp 0 == or
				if{ (L:SelectMagneto, enum) 25 - (>L:SelectMagneto, enum) }

				(L:SelectMagneto, enum) 75 &gt; if{ 75 (>L:SelectMagneto, enum) }
				(L:SelectMagneto, enum) 0 &lt; if{ 0 (>L:SelectMagneto, enum) }

				(L:SelectMagneto,enum) 0 == if{ (>K:MAGNETO1_BOTH) }
				(L:SelectMagneto,enum) 25 == if{ (>K:MAGNETO1_OFF) and (>K:MAGNETO1_LEFT) }
				(L:SelectMagneto,enum) 50 == if{ (>K:MAGNETO1_OFF) and (>K:MAGNETO1_RIGHT) }
				(L:SelectMagneto,enum) 75 == if{ (>K:MAGNETO1_OFF) }
			</CallbackCode>
		</MouseRect>
	</PartInfo>
 
Paul,

I am not real sure if gauges can communicate with parts - or - if you can put this type of code into the part <Animation><Parameter><Code> section. Either make a blank "ini" gauge that gets loaded via panel.cfg into the VC or put it right into the part animation code. EX.

Code:
(L:Magneto_Initialization, bool) 0 == if{ 

(A:RECIP ENG LEFT MAGNETO:1, bool) (A:RECIP ENG RIGHT MAGNETO:1, bool) and if{ 0 (>L:SelectMagneto, enum) }

(A:RECIP ENG LEFT MAGNETO:1, bool) (A:RECIP ENG RIGHT MAGNETO:1, bool) ! and if{ 25 (>L:SelectMagneto, enum) } 

(A:RECIP ENG LEFT MAGNETO:1, bool) ! (A:RECIP ENG RIGHT MAGNETO:1, bool) and if{ 50 (>L:SelectMagneto, enum) }

(A:RECIP ENG LEFT MAGNETO:1, bool) ! (A:RECIP ENG RIGHT MAGNETO:1, bool) ! and if{ 75 (>L:SelectMagneto, enum) } 

1 (>L:Magneto_Initialization, bool) 

}

Or, just use the following in the <Parameter><Code> section and let the part read directly from FS versus the L:Var.

Code:
(A:RECIP ENG LEFT MAGNETO:1, bool) (A:RECIP ENG RIGHT MAGNETO:1, bool) and if{ 0 }

(A:RECIP ENG LEFT MAGNETO:1, bool) (A:RECIP ENG RIGHT MAGNETO:1, bool) ! and if{ 25 } 

(A:RECIP ENG LEFT MAGNETO:1, bool) ! (A:RECIP ENG RIGHT MAGNETO:1, bool) and if{ 50 }

(A:RECIP ENG LEFT MAGNETO:1, bool) ! (A:RECIP ENG RIGHT MAGNETO:1, bool) ! and if{ 75 }

None of this has been tested, nor have I have ever dealt with the modeldef.xml.

Roman
 
This has been explained in detail in previous threads, but for 3d models the simplest method is to create a single, hidden polygon (just a simple triangle will do) to which you can attach a <Visibility> XML script.

Here is the start of my very lengthy* B737 XML Logic script showing the pattern. You can simply stuff Roman's suggestions in the <Code> section:
Code:
  <!-- MILVIZ B737 XML Code -->
  <PartInfo>
    <Name>B737_Logic</Name>
    <Visibility>
      <Parameter>
        <Code>
          (L:B737_Init,bool) !
          if{
          1 (>L:PowerAvailableNow,bool)
          1 (>L:B737_Init,bool)
          }
          <!-- INSERT ANY FURTHER STUFF HERE -->
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>
*BTW, I'm not kidding here. The entire script is ~2,500 lines!
 
Last edited:
That's why I love you guys, you give me just enough information to ensure that I still have to flex that muscle between my ears. ;)

BTW, I'm at 550 lines of code and counting on my J2F.
 
The gauge code (C++) I did for the Eaglesoft Citation X had over 130,000 lines of code.
 
The gauge code (C++) I did for the Eaglesoft Citation X had over 130,000 lines of code.

The average book novel has between 15,000 and 20,000 lines of text and a few spelling or punctuation errors have no effect on it so I consider what you have done quite a feat. I've played with C++ in the past but I'll stick with XML.
 
@ n4gix and WarpD

Purely as a matter of interest, do you have any estimate of how many man hours were required to plan, develop, and debug such amounts of code?.
 
Gerry, in the case of XML scripting (I refuse to give undue dignity to it by calling it 'code') much of it consists of copy/paste/edit, so it's rather difficult to apply any meaningful metric such as you've asked for.

Also, unlike C or C++, XML scripting is not really amenable to elegant structures, making flowcharting an exercise in futility... ;)

It's a pity that MS/ACES didn't choose Lua for the model's internal control, but instead insisted on using such a clumsy method like XML script.
 
Thanks for the help and this powerful bit of knowledge. I was not aware that I could pass variables to/from <PartInfo> sections. With your outline Bill and Roman's logic I ended with this and it does the trick. I'm doing the same for my tank selector valve which has a similar problem.

Code:
	<PartInfo>
		<Name>j2f-5_init_mag</Name>
		<Visibility>
			<Parameter>
				<Code>
				(A:RECIP ENG LEFT MAGNETO:1, bool) (A:RECIP ENG RIGHT MAGNETO:1, bool) and if{ 0 (>L:SelectMagneto, enum) }
				(A:RECIP ENG LEFT MAGNETO:1, bool) (A:RECIP ENG RIGHT MAGNETO:1, bool) ! and if{ 25 (>L:SelectMagneto, enum) } 
				(A:RECIP ENG LEFT MAGNETO:1, bool) ! (A:RECIP ENG RIGHT MAGNETO:1, bool) and if{ 50 (>L:SelectMagneto, enum) }
				(A:RECIP ENG LEFT MAGNETO:1, bool) ! (A:RECIP ENG RIGHT MAGNETO:1, bool) ! and if{ 75 (>L:SelectMagneto, enum) }
				</Code>
			</Parameter>
		</Visibility>
	</PartInfo>

	<PartInfo>
		<Name>j2f-5_switch_mag</Name>
		<!-- CCW - BOTH - LEFT - RIGHT - OFF -->
		<AnimLength>75</AnimLength>
		<Animation>
			<Parameter>
				<Code>
				(L:SelectMagneto, enum)
				</Code>
			<Lag>500</Lag>
			</Parameter>
		</Animation>
		<MouseRect>
			<Cursor>Hand</Cursor>
			<TooltipText>Magneto Switch</TooltipText>
			<MouseFlags>LeftSingle+RightSingle+WheelUp+WheelDown</MouseFlags>
			<CallbackCode>
				(M:Event) 'RightSingle' scmp 0 ==
				(M:Event) 'WheelDown' scmp 0 == or
				if{ (L:SelectMagneto, enum) 25 + (>L:SelectMagneto, enum) }
				(M:Event) 'LeftSingle' scmp 0 ==
				(M:Event) 'WheelUp' scmp 0 == or
				if{ (L:SelectMagneto, enum) 25 - (>L:SelectMagneto, enum) }

				(L:SelectMagneto, enum) 75 &gt; if{ 75 (>L:SelectMagneto, enum) }
				(L:SelectMagneto, enum) 0 &lt; if{ 0 (>L:SelectMagneto, enum) }

				(L:SelectMagneto,enum) 0 == if{ (>K:MAGNETO1_BOTH) }
				(L:SelectMagneto,enum) 25 == if{ (>K:MAGNETO1_OFF) and (>K:MAGNETO1_LEFT) }
				(L:SelectMagneto,enum) 50 == if{ (>K:MAGNETO1_OFF) and (>K:MAGNETO1_RIGHT) }
				(L:SelectMagneto,enum) 75 == if{ (>K:MAGNETO1_OFF) }
			</CallbackCode>
		</MouseRect>
	</PartInfo>

Thanks again,

Paul
 
Thanks for the help and this powerful bit of knowledge. I was not aware that I could pass variables to/from <PartInfo> sections.
Paul, it took me quite awhile to discover this technique myself. I got to thinking late one night whilst trying to get to sleep and the idea sort of "popped" into my head.

The next morning I tested out my idea and found out that it works...

It's actually quite logical when you consider that the "normal use" for a <Visibility> section is to detetermine when to show or hide something. Obviously then, everything contained within the scope of a <Visibility> section is going to be evaluated every gauge cycle, making it an ideal place to put XML scripts you want evaluated every gauge cycle!

If one is creating a virtual cockpit aircraft only, i.e., no 2d panel at all, then it is entirely possible to have all XML scripts embedded in the compiled model itself!
 
The average book novel has between 15,000 and 20,000 lines of text and a few spelling or punctuation errors have no effect on it so I consider what you have done quite a feat. I've played with C++ in the past but I'll stick with XML.
A ProLine 21 system I did was also over 100,000 lines of code.
@ n4gix and WarpD

Purely as a matter of interest, do you have any estimate of how many man hours were required to plan, develop, and debug such amounts of code?.

The Citation X took about two years, primarily because it had to be rewritten twice, from scratch. The ProLine 21 system... about a year.

The time is probably less, but that's close enough. ;)
 
If one is creating a virtual cockpit aircraft only, i.e., no 2d panel at all, then it is entirely possible to have all XML scripts embedded in the compiled model itself!

That is exactly what I have been doing with my J2F. I want everything including all the lights modeled and only a VC designed with TackIR in mind. I've been building a complete set of vintage instruments and had the ADF working on the ARC radio compass but could not get the NAV1/VOR to work until I ran across a your post "RMI Needles 3D" and after a little testing I got it working. I just need to animate and code the East-West VAR knob. I'm also trying to figure out how to get this really odd ball radio tuner to function.
You guys may have a lot of time in some of your coding but I have years in this model and I still can't see the light at the end of the tunnel. Oh well back to work.
 
The gauge code (C++) I did for the Eaglesoft Citation X had over 130,000 lines of code.

In development of something this big, is there a concern that the code might not be fully executed within one update cycle?

Bob
 
In development of something this big, is there a concern that the code might not be fully executed within one update cycle?

Bob

The short answer is no... but... to be honest... I think you're making a mistaken assumption that if one writes 10,000 lines of C++ code, well then all 10,000 lines of code get executed each update cycle... which, couldn't be further from the truth.
 
The short answer is no... but... to be honest... I think you're making a mistaken assumption that if one writes 10,000 lines of C++ code, well then all 10,000 lines of code get executed each update cycle... which, couldn't be further from the truth.

Nah, not making that assumption, just curious about code that big
 
Back
Top