EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  <20062007  2008  2009  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  <20062007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: cron-type scheduling in database or sequencer?
From: Andrew Johnson <[email protected]>
To: Kay-Uwe Kasemir <[email protected]>
Cc: tech talk <[email protected]>
Date: Thu, 14 Sep 2006 09:53:51 -0500
Here's the OSI version of consoleChime for non-vxWorks IOCs:

/* consoleChime.c,v 1.2 2005/07/19 18:20:52 norume 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 "epicsTime.h"
#include "subRecord.h"
#include "envDefs.h"
#include "registryFunction.h"
#include "epicsExport.h"


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;

    return 0;
}

long consoleChime(subRecord *psub)
{
    epicsUInt32 period, next;
    epicsTimeStamp now;
    const char *prompt = envGetConfigParamPtr(&IOCSH_PS1);

    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);
        fflush(stdout);
        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);


- Andrew -- There is considerable overlap between the intelligence of the smartest bears and the dumbest tourists -- Yosemite National Park Ranger

References:
cron-type scheduling in database or sequencer? Kay-Uwe Kasemir
Re: cron-type scheduling in database or sequencer? Andrew Johnson

Navigate by Date:
Prev: Re: cron-type scheduling in database or sequencer? Andrew Johnson
Next: Re: cron-type scheduling in database or sequencer? Maren Purves
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: cron-type scheduling in database or sequencer? Andrew Johnson
Next: Re: cron-type scheduling in database or sequencer? Maren Purves
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  <20062007  2008  2009  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 ·