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

FSXA XML Decode Flags - NAV CODES

Messages
204
Country
portugal
Has anyone ever used the NAV CODES decode flags with success?

I've been testing this macros (from the WIKI):
Code:
<Macro Name="IsVor">(A:NAV CODES:1, flags) 128 &amp; 128 !=</Macro>
<Macro Name="IsLoc">(A:NAV CODES:1, flags) 128 &amp; 128 ==</Macro>
And the result has been that all NAV1 tuned station return "VOR", and none returned "LOC".

I also tested with these macros of my own:
Code:
<Macro Name="IsVor">(A:NAV CODES:1, flags) 10000000 / int 0 == <Macro>
<Macro Name="IsLoc">(A:NAV CODES:1, flags) 10000000 / int 1 ==</Macro>
and the result was the same - everything is a VOR.

Could it be that the NAV CODES bit7 is always zero? Or should I continue to look for a genuine LOCALIZER around the globe?
 
Joao,

I have never used that A:Var, but if I wanted to know what it represented, my initial approach would be to see what number it returns and compare that to gps variables WaypointAirportBestApproachEnum and especially WaypointVorType. The reason I would look to the gps module for an answer is that all Nav facilities in Flight Sim are in that database, so that particular A:Var should cross-correlate with a gps variable ... I suppose.

Converting the number to binary and comparing that to the bit tables for those gps variables might lead to an understanding. Who knows?

Have you tried this yet?

Bob
 
Has anyone ever used the NAV CODES decode flags with success?

I've been testing this macros (from the WIKI):
Code:
<Macro Name="IsVor">(A:NAV CODES:1, flags) 128 &amp; 128 !=</Macro>
<Macro Name="IsLoc">(A:NAV CODES:1, flags) 128 &amp; 128 ==</Macro>
And the result has been that all NAV1 tuned station return "VOR", and none returned "LOC".


This is a proper coding:

Code:
<Macro Name="IsVor">(A:NAV CODES:1, flags) 128 and !</Macro>
<Macro Name="IsLoc">(A:NAV CODES:1, flags) 128 and</Macro>

It takes almost a second to recognize the new type when the frequency changes.

Tom
 
This is a proper coding:

Code:
<Macro Name="IsVor">(A:NAV CODES:1, flags) 128 and !</Macro>
<Macro Name="IsLoc">(A:NAV CODES:1, flags) 128 and</Macro>

It takes almost a second to recognize the new type when the frequency changes.

Tom
Yes, now it works. Thanks.
Someone should correct that bit operators on the WIKI, because all of them are incorrect.
 
Last edited:
Yes, now it works. Thanks.
Someone should correct that bit operators on the WIKI, because all of them are incorrect.

"Someone" can be "anyone..." All it takes is clicking on the "Edit" button! That's the beauty of this Wiki.

Actually, even though the original entries had "&amp;&amp;" the silly Wiki software removed one of the "&amp;" entries when displayed!

I've now made all needed corrections and substitutued "and" for "&amp;&amp;" so the Wiki program won't screw it up again... :rolleyes:

Thanks for catching the error(s)! :D
 
Can someone explain how FSX XML handles the & and && operators.

The FSX SDK states & is a bitwise operator and gives the example

5 3 & = 1

ie in binary 101 011 = 001 which is standard C which seems as expected.

It also states && is a logical operator and gives the example

(L:Local) 0xFF00 && (>L:Local)

What is assigned to (L:Local)? If the C convention that true = non-zero and false = 0 applies,then because 0xFF00 is non-zero (true) the result will be true if (L:Local) is true and false otherwise. This would mean 0xFF00 is redundant!
 
Yes, now it works. Thanks.
Someone should correct that bit operators on the WIKI, because all of them are incorrect.

Huh...NO!, we must revert those wiki macros to their original content.
See, after reading further posts from my own, something made me become uncomfortable with the solution (mgh post was relevant!). So I did a couple of tests (that's what I usually do when I feel something doesn't "fit well" in the code) and found that &amp; is indeed the bitwise operator to use.

