• 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.

Using a variable for <Maximum> [SOLVED]

Messages
67
Country
unitedstates
In one of my gauges, I'd like to use this code:
Code:
<Rotation id="Rotation">
  <PointsTo>SOUTH</PointsTo>
  <Expression id="Expression">
    <Minimum>0</Minimum>
    <Maximum>2500</Maximum>
    <Script>(A:Prop1 RPM, rpm) abs</Script>
  </Expression>
  <NonlinearityTable id="NonlinearityTable">
    <NonlinearityEntry id="NonlinearityEntry">
    <ExpressionResult>0</ExpressionResult>
    <FloatPosition>69.000,97.000</FloatPosition>
    </NonlinearityEntry>
    <NonlinearityEntry id="NonlinearityEntry">
    <ExpressionResult>1800</ExpressionResult>
    <FloatPosition>21.000,101.000</FloatPosition>
    </NonlinearityEntry>
  </NonlinearityTable>
</Rotation>

BUT, I'd like to have the maximum value not be 2500, but be specified by a variable. I tried
Code:
  <Maximum>(L:RPMt, number)</Maximum>

but that doesn't work (L:RPMt is a valid variable, and has the value I want to use). Can I use a variable to set the maximum value of an Expression to set rotation of an element?

Thanks!
 
Hi!
Adjust your script:
Code:
<Script>(A:Prop1 RPM, rpm) abs (L:RPMt, number) max<Script>

That should do it! "max" picks whatever is the largest of the two input parameters (also try "min" as needed)
 
Use the min/max operators instead of the maximum/minimum tags.
Code:
<Script>(A:Prop1 RPM, rpm) abs (L:Upper Limit, number) min (L:Lover Limit, number) max</Script>
:alert: note: min for "Maximum", max for "Minimum"
 
Last edited:
So I swapped them once more! Every time I need to spend a few seconds reasoning on them... :D
Yes, it's very backwards isn't it?

If you want to limit something to a maximum value then you use the min function to choose the minimum value between the variable and the maximum value.

So the following code will return which is lower, either Prop1 or RPMt. If Prop1 is 2300 and RPMt is 2100 then 2100 is returned. If Prop1 is 2300 and RPMt is 2500 then 2300 is returned.

Code:
<Script>(A:Prop1 RPM, rpm) abs (L:RPMt, number) min</Script>
 
No! It is NOT backwards. MIN / MAX takes the comparison of the stack and returns the limit if reached. That is all.

RPN
 
Guys,

There's no limit involved here, each operator simply takes the last two values from the stack and keeps:

with max, the largest of the two
with min, the smallest of the two.

both are similar to max(a,b) and min(a,b) in C languages.

I think the confusion rises because it is usual for one of the values to be used as a limit against the other.

Tom
 
Thank you all for your help; but as is often the case, the problem wasn't really where I thought it was! Scaling the maximum value for the RPM will be helpful, but what I really need is to be able to scale the gauge. So, in
Code:
<NonlinearityEntry id="NonlinearityEntry">
<ExpressionResult>1800</ExpressionResult>
<FloatPosition>21.000,101.000</FloatPosition>
</NonlinearityEntry>

I need to specify the value in the NonlinearityEntry as (L:RPMt,number) rather than 1800. I've tried (L:RPMt,number), %(L:RPMt,number), ((L:RPMt,number)) and %((L:RPMt,number)), but none of those combinations work.

Can it be done?!
 
I believe <ExpressionResult> only accepts values, not scripts. You should think of coding a conversion factor if you want to apply a multiple/limit criteria.

Tom
 
You do realize that you can add as many non-linearity entry elements as you want, to a non-linearity table, don't you?
And you can use degrees, counting from the start position (NORTH=0°, EAST=90°, etc...) of the needle.

The script to determine the expression result can also be called from a macro. If the "(L:RPMt, number)" variable refuses to work in the script, try putting it in one.


