add example from appDevGuide
This commit is contained in:
@@ -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
|
||||
|
||||
31
src/libCom/test/epicsTimerExample.cpp
Normal file
31
src/libCom/test/epicsTimerExample.cpp
Normal 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();
|
||||
}
|
||||
38
src/libCom/test/epicsTimerExampleMain.cpp
Normal file
38
src/libCom/test/epicsTimerExampleMain.cpp
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user