add example from appDevGuide

This commit is contained in:
Marty Kraimer
2002-02-01 20:04:05 +00:00
parent 58a16ba21d
commit 51bb0b0a44
3 changed files with 73 additions and 0 deletions

View File

@@ -31,6 +31,10 @@ epicsTimerTestHost_SRCS += epicsTimerTestMain.cpp epicsTimerTest.cpp
PROD_HOST += epicsTimerTestHost
OBJS_IOC += epicsTimerTest
epicsTimerExampleHost_SRCS += epicsTimerExampleMain.cpp epicsTimerExample.cpp
PROD_HOST += epicsTimerExampleHost
OBJS_IOC += epicsTimerExample
ringPointerTestHost_SRCS += ringPointerTestMain.cpp ringPointerTest.c
PROD_HOST += ringPointerTestHost
OBJS_IOC += ringPointerTest

View File

@@ -0,0 +1,31 @@
#include <stdio.h>
#include "epicsTimer.h"
class something : public epicsTimerNotify {
public:
something(const char* nm,epicsTimerQueueActive &queue)
: name(nm), timer(queue.createTimer()) {}
virtual ~something() { timer.destroy();}
void start(double delay) {timer.start(*this,delay);}
virtual expireStatus expire(const epicsTime & currentTime) {
printf("%s\n",name);
currentTime.show(1);
return(noRestart);
}
private:
const char* name;
epicsTimer &timer;
};
void epicsTimerExample()
{
epicsTimerQueueActive &queue = epicsTimerQueueActive::allocate(true);
something first("first",queue);
something second("second",queue);
first.start(1.0);
second.start(1.5);
epicsThreadSleep(2.0);
queue.release();
}

View File

@@ -0,0 +1,38 @@
/*
* $Id$
*
* Author Jeffrey O. Hill
* johill@lanl.gov
* 505 665 1831
*
* Experimental Physics and Industrial Control System (EPICS)
*
* Copyright 1991, the Regents of the University of California,
* and the University of Chicago Board of Governors.
*
* This software was produced under U.S. Government contracts:
* (W-7405-ENG-36) at the Los Alamos National Laboratory,
* and (W-31-109-ENG-38) at Argonne National Laboratory.
*
* Initial development by:
* The Controls and Automation Group (AT-8)
* Ground Test Accelerator
* Accelerator Technology Division
* Los Alamos National Laboratory
*
* Co-developed with
* The Controls and Computing Group
* Accelerator Systems Division
* Advanced Photon Source
* Argonne National Laboratory
*
*/
void epicsTimerExample ( void );
int main ( int /* argc */, char /* *argv[] */ )
{
epicsTimerExample ();
return 0;
}