Below is part of the script for an EGT gauge. The limitation marker is dynamically adjusted depending on the engine type installed in the aircraft. Note the rotation based on degrees instead of the rather clumsy float position. The needle itself is driven by code in an update element and the variable contains a call for a macro which is located at the top of the gauge and fetches a simple "1", "2" or "3".
Code:
<Element id="egt_limit">
<FloatPosition>64.000,64.000</FloatPosition>
<Image id="eng_egt_limit.bmp" Name="eng_egt_limit.bmp">
<Transparent>True</Transparent>
<Axis>64.000,64.000</Axis>
</Image>
<Rotation id="Rotation">
<PointsTo>EAST</PointsTo>
<Expression id="Expression">
<Minimum>400.000</Minimum>
<Maximum>700.000</Maximum>
<Script>@EngineTypeMaxTemp</Script>
</Expression>
<NonlinearityTable id="NonlinearityTable">
<NonlinearityEntry id="NonlinearityEntry">
<ExpressionResult>400</ExpressionResult>
<Degrees>54</Degrees>
</NonlinearityEntry>
<NonlinearityEntry id="NonlinearityEntry">
<ExpressionResult>500</ExpressionResult>
<Degrees>94</Degrees>
</NonlinearityEntry>
<NonlinearityEntry id="NonlinearityEntry">
<ExpressionResult>600</ExpressionResult>
<Degrees>134</Degrees>
</NonlinearityEntry>
<NonlinearityEntry id="NonlinearityEntry">
<ExpressionResult>700</ExpressionResult>
<Degrees>174</Degrees>
</NonlinearityEntry>
<NonlinearityEntry id="NonlinearityEntry">
<ExpressionResult>800</ExpressionResult>
<Degrees>214</Degrees>
</NonlinearityEntry>
</NonlinearityTable>
</Rotation>
</Element>
<Element id="egt_needle">
<FloatPosition>64.000,64.000</FloatPosition>
<Image id="eng_egt_needle.bmp" Name="eng_egt_needle.bmp">
<Transparent>True</Transparent>
<Axis>19.000,19.000</Axis>
</Image>
<Rotation id="Rotation">
<PointsTo>EAST</PointsTo>
<Expression id="Expression">
<Minimum>0.000</Minimum>
<Maximum>700.000</Maximum>
<Script>(L:EGT E@EngineNumber,enum) 0 max</Script>
</Expression>
<NonlinearityTable id="NonlinearityTable">
<NonlinearityEntry id="NonlinearityEntry">
<ExpressionResult>0</ExpressionResult>
<Degrees>-15.5</Degrees>
</NonlinearityEntry>
<NonlinearityEntry id="NonlinearityEntry">
<ExpressionResult>100</ExpressionResult>
<Degrees>15.5</Degrees>
</NonlinearityEntry>
<NonlinearityEntry id="NonlinearityEntry">
<ExpressionResult>200</ExpressionResult>
<Degrees>45.5</Degrees>
</NonlinearityEntry>
<NonlinearityEntry id="NonlinearityEntry">
<ExpressionResult>300</ExpressionResult>
<Degrees>75.5</Degrees>
</NonlinearityEntry>
<NonlinearityEntry id="NonlinearityEntry">
<ExpressionResult>400</ExpressionResult>
<Degrees>115.5</Degrees>
</NonlinearityEntry>
<NonlinearityEntry id="NonlinearityEntry">
<ExpressionResult>500</ExpressionResult>
<Degrees>155.5</Degrees>
</NonlinearityEntry>
<NonlinearityEntry id="NonlinearityEntry">
<ExpressionResult>600</ExpressionResult>
<Degrees>195.5</Degrees>
</NonlinearityEntry>
<NonlinearityEntry id="NonlinearityEntry">
<ExpressionResult>700</ExpressionResult>
<Degrees>235.5</Degrees>
</NonlinearityEntry>
<NonlinearityEntry id="NonlinearityEntry">
<ExpressionResult>800</ExpressionResult>
<Degrees>275.5</Degrees>
</NonlinearityEntry>
</NonlinearityTable>
</Rotation>
</Element>
 
Bjoern, it's much easier than that.

What he needs IMO is to adapt the scale to a range that varies depending on the upper limit value.

So, instead of using numbers as limits, ie 2500, 1800, etc, using max percent solves it.

For example, if (L:RPMt, number) holds the limit value then:

Code:
<Rotation id="Rotation">
   <PointsTo>SOUTH</PointsTo>
      <Expression id="Expression">
        <Script>(A:Prop1 RPM, rpm) abs (L:RPMt, number) min (L:RPMt, number) / 100 *</Script>
     </Expression>
   <NonlinearityTable id="NonlinearityTable">
       <NonlinearityEntry id="NonlinearityEntry">
            <ExpressionResult>0</ExpressionResult>
            <FloatPosition>69.000,97.000</FloatPosition>
       </NonlinearityEntry>
       <NonlinearityEntry id="NonlinearityEntry">
            <ExpressionResult>100</ExpressionResult>
            <FloatPosition>21.000,101.000</FloatPosition>
       </NonlinearityEntry>
   </NonlinearityTable>
</Rotation>

He could also use PROP MAX RPM PERCENT:index AVar directly instead of doing the conversion.

Tom
 
Back
Top