Go to Post I am just very happy that I have never been responsible for the spelling of Karthik's last name on a name tag. Seriously. - JaneYoung [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Spotlight this post!  
Unread 16-02-2010, 23:33
slavik262's Avatar
slavik262 slavik262 is offline
We do what we must because we can.
AKA: Matt Kline
FRC #0537 (Charger Robotics)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Sussex, WI
Posts: 310
slavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to behold
Send a message via AIM to slavik262
Re: How to write Notifier help!!

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:

Code:
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:

Code:
//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
Code:
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?
__________________
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to write a good proposal and sponsorship letter for a event alanelf Fundraising 17 03-05-2011 06:58
Notifier fixes (impacting PIDController) heydowns C/C++ 0 05-02-2009 11:06
Notifier Class Phoenix Spud Programming 0 26-01-2009 20:16
How long to understand camera and write useful code RGuindon Programming 3 16-12-2007 01:37
How to write image data to binary PGM file format(P5)? tommy_chai Programming 0 08-10-2007 08:22


All times are GMT -5. The time now is 18:11.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi