This is Unofficial EPICS BASE Doxygen Site
ts.c
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2010 Brookhaven National Laboratory.
3 * Copyright (c) 2010 Helmholtz-Zentrum Berlin
4 * fuer Materialien und Energie GmbH.
5 * EPICS BASE is distributed subject to a Software License Agreement found
6 * in file LICENSE that is included with this distribution.
7 \*************************************************************************/
8 
9 /*
10  * Author: Ralph Lange <Ralph.Lange@bessy.de>
11  */
12 
13 #include <stdio.h>
14 
15 #include <chfPlugin.h>
16 #include <dbLock.h>
17 #include <db_field_log.h>
18 #include <epicsExport.h>
19 
20 static db_field_log* filter(void* pvt, dbChannel *chan, db_field_log *pfl) {
21  epicsTimeStamp now;
22  epicsTimeGetCurrent(&now);
23 
24  /* If string or array, must make a copy (to ensure coherence between time and data) */
25  if (pfl->type == dbfl_type_rec) {
26  dbScanLock(dbChannelRecord(chan));
27  dbChannelMakeArrayCopy(pvt, pfl, chan);
28  dbScanUnlock(dbChannelRecord(chan));
29  }
30 
31  pfl->time = now;
32  return pfl;
33 }
34 
35 static void channelRegisterPre(dbChannel *chan, void *pvt,
36  chPostEventFunc **cb_out, void **arg_out, db_field_log *probe)
37 {
38  *cb_out = filter;
39 }
40 
41 static void channel_report(dbChannel *chan, void *pvt, int level, const unsigned short indent)
42 {
43  printf("%*sTimestamp (ts)\n", indent, "");
44 }
45 
46 static chfPluginIf pif = {
47  NULL, /* allocPvt, */
48  NULL, /* freePvt, */
49 
50  NULL, /* parse_error, */
51  NULL, /* parse_ok, */
52 
53  NULL, /* channel_open, */
54  channelRegisterPre,
55  NULL, /* channelRegisterPost, */
56  channel_report,
57  NULL /* channel_close */
58 };
59 
60 static void tsInitialize(void)
61 {
62  chfPluginRegister("ts", &pif, NULL);
63 }
64 
65 epicsExportRegistrar(tsInitialize);
epicsExportRegistrar(tsInitialize)
#define printf
Definition: epicsStdio.h:41
#define NULL
Definition: catime.c:38
int epicsStdCall epicsTimeGetCurrent(epicsTimeStamp *pDest)
Get current time into *pDest.
EPICS time stamp, for use from C code.
Definition: epicsTime.h:33
Exporting IOC objects.