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

Back Course Flag

Messages
57
Country
finland
Dear Experts,

I try to replicate the ARC (Cessna) IN-385 VOR/LOC as closely as possible, but I can't make a back course flag work (a highlighted portion of the code below).

Either I do something wrong in the code or I don't understand how it is supposed to function, but when I place an aircraft on the back course of the localizer, the light doesn't illuminate.

I will highly appreciate if somebody takes a look at the code and says what's wrong with it (or with me :)) in that portion.

Thank you.

Code:
<Gauge Name="vor1" Version="1.0">
   <Image Name="vor_background2.bmp"/>
   <Element>
      <Position X="187" Y="267"/>
      <Visible>(A:NAV TOFROM:1,enum) 2 ==</Visible>
      <Image Name="vor_from_arrow2.bmp"/>
   </Element>
   <Element>
      <Position X="187" Y="267"/>
      <Visible>(A:NAV TOFROM:1,enum) 1 ==</Visible>
      <Image Name="vor_to_arrow2.bmp"/>
   </Element>
   <Element>
      <Position X="187" Y="267"/>
      <Visible>(A:NAV1 HAS NAV,bool) (A:CIRCUIT AVIONICS ON,bool) &amp;&amp; !</Visible>
      <Image Name="vor_bug2.bmp">
         <Transparent>True</Transparent>
      </Image>
   </Element>
   <Element>
     <Position X="216" Y="221"/>
      <Image Name="vor_needle2.bmp" ImageSizes="5,221,0,0">
         <Axis X="2" Y="90"/>
      </Image>
      <Shift>
         <Value Minimum="-120" Maximum="120">(A:NAV1 CDI, number)</Value>
         <Failures>
            <SYSTEM_ELECTRICAL_PANELS Action="0"/>
            <SYSTEM_ELECTRICAL_AVIONICS Action="0"/>
            <GAUGE_NAVIGATION_VOR1 Action="0"/>
         </Failures>
         <Nonlinearity>
            <Item Value="-120" X="122" Y="214"/>
            <Item Value="0" X="216" Y="214"/>
            <Item Value="120" X="309" Y="214"/>
         </Nonlinearity>
         <Delay PixelsPerSecond="33"/>
      </Shift>
   </Element>
   <Element>
      <Position X="0" Y="0"/>
      <MaskImage Name="vor_maskimage.bmp">
         <Axis X="216" Y="210"/>
      </MaskImage>
      <Image Name="vor_compass_ring2.bmp">
         <Axis X="213" Y="213"/>
      </Image>
      <Rotate>
         <Value>(A:NAV1 OBS,radians) /-/</Value>
      </Rotate>
   </Element>
   <Element>
      <Position X="50" Y="402"/>
      <Image Name="VOR1_Knob.bmp" ImageSizes="74,74,0,0">
         <Axis X="37" Y="37"/>
      </Image>
      <Rotate>
         <Value>(A:NAV1 OBS,radians) 3 *</Value>
      </Rotate>
   </Element>
[COLOR="Red"]   <Element>
      <Position X="170" Y="157"/>
      <Select>
         <Value>(A:NAV1 BACK COURSE FLAGS, bool)</Value> 
            <Case Value="0">
            <Image Name="vor_bc_flag_off.bmp" ImageSizes="24,24"/>
            </Case>
            <Case Value="1">
            <Image Name="vor_bc_flag.bmp" ImageSizes="24,24"/>
            </Case>
      </Select>
   </Element>[/COLOR]
   <Mouse>
      <Tooltip ID="TOOLTIPTEXT_VHF_NAV1_COURSE"/>
      <Area Left="0" Top="0" Width="433" Height="315">
         <Cursor Type="Hand"/>
         <Click>1850 (> K:PANEL_ID_TOGGLE)</Click>
      </Area>
      <Area Left="8" Right="90" Top="365" Bottom="440">
         <Area Left="40">
            <Cursor Type="DownArrow"/>
            <Click Event="VOR1_OBI_DEC" Repeat="Yes"/>
         </Area>
         <Area Right="40">
            <Cursor Type="UpArrow"/>
            <Click Event="VOR1_OBI_INC" Repeat="Yes"/>
         </Area>
      </Area>
   </Mouse>
</Gauge>
 
Thanks for the question, because it made me realize I had not yet added an entry in the FS-Developer Wiki on this topic... :)

That variable is not a boolean. It is a flag variable that returns a bits set/unset as a result:

NAV BACK COURSE FLAGS:index

Returns the following bit flags:
BIT0: 1=back course available
BIT1: 1=localizer tuned in
BIT2: 1=on course
BIT7: 1=station active

Please refer to this Wiki entry I wrote for information on how to "decode" flag variables!

