Experimental Physics and
| |||||||||||||||
|
Is there a way to: 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; } }%
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 */ } ...
| ||||||||||||||
ANJ, 10 Nov 2011 |
·
Home
·
News
·
About
·
Base
·
Modules
·
Extensions
·
Distributions
·
Download
·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing · |