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

P3D v2 AP Manager, hidden gauge, problem

Messages
10,163
Country
us-arizona
Hey all,

I am making an Autopilot 'hidden gauge' manager. The old AP system on a Lear 24 was odd. You clicked 'ALT' button and the AP would hold ALT. No AP buttons for system on/off, just ALT, HDG, etc.

So I am making a hidden gauge that reads the L:vars and activates/runs the AP commands. (Sounds reasonable and saves me tons of code in the animated switches code in the modeldef.XML.


But I am having issues getting it to fire up. I thought I would show it here to see if anyone can figure out what I am doing wrong.


The system will have 5 triggers, such as ALT, HDG, etc.

If the L:var is active (1) then that system it represents (like ALT hold) should be on, as well as the AP system being powered up. If you turn off a command, the AP should turn off also unless one of the other commands for AP is active.


Draft;
Turn on HDG L:var
* turns on AP system
* turns on HDG Hold
Turn off HDG L:var
* checks to make sure no other AP systems are 'on'
-if on, leave AP system live or active
-els, if no other systems are left on, zero commands active, then AP
is turned off


For some reason the code isn't working. Is there a simple mis-use of code, or is this possible to run an AP manager off of L:var inputs? I would think it is.


Code so far;


Code:
<Gauge Name="Autopilot_Manager" Version="1.1">
  <Size X="5" Y="5" />

  <Update Hidden="Yes">
    <!-- 1 SECOND UPDATE -->
    (P:Absolute time,seconds) 1 % 1 > !
    if{
          (* XML script goes in here *)
            (L:LJ24B AUTOPILOT ALT SW, bool) 1 ==
            (L:LJ24B AUTOPILOT HDG SW, bool) 1 ==
            (L:LJ24B AUTOPILOT APP SW, bool) 1 ==
            (L:LJ24B AUTOPILOT HDG SW, bool) 1 ==
            (L:LJ24B AUTOPILOT NAV LOC SW, bool) 1 ==
               or or or or 
                   if{
                       1 (>K:AUTOPILOT_ON,bool) 
                      }
                   els{
                       1 (>K:AUTOPILOT_OFF,bool) 
                      }                   
      }


   <Element>
    <Select>
     <Value>
            (L:LJ24B AUTOPILOT ALT SW, bool) 1 ==
               if{ 
                  1 (K:AP_PANEL_ALTITUDE_HOLD,bool)
                  }
     </Value>
    </Select>
   </Element>

   <Element>
    <Select>
     <Value>
            (L:LJ24B AUTOPILOT ALT SW, bool) 0 ==
                    if{ 
                  0 (K:AP_PANEL_ALTITUDE_HOLD,bool)
                      }
     </Value>
    </Select>
   </Element>
 </Gauge>


Right now, I am just trying to get the ALT to work and I can go from there. I have tried putting the on/off commands in the same Element, but that didn't work, so I split them up, which didn't work either.



Bill
 
Last edited:
Bill,

Your code contains some errors, starting from an unclosed <Update>, etc.

I'm posting a reworked version that should work, or almost :). It is in a verbose mode.


Code:
<Gauge Name="Autopilot_Manager" Version="1.1">
  <Size X="5" Y="5" />

  <Update Hidden="Yes">
            (L:LJ24B AUTOPILOT ALT SW, bool) 1 ==
            (L:LJ24B AUTOPILOT HDG SW, bool) 1 ==
            (L:LJ24B AUTOPILOT APP SW, bool) 1 ==
            (L:LJ24B AUTOPILOT HDG SW, bool) 1 ==
            (L:LJ24B AUTOPILOT NAV LOC SW, bool) 1 ==
             or or or or 
            (A:Autopilot Master,bool) 0 ==  and 
              if{
                    (>K:AUTOPILOT_ON) 
                 }
             els{
                     (L:LJ24B AUTOPILOT ALT SW, bool) 0 ==
                     (L:LJ24B AUTOPILOT HDG SW, bool) 0 ==
                     (L:LJ24B AUTOPILOT APP SW, bool) 0 ==
                     (L:LJ24B AUTOPILOT HDG SW, bool) 0 ==
                     (L:LJ24B AUTOPILOT NAV LOC SW, bool) 0 ==
                     and and and and 
                      (A:Autopilot Master,bool) 1 ==  and
                      if{ 
                          (>K:AUTOPILOT_OFF) 
                         }
                  }                   
            (L:LJ24B AUTOPILOT ALT SW, bool) 1 ==
            (A:Autopilot Altitude Lock,bool) 0 == and
               if{ 
                    (>K:AP_ALT_HOLD_ON)
                  }
            (L:LJ24B AUTOPILOT ALT SW, bool) 0 ==
            (A:Autopilot Altitude Lock,bool) 1 == and
               if{ 
                    (>K:AP_ALT_HOLD_OFF)
                  }
   </Update>    
</Gauge>

I removed the 1 second update as it turns to be irrelevant

Tom
 
Good morning Bill,

Aren't you flooding the sim with constant AUTOPILOT_ON, AUTOPILOT_OFF K:Events by putting that code in the Update section? I would have thought you would put the AUTOPILOT_ON / OFF in a Mouse section where the K:Event is keyed once only after an associated button push like ALT or HDG.

Also, I believe you are missing the > in (>K:AP_PANEL_ALTITUDE_HOLD,bool)

Bob
 
Bill,

Your code contains some errors, starting from an unclosed <Update>, etc.

I'm posting a reworked version that should work, or almost :). It is in a verbose mode.


Code:
<Gauge Name="Autopilot_Manager" Version="1.1">
  <Size X="5" Y="5" />

  <Update Hidden="Yes">
            (L:LJ24B AUTOPILOT ALT SW, bool) 1 ==
            (L:LJ24B AUTOPILOT HDG SW, bool) 1 ==
            (L:LJ24B AUTOPILOT APP SW, bool) 1 ==
            (L:LJ24B AUTOPILOT HDG SW, bool) 1 ==
            (L:LJ24B AUTOPILOT NAV LOC SW, bool) 1 ==
             or or or or 
            (A:Autopilot Master,bool) 0 ==  and 
              if{
                    (>K:AUTOPILOT_ON) 
                 }
             els{
                     (L:LJ24B AUTOPILOT ALT SW, bool) 0 ==
                     (L:LJ24B AUTOPILOT HDG SW, bool) 0 ==
                     (L:LJ24B AUTOPILOT APP SW, bool) 0 ==
                     (L:LJ24B AUTOPILOT HDG SW, bool) 0 ==
                     (L:LJ24B AUTOPILOT NAV LOC SW, bool) 0 ==
                     and and and and 
                      (A:Autopilot Master,bool) 1 ==  and
                      if{ 
                          (>K:AUTOPILOT_OFF) 
                         }
                  }                   
            (L:LJ24B AUTOPILOT ALT SW, bool) 1 ==
            (A:Autopilot Altitude Lock,bool) 0 == and
               if{ 
                    (>K:AP_ALT_HOLD_ON)
                  }
            (L:LJ24B AUTOPILOT ALT SW, bool) 0 ==
            (A:Autopilot Altitude Lock,bool) 1 == and
               if{ 
                    (>K:AP_ALT_HOLD_OFF)
                  }
   </Update>    
</Gauge>

I removed the 1 second update as it turns to be irrelevant

Tom


Thanks Tom. I'll check that out. Much appreciated.


Good morning Bill,

Aren't you flooding the sim with constant AUTOPILOT_ON, AUTOPILOT_OFF K:Events by putting that code in the Update section? I would have thought you would put the AUTOPILOT_ON / OFF in a Mouse section where the K:Event is keyed once only after an associated button push like ALT or HDG.

Also, I believe you are missing the > in (>K:AP_PANEL_ALTITUDE_HOLD,bool)

Bob


Hey Bob,

There is no mouserect on this as its a hidden gauge. It collects the L:vars and uses that.

But, I had intended the two elements to be below the update area. I only needed the L:vars to be read/looked for, instead of the AP commands.
 
IIIIT IIIIIIS ALIVE!!!!!!!!!!!!!!!!!!!

YESSSSSSSSSSS!!!


Many thanks guys.


I thought you needed bool's in with K: commands. I am rusty. :(
 
No AP buttons for system on/off, just ALT, HDG, etc.

The system will have 5 triggers, such as ALT, HDG, etc.

Bill, glad it's working! I have a question, if there are no buttons, then how does the user select ALT, HDG, etc.? How are the 5 triggers ... triggered?

Curious,

Bob
 
Hey Bob,

No problem. I created L:var's for the 3D buttons in the VC. These manage the animation and sound effects of the buttons. The hidden AP Manager turns on the AP system as well as working the various AP 'holds'.

The AP for these is very simple with no pre-sets, similar to the very early 737's. You aquire the altitude you desire and click the ALT button when you are there and the system holds that altitude.

The system has;
* ALT
* HDG
* NAV LOC
* GPS (I am putting that in there, custom for the simmers, GPS/NAV alternative)
* APR


I also have a Damper switch on the other side of the panel, so I will bring that into the AP Manager also as the Damper is part of the AP system.



Here is the AP Manager, by the way...


Code:
<Gauge Name="Autopilot_Manager" Version="1.1">
  <Size X="5" Y="5" />

  <Update Hidden="Yes">
            (L:LJ24B AUTOPILOT ALT SW, bool) 1 ==
            (L:LJ24B AUTOPILOT HDG SW, bool) 1 ==
            (L:LJ24B AUTOPILOT APP SW, bool) 1 ==
            (L:LJ24B AUTOPILOT HDG SW, bool) 1 ==
            (L:LJ24B AUTOPILOT NAV LOC SW, bool) 1 ==
             or or or or 
            (A:Autopilot Master,bool) 0 ==  and 
              if{
                    (>K:AUTOPILOT_ON) 
                 }
             els{
                     (L:LJ24B AUTOPILOT ALT SW, bool) 0 ==
                     (L:LJ24B AUTOPILOT HDG SW, bool) 0 ==
                     (L:LJ24B AUTOPILOT APP SW, bool) 0 ==
                     (L:LJ24B AUTOPILOT HDG SW, bool) 0 ==
                     (L:LJ24B AUTOPILOT NAV LOC SW, bool) 0 ==
                     and and and and 
                      (A:Autopilot Master,bool) 1 ==  and
                      if{ 
                          (>K:AUTOPILOT_OFF) 
                         }
                  }                   
            (L:LJ24B AUTOPILOT ALT SW, bool) 1 ==
            (A:Autopilot Altitude Lock,bool) 0 == and
               if{ 
                    (>K:AP_ALT_HOLD_ON)
                  }
            (L:LJ24B AUTOPILOT ALT SW, bool) 0 ==
            (A:Autopilot Altitude Lock,bool) 1 == and
               if{ 
                    (>K:AP_ALT_HOLD_OFF)
                  }



            (L:LJ24B AUTOPILOT HDG SW, bool) 1 ==
            (A:AUTOPILOT HEADING LOCK,bool) 0 == and
               if{ 
                    (>K:AP_HDG_HOLD_ON)
                  }
            (L:LJ24B AUTOPILOT HDG SW, bool) 0 ==
            (A:AUTOPILOT HEADING LOCK,bool) 1 == and
               if{ 
                    (>K:AP_HDG_HOLD_OFF)
                  }

            (L:LJ24B AUTOPILOT NAV LOC SW, bool) 1 ==
            (A:AUTOPILOT NAV1 LOCK,bool) 0 == and
               if{ 
                    (>K:AP_NAV1_HOLD)
                  }
            (L:LJ24B AUTOPILOT NAV LOC SW, bool) 0 ==
            (A:AUTOPILOT NAV1 LOCK,bool) 1 == and
               if{ 
                    (>K:AP_NAV1_HOLD)
                  }

            (L:LJ24B AUTOPILOT GPS SW, bool) 1 ==
            (A:Autopilot Altitude Lock,bool) 0 == and
               if{ 
                    (>K:AP_ALT_HOLD_ON)
                  }
            (L:LJ24B AUTOPILOT GPS SW, bool) 0 ==
            (A:Autopilot Altitude Lock,bool) 1 == and
               if{ 
                    (>K:AP_ALT_HOLD_OFF)
                  }

            (L:LJ24B AUTOPILOT APP SW, bool) 1 ==
            (A:AUTOPILOT APPROACH HOLD,bool) 0 == and
               if{ 
                    (>K:AP_APR_HOLD_ON)
                  }
            (L:LJ24B AUTOPILOT APP SW, bool) 0 ==
            (A:AUTOPILOT APPROACH HOLD,bool) 1 == and
               if{ 
                    (>K:AP_APR_HOLD_OFF)
                  }

   </Update>    
</Gauge>


Below is a typical button (L:var) that is a 3D object/animated that interacts with the hidden AP Manager. (This code is in the ModelDef.XML parts sheet). This also have the sound code.


Code:
<PartInfo>
   <Name>lj24b_alt</Name>
       <AnimLength>100</AnimLength>
      <Animation>
	<Parameter>
	  <Code>(L:LJ24B AUTOPILOT ALT SW, bool) 50 *</Code>
 	  <Lag>160</Lag>
	</Parameter>
      </Animation>
   <MouseRect>
	<Cursor>Hand</Cursor>
   <TooltipText>Altitude Hold Switch (%((A:AUTOPILOT ALTITUDE LOCK, BOOL))%{if}on%{else}off%{end})
</TooltipText>
   <CallbackCode>
            (L:LJ24B AUTOPILOT ALT SW, bool) ! (>L:LJ24B AUTOPILOT ALT SW, bool)
          1 (&gt;L:XMLSND151,enum)      
   </CallbackCode>
   </MouseRect>
</PartInfo>

There is an issue with HDG and ALT when you click on APR if ALT and HDG are on. They argue, so I need to come up with some logic that turns off HDG and ALT when APR is selected. This also does not have the damper in it yet either.
 
Last edited:
Tom,

A thousand thanks. I found more of your edits and things in there. I am greatful man.



Bill
 
Thank you for posting your AP script Bill.

With the addition of
Code:
(A:Autopilot Master,bool) 0 == and
(A:Autopilot Master,bool) 1 == and
as suggested by Tom, I see that you do not continuously fire K:Events in your Update section. That was my original concern.

Bob
 
Tom,

A thousand thanks. I found more of your edits and things in there. I am greatful man.



Bill

Bill, I'm glad that it worked for you.
Remember also to put this gauge in any [VCockpit] section, in which case you can remove the Hidden="Yes" property of the <Update> section.

Tom
 
Back
Top