Experimental Physics and Industrial Control System
On Mar 19, 2007, at 17:12 , David Dudley wrote:
Is there a way to:
1. Set a particular database block to scan at a specific time?
Hi Dave:
There is no simple building block like a "run-at" record.
I had a similar question some time ago,
and when you search tech-talk, you might still find the answers.
Things one can do:
1) run a 'cron' job on the host that basically performs a 'caput'
to some PV which then triggers stuff.
Trivial to set up, but then you depend on the host to trigger
the IOC.
2) Andrew Johnson had a device support module that periodically
causes a record to do something. As far as I remember, it's used
to basically print a periodic time stamp to the console, which helps
the debug port logger because now you have some idea if the
IOC is still alive, plus you get time stamps.
3) You compute times yourself within a sequence (SNL) program.
Below is an example of what I do to schedule stuff at some
specific hour:minute + N * period each day.
-Kay
%{
/* Determine delay in seconds until the next arrival
* of target hour:minutes + multiple of period_sec
*
* hour: 0..23
* minute: 0..59
* period_sec: >=1
*/
static long determine_sleep_seconds(int hour, int minute, int
period_sec)
{
epicsTimeStamp now_ts;
struct tm tm;
unsigned long nano;
long now_sec, pivot, goal;
long sleep_sec;
if (period_sec < 1)
{
printf("Schedule: Invalid period of %d seconds, correcting
to 24 hours\n", period_sec);
period_sec = 24*60*60;
}
epicsTimeGetCurrent(&now_ts);
epicsTimeToTM(&tm, &nano, &now_ts);
now_sec = tm.tm_hour*60*60 + tm.tm_min*60 + tm.tm_sec;
printf("\nNow: %02d:%02d:%02d (%ld seconds)\n", tm.tm_hour,
tm.tm_min, tm.tm_sec, now_sec);
printf("Schedule: %02d:%02d + N* %g minutes\n", hour, minute,
period_sec/60.0);
/* Calculation of the next time (goal) */
pivot = hour*60*60 + minute*60;
/* Correction to assert pivot <= 'now' */
if (pivot > now_sec)
pivot -= (1 + (pivot - now_sec)/period_sec) * period_sec;
goal = (1 + (now_sec - pivot)/period_sec) * period_sec + pivot;
/* Delay in seconds until then */
sleep_sec = goal - now_sec;
printf("Need to wait %ld seconds, until ", sleep_sec);
show_seconds_as_time(goal);
return sleep_sec;
}
}%
ss Schedule /* Schedule Tests */
{
...
state schedule /* Determine next runtime */
{
when (ctl == 0)
{} state disabled /* when disabled */
when ()
{
%% pVar->sleep_secs = determine_sleep_seconds(
%% (int)pVar->hour, (int)pVar->minute, (int)(pVar-
>period*60));
} state wait /* when have next runtime */
}
state wait /* Wait */
{
when (efTestAndClear(hour_mon) ||
efTestAndClear(minute_mon) ||
efTestAndClear(period_mon) ||
ctl == 0)
{} state schedule /* when setup was changed */
when (cmd)
{
cmd = 0;
} state trigger /* when manual trigger */
when (delay(sleep_secs))
{} state trigger /* when at scheduled time */
}
...
- Replies:
- Re: Timed Execution Maren Purves
- References:
- Timed Execution David Dudley
- Navigate by Date:
- Prev:
.cmd file downloading problem 师昊礼
- Next:
EPICS_TIMEZONE, TIMEZONE, vxWorks daylight saving Kay-Uwe Kasemir
- 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:
Timed Execution David Dudley
- Next:
Re: Timed Execution Maren Purves
- 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