• 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 How to produce different action depending on a conditions with a single mouse click?

Messages
14
Country
yugoslavia
My name is Miloš, I'm 45, a professional orchestra musician, father of two boys age 1 and 8. So, not a gauge developer, or an XML expert in any way. Just a flightsim fan for over 25 years. I own a FSX Steam (it was as cheep as 5 EUR on a sale, so I got it) but I don't use it. It's heavy on my 10 years old PC's resources. Instead, I still use my FS2004 and I'm happy with it.

I've been visiting this forum occasionally for a long time. About from when fs2x.com forum was closed. Since then, I have created several very basic XML gauges my self, and modified a few freely available on the web made by others, for my personal use.

Several days ago I've started making this ATS gauge for use in a DC-10 by HJG (former SGA aircraft with Mike Baumann panel, edited by HJG team). It's the first time for me trying to use L: vars in a gauge. And I'm stuck. I was wondering if someone can give me a push? Or a helping hand, anyway. I suppose it's a peace of cake for you guys.

Anyway, here is the code. What it should do is by moving the ATS (autothrottle) levers on a MCP turn ON the TOGA if the aircraft is on the ground, or engage SPD mode if levers are moved from OFF to ON position inflight. Here:
Moving lever to
ON (inflight) will engage SPD mode
unless TAKEOFF or G/A mode is
energized. On the ground, moving
lever to ON will engage CLAMP mode
unless TAKEOFF mode is energized.
No automatic movement of throttles
can occur with CLAMP mode
engaged.
Using L: vars, is it even possible, I wonder... I got the TOGA to activate, eventually. But it won't stay ON. Instead, the commandand the indication light are flickering, turning on and off very fast.

Code:
<Gauge Name="DC-10 ATS" Version="1.0">
   <Image Name="ATS base.bmp" ImageSizes="575,762" Luminous="1"/>

   <Element>
       <Select>
           <Value>(L:ATS levers, bool)</Value>
           <Case Value="0">
               <Image Name="ATS levers OFF.bmp" Luminous="1"/>
           </Case>
           <Case Value="1">
               <Image Name="ATS levers ON.bmp" Luminous="1"/>
           </Case>
       </Select>
   </Element>

   <Element>
       <Select>
           <Value>(L:ATS levers, bool) if{ (&gt;K:AUTO_THROTTLE_ARM) }</Value>
       </Select>
   </Element>

                                <!-- ATS levers activation on ground trigers TO/GA mode
                                         ATS levers activation inflight engages SPD mode -->
   <Element>
       <Select>
           <Value>(A:SIM ON GROUND, bool) (L:ATS levers, bool) if{ (&gt;L:ATS TOGA, bool) }</Value>
       </Select>
   </Element>

   <Element>
       <Select>
           <Value>(L:ATS TOGA, bool)  if{ (&gt;K:AUTO_THROTTLE_TO_GA) }</Value>
       </Select>
   </Element>

   <Mouse>
       <Area Left="50" Top="143" Width="463" Height="289">
           <Help ID="HELPID_AUTOPILOT_AUTOTHROTTLE"/>
           <Cursor Type="Hand"/>
           <Click>(L:ATS levers, bool) ! (&gt;L:ATS levers, bool) }</Click>
       </Area>
   </Mouse>

</Gauge>

If someone can help me, please? It's been a three days struggle for me.

Thanks, Miloš
 
Last edited:

ddawson

Resource contributor
Messages
862
Country
canada
...
Code:
   <Element>
       <Select>
           <Value>(L:ATS levers, bool) if{ (&gt;K:AUTO_THROTTLE_ARM) }</Value>
       </Select>
   </Element>

                                <!-- ATS levers activation on ground trigers TO/GA mode
                                         ATS levers activation inflight engages SPD mode -->
   <Element>
       <Select>
           <Value>(A:SIM ON GROUND, bool) (L:ATS levers, bool) if{ (&gt;L:ATS TOGA, bool) }</Value>
       </Select>
   </Element>

   <Element>
       <Select>
           <Value>(L:ATS TOGA, bool)  if{ (&gt;K:AUTO_THROTTLE_TO_GA) }</Value>
       </Select>
   </Element>
