EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  <20082009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  <20082009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Scan Time Definitions
From: Andrew Johnson <[email protected]>
To: [email protected]
Cc: David Dudley <[email protected]>
Date: Tue, 12 Aug 2008 09:04:30 -0500
hi David,

On Monday 11 August 2008 19:00:08 David Dudley wrote:
>
> I've got some fields that only need to be scanned once a minute, once
> an hour, once every 4 hours, once every 12 hours, and once each night at
> midnite (actually, 24 hours from the last scan).
>
> These are for compliance reporting information, the information comes
> from remote sites, and it takes some time (a minute or so) to get each
> of the hourly readings.  I'd rather not scan these when I don't have to,
> and it would make more sense to admin if I could say "I scan this once
> every 4 hours" instead of "I scan this once every 14,400 seconds".

We have a subroutine record in all our vxWorks IOCs that generates a "console 
chime" at a programmable period; in our case it prints a new prompt on the 
vxWorks console with the current time at the top of every hour like this, so 
that we can see in the console log when any error messages were generated:

2008-08-12 01:00   iocmcr1>
2008-08-12 02:00   iocmcr1> 0xc6f638 (METASYS Ch1): Wrong Sequence Number - 
Expected 1397, Got 1395
0xc6f638 (METASYS Ch1): Wrong Sequence Number - Expected 1397, Got 1396

2008-08-12 03:00   iocmcr1>
2008-08-12 04:00   iocmcr1>
2008-08-12 05:00   iocmcr1>

You might want to re-use my subroutine code (attached) but replace the chime 
printf() with something like post_event(prec->b) to generate a soft event at 
the relevent period which will then trigger any records with SCAN=Event and 
EVNT=<n> on that IOC.  You can then instantiate as many of these records as 
you need periods, just set A to the period in minutes and B to the event 
number.

HTH,

- Andrew
-- 
Talk is cheap. Show me the code. -- Linus Torvalds
/* $Id: consoleChime.c,v 1.1 2005/01/07 22:36:08 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 "epicsTime.h"
#include "subRecord.h"
#include "registryFunction.h"
#include "epicsExport.h"

static char prompt[20];

static long consoleChimeInit(subRecord *psub)
{
    epicsTimeStamp now;

    if (psub->a < 1.0) psub->a = 60.0;  /* Default to chiming hourly */

    epicsTimeGetCurrent(&now);
    psub->l = now.secPastEpoch;

    sprintf(prompt, "%.13s> ", sysBootParams.targetName);
    shellPromptSet(prompt);

    return 0;
}

static long consoleChime(subRecord *psub)
{
    epicsUInt32 period, next;
    epicsTimeStamp 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);

    epicsTimeGetCurrent(&now);
    if (now.secPastEpoch >= next) {    /* Bong bong bong bong */
        char out[21];
        epicsTimeToStrftime(out, 20, "%Y-%m-%d %H:%M", &now);
        printf("\n%s   %s", out, prompt);
        psub->l = now.secPastEpoch;
    }
    return 0;
}

static registryFunctionRef consoleChimeRef[] = {
    {"consoleChimeInit",(REGISTRYFUNCTION)consoleChimeInit},
    {"consoleChime",(REGISTRYFUNCTION)consoleChime}
};

static void consoleChimeRegister(void)
{
    registryFunctionRefAdd(consoleChimeRef,NELEMENTS(consoleChimeRef));
}
epicsExportRegistrar(consoleChimeRegister);
record(sub, "$(IOC):consoleChime") {
	field(DESC, "Print time on IOC console")
	field(INAM, "consoleChimeInit")
	field(SNAM, "consoleChime")
	field(SCAN, "10 second")
	field(PRIO, "LOW")
}

References:
Scan Time Definitions David Dudley

Navigate by Date:
Prev: Re: Scan Time Definitions David Dudley
Next: EPICS Gateway question Kevin Tsubota
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  <20082009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Scan Time Definitions David Dudley
Next: asyn driver question: raw socket support Burkhard Kolb
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  <20082009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 02 Sep 2010 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·