added dbCaGetTimeStamp
This commit is contained in:
@@ -2,6 +2,7 @@ TOP = ../../..
|
||||
include $(TOP)/config/CONFIG_BASE
|
||||
|
||||
USER_DBDFLAGS += -I ..
|
||||
USR_CFLAGS += -ansi
|
||||
|
||||
SRCS.c = \
|
||||
../dbLock.c\
|
||||
|
||||
+3
-1
@@ -255,7 +255,8 @@ void dbCaAddLink(struct link *plink);
|
||||
void dbCaRemoveLink(struct link *plink);
|
||||
long dbCaGetLink(struct link *plink,short dbrType,void *pbuffer,
|
||||
unsigned short *psevr,long *nRequest);
|
||||
long dbCaPutLink(struct link *plink,short dbrType,const void *pbuffer,long nRequest);
|
||||
long dbCaPutLink(struct link *plink,short dbrType,
|
||||
const void *pbuffer,long nRequest);
|
||||
long dbCaGetAttributes(struct link *plink,
|
||||
void (*callback)(void *usrPvt),void *usrPvt);
|
||||
long dbCaGetControlLimits(struct link *plink,double *low, double *high);
|
||||
@@ -265,6 +266,7 @@ long dbCaGetAlarmLimits(struct link *plink,
|
||||
long dbCaGetNelements(struct link *plink,long *nelements);
|
||||
long dbCaGetPrecision(struct link *plink,short *precision);
|
||||
long dbCaGetSevr(struct link *plink,short *severity);
|
||||
long dbCaGetTimeStamp(struct link *plink,TS_STAMP *pstamp);
|
||||
long dbCaGetUnits(struct link *plink,char *units,int unitsSize);
|
||||
int dbCaIsLinkConnected(struct link *plink);
|
||||
int dbCaGetLinkDBFtype(struct link *plink);
|
||||
|
||||
+26
-11
@@ -393,6 +393,18 @@ long dbCaGetSevr(struct link *plink,short *severity)
|
||||
return(0);
|
||||
}
|
||||
|
||||
long dbCaGetTimeStamp(struct link *plink,TS_STAMP *pstamp)
|
||||
{
|
||||
caLink *pca;
|
||||
|
||||
if(!plink) return(-1);
|
||||
if(plink->type != CA_LINK) return(-1);
|
||||
pca = (caLink *)plink->value.pv_link.pvt;
|
||||
if(!pca->chid || ca_state(pca->chid)!=cs_conn) return(-1);
|
||||
memcpy(pstamp,&pca->timeStamp,sizeof(TS_STAMP));
|
||||
return(0);
|
||||
}
|
||||
|
||||
int dbCaIsLinkConnected(struct link *plink)
|
||||
{
|
||||
caLink *pca;
|
||||
@@ -427,6 +439,7 @@ static void eventCallback(struct event_handler_args arg)
|
||||
long size;
|
||||
STATUS semStatus;
|
||||
dbCommon *precord = 0;
|
||||
struct dbr_time_double *pdbr_time_double;
|
||||
|
||||
if(!pca) {
|
||||
epicsPrintf("eventCallback why was arg.usr NULL\n");
|
||||
@@ -456,17 +469,17 @@ static void eventCallback(struct event_handler_args arg)
|
||||
goto done;
|
||||
}
|
||||
size = arg.count * dbr_value_size[arg.type];
|
||||
if((arg.type==DBR_STS_STRING) && (ca_field_type(pca->chid)==DBR_ENUM)) {
|
||||
if((arg.type==DBR_TIME_STRING) && (ca_field_type(pca->chid)==DBR_ENUM)) {
|
||||
memcpy(pca->pgetString,dbr_value_ptr(arg.dbr,arg.type),size);
|
||||
pca->gotInString = TRUE;
|
||||
} else switch (arg.type){
|
||||
case DBR_STS_STRING:
|
||||
case DBR_STS_SHORT:
|
||||
case DBR_STS_FLOAT:
|
||||
case DBR_STS_ENUM:
|
||||
case DBR_STS_CHAR:
|
||||
case DBR_STS_LONG:
|
||||
case DBR_STS_DOUBLE:
|
||||
case DBR_TIME_STRING:
|
||||
case DBR_TIME_SHORT:
|
||||
case DBR_TIME_FLOAT:
|
||||
case DBR_TIME_ENUM:
|
||||
case DBR_TIME_CHAR:
|
||||
case DBR_TIME_LONG:
|
||||
case DBR_TIME_DOUBLE:
|
||||
memcpy(pca->pgetNative,dbr_value_ptr(arg.dbr,arg.type),size);
|
||||
pca->gotInNative = TRUE;
|
||||
break;
|
||||
@@ -474,7 +487,9 @@ static void eventCallback(struct event_handler_args arg)
|
||||
errMessage(-1,"dbCa: eventCallback Logic Error\n");
|
||||
break;
|
||||
}
|
||||
pca->sevr=(unsigned short)((struct dbr_sts_double *)arg.dbr)->severity;
|
||||
pdbr_time_double = (struct dbr_time_double *)arg.dbr;
|
||||
pca->sevr = (unsigned short)pdbr_time_double->severity;
|
||||
memcpy(&pca->timeStamp,&pdbr_time_double->stamp,sizeof(TS_STAMP));
|
||||
if(precord) {
|
||||
struct pv_link *ppv_link = &(plink->value.pv_link);
|
||||
|
||||
@@ -679,7 +694,7 @@ void dbCaTask()
|
||||
element_size = dbr_value_size[ca_field_type(pca->chid)];
|
||||
pca->pgetNative = dbCalloc(pca->nelements,element_size);
|
||||
status = ca_add_array_event(
|
||||
ca_field_type(pca->chid)+DBR_STS_STRING,
|
||||
ca_field_type(pca->chid)+DBR_TIME_STRING,
|
||||
ca_element_count(pca->chid),
|
||||
pca->chid, eventCallback,pca,0.0,0.0,0.0,
|
||||
0);
|
||||
@@ -689,7 +704,7 @@ void dbCaTask()
|
||||
}
|
||||
if(link_action&CA_MONITOR_STRING) {
|
||||
pca->pgetString = dbCalloc(MAX_STRING_SIZE,sizeof(char));
|
||||
status = ca_add_array_event(DBR_STS_STRING,1,
|
||||
status = ca_add_array_event(DBR_TIME_STRING,1,
|
||||
pca->chid, eventCallback,pca,0.0,0.0,0.0,
|
||||
0);
|
||||
if(status!=ECA_NORMAL)
|
||||
|
||||
@@ -57,6 +57,7 @@ typedef struct caLink
|
||||
short dbrType;
|
||||
short link_action;
|
||||
unsigned short sevr;
|
||||
TS_STAMP timeStamp;
|
||||
char gotInNative;
|
||||
char gotOutNative;
|
||||
char gotInString;
|
||||
|
||||
+45
-4
@@ -46,7 +46,7 @@
|
||||
/* Global Database Test Routines - All can be invoked via vxWorks shell*/
|
||||
long dba(char*pname); /*dbAddr info */
|
||||
long dbel(char*pname); /*CA event list */
|
||||
long dbl(char *precordTypename,char *filename); /*list records*/
|
||||
long dbl(char *precordTypename,char *filename,char *fields); /*list records*/
|
||||
long dbnr(int verbose); /*list number of records of each type*/
|
||||
long dbgrep(char *pmask); /*list records with mask*/
|
||||
long dbgf(char *pname); /*get field value*/
|
||||
@@ -153,13 +153,39 @@ long dbel(char*pname)
|
||||
return(0);
|
||||
}
|
||||
|
||||
long dbl(char *precordTypename,char *filename)
|
||||
long dbl(char *precordTypename,char *filename,char *fields)
|
||||
{
|
||||
DBENTRY dbentry;
|
||||
DBENTRY *pdbentry=&dbentry;
|
||||
long status;
|
||||
FILE *stream = NULL;
|
||||
int nfields = 0;
|
||||
int ifield;
|
||||
char *fieldnames = 0;
|
||||
char **papfields = 0;
|
||||
|
||||
if(fields) {
|
||||
char *pnext;
|
||||
|
||||
fieldnames = calloc(strlen(fields) + 1,sizeof(char));
|
||||
strcpy(fieldnames,fields);
|
||||
nfields=1;
|
||||
pnext=fieldnames;
|
||||
while(*pnext && (pnext = strchr(pnext,' '))) {
|
||||
nfields++;
|
||||
while(*pnext == ' ') pnext++;
|
||||
}
|
||||
papfields = dbCalloc(nfields,sizeof(char *));
|
||||
pnext = fieldnames;
|
||||
for(ifield=0; ifield<nfields; ifield++) {
|
||||
papfields[ifield] = pnext;
|
||||
if(ifield<nfields-1) {
|
||||
pnext = strchr(pnext,' ');
|
||||
*pnext++ = 0;
|
||||
while(*pnext == ' ') pnext++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(filename && strlen(filename)) {
|
||||
int fd;
|
||||
|
||||
@@ -186,13 +212,28 @@ long dbl(char *precordTypename,char *filename)
|
||||
while(!status) {
|
||||
status = dbFirstRecord(pdbentry);
|
||||
while(!status) {
|
||||
if(stream) fprintf(stream,"%s\n",dbGetRecordName(pdbentry));
|
||||
else printf("%s\n",dbGetRecordName(pdbentry));
|
||||
if(stream) fprintf(stream,"%s",dbGetRecordName(pdbentry));
|
||||
else printf("%s",dbGetRecordName(pdbentry));
|
||||
for(ifield=0; ifield<nfields; ifield++) {
|
||||
char *pvalue;
|
||||
status = dbFindField(pdbentry,papfields[ifield]);
|
||||
if(status) continue;
|
||||
pvalue = dbGetString(pdbentry);
|
||||
if(pvalue) {
|
||||
if(stream) fprintf(stream,",\"%s\"",pvalue);
|
||||
else printf(",\"%s\"",pvalue);
|
||||
}
|
||||
}
|
||||
if(stream) fprintf(stream,"\n"); else printf("\n");
|
||||
status = dbNextRecord(pdbentry);
|
||||
}
|
||||
if(precordTypename) break;
|
||||
status = dbNextRecordType(pdbentry);
|
||||
}
|
||||
if(nfields>0) {
|
||||
free((void *)papfields);
|
||||
free((void *)fieldnames);
|
||||
}
|
||||
dbFinishEntry(pdbentry);
|
||||
if(stream) fclose(stream);
|
||||
return(0);
|
||||
|
||||
Reference in New Issue
Block a user