Experimental Physics and Industrial Control System
Kay-Uwe Kasemir wrote:
Hi:
Both the database and the sequencer have good support for
periodic scheduling (scan field resp. delay() routine).
But I now have a need for scheduling things at certain times,
for example "at 00:15 and then every 6 hours",
meaning: run at 00:15, 06:15, 12:15 and 18:15 each day.
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
- References:
- cron-type scheduling in database or sequencer? Kay-Uwe Kasemir
- Navigate by Date:
- Prev:
Re: cron-type scheduling in database or sequencer? Andrew Johnson
- Next:
Active-X and Epics Bill Nolan
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
<2006>
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
- Navigate by Thread:
- Prev:
Re: cron-type scheduling in database or sequencer? Andrew Johnson
- Next:
Active-X and Epics Bill Nolan
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
<2006>
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025