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

FS2004 Still another can this be done? Question

Messages
231
Country
us-alabama
Designing in gmax for FS 2004. I want to create a gauge which functions as automatic switch to turn on a L:Variable part animation at 103 knots indicated airspeed. I found this code over at FFDS forum archive;

<Gauge Name="KCAileron" Version="1.0">
<Element>
<Select>
<Value>
(A:AIRSPEED INDICATED,knots) 3 &gt; if{ (&gt;K:FLAPS_UP) } els{ (&gt;K:FLAPS_DOWN) }
</Value>
</Select>
</Element>
</Gauge>

Which I reedited as;

<Gauge Name="A_Spd_Snsr" Version="1.0">
<Element>
<Select>
<Value>
(A:AIRSPEED INDICATED,knots) 103 &gt; if{ (&gt;K:FLAPS_UP) } els{ (&gt;K:FLAPS_DOWN) }
</Value>
</Select>
</Element>
</Gauge>

This works fine to raise the flaps at 103 knots. But when I try to use my L variable statement the gauge fails to trigger the part

animation at any speed. Below is my base gauge, which should flip a switch in the VC if the gauge functions;

<Gauge Name="A_Spd_Snsr" Version="1.0">
<Element>
<Select>
<Value>
(A:AIRSPEED INDICATED,knots) 103 &gt; (L:AS_Trgr_Switch,bool) ! (>L:AS_Trgr_Switch,bool)
</Value>
</Select>
</Element>
</Gauge>

The gauge above does not function. I have reedited the value statement many different ways with no results. The more I play

with this problem the more confused and discouraged I become. So my question now, is it even possible to use the

(A:AIRSPEED INDICATED,knots) 103 &gt; statement to trigger a key frame part animation?

Carl
 
Messages
2,079
Country
us-ohio
It is because you are constantly changing the state of the switch. Up, down, up, down, up, down. The animation probably won't do a thing because it's being done 18 times a second. Also... that original code FLOODS the sim with FLAPS_UP or FLAPS_DOWN commands. One should always check to see if the variable is already at the value it needs to be, before changing it.
 

Heretic

Resource contributor
Messages
6,830
Country
germany
Your code does nothing because you did not implement a condition evaluation and did a simple continuous toggle (value inversion at every cycle) instead.

You probably want this:
Code:
(A:AIRSPEED INDICATED,knots) 103 &gt; if{ 0 (>L:AS_Trgr_Switch,bool) } els{ 1 (>L:AS_Trgr_Switch,bool) }
 

tgibson

Resource contributor
Messages
11,343
Country
us-california
Never hurts to say it in two different ways. Different people learn in different ways. :)
 
Messages
231
Country
us-alabama
I think I have tried that statement. I will check my notes to see. Let you know soon.
Carl
 
Messages
231
Country
us-alabama
Thanks for the reply guys! I had that code as a parts parameter in one of my early notes files. Not as a gauge. I tried the code Heretic suggested the switch did not play it's animation. I have tried all of the following variations also with no success;
Code:
       (A:AIRSPEED INDICATED,knots) 103 &gt; if{ 1 (>L:AS_Trgr_Switch,bool) } els{ 0 (>L:AS_Trgr_Switch,bool) }
       (A:AIRSPEED INDICATED,knots) 103 &gt; if{ 1 (>L:AS_Trgr_Switch,bool) } els{ 0 (L:AS_Trgr_Switch,bool) }
       (A:AIRSPEED INDICATED,knots) 103 &gt; if{ 1 (L:AS_Trgr_Switch,bool) } els{ 0 (>L:AS_Trgr_Switch,bool) }
       (A:AIRSPEED INDICATED,knots) 103 &gt; if{ 0 (>L:AS_Trgr_Switch,bool) } els{ 1 (L:AS_Trgr_Switch,bool) }
       (A:AIRSPEED INDICATED,knots) 103 &gt; if{ 0 (L:AS_Trgr_Switch,bool) } els{ 1 (>L:AS_Trgr_Switch,bool) }

Carl
 
Messages
258
Country
ireland
The only line that stood any chance of working is the first - the others have errors in them.
 

rcbarend

Resource contributor
Messages
435
Country
netherlands
Hi Carl,

Only the first line in post#7 makes sense; the others don't since in either the if and/or els part the Lvar is not written.

If that line doesn't work:
There's a lot of simple and trivial things you could do wrong (trust me, I know ....LoL)

