Experimental Physics and
| |||||||||||||||||
|
Hi: spawn a task? We have the following running every UT midnight (originally written by Nick Rees): taskSpawn ("dhsDailyUpdate", 100, 8, 20000, dhsDailyUpdate) (this is from the IOS's startup script) and it does: /* dhsDailyUpdate - task that executes once a day at 00:00 UT to update the file number */ void dhsDailyUpdate() { time_t timeNextUpdate = 0; time_t timeNow, timeToday, timeTomorrow; struct tm tmNow, tmToday, tmTomorrow; int secondsDelay; do { /* Find the current time in time_t and struct tm formats */ timeNow = time(NULL); gmtime_r( &timeNow, &tmNow ); /* Create a tm structure and time_t which is the beginning of today UTC */ tmToday = tmNow; tmToday.tm_hour = 0; tmToday.tm_min = 0; tmToday.tm_sec = 0; timeToday = mktime( &tmToday ); /* Now create a tm structure and time_t which is the beginning of tomorrow UTC Note we rely on the ability of mktime to notice month and year changes to sort these out just from the addition of the day number */ tmTomorrow = tmToday; tmTomorrow.tm_mday++; timeTomorrow = mktime( &tmTomorrow ); /* Now update the observation number if the next update is before today (the normal occurance) or after tomorrow (indicating that a time error has occurred in the last iteration */ if (timeNextUpdate <= timeToday || timeNextUpdate > timeTomorrow ) { DHS_ID pDrv = &dhsDrv; dhsObsnum ( pDrv ); <--------------- or whatever you want it to run timeNextUpdate = timeTomorrow; } /* Calculate the number of seconds left in today */ secondsDelay = 86400 - (tmNow.tm_hour*3600 + tmNow.tm_min*60 + tmNow.tm_sec); taskDelay( secondsDelay * sysClkRateGet() ); } while (TRUE); } Obviously you can make it run at other times and other frequencies. Aloha, Maren
| ||||||||||||||||
ANJ, 02 Sep 2010 |
·
Home
·
News
·
About
·
Base
·
Modules
·
Extensions
·
Distributions
·
Download
·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing · |