Experimental Physics and Industrial Control System
Hello Kay,
Kay-Uwe Kasemir wrote:
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.
...
Has anybody done something like this?
PVs for configuring the time, plus sequencer code
for determining the next runtime etc.?
We have a 'console chime' subroutine record that we run on all our
vxWorks IOCs here; it prints out the time on the IOC console at a
selected interval but could be used as the basis of what you're after.
The default is to chime hourly on the hour, but it can be set to any
minute period by changing the value in A - set it to 15 and you'll get
chimes at 15, 30 and 45 minutes past the hour (not just at 15 minute
intervals after the IOC started up - it's cleverer than that).
For your purposes you'd want to replace the 'printf' with a call to
post_event(psub->b) and you will get the soft event number in B posted
at the minute interval in A. The subroutines used are:
/* consoleChime.c,v 1.1.2.1 2004/12/23 16:53:44 anj Exp */
/* consoleChime field usage:
*
* A = chime period in minutes, defaults to 60 if not set
* L = timestamp (secPastEpoc) when we last chimed
*/
#include <stdio.h>
#include <sysLib.h>
#include <shellLib.h>
#include "tsDefs.h"
#include "subRecord.h"
static char prompt[20];
long consoleChimeInit(subRecord *psub)
{
TS_STAMP now;
if (psub->a < 1.0) psub->a = 60.0; /* Default to chiming hourly */
tsLocalTime(&now);
psub->l = now.secPastEpoch;
sprintf(prompt, "%.13s> ", sysBootParams.targetName);
shellPromptSet(prompt);
return 0;
}
long consoleChime(subRecord *psub)
{
epicsUInt32 period, next;
TS_STAMP now;
if (psub->a < 1.0) psub->a = 1.0; /* Chime at most once a minute */
period = 60 * (epicsUInt32) psub->a;
next = period * (1 + (epicsUInt32) psub->l / period);
tsLocalTime(&now);
if (now.secPastEpoch >= next) { /* Bong bong bong bong */
TS_DETAIL chime;
tsStampToLocal(now, &chime);
printf("\n%4.4d-%2.2d-%2.2d %2.2d:%2.2d %s",
chime.year, chime.monthNum+1, chime.dayMonth+1,
chime.hours, chime.minutes, prompt);
psub->l = now.secPastEpoch;
}
return 0;
}
The record looks like this:
record(sub, "$(IOC):consoleChime") {
field(DESC, "Print time on IOC console")
field(INAM, "consoleChimeInit")
field(SNAM, "consoleChime")
field(SCAN, "10 second")
field(PRIO, "LOW")
}
For those curious, the console chime allows us to see when any error
messages that appear on an IOC's console actually occurred, since it may
be days or even longer between someone looking at the IOC console and
many errors don't get sent to the error logger. If course if it's weeks
you would probably want to set the chime period to something like
1440=24 hours unless you have a *really* long history buffer on your
screens sessions.
- Andrew
--
There is considerable overlap between the intelligence of the smartest
bears and the dumbest tourists -- Yosemite National Park Ranger
- Replies:
- Re: cron-type scheduling in database or sequencer? Andrew Johnson
- References:
- cron-type scheduling in database or sequencer? Kay-Uwe Kasemir
- Navigate by Date:
- Prev:
cron-type scheduling in database or sequencer? Kay-Uwe Kasemir
- Next:
Re: cron-type scheduling in database or sequencer? Andrew Johnson
- 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
- Navigate by Thread:
- Prev:
cron-type scheduling in database or sequencer? Kay-Uwe Kasemir
- Next:
Re: cron-type scheduling in database or sequencer? Andrew Johnson
- 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