</Gauge>
These three elements are being evaluated 18 times per second, which means those events are being thrown 18 times per second.
The individual <value> lines should be in your mouse click.
 
Messages
14
Country
yugoslavia
These three elements are being evaluated 18 times per second, which means those events are being thrown 18 times per second.
The individual <value> lines should be in your mouse click.
Thank you, sir! Did you mean all three, like this?
Code:
            <Click>(L:ATS levers, bool) if{ (&gt;K:AUTO_THROTTLE_ARM) }
                      (A:SIM ON GROUND, bool) (L:ATS levers, bool) if{ (&gt;L:ATS TOGA, bool) }
                      (L:ATS TOGA, bool)  if{ (&gt;K:AUTO_THROTTLE_TO_GA) }
            </Click>
        </Area>
    </Mouse>
Obviously not. How can I do it, then? Sorry, I am really a beginner in this. Have mercy :laughing:
 

Heretic

Resource contributor
Messages
6,830
Country
germany
When interacting with a K: type variable, you should check the status of the corresponding A: type variable to avoid the event flooding that Doug described.

Also, you need to link your conditional statements and provide code for disengagement and any combination of input conditions that may occur.


Here's how I would do it:
Code:
Code:
<Gauge Name="DC-10 ATS" Version="1.0">
   <Image Name="ATS base.bmp" ImageSizes="575,762" Luminous="1"/>

                               <!-- ATS levers activation on ground trigers TO/GA mode
                                        ATS levers activation inflight engages SPD mode -->
   <Element>
      <Select>
          <Value>
(L:ATS levers, bool)
if{ (A:SIM ON GROUND, bool)
     if{ (A:AUTOPILOT THROTTLE ARM, bool) ! if{ (&gt;K:AUTO_THROTTLE_ARM) }
         (A:AUTOPILOT TAKEOFF POWER ACTIVE, bool) ! if{ (&gt;K:AUTO_THROTTLE_TO_GA) } }
     els{ (A:AUTOPILOT AIRSPEED HOLD, bool) ! if{ (>K:AP_PANEL_SPEED_HOLD_TOGGLE)  } } }
els{ (A:AUTOPILOT AIRSPEED HOLD, bool) if{ (>K:AP_AIRSPEED_HOLD) }
      (A:AUTOPILOT THROTTLE ARM, bool) if{ (&gt;K:AUTO_THROTTLE_ARM) }
      (A:AUTOPILOT TAKEOFF POWER ACTIVE, bool) if{ (&gt;K:AUTO_THROTTLE_TO_GA) } }
</Value>
      </Select>
   </Element>


   <Element>
      <Select>
          <Value>(L:ATS levers, bool)</Value>
          <Case Value="0">
              <Image Name="ATS levers OFF.bmp" Luminous="1"/>
          </Case>
          <Case Value="1">
              <Image Name="ATS levers ON.bmp" Luminous="1"/>
          </Case>
      </Select>
   </Element>

   <Mouse>
      <Area Left="50" Top="143" Width="463" Height="289">
          <Tooltip>Automatic Throttle System%((L:ATS levers, bool) (A:AUTOPILOT TAKEOFF POWER ACTIVE, bool) and)%{if} (On, TOGA mode)%{end}%((L:ATS levers, bool) (A:AUTOPILOT AIRSPEED HOLD, bool) and)%{if} (On, Airspeed mode)%{end}</Tooltip>
          <Cursor Type="Hand"/>
          <Click>(L:ATS levers, bool) ! (&gt;L:ATS levers, bool) }</Click>
      </Area>
   </Mouse>

</Gauge>

I hope this works. My regular text editor marks all opening and closing brackets, which immensely helps with determining the right amount of brackets to use.

