Understanding Notifications and TimerEvents

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Understanding Notifications and TimerEvents

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:10 pm

by Dave >> Thu, 6 Sep 2007 13:14:28 GMT

Hi my name is Dave,

I'm a 2nd Year Computer Science student at Canterbury, doing a Introductory JADE course and I'm well into the thick of my Assignment due fairly soon, well I've developed a music player in JADE loosely replicating the GUI and basic functionality of ITunes.

Anyway I've come to a point where I'm really starting to enjoy the JADE language (You get so much done so quickly) but find that theres actually very little help when it comes to understanding some of the workings of JADE.

My problem is simply that I need a method to be called every 100 milliseconds until the user stops it.

Now in any other OO language its fairly straight forward, java for instance would perhaps go Thread.tick(100); no problem.

I read and reread what I could get from the JADE Documentation but I'm still here scratching my head. I'd ask my lecturer but its the holidays, and I ts one of those things that I'd expect more than one person struggles with.

Any tips and Pointers would be great.


Dave

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Understanding Notifications and TimerEvents

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:10 pm

by BeeJay >> Thu, 6 Sep 2007 20:27:58 GMT

There's three methods you'll want to read about and use as follows:

beginTimer(delay: Integer; option: Integer; eventTag: Integer);
Use this method to arm the timer against the object you want to be the receiver of the timer event. The first option is self explanatory, it's the delay in milliseconds. The second option says what you want to do when the timer fires. In your case, you'll want to use Timer_Continuous for the second parameter rather than Timer_OneShot. The third parameter is a unique value for you to recognise which timer has fired, for when you have more than one timer registered for a given object.

endTimer(eventTag: Integer);
Use this method to stop the timer when the user requests it to be stopped.

timerEvent(eventTag: Integer) updating;
This is the method you need to implement on the class of the object that will be receiving the timer event. You interrogate the value of eventTag to determine which of your timer events has occurred, if applicable, and then take the appropriate action.

Out of interest, what are you intending to use a continuous 100ms timerEvent for? 100ms is quite short for a continuous timer, and you would need to ensure that whatever you do within your timer event is very quick to execute. It may be more appropriate to arm the timer using Timer_OneShot and keep re-arming it in the epilog of your timerEvent, depending on what you're trying to achieve.

Cheers,
BeeJay.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Understanding Notifications and TimerEvents

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:10 pm

by Dave >> Fri, 7 Sep 2007 13:44:23 GMT

Thankyou! I shall have a go at this now.

Well seeing as you asked, I have a text field in my Gui that displays the current Song being played, and would like it to scroll with data such as the Song name, the current position of the song, and the total length of the song,

I think it would look pretty cool :D

Heres my current GUI if your interested:

I don't think it'd get a whole lot of marks for HCI, but the code behind the scenes hopefully does the job.
Attachments
4963.jpg
4963.jpg (100.33 KiB) Viewed 3294 times
Last edited by ConvertFromOldNGs on Fri Aug 07, 2009 4:23 pm, edited 1 time in total.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Understanding Notifications and TimerEvents

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:10 pm

by Murray Symon >> Sat, 8 Sep 2007 3:33:45 GMT

As your application is not reliant on critical timing, I think you should consider following BeeJay's advice and use a OneShot timer. That way, the timer events will not "back up" if there is some contention or slowdown. Only execute another 'beginTimer' when you have finised handling the last one, e.g. in the epilog section.

Another unrelated issue with timers is that the timer event only ever gets generated in the same Process that executed the 'beginTimer'. We ran into this a while ago where one app executed a 'beginTimer' on a persistent Object for a long time period. The original app terminated before the timer expired, so there was no Process running to handle the 'timerEvent' when it occurred.

Murray.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Understanding Notifications and TimerEvents

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:10 pm

by Dave >> Thu, 11 Oct 2007 0:33:17 GMT

Hey guys, heres the schema files so far, let me know what you think, I didn't really get anywhere enough time to finish it off properly, just way too busy with work and University course work.

http://dvd.nzl.googlepages.com/JADETUNES.zip

heres a screenshot http://dvd.nzl.googlepages.com/latestVersion.JPG


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 24 guests