Experimental Physics and
| |||||||||||||||||
|
/* 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"
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);
| ||||||||||||||||
ANJ, 02 Sep 2010 |
·
Home
·
News
·
About
·
Base
·
Modules
·
Extensions
·
Distributions
·
Download
·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing · |