Archived

This topic is now archived and is closed to further replies.

n4gix

Decoding An Xml "flag" Variable

Recommended Posts

What would be the easiest way to decode the XML flag variable (A:NAV CODES:index,flags)...

BIT7: 0= VOR  1= Localizer  BIT6: 1= glideslope available  BIT5: 1= no localizer backcourse  BIT4: 1= DME transmitter at glide slope transmitter  BIT3: 1= no nav signal available  BIT2: 1= voice available  BIT1: 1 = TACAN available  BIT0: 1= DME available

:(

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

What would be the easiest way to decode the XML flag variable (A:NAV CODES:index,flags)...
BIT7: 0= VOR  1= Localizer  BIT6: 1= glideslope available  BIT5: 1= no localizer backcourse  BIT4: 1= DME transmitter at glide slope transmitter  BIT3: 1= no nav signal available  BIT2: 1= voice available  BIT1: 1 = TACAN available  BIT0: 1= DME available

:(

Use a bitwise and process... for example: if (NAV CODES && 0x08)==0x08 (or != 0) then 'no nav signal available'.

Share this post


Link to post
Share on other sites

Look in sd2gau25(?).zip for the code!!!!! :( -Dai(Sorry Bill - couldn't resist. As Ed says, do a bitwise lookup. The sample I supply checks to see what the type of VOR you've locked onto. Yes, it's C-code and you're after XML, but the principle is there?).

Share this post


Link to post
Share on other sites

I know how to accomplish the task in C... :( There are absolutely NO examples of the XML Script syntax though... that's the problem! :( Well, that's not entirely true if anyone can possibly consider this a reasonable example:

Operator	  Operation	 Arguments	   Example	  Result _____________________________________________________________________			    &		  bitwise AND	  2			5 3 &			1

Oh yeah! That's real clear! :(

Share this post


Link to post
Share on other sites
I know how to accomplish the task in C... :( There are absolutely NO examples of the XML Script syntax though... that's the problem! :( Well, that's not entirely true if anyone can possibly consider this a reasonable example:
Operator	  Operation	 Arguments	   Example	  Result _____________________________________________________________________			    &		  bitwise AND	  2			5 3 &			1

Oh yeah! That's real clear! :(

Ok... bitwise means binary... so...5 in binary is 1013 in binary is 011And them together results in 001.

Share this post


Link to post
Share on other sites
Ok... bitwise means binary... so...5 in binary is 1013 in binary is 011And them together results in 001.
:( Again, the "math" isn't the question...What is the precise syntax for scripting this in XML... :(

Share this post


Link to post
Share on other sites
:( Again, the "math" isn't the question...What is the precise syntax for scripting this in XML... :(
Well, you're the XML guy... not me... but... should be something like this:5 3 & 1 == if{

Share this post


Link to post
Share on other sites
Well, you're the XML guy... not me... but... should be something like this:5 3 & 1 == if{
Hey, I ain't no eggspurt at this here ExML stuff! I jist play 'round 'till stuff wurks!This compilicated sequence will work but it doesn't use the bitwise operator "&" at all:
<Macro Name="NavCodes">(A:NAV CODES:1,flags)</Macro><Element Name="Decode NavCodes>	<Select>		<Value>			@NavCodes 128 >= 				if{ 1 (>L:IsLocalizer,bool) }				els{ 1 (>L:IsVor,bool) }			@NavCodes 128 >=				if{ 					@NavCodes 128 - (>@NavCodes)					@NavCodes 64 >=						if{ 1 (>L:IsGlideslope,bool) }						els{ 0 (>L:IsGlideslope,bool) }					}			@NavCodes 64 >=				if{ 					@NavCodes 32 - (>@NavCodes) 					@NavCodes 32 >=						if{ 1 (L:NoBackcourse,bool) }						els{ 0 (L:NoBackcourse,bool) }					)			@NavCodes 32 >=				if{					@NavCodes 16 - (>@NavCodes)					@NavCodes 16 >=						if{ 1 (>L:HasDMEatGS,bool) }						els{ 0 (>L:HasDMEatGS,bool) }					}			@NavCodes 16 >=				if{					@NavCodes 8 - (>@NavCodes)					@NavCodes 8 >=						if{ 1 (>L:NoNavSignal,bool) }						els{ 0 (>L:NoNavSignal,bool) }			@NavCodes 8 >=				if{					@NavCodes 4 - (>@NavCodes)					@NavCodes 4 >=						if{ 1 (>L:HasVoice,bool) }						els{ 0 (>L:HasVoice,bool) }					}			@NavCodes 4 >=				if{					@NavCodes 2 - (>@NavCodes)					@NavCodes 2 >=						if{ 1 (>L:HasTacan,bool) }						els{ 0 (>L:HasTacan,bool) }					}			@NavCodes 2 >=				if{					@NavCodes 1 - (>@NavCodes)					@NavCodes 1 >=						if{ 1 (>L:HasDME,bool) }						els{ 0 (>L:HasDME,bool) }					}		</Value>		</Select></Element>

One could keep subtracting the decimal value of the BITn and thereby decode every flag...But, it's rediculously complex. There has to be a simpler method!

Share this post


Link to post
Share on other sites

Bill, forget about that complicated code :( As Ed stated, it's a simple bitwise operationSo:decimal codes for BIT0 to 7128 BIT7: 0= VOR 1= Localizer 64 BIT6: 1= glideslope available 32 BIT5: 1= no localizer backcourse 16 BIT4: 1= DME transmitter at glide slope transmitter 8 BIT3: 1= no nav signal available 4 BIT2: 1= voice available 2 BIT1: 1 = TACAN available 1 BIT0: 1= DME availableThen for example, to test if a VOR has not localizer backcourse:(A:NAV CODES:1, flags) 32 & 32 == To test for glideslope available(A:NAV CODES:1, flags) 64 & 64 == etc etcTom

Share this post


Link to post
Share on other sites
(A:NAV CODES:1, flags) 32 & 32 == To test for glideslope available(A:NAV CODES:1, flags) 64 & 64 ==
Thanks Tom. That's all I needed to know: the SYNTAX of the XML script... :( Sometimes I have problems seeing the obvious... :(Funny that I had written out the same "table" yesterday correlating the decimal values with the BITn values...This will allow me to script some handy <Macro> for later consumption:<Macro Name="IsVor">(A:NAV CODES:1, flags) 128 & 128 !=</Macro><Macro Name="IsLoc">(A:NAV CODES:1, flags) 128 & 128 ==</Macro><Macro Name="HasGS">(A:NAV CODES:1, flags) 64 & 64 ==</Macro>etc.When you have a chance Tom, please review this new Wiki entry to see if I've posted something incorrectly:http://forums.flightsim.com/fswiki/index.p...L_Decode_Macros

Share this post


Link to post
Share on other sites

These are some more from past notes I had..VOR ONLY = 32DME only = 41VOR + DME = 33It can also Work with the other flag sets..IE BackCourse Flags 131= Tuned and available 135= Tuned, Avail, & on back course sideRoman

Share this post


Link to post
Share on other sites
Hi Bill, I checked the Wiki and seems OK. BTW, thank you for taking the effort to maintain the Wikis ( I understand you post on more than one) :( Tom
Yes, I do. Actually, I find them wonderful places to stick stuff I will likely need at some point in the future... ;)

Share this post


Link to post
Share on other sites