Sign in to follow this  
Guest

Timer in XML

Recommended Posts

I have tried to make somekind of timer code. When you switch battery on there is a light that should light up for 60 seconds and then it should go off. I haven't got it working. How is that done?And is there a possibility to do a blinking light? There is a switch to turn it on and off?

Share this post


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

Hey JukSii.In C there is the TokenVar ELAPSED_SECONDS. There might be something similar in XML, although I am not sure. If so, then all you have to do is initiate a variable that adds 60 to ELAPSED_SECONDS, and then just check, through a loop, if the ELAPSED_SECONDS time is still smaller than this variable.As far as the blinking light, take a look at the following code, courtesy of Arne Bartels:

		time_code_blink=fmod(pelement->source_var[1].var_value.n,BLINK_FREQUENCY);	  //recalc to something between 0...1		time_code_blink/=BLINK_FREQUENCY;		if(time_code_blink>0.5)			is_masked=TRUE;		if(is_masked)			pelement->string[selected_code_digit]=' ';

What is happening here is the function fmod is the floating point remainder of a division. The first argument passed to this function is not clear here, because the code is not complete, but it is ELAPSED_SECONDS. The second one is the BLINK_FREQUENCY, which has been defined at the beggining of my code as 0.5.What this means, as explained by the comment after //, is that time_code_blink is being calculated to something between 0 and 1 because it is the remainder, so it will never be bigger than one.Then all you need to do is see if time_blink_code is smaller or bigger than the BLINK_FREQUENCY. So in this case, with a value of 0.5, the string I have in my code will blink every second (half a second blank, half a second the character). All I have to do to change the frequency of blinks is to change the 0.5.How this translates to XML is beyond me, but I thought this could be of some help.

Share this post


Link to post
Share on other sites

>I have tried to make somekind of timer code. When you switch>battery on there is a light that should light up for 60>seconds and then it should go off. I haven't got it working.>How is that done?>>And is there a possibility to do a blinking light? There is a>switch to turn it on and off?Do a search of the forum messages using the criteria "XML Timer"The solution(s) have been posted many times over the last few months! :)BillAVSIM OmbudsmanFounder and Director,Creative Recycling of Aircraft Partshttp://mtco.com/~rsam/fartslogo.jpg

Share this post


Link to post
Share on other sites

My apologies to slightly change the subject ever so slightly, but concerning strobe lights. I am learning FSDS V2 and would like to speed up the 'slow' flashing of my strobes on the project I am doing. I would love to have a 'double-flash' pause 'double-flash' frequency, but just a quicker pulse would be nice. Is there a simple simple way to get this function modified?Sincerely,Bill

Share this post


Link to post
Share on other sites

>Do a search of the forum messages using the criteria "XML>Timer">>The solution(s) have been posted many times over the last few>months! :)Ooopss... ;) I tried to find something but I didn't use those words... But found them and now trying them out.Thanks. Maybe another question tomorrow :)

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