http://www.fsdeveloper.com/wiki/index.php?title=XML:_Decode_Flags
or here
http://forums.flightsim.com/fswiki/index.php/Code_Samples:_XML_Decode_Macros#XML_Decode_Macros

Add the <Macros> to your script near the top, then when you want to use any of the flags it is as simple as this:

Code:
<!-- ===============DECODE BACK COURSE FLAGS ================= -->
<Macro Name="IsBCavailable">(A:NAV BACK COURSE FLAGS:1, flags) 1 &amp; 1 ==</Macro>
<Macro Name="IsLocalizerTuned">(A:NAV BACK COURSE FLAGS:1, flags) 2 &amp; 2 ==</Macro>
<Macro Name="IsOnCourse">(A:NAV BACK COURSE FLAGS:1, flags) 4 &amp; 4 ==</Macro>
<Macro Name="[COLOR="red"]IsStationActive[/COLOR]">(A:NAV BACK COURSE FLAGS:1, flags) 128 &amp; 128 ==</Macro>

   <Element>
      <Position X="170" Y="157"/>
      <Select>
         <Value[COLOR="Red"]>@IsStationActive[/COLOR]</Value> 
            <Case Value="0">
                 <Image Name="vor_bc_flag_off.bmp" ImageSizes="24,24"/>
            </Case>
            <Case Value="1">
                 <Image Name="vor_bc_flag.bmp" ImageSizes="24,24"/>
            </Case>
      </Select>
   </Element>
 
Last edited:
Bill,

Thank you very much for you answer, it has clarified things to me a little bit, but it looks like that it's still something wrong with what I'm doing, because when I add the <Macro> lines anywhere in my gauge it just doesn't display at all on the panel :confused:
 
Bill,

Thank you very much for you answer, it has clarified things to me a little bit, but it looks like that it's still something wrong with what I'm doing, because when I add the <Macro> lines anywhere in my gauge it just doesn't display at all on the panel :confused:

Where are you putting the <Macro>s?

At a minimum, they must be encapsulated within the <Gauge> structure. For ease of maintenance, I put most <Macro>s and constant value definitions at the top of the script, immediately after my background <Image> definition...

Code:
<Gauge Name="G1000_MFD" Version="1.0">
	<Image Name="G1000_PFD_bgnd.bmp"/>
	
	<!-- ====== MACROS & CONSTANTS ====== -->
	<!-- ====== DECODE BACK COURSE FLAGS ====== -->
	<Macro Name="IsBCavailable">(A:NAV BACK COURSE FLAGS:1, flags) 1 &amp; 1 ==</Macro>
	<Macro Name="IsLocalizerTuned">(A:NAV BACK COURSE FLAGS:1, flags) 2 &amp; 2 ==</Macro>
	<Macro Name="IsOnCourse">(A:NAV BACK COURSE FLAGS:1, flags) 4 &amp; 4 ==</Macro>
	<Macro Name="IsStationActive">(A:NAV BACK COURSE FLAGS:1, flags) 128 &amp; 128 ==</Macro>
 
Last edited:
Where are you putting the <Macro>s?
At a minimum, they must be encapsulated within the <Gauge> structure. For ease of maintenance, I put most <Macro>s and constant value definitions at the top of the script, immediately after my background <Image> definition...

Oh, yes! I do it the same! Here is the new code below. The panel loads, but there is no instrument in the right place.

Code:
<Gauge Name="vor1" Version="1.0">
   <Image Name="vor_background2.bmp"/>

[COLOR="red"]   <Macro Name="IsBCavailable">(A:NAV1 BACK COURSE FLAGS:1, flags) 1 & 1 ==</Macro>
   <Macro Name="IsLocalizerTuned">(A:NAV1 BACK COURSE FLAGS:1, flags) 2 & 2 ==</Macro>
   <Macro Name="IsOnCourse">(A:NAV1 BACK COURSE FLAGS:1, flags) 4 & 4 ==</Macro>
   <Macro Name="IsStationActive">(A:NAV1 BACK COURSE FLAGS:1, flags) 128 & 128 ==</Macro>[/COLOR]
   <Element>
      <Position X="187" Y="267"/>
      <Visible>(A:NAV TOFROM:1,enum) 2 ==</Visible>
      <Image Name="vor_from_arrow2.bmp"/>
   </Element>
   <Element>
      <Position X="187" Y="267"/>
      <Visible>(A:NAV TOFROM:1,enum) 1 ==</Visible>
      <Image Name="vor_to_arrow2.bmp"/>
   </Element>
   <Element>
      <Position X="187" Y="267"/>
      <Visible>(A:NAV1 HAS NAV,bool) (A:CIRCUIT AVIONICS ON,bool) &amp;&amp; !</Visible>
      <Image Name="vor_bug2.bmp">
         <Transparent>True</Transparent>
      </Image>
   </Element>
   <Element>
      <Position X="0" Y="0"/>
      <MaskImage Name="vor_maskimage.bmp">
         <Axis X="216" Y="210"/>
      </MaskImage>
      <Image Name="vor_compass_ring2.bmp">
         <Axis X="213" Y="213"/>
      </Image>
      <Rotate>
         <Value>(A:NAV1 OBS,radians) /-/</Value>
      </Rotate>
   </Element>
   <Element>
      <Position X="50" Y="402"/>
      <Image Name="VOR1_Knob.bmp" ImageSizes="74,74,0,0">
         <Axis X="37" Y="37"/>
      </Image>
      <Rotate>
         <Value>(A:NAV1 OBS,radians) 3 *</Value>
      </Rotate>
   </Element>