So:

Code:
<Macro Name="IsVor">(A:NAV CODES:1, flags) 128 &amp; 128 !=</Macro>
<Macro Name="IsLoc">(A:NAV CODES:1, flags) 128 &amp; 128 ==</Macro>
are both Ok; what may lead to confusion is that LOC won't give true unless the a/c is at a distance recognized by the NAV radio. And the same happens to VOR; that's the reason my own (wrong) code worked :

Code:
(A:NAV CODES:1, flags) 128 and

for a near LOC gives true because any positive number and 128 is true; and false for a VOR because it was so far that its flag bits were all 0.
I did a test with a VOR I know works OK , in proper distance (dec.flags=33), and was true also, as expected for an and comparison.

Just for the records, in FS XML &amp; is the bitwise operator and &amp;&amp; is the same as and.

Tom
 
A further small point, the FSX SDK states && and AND are equivalent. Is this correct, or does and have to be used?
 
A further small point, the FSX SDK states && and AND are equivalent. Is this correct, or does and have to be used?

No, it's wrong. AND is not recognized by the parser as a valid expression; and has to be used instead.

Tom
 
Thanks. That's very useful to know. I'm revisiting XML gauges.

EDIT

A further thought. If the C convention applies (A:NAV CODES:1, flags) 128 &amp; is 128 (true) if Bit7 is set and 0 (false) otherwise. There should then be no need for any further comparison with 128 resulting in?

Code:
<Macro Name="IsVor">(A:NAV CODES:1, flags) 128 &amp; !</Macro>
<Macro Name="IsLoc">(A:NAV CODES:1, flags) 128 &amp;</Macro>
 
Last edited:
Huh...NO!, we must revert those wiki macros to their original content.
See, after reading further posts from my own, something made me become uncomfortable with the solution (mgh post was relevant!). So I did a couple of tests (that's what I usually do when I feel something doesn't "fit well" in the code) and found that &amp; is indeed the bitwise operator to use.

So:

Code:
<Macro Name="IsVor">(A:NAV CODES:1, flags) 128 &amp; 128 !=</Macro>
<Macro Name="IsLoc">(A:NAV CODES:1, flags) 128 &amp; 128 ==</Macro>
are both Ok; what may lead to confusion is that LOC won't give true unless the a/c is at a distance recognized by the NAV radio. And the same happens to VOR; that's the reason my own (wrong) code worked :

Code:
(A:NAV CODES:1, flags) 128 and

for a near LOC gives true because any positive number and 128 is true; and false for a VOR because it was so far that its flag bits were all 0.
I did a test with a VOR I know works OK , in proper distance (dec.flags=33), and was true also, as expected for an and comparison.

Just for the records, in FS XML &amp; is the bitwise operator and &amp;&amp; is the same as and.

Tom
Now I'm totally confused...:confused:
I started by using the original WIKI bitwise solution
Code:
<Macro Name="IsVor">(A:NAV CODES:1, flags) 128 &amp; 128 !=</Macro>
<Macro Name="IsLoc">(A:NAV CODES:1, flags) 128 &amp; 128 ==</Macro>
and all I had were VOR's...
Then I tried your correction:
Code:
<Macro Name="IsVor">(A:NAV CODES:1, flags) 128 &amp; !</Macro>
<Macro Name="IsLoc">(A:NAV CODES:1, flags) 128 &amp;</Macro>
And it worked ok!
Now you say the original code was right?!? But I still can't get a LOC return with it...:(

