Sign in to follow this  
n4gix

Transponder Units???

Recommended Posts

Hey guys,Hope everyone had a great Thanksgiving holiday (if you celebrate it), and a good weekend.In my NavCom.cpp, I'm doing this:wstring NavCom::GetCom1ActiveFreq(){ return GetFreq("(A:COM ACTIVE FREQUENCY:1, MHz)");}which works great, and now I want to do something similar with the Transponder(s).In the above, you have MHz as the units... and wondering what you put in the Transponder code... like this:wstring Xpdr::GetXpdr2(){ return GetFreq("(A:TRANSPONDER CODE:2, ???)");}Thanks.

Share this post


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

Try (A:TRANSPONDER CODE:2,enum)This will return a 4 digit value. I would suggest putting the return into a string, so you can seperate out each of the four digits individually.I use the more "traditional" approach myself, with the following:/* XPNDR Hex Conversion */ //Clear out the previous displayed transponder code high_units_left = 0; //Thou high_units_right = 0; //Hun low_units_left = 0; //Ten low_units_right = 0; //Unit //Get the current code lookup_var(&trans); if (xpdrFlag == false) { xpdr_mem1 = trans.var_value.d; xpdr = xpdr_mem1; } else { xpdr_mem2 = trans.var_value.d; xpdr = xpdr_mem2; } //Run a continous loop to break down the return into decimal //figures while (xpdr > 4095) { high_units_left = high_units_left + 1; xpdr = xpdr - 4096; } while (xpdr > 255) { high_units_right = high_units_right + 1; xpdr = xpdr - 256; } while (xpdr > 15) { low_units_left = low_units_left + 1; xpdr = xpdr - 16; } low_units_right = xpdr; //At this point we have the new transponder code so go //and display it

Share this post


Link to post
Share on other sites

Have tried "enum" and "number" and both do not work.I have a 'C' method that does, but just trying to write the 'XML' version too, to be complete.Guess I'll have to find an FS Xpdr that I can look at to see how it works.

Share this post


Link to post
Share on other sites

FL %((A:Indicated Altitude, feet) 100 / )%!3d!(A:Electrical master battery,bool)(A:Transponder1 Code, enum) 0 max 10000 % 1000 / flr(A:Electrical master battery,bool)(A:Transponder1 Code, enum) 0 max 1000 % 100 / flr(A:Electrical master battery,bool)(A:Transponder1 Code, enum) 0 max 100 % 10 / flr)(A:Electrical master battery,bool)(A:Transponder1 Code, enum) 0 max 10 % flrPush To Ident(P:Absolute time, seconds) 5 + (>L:Xpdrtimer,seconds)0 (>K:XPNDR_1000_INC) 0 (>K:XPNDR_1000_INC) 0 (>K:XPNDR_1000_INC) 0 (>K:XPNDR_1000_INC) 0 (>K:XPNDR_1000_INC) 0 (>K:XPNDR_1000_INC) 0 (>K:XPNDR_1000_INC)0 (>K:XPNDR_100_INC) 0 (>K:XPNDR_100_INC) 0 (>K:XPNDR_100_INC) 0 (>K:XPNDR_100_INC) 0 (>K:XPNDR_100_INC) 0 (>K:XPNDR_100_INC) 0 (>K:XPNDR_100_INC)0 (>K:XPNDR_10_INC) 0 (>K:XPNDR_10_INC) 0 (>K:XPNDR_10_INC) 0 (>K:XPNDR_10_INC) 0 (>K:XPNDR_10_INC) 0 (>K:XPNDR_10_INC) 0 (>K:XPNDR_10_INC)0 (>K:XPNDR_1_INC) 0 (>K:XPNDR_1_INC) 0 (>K:XPNDR_1_INC) 0 (>K:XPNDR_1_INC) 0 (>K:XPNDR_1_INC) 0 (>K:XPNDR_1_INC) 0 (>K:XPNDR_1_INC)

Share this post


Link to post
Share on other sites