You can leave out the custom tooltip if it is too complicated. I prefer to invest a bit of effort in them to have appropriate readouts while in the cockpit.
 
Messages
14
Country
yugoslavia
When interacting with a K: type variable, you should check the status of the corresponding A: type variable to avoid the event flooding that Doug described.

Also, you need to link your conditional statements and provide code for disengagement and any combination of input conditions that may occur.


Here's how I would do it:
Code:
Code:
<Gauge Name="DC-10 ATS" Version="1.0">
   <Image Name="ATS base.bmp" ImageSizes="575,762" Luminous="1"/>

                               <!-- ATS levers activation on ground trigers TO/GA mode
                                        ATS levers activation inflight engages SPD mode -->
   <Element>
      <Select>
          <Value>
(L:ATS levers, bool)
if{ (A:SIM ON GROUND, bool)
     if{ (A:AUTOPILOT THROTTLE ARM, bool) ! if{ (&gt;K:AUTO_THROTTLE_ARM) }
         (A:AUTOPILOT TAKEOFF POWER ACTIVE, bool) ! if{ (&gt;K:AUTO_THROTTLE_TO_GA) } }
     els{ (A:AUTOPILOT AIRSPEED HOLD, bool) ! if{ (>K:AP_PANEL_SPEED_HOLD_TOGGLE)  } } }
els{ (A:AUTOPILOT AIRSPEED HOLD, bool) if{ (>K:AP_AIRSPEED_HOLD) }
      (A:AUTOPILOT THROTTLE ARM, bool) if{ (&gt;K:AUTO_THROTTLE_ARM) }
      (A:AUTOPILOT TAKEOFF POWER ACTIVE, bool) if{ (&gt;K:AUTO_THROTTLE_TO_GA) } }
</Value>
      </Select>
   </Element>


   <Element>
      <Select>
          <Value>(L:ATS levers, bool)</Value>
          <Case Value="0">
              <Image Name="ATS levers OFF.bmp" Luminous="1"/>
          </Case>
          <Case Value="1">
              <Image Name="ATS levers ON.bmp" Luminous="1"/>
          </Case>
      </Select>
   </Element>

   <Mouse>
      <Area Left="50" Top="143" Width="463" Height="289">
          <Tooltip>Automatic Throttle System%((L:ATS levers, bool) (A:AUTOPILOT TAKEOFF POWER ACTIVE, bool) and)%{if} (On, TOGA mode)%{end}%((L:ATS levers, bool) (A:AUTOPILOT AIRSPEED HOLD, bool) and)%{if} (On, Airspeed mode)%{end}</Tooltip>
          <Cursor Type="Hand"/>
          <Click>(L:ATS levers, bool) ! (&gt;L:ATS levers, bool) }</Click>
      </Area>
   </Mouse>

</Gauge>

I hope this works. My regular text editor marks all opening and closing brackets, which immensely helps with determining the right amount of brackets to use.

You can leave out the custom tooltip if it is too complicated. I prefer to invest a bit of effort in them to have appropriate readouts while in the cockpit.

Thank you so much for your help, Bjoern! It means a lot! Let me take some time to "translate" your code completely, (including fantastically complicated Tooltip) so I can learn something. It's not my goal to use you people for writing free codes for me.

Thanks again! I'll get back to you!
 

Heretic

Resource contributor
Messages
6,830
Country
germany
Formatted text is a whole different world in terms of syntax, but is pretty easy to use for simpler conditional text once you've practiced for a bit.
 
Messages
14
Country
yugoslavia
Thanks again, Bjoern! I have understood at least this level of coding, thanks to you. You know how it goes, every time you learn something new, you would love to use it again, and again. Because, it's a great feeling when you create something by your self, and it works!
However, I would like to write codes to quickly, I'm afraid. I've looked everywhere. Nick Pike's tutorials are of big help! I just can't get this new code to work. Will someone care to help, again?

Here is the code with my custom variables. I would like to be able to trigger TOGA power if all these conditions are met. That new L variable is L:Automatic TO takeoff