Let me clarify what I want: I want my EADI to show a distinct horizontal deviation indicator when the NAV1 tuned station is a LOCALIZER, as an approach aid (even if it hasn't a glidesope); and another symbol when its a VOR, for navigation or a non-precision approach - that's how this gauge works in RL. As I said, using the original decode macros from the WIKI, I wasn't able to get a LOC return with a localizer tuned in, near the airport.
The correct code you posted works perfect in these situation, returning VORs and LOCs according to what they really are - at least this is what I believe, and of course, I'm talking about FSX.

(...)A further thought. If the C convention applies (A:NAV CODES:1, flags) 128 &amp; is 128 (true) if Bit7 is set and 0 (false) otherwise. There should then be no need for any further comparison with 128 resulting in?

Code:
<Macro Name="IsVor">(A:NAV CODES:1, flags) 128 &amp; !</Macro>
<Macro Name="IsLoc">(A:NAV CODES:1, flags) 128 &amp;</Macro>
In my point of view, this makes sense, and fits with what I've been testing.
 
Last edited:
Thanks. That's very useful to know. I'm revisiting XML gauges.

EDIT

A further thought. If the C convention applies (A:NAV CODES:1, flags) 128 &amp; is 128 (true) if Bit7 is set and 0 (false) otherwise. There should then be no need for any further comparison with 128 resulting in?

Code:
<Macro Name="IsVor">(A:NAV CODES:1, flags) 128 &amp; !</Macro>
<Macro Name="IsLoc">(A:NAV CODES:1, flags) 128 &amp;</Macro>

It depends. (A:NAV CODES:1, flags) 128 &amp; ! equals 0 but (A:NAV CODES:1, flags) 128 &amp; equals 128 which is an implicit true indeed. Now, if you're going to use it as a source for a conditional if{ or similar, that will work Ok but if you need it in other type of calculations this could lead to confusions.
That's the reason to transform the implicit true (128) to a bool true (1) by doing a comparison with the resulting value ie (A:NAV CODES:1, flags) 128 &amp; 128 ==



Now I'm totally confused...:confused:
I started by using the original WIKI bitwise solution
Code:
<Macro Name="IsVor">(A:NAV CODES:1, flags) 128 &amp; 128 !=</Macro>
<Macro Name="IsLoc">(A:NAV CODES:1, flags) 128 &amp; 128 ==</Macro>
and all I had were VOR's...
Then I tried your correction:
Code:
<Macro Name="IsVor">(A:NAV CODES:1, flags) 128 &amp; !</Macro>
<Macro Name="IsLoc">(A:NAV CODES:1, flags) 128 &amp;</Macro>
And it worked ok!
Now you say the original code was right?!? But I still can't get a LOC return with it...:(

I don't know about the way you're using that code within the rest of the gauge, but (A:NAV CODES:1, flags) 128 &amp; 128 == works Ok. And (A:NAV CODES:1, flags) 128 &amp; works as well, but considering what I've stated above.
What seems to work but is a false presumption, is (A:NAV CODES:1, flags) 128 and (remember &amp; is NOT the same as and)

Tom
 
(...)I don't know about the way you're using that code within the rest of the gauge, but (A:NAV CODES:1, flags) 128 &amp; 128 == works Ok. And (A:NAV CODES:1, flags) 128 &amp; works as well, but considering what I've stated above.
What seems to work but is a false presumption, is (A:NAV CODES:1, flags) 128 and (remember &amp; is NOT the same as and)

Tom
I'm just using the code as a condition for visibility of a symbol instead of another (VOR/LOC).
 
But surely in this case Isvor and IsLoc are only going to be used as booleans - what other types of calculation would they be used in? Their purpose is to determine if a bit is set or not.

What seems to work but is a false presumption, is (A:NAV CODES:1, flags) 128 and (remember &amp; is NOT the same as and)

I don't think it does work. It should return 1 (true) if any bits or combination of bits in A:NAV CODES are set, and 0 (false) only if no bits are set.
 
Joao, et. al,

Apologies in advance if I am not correctly following the discussion, but why can't this be used to tell if a Nav radio is tuned to and receiving a localizer?:

Code:
(A:NAV1 CODES, flags) 128 >= if{ 1 (>L:NavReceivingLocalizer, bool) }

Bob

(FS9 syntax)

Joao - you need a list of FS airports that have localizer and/or ILSs vs non-precision approaches?
 
Last edited:
Back
Top