Interesting.I just found out the problem wasn't with my "units".Interestingly, I have found that you can use different units, as this appears to really just be a clue to FS which conversion routine to use.Turns out "number" will return the transponder code in decimal (ie. the string "1200"), while Bco16 (the unit indicated in the docs) will return the string "4608" which is the decimal of 1200 hex!In other words, using Bco16 told FS to interpret the value as Octal digits, which it then "converted" to decimal for me. As the value is apparently stored internally as "1200", by using "number" I avoid any conversion.So, now I have a class that can retrive the value using the C vars, or the XML.I'm thinking of publishing this (maybe on a Wiki) with some documentation so that people don't have to keep re-inventing the wheel, and with the interface to FS more public we can all move on to coding the other parts of stuff.Thanks for the help.

Share this post


Link to post
Share on other sites

Hi Bill>I use the more "traditional" approach myself, with the>following::-lol That looks awfully familiar from some of my transponders too. However, thanks to some help I received from you, today's version looks like this://---------------------------------------------------------------------------void SetXpndrFrequency(){ int xpndr_x=0; xpndr_x=xpndr_thou*4096; xpndr_x=(xpndr_hun*256)+xpndr_x; xpndr_x=(xpndr_ten*16)+xpndr_x; xpndr_x=xpndr_unit+xpndr_x; trigger_key_event(KEY_XPNDR_SET,xpndr_x); return;}//---------------------------------------------------------------------------void GetXpndrFrequency(){ int freq=0; int xpndr_thou_temp=-1; int xpndr_hun_temp=-1; int xpndr_ten_temp=-1; int xpndr_unit_temp=-1; execute_calculator_code("(A:TRANSPONDER CODE:1,KHz)",&xpndr_current_freq,NULL,NULL);xpndr_current_freq*=1000;//Set the return into temporary decimal figures xpndr_thou_temp=(int)xpndr_current_freq/1000; xpndr_hun_temp=((int)xpndr_current_freq-(xpndr_thou_temp*1000))/100; xpndr_ten_temp=((int)xpndr_current_freq-((xpndr_thou_temp*1000)+(xpndr_hun_temp*100)))/10; xpndr_unit_temp=(int)xpndr_current_freq-((xpndr_thou_temp*1000)+(xpndr_hun_temp*100)+(xpndr_ten_temp*10));//Compare the tempary figures to the current figures -//If we have a frequency change then force an FS update if((xpndr_thou_temp!=xpndr_thou)||(xpndr_hun_temp!=xpndr_hun)||(xpndr_ten_temp!=xpndr_ten)||(xpndr_unit_temp!=xpndr_unit)) { xpndr_freq=(xpndr_thou*1000)+(xpndr_hun*100)+(xpndr_ten*10)+xpndr_unit; SetXpndrFrequency(); } return;}//---------------------------------------------------------------------------//Digital readout callback//---------------------------------------------------------------------------FLOAT64 FSAPI xpndr_code_string_cb(PELEMENT_STRING pelement){ GetXpndrFrequency(); sprintf(pelement->string, "%04.0f", (double)xpndr_freq); return 0;}//---------------------------------------------------------------------------//This sets the first (leftmost) digit//---------------------------------------------------------------------------BOOL FSAPI xpndr_thou_up_mcb( PPIXPOINT relative_point, FLAGS32 mouse_flags ){//Rotate the control knob clockwise xpndr_thou_pos+=12; if(xpndr_thou_pos>360)xpndr_thou_pos=0;//Set the digit xpndr_thou++; if(xpndr_thou>7)xpndr_thou=0; return FALSE;}//---------------------------------------------------------------------------BOOL FSAPI xpndr_thou_dn_mcb( PPIXPOINT relative_point, FLAGS32 mouse_flags ){//Rotate the control knob anti-clockwise xpndr_thou_pos-=12; if(xpndr_thou_pos<0)xpndr_thou_pos=360;//Set the digit xpndr_thou--; if(xpndr_thou<0)xpndr_thou=7; return FALSE;}//Etc for all the other digitsSomewhat neater and I suspect a bit faster too. I haven't tried setting the return from execute_calculator_code as MHz - which would reduce the code by one line - but it would probably work. The entire update cycle is triggered from the string update and that has a TICK18 in the first MODULE_VAR line.-Dai

Share this post


Link to post
Share on other sites

Yes, the "tradional method" was lifted in toto from your marvelous "tutorial" file and - since it works - I never felt the need to revisit it...However, the code you've posted above is not only "neater," but is likely to be somewhat faster overall, even if not discernably so. ;)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this