Code:
    <Element>
    <Select>
        <Value>(L:Automatic TO takeoff, bool)
            if{ (A:SIM ON GROUND, bool) 
            if{ (A:TURB ENG N1:1, percent) 35 &gt;
            if{ (L:TRC TO mode, bool) (A:LIGHT LANDING, bool) and (A:AUTOPILOT THROTTLE ARM, bool) and
            if{ (A:AUTOPILOT TAKEOFF POWER ACTIVE, bool) ! if{ (&gt;K:AUTO_THROTTLE_TO_GA) } } } } }
        </Value>
    </Select>
</Element>

I'm struggling again. Nothing that I've tried worked.

Thanks!
 
Messages
1,564
Country
thailand
I would like to be able to trigger TOGA power if all these conditions are met.
Try
Code:
(A:SIM ON GROUND, bool) (A:TURB ENG N1:1, percent) 35 &gt; and
(L:TRC TO mode, bool) and
(A:LIGHT LANDING, bool) and
(A:AUTOPILOT THROTTLE ARM, bool) and
(A:AUTOPILOT TAKEOFF POWER ACTIVE, bool) ! and
   if{ (>K:AUTO_THROTTLE_TO_GA) }
Note that brief event flooding will occur until the a/c is no longer on the ground.

I don't see the need to create (L:Automatic TO takeoff, bool).

Bob
 
Messages
14
Country
yugoslavia
Hello, Bob!
I have tried lot's of variants of that code, with the and too, but always with
Code:
if{ A:AUTOPILOT TAKEOFF POWER ACTIVE, bool) ! if{ (>K:AUTO_THROTTLE_TO_GA) } }
like this.

I don't see the need to create (L:Automatic TO takeoff, bool)
I thought I need (L:Automatic TO takeoff, bool) for the annunciator lamp, but you're right, I could make only
Code:
(A:SIM ON GROUND, bool) (>K:AUTO_THROTTLE_TO_GA)
for that one.

Thanks very much! I'll give it a try and let you know!
 
Messages
1,564
Country
thailand
Hello Milos,
Code:
(A:SIM ON GROUND, bool) (>K:AUTO_THROTTLE_TO_GA)
That will create a problem. Anytime the aircraft is on the ground the autothrottle is set to Takeoff/Go Around.

This might help - experiment with the attached gauge. It's a replica of your example, but instead of using the AVars, it uses LVars that you can change (on lines 6 through 10) to see what's happening. The gauge size is a 200 x 100 and can be added as a separate window in panel.cfg.

Eventually, you might want to use a gauge debugging app like Blackbox or LOCALVARS class in XMLTOOLS to help debug code logic.

Bob
 

Attachments

  • TestGauge.zip
    730 bytes · Views: 168
Messages
14
Country
yugoslavia
Bob, no luck again... Like in my previous attempts, only thing I get is FD to engage at (A:TURB ENG N1:1, percent) 35 &gt; if it wasn't on before, and that's it.

But then I tried your code in FS2004 default B737, and in worked as it should :) I guess Steffan Ahlberg's Mike Baumann's old DC-10 panel has some custom gauges preventing my (and yours) code to work correctly. That's OK, I know now that I have to base my test gauges on default aircraft, with default FS2004 autopilot. That is, until I construct my own, some day :) Thanks for your help!
 
Messages
14
Country
yugoslavia
One thing I don't understand. Why this code work like Bob put it together, but not if introducing L var with it, like I want it. Even with default 737.
Code:
Element>
      <Select>
          <Value>(L:Automatic TO mode, bool)
              if{ (A:SIM ON GROUND, bool)
              (A:TURB ENG N1:1, percent) 35 &gt; and
              (L:TRC TO mode, bool) and
              (A:LIGHT LANDING, bool) and
              (A:AUTOPILOT THROTTLE ARM, bool) and
              (A:AUTOPILOT TAKEOFF POWER ACTIVE, bool) ! and
              if{ (&gt;K:AUTO_THROTTLE_TO_GA) } }
          </Value>
      </Select>
    </Element>