First, split the problem into two parts:
1. the gauge control of the Lvar (L:AS_Trgr_Switch,bool)
2. the usage of the Lvar (L:AS_Trgr_Switch,bool) in your animation code.

Ad. 1:
Are you sure the gauge is loaded and running ??
Like: did you define it in a VC section, and did you use the correct panel.cfg definition ?? (both in path and gaugename )
So check if the Lvar is actually following the airspeed condition, by reading the state of the Lvar in visible test gauge, or use a gauge that displays all Lvars used and their states.
That way, you are sure the Lvar is actually set correctly.

If that's Okay:
Ad.2:
Check the animation code again.
Like: does it use the correct Lvar ??
Example: does the animation code really use (L:AS_Trgr_Switch,bool) and not e.g. (L:IAS_Trgr_Switch,bool) ?? ( L:AS vs. L:IAS ..)

Because what you are trying to do is quite simple and certainly possible.
I'm pretty sure it's a very trivial typo error somewhere; either in the gauge definition, panel definition or animation code.

So first: read/display the value of the Lvar in another gauge, so you are sure it's follows the speed condition.
Like me, and I assume everyone else here: we all had our fair share of "staring at the obvious" ….LoL

Hope this helps debugging it ...

Cheers, Rob
 
Messages
231
Country
us-alabama
Good Morning Walter and Rob! I thank you both for your reply.

Walter
I assume you are referring to the top line;
Code:
(A:AIRSPEED INDICATED,knots) 103 &gt; if{ 1 (>L:AS_Trgr_Switch,bool) } els{ 0 (>L:AS_Trgr_Switch,bool) }
if and els coding has always been confusing to me. what I think I am seeing in the above line is, if the airspeed is greater than 103 then switch the L:AS_Trgr_Switch,bool to 1, the els leaves the L:AS_Trgr_Switch,bool at 0 at less than 103 airspeed. Please correct me if I am wrong.

Rob
I am fairly sure the gauge is loaded and running. one of my first tests was with the reedit I mentioned above.

Code:
<Gauge Name="A_Spd_Snsr" Version="1.0">
  <Element>
    <Select>
     <Value>
       (A:AIRSPEED INDICATED,knots) 103 &gt; if{ (&gt;K:FLAPS_UP) } els{ (&gt;K:FLAPS_DOWN) }
     </Value>
    </Select>
  </Element>
</Gauge>
When compiled into a .cab this runs the flaps up at 103 airspeed. I use the same A_Spd_Snsr name and .xml structure, replacing only the value statement for my lvar gauge testing.
below is the parts code for the switch from my mkmdl.parts file;
Code:
<part>
    <name>AS_Trgr_Switch</name>
    <animlength>100</animlength>
      <animation>
    <parameter>
      <code>(L:AS_Trgr_Switch,bool) 100 *</code>
    </parameter>
      </animation>
   <mouserect>
    <cursor>Hand</cursor>
   <tooltip_text>Turn on drop an</tooltip_text>
   <callback_code>
     (L:AS_Trgr_Switch,bool) ! (>L:AS_Trgr_Switch,bool) (L:Wtr_Jt_Drv_an,bool) ! (>L:Wtr_Jt_Drv_an,bool)
   </callback_code>
   </mouserect>
</part>

<part>
    <name>Wtr_Jt_Drv_an</name>
    <animation>
        <parameter>
            <code>
                                                       (L:Wtr_Jt_Drv_an,bool) 100 *
            </code>
                                       <lag>100</lag>
        </parameter>
    </animation>
    <mouserect>
        <cursor>Hand</cursor>
   <tooltip_text>Turn on drop animation</tooltip_text>
        <callback_code>(L:Wtr_Jt_Drv_an,bool) ! (>L:Wtr_Jt_Drv_an,bool)</callback_code>
    </mouserect>
</part>
The second part's animation is controlled by the AS_Trgr_Switch,bool and both parts animate when I click the AS_Trgr_Switch in the VC.
I am suffering from gout and must go lie down until the swelling and pain goes away. I will double check the rest of your suggestions later. I hate getting old!

Carl
 
Messages
258
Country
ireland
Hi Carl,

your assumption is correct.

A problem I can see with the code is that at any time the aircraft is flying faster than 103 kts the code is constantly setting the switch to 1 (I forget but it might be something like 18 times every second) and likewise when it is slower than 103 kts the code is constantly setting the switch to 0.

