How to write Notifier help!!

OK im trying to write a notifier class to cause a delay in my program where one task would be preformed after another with a specific delay.

I get to the part where i named what the notifier is but when the little box appears after i put the name then -> the box says

Notifier(TimerEventHandler handler, void *param)

Now i dont know whatvalues to put in or what any of this means

Any documentation or code any one could give me to simply write a notifier would be much appreciated

I’ll post some help later tonight.

First you write a function that does whatever you want to do after the notifier delay. Say you want to activate a solenoid after the delay. The Notifier calls a function that takes a void pointer as an argument. We’ll pass it a pointer to our solenoid and cast it back in the function so we can use it.

Here’s the function:


void SolenoidDelayEventHandler(void* param)
{
        //Cast the pointer back to the solenoid type
	Solenoid* sol = (Solenoid*)param;
        //Activate the solenoid
	sol->Set(true);
}

Now, when we create our Notifier class, it wants two arguments: the function and what to pass to the function. We create it like so:


//As a member of your robot class,
Notifier solenoidNotifier;

//Then in the constructor of your robot class
solenoidNotifier(SolenoidDelayEventHandler, &mySolenoid)
//assuming mySolenoid is declared statically in the robot class as well
//and not with the keyword new

Now whenever you want to call your notifier function (and therefore activate the solenoid) after a delay time, just call


solenoidNotifier.StartSingle(time);

where time is the delay time in seconds. There’s also a StartPeriodic(time) function in the Notifier class that calls the function continuously, where time is the delay between calls. It stops when you call Notifier::Stop().

Any questions?

Yes. :]

I just downloaded the WPILibSource20100107.zip because I am curious how they implemented the notifiers.
Is that the latest library source from WPI as far as you know?
THX!

Off the top of my head, I don’t know the current version number and I can’t download the newest update to check since I’m at school at the moment.

As far as how notifiers work, they seem to work on an interrupt level (I’m assuming through a hardware timer run in the FPGA). This is just a guess from glancing over the header file; anyone can feel free to confirm or correct me here.

I still need help with the notifier if anyone else has info

kinda close to ship date :eek:

And the last workbench update is WorkbenchUpdate20100217.exe
http://first.wpi.edu/Images/CMS/First/WorkbenchUpdate20100217.exe