camonitor += relative and incremental timestamps
This commit is contained in:
@@ -29,9 +29,8 @@
|
||||
|
||||
#define VALID_DOUBLE_DIGITS 18 /* Max usable precision for a double */
|
||||
|
||||
static int nConn = 0; /* Number of connected PVs */
|
||||
/* Event mask used */
|
||||
static unsigned long eventMask = DBE_VALUE | DBE_ALARM;
|
||||
static int nConn = 0; /* Number of connected PVs */
|
||||
static unsigned long eventMask = DBE_VALUE | DBE_ALARM; /* Event mask used */
|
||||
|
||||
|
||||
void usage (void)
|
||||
@@ -42,6 +41,11 @@ void usage (void)
|
||||
" -w <sec>: Wait time, specifies longer CA timeout, default is %f second\n"
|
||||
" -m <mask>: Specify CA event mask to use, with <mask> being any combination of\n"
|
||||
" 'v' (value), 'a' (alarm), 'l' (log). Default: va\n"
|
||||
"Timestamps:\n"
|
||||
" Default: Print absolute timestamps (as reported by CA)\n"
|
||||
" -r: Relative timestamps (time elapsed since start of program)\n"
|
||||
" -i: Incremental timestamps (time elapsed since last update)\n"
|
||||
" -I: Incremental timestamps (time elapsed since last update for this channel)\n"
|
||||
"Enum format:\n"
|
||||
" -n: Print DBF_ENUM values as number (default are enum string values)\n"
|
||||
"Arrays: Value format: print number of requested values, then list of values\n"
|
||||
@@ -196,7 +200,7 @@ int main (int argc, char *argv[])
|
||||
|
||||
setvbuf(stdout,NULL,_IOLBF,0); /* Set stdout to line buffering */
|
||||
|
||||
while ((opt = getopt(argc, argv, ":nhm:e:f:#:d:0:w:")) != -1) {
|
||||
while ((opt = getopt(argc, argv, ":nhriIm:e:f:#:d:0:w:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'h': /* Print usage */
|
||||
usage();
|
||||
@@ -204,6 +208,15 @@ int main (int argc, char *argv[])
|
||||
case 'n': /* Print ENUM as index numbers */
|
||||
charAsNr=1;
|
||||
break;
|
||||
case 'r': /* Select relative timestamps */
|
||||
tsType = relative;
|
||||
break;
|
||||
case 'i': /* Select incremental timestamps */
|
||||
tsType = incremental;
|
||||
break;
|
||||
case 'I': /* Select incremental timestamps (by channel) */
|
||||
tsType = incrementalByChan;
|
||||
break;
|
||||
case 'w': /* Set CA timeout value */
|
||||
if(sscanf(optarg,"%lf", &timeout) != 1)
|
||||
{
|
||||
|
||||
@@ -28,14 +28,14 @@
|
||||
|
||||
#include "tool_lib.h"
|
||||
|
||||
/* Time stamps for program start, previous value (used for differential
|
||||
* times with monitors) */
|
||||
static TS_STAMP tsStart, tsPrev;
|
||||
/* Time stamps for program start, previous value (used for relative resp.
|
||||
* incremental times with monitors) */
|
||||
static TS_STAMP tsStart, tsPrevious;
|
||||
|
||||
static int tsInit = 0; /* Flag: Timestamps init'd */
|
||||
static int firstStampPrinted = 0; /* Flag: First timestamp already printed */
|
||||
|
||||
TimeT tsType = absTime; /* Timestamp type flag (-q or -Q option) */
|
||||
TimeT tsType = absolute; /* Timestamp type flag (-q or -Q option) */
|
||||
IntFormatT outType = dec; /* For -0.. output format option */
|
||||
|
||||
char dblFormatStr[30] = "%g"; /* Format string to print doubles (see -e -f option) */
|
||||
@@ -370,36 +370,53 @@ double tsDiffDbl(TS_STAMP *ts1, TS_STAMP * ts2)
|
||||
|
||||
#define PRN_TIME_VAL_STS(TYPE,TYPE_ENUM) \
|
||||
if (!tsInit) \
|
||||
{ /* Initialise reference timestamp */ \
|
||||
tsStart = tsPrev = ((struct TYPE *)value)->stamp; \
|
||||
{ /* Initialize start timestamp */ \
|
||||
tsStart = tsPrevious = ((struct TYPE *)value)->stamp; \
|
||||
tsInit = 1; \
|
||||
} \
|
||||
/* Print Timestamp */ \
|
||||
if (!firstStampPrinted) \
|
||||
{ /* First stamp is always absolute */ \
|
||||
printf("%s ", tsStampToText(&(((struct TYPE *)value)->stamp), \
|
||||
TS_TEXT_MMDDYY, timeText)); \
|
||||
firstStampPrinted = 1; \
|
||||
} else { \
|
||||
switch (tsType) { \
|
||||
case incTime: /* The following can be incremental, */ \
|
||||
printf("%10.4fs ", \
|
||||
tsDiffDbl( &(((struct TYPE *)value)->stamp), \
|
||||
&tsPrev) ); \
|
||||
break; \
|
||||
case relTime: /* relative, */ \
|
||||
printf("%10.4fs ", \
|
||||
tsDiffDbl( &(((struct TYPE *)value)->stamp), \
|
||||
&tsStart)); \
|
||||
break; \
|
||||
default : /* or also absolute */ \
|
||||
printf("%s ", \
|
||||
tsStampToText( &(((struct TYPE *)value)->stamp), \
|
||||
TS_TEXT_MMDDYY, timeText)); \
|
||||
break; \
|
||||
\
|
||||
switch (tsType) { \
|
||||
case relative: \
|
||||
if (pv->firstStampPrinted) \
|
||||
{ \
|
||||
printf("%10.4fs ", tsDiffDbl( &(((struct TYPE *)value)->stamp), \
|
||||
&tsStart) ); \
|
||||
} else { /* First stamp is always absolute */ \
|
||||
printf("%s ", tsStampToText(&(((struct TYPE *)value)->stamp), \
|
||||
TS_TEXT_MMDDYY, timeText)); \
|
||||
pv->firstStampPrinted = 1; \
|
||||
} \
|
||||
break; \
|
||||
case incremental: \
|
||||
if (firstStampPrinted) \
|
||||
{ \
|
||||
printf("%10.4fs ", tsDiffDbl( &(((struct TYPE *)value)->stamp), \
|
||||
&tsPrevious) ); \
|
||||
} else { /* First stamp is always absolute */ \
|
||||
printf("%s ", tsStampToText(&(((struct TYPE *)value)->stamp), \
|
||||
TS_TEXT_MMDDYY, timeText)); \
|
||||
firstStampPrinted = 1; \
|
||||
} \
|
||||
break; \
|
||||
case incrementalByChan: \
|
||||
if (pv->firstStampPrinted) \
|
||||
{ \
|
||||
printf("%10.4fs ", tsDiffDbl( &(((struct TYPE *)value)->stamp), \
|
||||
&pv->tsPrevious) ); \
|
||||
} else { /* First stamp is always absolute */ \
|
||||
printf("%s ", tsStampToText(&(((struct TYPE *)value)->stamp), \
|
||||
TS_TEXT_MMDDYY, timeText)); \
|
||||
pv->firstStampPrinted = 1; \
|
||||
} \
|
||||
pv->tsPrevious = ((struct TYPE *)value)->stamp; \
|
||||
break; \
|
||||
default : /* Absolute */ \
|
||||
printf("%s ", tsStampToText( &(((struct TYPE *)value)->stamp), \
|
||||
TS_TEXT_MMDDYY, timeText)); \
|
||||
break; \
|
||||
} \
|
||||
tsPrev = ((struct TYPE *)value)->stamp; \
|
||||
\
|
||||
tsPrevious = ((struct TYPE *)value)->stamp; \
|
||||
/* Print Values */ \
|
||||
for (i=0; i<nElems; ++i) { \
|
||||
printf ("%s ", val2str(value, TYPE_ENUM, i)); \
|
||||
@@ -415,7 +432,7 @@ double tsDiffDbl(TS_STAMP *ts1, TS_STAMP * ts2)
|
||||
}
|
||||
|
||||
|
||||
void print_time_val_sts (const pv* pv, int nElems)
|
||||
void print_time_val_sts (pv* pv, int nElems)
|
||||
{
|
||||
char timeText[28];
|
||||
int i;
|
||||
|
||||
@@ -19,12 +19,14 @@
|
||||
#ifndef INCLtool_libh
|
||||
#define INCLtool_libh
|
||||
|
||||
#include <tsDefs.h>
|
||||
|
||||
/* Convert status and severity to strings */
|
||||
#define stat_to_str(stat) \
|
||||
#define stat_to_str(stat) \
|
||||
((stat) >= 0 && (stat) <= (signed)lastEpicsAlarmCond) ? \
|
||||
epicsAlarmConditionStrings[stat] : "??"
|
||||
|
||||
#define sevr_to_str(stat) \
|
||||
#define sevr_to_str(stat) \
|
||||
((stat) >= 0 && (stat) <= (signed)lastEpicsAlarmSev) ? \
|
||||
epicsAlarmSeverityStrings[stat] : "??"
|
||||
|
||||
@@ -33,8 +35,8 @@
|
||||
#define DEFAULT_TIMEOUT 1.0 /* Default CA timeout */
|
||||
|
||||
|
||||
/* Type of timestamp (absolute, relative, incremental) */
|
||||
typedef enum { absTime, relTime, incTime } TimeT;
|
||||
/* Type of timestamp */
|
||||
typedef enum { absolute, relative, incremental, incrementalByChan } TimeT;
|
||||
|
||||
/* Output formats for integer data types */
|
||||
typedef enum { dec, bin, oct, hex } IntFormatT;
|
||||
@@ -50,10 +52,12 @@ typedef struct
|
||||
unsigned long reqElems;
|
||||
int status;
|
||||
void* value;
|
||||
TS_STAMP tsPrevious;
|
||||
int firstStampPrinted;
|
||||
} pv;
|
||||
|
||||
|
||||
extern TimeT tsType; /* Timestamp type flag (-q or -Q option) */
|
||||
extern TimeT tsType; /* Timestamp type flag (-r -i -I options) */
|
||||
extern IntFormatT outType; /* Flag used for -0.. output format option */
|
||||
extern int charAsNr; /* Used for -n option (get DBF_CHAR as number) */
|
||||
extern double timeout; /* Wait time default (see -w option) */
|
||||
@@ -62,7 +66,7 @@ extern char dblFormatStr[]; /* Format string to print doubles (see -e -f option)
|
||||
|
||||
extern char *val2str (const void *v, unsigned type, int index);
|
||||
extern char *dbr2str (const void *value, unsigned type);
|
||||
extern void print_time_val_sts (const pv *pv, int nElems);
|
||||
extern void print_time_val_sts (pv *pv, int nElems);
|
||||
extern int connect_pvs (pv *pvs, int nPvs);
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user