I believe it is the same with the code:

Code:
(A:AIRSPEED INDICATED,knots) 103 &gt; if{ (&gt;K:FLAPS_UP) } els{ (&gt;K:FLAPS_DOWN) }

i.e. above 103 kts it is constantly trying to trying to bring the flaps up and below 103 kts it is constantly trying to put the flaps down. It only needs to do either action once.
 
Messages
231
Country
us-alabama
Perhaps using an == instead of &gt; in the airspeed part pf the statement would switch the Kvar only once at the 103 speed?
Code:
(A:AIRSPEED INDICATED,knots) 103 == if{ (&gt;K:FLAPS_UP) } els{ (&gt;K:FLAPS_DOWN) }

In any case it is something I will have to check later. My doctor refered me to a foot specialist and I am going in for surgery this morning. I must suspend my participation in this thread for a while. I will resume when I can.

Carl
 

tgibson

Resource contributor
Messages
11,343
Country
us-california
The equals may work, but if you are accelerating rapidly you might miss it. Best to check for "if greater than 103 kts AND flaps are down (i.e. greater than 0%) THEN put the flaps up".

Best wishes for a speedy recovery.
 
D

Deleted member 1281

Guest
Tom's suggestion is a good one, but perhaps one ought to think further along the road. So far we have been assuming we are on an after-takeoff climb, I suppose. But what would happen when you are descending and, say, set flaps 1 at 135 KIAS? Right, the gauge would reset them to 0. Hurroar! AI rules OK!
 
Messages
231
Country
us-alabama
I am back. Hospital released me yesterday. Problem was not gout, it was an abscess in the first joint of the left big toe. I will be off real world work about 6 weeks for antibiotic infusion therapy. Glad I signed up for Aflac.

The time off should give me plenty of time to work thru the code I am trying to work out.

mjahn
For my project, if I can get the AS_Trgr_Switch code to function at airspeed 103. My plan is to write a simular gauge to raise the wing floats at a slightly higher airspeed. Raising the wing floats resets the rest of the display's parts to off, in the mkmdl.parts file.

Tom
I tried the == with my code. another fail. You are probably right, I will try to cobble something together my next work session.

For now I must prepare for my meds.

I will post testing results when I have them.

Carl
 
Messages
495
Country
austria
There a different ways to check the flaps position.

i use
Code:
(A:TRAILING EDGE FLAPS0 LEFT ANGLE,degree)

But you have to check your aircraft.cfg which flapsystem you are using. Normally it's FLAPS0.


Code:
  (A:TRAILING EDGE FLAPS0 LEFT ANGLE,degree) 0 ==
  (A:AIRSPEED INDICATED,knots) 103 &gt;
  &amp;&amp;
   if{ 
    (&gt;K:FLAPS_DOWN)
    }

  (A:TRAILING EDGE FLAPS0 LEFT ANGLE,degree) 0 &gt;
  (A:AIRSPEED INDICATED,knots) 100 &lt;
  &amp;&amp;
   if{ 
     (&gt;K:FLAPS_UP) 
     }


 instead   &amp;&amp;    you can also   and

Use different speeds for UP and DOWN to prevent permanent changes if you are flying near 103.

https://en.wikipedia.org/wiki/Hysteresis

Code not tested.

Edi
 
Messages
231
Country
us-alabama
Hi Edi

The meds are a bit more taxing than I thought they would be. I am testing your code for my project, and rechecking parts and parts coding in the .mdl file. I will report any success but the work time I am able to put in is limited.

Carl
 
Messages
231
Country
us-alabama
Hi Guys
I decided to follow Rob's advice and found a flaw in the AS_Trgr_Switch part's animation keyframes. I fixed the flaw in the gmax file, the gauge and part animations work perfectly with this code:

Code:
<Gauge Name="A_Spd_Snsr" Version="1.0">
  <Element>
    <Select>
     <Value>
       (A:AIRSPEED INDICATED,knots) 103 &gt; if{ 1 (>L:AS_Trgr_Switch,bool) } els{ 0 (>L:AS_Trgr_Switch,bool) }
     </Value>
    </Select>
  </Element>
</Gauge>

I thank you all for your advice. Now, to write the overall control gauge for the entire display. I can at least visualize the xml structure needed for that one now.
Thanks again Guys!

Carl
 
Top