BlackBox gauge shows all conditions at 1, but still, no TOGA no TOGA.png
gFGt3k

no_TOGA

 
Last edited:
Messages
1,564
Country
thailand
Milos,

First of all, it's very nice to see the use of gauge debug tools like Robbie McElrath's Blackbox and Doug Dawson's xml vars, as well as a panel Reload button. Those are best practices. Well done.

You say Blackbox shows all conditions at 1, however (L:Automatic TO mode, bool) is zero. Because of that, the red if{ below, which includes the nested >K:AUTO_THROTTLE_TO_GA, will not be evaluated.


upload_2017-9-19_20-40-4.png


The if{ operates based on what precedes it. If it (the top of the stack) is 1, then if{ is evaluated. If the top of the stack is 0, the if{ is not evaluated.

For example, this would have given you TOGA:
Code:
<Element>
 <Value>
  1
   if{
    (A:SIM ON GROUND, bool)
    (A:TURB ENG N1:1, percent) 35 &gt; and
    (L:TRC TO mode, bool) and
    (A:LIGHT LANDING, bool) and
    (A:AUTOPILOT THROTTLE ARM, bool) and
    (A:AUTOPILOT TAKEOFF POWER ACTIVE, bool) ! and
     if{
      (&gt;K:AUTO_THROTTLE_TO_GA)
     }
   }
 </Value>
</Element>

Bob



 
Last edited:
Messages
14
Country
yugoslavia
Milos,

First of all, it's very nice to see the use of gauge debug tools like Robbie McElrath's Blackbox and Doug Dawson's xml vars, as well as a panel Reload button. Those are best practices. Well done.

Thanks, Bob. As I've already said replying to Bjoern, It's not my goal to use you people for writing free codes for me. I want to learn XML if possible, or as much as possible, so I can create XML gauges of my own, and ultimately fly a DC-10 with my own panel, and possibly share it with FS community :) I use FS2004 panels and gauges SDK, Nick Pike's tutorials, BlackBox and XML vars. But, I need help from time to time. More then the others, I might say ;) Thanks for your nice words, and your help! It's greatly appreciated! I new how if{ works, but didn't quite understand defining L vars.

My code now looks like this:
Code:
   <Select>
          <Value>(A:SIM ON GROUND, bool)
              (A:LIGHT LANDING, bool) and
              (A:AUTOPILOT THROTTLE ARM, bool) and
              (L:TRC TO mode, bool) and
              (A:TURB ENG N1:1, percent) 40 &gt; and
              (&gt;L:Automatic TO mode, bool)
          </Value>
      </Select>
    </Element>

        <Element>
        <Select>
            <Value>(L:Automatic TO mode, bool)
                if{ (A:AUTOPILOT TAKEOFF POWER ACTIVE, bool) ! if{ (&gt;K:AUTO_THROTTLE_TO_GA) } }
            </Value>
        </Select>
    </Element>

My problem was introducing the new L variable in the correct way. Now the L:Automatic TO mode is defined, and used to trigger TOGA power, which is what I wanted to begin with. Now comes the tremendously difficult task of creating other modes in Thrust Rating Computer. OK, one code at the time :)

And one more question if I may ask. This has now nothing to do with the initial theme of this post titled
How to produce different action depending on a conditions with a single mouse click
What is the right way on the forum? Should I open new post every time, or I can continue using this post for my XML related questions?
Thank you all!
 
Messages
1,564
Country
thailand
What is the right way on the forum? Should I open new post every time, or I can continue using this post for my XML related questions?
Thank you all!
It's a judgement call, but I'd say if you think the specific topic changes, then start a new thread, taking time to write a good, descriptive title so forum readers clearly know what its about. That will help greatly with future topic searches.

Some threads in here meander far off the original topic and it probably would have been better to snip it and start afresh.

Bob
 
Top