December 2, 200817 yr Moderator 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 :( Fr. Bill AOPA Member: 07141481 AARP Member: 3209010556 Avsim Board of Directors | Avsim Forums Moderator
December 2, 200817 yr Commercial Member 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'. Ed Wilson Mindstar AviationMy Playland - I69
December 2, 200817 yr Commercial Member 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?).
December 3, 200817 yr Author Moderator 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! :( Fr. Bill AOPA Member: 07141481 AARP Member: 3209010556 Avsim Board of Directors | Avsim Forums Moderator
December 3, 200817 yr Commercial Member 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. Ed Wilson Mindstar AviationMy Playland - I69
December 3, 200817 yr Author Moderator 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... :( Fr. Bill AOPA Member: 07141481 AARP Member: 3209010556 Avsim Board of Directors | Avsim Forums Moderator
December 3, 200817 yr Commercial Member :( 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{ Ed Wilson Mindstar AviationMy Playland - I69
December 3, 200817 yr Author Moderator 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! Fr. Bill AOPA Member: 07141481 AARP Member: 3209010556 Avsim Board of Directors | Avsim Forums Moderator
December 3, 200817 yr 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
December 3, 200817 yr Author Moderator (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 Fr. Bill AOPA Member: 07141481 AARP Member: 3209010556 Avsim Board of Directors | Avsim Forums Moderator
December 4, 200817 yr 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 FS RTWR SHRS F-111 JoinFS Little Navmap
December 5, 200817 yr 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 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
December 5, 200817 yr Author Moderator 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) :( TomYes, I do. Actually, I find them wonderful places to stick stuff I will likely need at some point in the future... ;) Fr. Bill AOPA Member: 07141481 AARP Member: 3209010556 Avsim Board of Directors | Avsim Forums Moderator
Create an account or sign in to comment