[COLOR="Red"]
   <Element>
      <Position X="170" Y="157"/>
      <Select>
         <Value>@IsStationActive</Value> 
            <Case Value="0">
            <Image Name="vor_bc_flag_off.bmp" ImageSizes="24,24"/>
            </Case>
            <Case Value="1">
            <Image Name="vor_bc_flag.bmp" ImageSizes="24,24"/>
            </Case>
      </Select>
   </Element>
[/COLOR]
   <Element>
     <Position X="214" Y="101"/>
      <Image Name="vor_needle2.bmp" ImageSizes="5,221,0,0" PointsTo="South">
         <Axis X="2" Y="11"/>
      </Image>
      <Rotate>
         <Value Minimum="-120" Maximum="120">(A:NAV1 CDI, number)</Value>
         <Nonlinearity>
            <Item Value="120" X="332" Y="283"/>
            <Item Value="0" X="214" Y="311"/>
            <Item Value="-120" X="95" Y="283"/>
         </Nonlinearity>
         <Delay DegreesPerSecond="33"/>
         <Failures>
            <SYSTEM_ELECTRICAL_PANELS Action="0"/>
            <SYSTEM_ELECTRICAL_AVIONICS Action="0"/>
            <GAUGE_NAVIGATION_VOR1 Action="0"/>
         </Failures>
      </Rotate>
   </Element>
   <Mouse>
      <Tooltip ID="TOOLTIPTEXT_VHF_NAV1_COURSE"/>
      <Area Left="0" Top="0" Width="433" Height="315">
         <Cursor Type="Hand"/>
         <Click>1850 (> K:PANEL_ID_TOGGLE)</Click>
      </Area>
      <Area Left="8" Right="90" Top="365" Bottom="440">
         <Area Left="40">
            <Cursor Type="DownArrow"/>
            <Click Event="VOR1_OBI_DEC" Repeat="Yes"/>
         </Area>
         <Area Right="40">
            <Cursor Type="UpArrow"/>
            <Click Event="VOR1_OBI_INC" Repeat="Yes"/>
         </Area>
      </Area>
   </Mouse>
</Gauge>
 
Last edited:
Your <Macro> entries are invalid! The purpose of the :1 is to specify Nav1 or Nav2. You can NOT use "NAV1" since that is NOT the variable's name!

The variable's "name" is (A:NAV BACK COURSE FLAGS:index,flags), where index should be either 1 or 2.

<Macro Name="IsBCavailable">(A:NAV1 BACK COURSE FLAGS:1, flags) 1 &amp; 1 ==</Macro>
<Macro Name="IsLocalizerTuned">(A:NAV1 BACK COURSE FLAGS:1, flags) 2 &amp; 2 ==</Macro>
<Macro Name="IsOnCourse">(A:NAV1 BACK COURSE FLAGS:1, flags) 4 &amp; 4 ==</Macro>
<Macro Name="IsStationActive">(A:NAV1 BACK COURSE FLAGS:1, flags) 128 &amp; 128 ==</Macro>

Remove the "1"s highlighted in red to fix the problem!

I deliberately posted the original <Macro> definitions in a CODE BOX so you could simply copy/paste them to your XML script... :teacher:
 
Last edited:
Bill,

Thank you, I tried to do it in all the different ways (actually, what you see now is one of the "trial and error" steps I tried to debug it myself). First what I've done was copy/paste, but still the same :confused:

I'm in despair. I believe you, I've never even thought about any doubt in your competence, I realize that if you say it must work then it must :) , but I still get the empty hole in the panel :confused: even having that NAV1 changed for NAV. I can't understand, what's wrong.

Maybe, I could send you the file and the bitmaps, so you could take a look?

I'm very sorry for so much trouble.
 
File received, corrections made and returned...

Just for the record, the silly Wiki software converts all &amp; entries to a single & symbol, which of course XML simply cannot abide...

...so, while the Wiki entries are technically correct, they are syntactically incorrect for the FS XML schema. :eek:
 
Back
Top