diff --git a/src/ca/CAref.html b/src/ca/CAref.html index 2b1e58a1c..eb1bae512 100644 --- a/src/ca/CAref.html +++ b/src/ca/CAref.html @@ -122,6 +122,7 @@ height="31" width="88">

  • flush outstanding requests to the server
  • replace the default exception handler
  • +
  • dump dbr type to standard out
  • Function Call Interface Index

    @@ -136,6 +137,7 @@ height="31" width="88">

  • ca_context_destroy
  • ca_create_channel
  • ca_current_context
  • +
  • ca_dump_dbr()
  • ca_element_count
  • ca_field_type
  • ca_flush_io
  • @@ -2939,6 +2941,25 @@ preemptively from more than one thread.

    ca_current_context()

    +

    ca_dump_dbr()

    + +

    void ca_dump_dbr ( chtype TYPE, unsigned COUNT, const +void * PDBR );

    + +

    Description

    + +

    Dumps the specified dbr data type to standard out.

    + +

    Arguments

    +
    +
    TYPE
    +
    The data type (from the DBR_XXX set described in db_access.h).
    +
    COUNT
    +
    The array element count
    +
    PDBR
    +
    A pointer to data of the specified count and number.
    +
    +

    Return Codes

    ECA_NORMAL
    diff --git a/src/ca/cadef.h b/src/ca/cadef.h index b3ff33c6d..135353a81 100644 --- a/src/ca/cadef.h +++ b/src/ca/cadef.h @@ -889,6 +889,9 @@ ca_sg_array_put (gid, type, 1u, chan, pValue) */ epicsShareFunc int epicsShareAPI ca_sg_stat (CA_SYNC_GID gid); +epicsShareFunc void epicsShareAPI ca_dump_dbr (chtype type, unsigned count, const void * pbuffer); + + /* * ca_v42_ok() * diff --git a/src/ca/test_event.cpp b/src/ca/test_event.cpp index f0f9ab157..f198db14e 100644 --- a/src/ca/test_event.cpp +++ b/src/ca/test_event.cpp @@ -9,9 +9,9 @@ \*************************************************************************/ /* * - * T E S T _ E V E N T . C - * Author: Jeffrey O. Hill - * simple stub for testing monitors + * T E S T _ E V E N T . C + * Author: Jeffrey O. Hill + * simple stub for testing monitors */ #define epicsExportSharedSymbols @@ -19,57 +19,568 @@ extern "C" void epicsShareAPI ca_test_event ( struct event_handler_args args ) { - printf ( "CAC: ~~~### in test event for [%s] ###~~~\n", ca_name(args.chid) ); - printf ( "CAC: User argument\t%p\n", args.usr); - printf ( "CAC: Native channel data type\t%d\n", ca_field_type(args.chid) ); - printf ( "CAC: Monitor data type\t%ld\n", args.type ); - printf ( "CAC: CA Status \"%s\"\n", ca_message(args.status) ); + chtype nativeType = ca_field_type ( args.chid ); + const char * pNativeTypeName = ""; + if ( VALID_DB_REQ ( nativeType ) ) { + pNativeTypeName = dbr_text[nativeType]; + } + else { + if ( nativeType == TYPENOTCONN ) { + pNativeTypeName = ""; + } + } - if ( !args.dbr || !(CA_M_SUCCESS&args.status) ){ - return; - } + printf ( "ca_test_event() for channel \"%s\" with native type %s\n", + ca_name(args.chid), pNativeTypeName ); - switch ( args.type ) { - case DBR_STRING: - printf ( "CAC: Value:\t<%s>\n", (char *) args.dbr ); - break; - case DBR_CHAR: - printf ( "CAC: Value:\t<%d>\n", *(dbr_char_t *) args.dbr ); - break; -#if DBR_INT != DBR_SHORT - case DBR_INT: -#endif - case DBR_SHORT: - case DBR_ENUM: - printf ( "CAC: Value:\t<%d>\n", *(dbr_short_t *) args.dbr ); - break; - case DBR_LONG: - printf ( "CAC: Value:\t<%d>\n", *(dbr_long_t *)args.dbr ); - break; - case DBR_FLOAT: - printf ( "CAC: Value:\t<%f>\n", *(dbr_float_t *)args.dbr ); - break; - case DBR_DOUBLE: - printf ( "CAC: Value:\t<%f>\n", *(dbr_double_t *)args.dbr ); - break; - case DBR_STS_STRING: - printf ( "CAC: Value:\t<%s>\n", ((struct dbr_sts_string *)args.dbr)->value ); - break; - case DBR_STS_INT: - printf ( "CAC: Value:\t<%d>\n", ((struct dbr_sts_int *)args.dbr)->value ); - break; - case DBR_STS_FLOAT: - printf ( "CAC: Value:\t<%f>\n",((struct dbr_sts_float *)args.dbr)->value ); - break; - case DBR_STS_ENUM: - printf ( "CAC: Value:\t<%d>\n", ((struct dbr_sts_enum *)args.dbr)->value ); - break; - case DBR_GR_FLOAT: - printf ( "CAC: Value:\t<%f>\n", ((struct dbr_gr_float *)args.dbr)->value ); - break; - default: - printf ( "CAC: Sorry test_event does not handle data type %ld yet\n", - args.type ); - } + if ( ! ( CA_M_SUCCESS & args.status ) ) { + printf ( "Invalid CA status \"%s\"\n", ca_message ( args.status ) ); + return; + } + + if ( args.dbr ) { + ca_dump_dbr ( args.type, args.count, args.dbr ); + } +} + +/* + * ca_dump_dbr() + * dump the specified dbr type to stdout + */ +extern "C" void epicsShareAPI ca_dump_dbr ( + chtype type, unsigned count, const void * pbuffer ) +{ + unsigned i; + char tsString[50]; + + if ( INVALID_DB_REQ ( type ) ) { + printf ( "bad DBR type %ld\n", type ); + } + + printf ( "%s\t", dbr_text[type] ); + + switch ( type ) { + case DBR_STRING: + { + dbr_string_t *pString = (dbr_string_t *) pbuffer; + + for(i=0; istatus,pvalue->severity); + printf("\tValue: %s",pvalue->value); + break; + } + case DBR_STS_ENUM: + { + struct dbr_sts_enum *pvalue + = (struct dbr_sts_enum *)pbuffer; + dbr_enum_t *pEnum = &pvalue->value; + printf("%2d %2d",pvalue->status,pvalue->severity); + if(count==1) printf("\tValue: "); + for (i = 0; i < count; i++,pEnum++){ + if(count!=1 && (i%10 == 0)) printf("\n"); + printf("%u ",*pEnum); + } + break; + } + case DBR_STS_SHORT: + { + struct dbr_sts_short *pvalue + = (struct dbr_sts_short *)pbuffer; + dbr_short_t *pshort = &pvalue->value; + printf("%2d %2d",pvalue->status,pvalue->severity); + if(count==1) printf("\tValue: "); + for (i = 0; i < count; i++,pshort++){ + if(count!=1 && (i%10 == 0)) printf("\n"); + printf("%u ",*pshort); + } + break; + } + case DBR_STS_FLOAT: + { + struct dbr_sts_float *pvalue + = (struct dbr_sts_float *)pbuffer; + dbr_float_t *pfloat = &pvalue->value; + printf("%2d %2d",pvalue->status,pvalue->severity); + if(count==1) printf("\tValue: "); + for (i = 0; i < count; i++,pfloat++){ + if(count!=1 && (i%10 == 0)) printf("\n"); + printf("%6.4f ",*pfloat); + } + break; + } + case DBR_STS_CHAR: + { + struct dbr_sts_char *pvalue + = (struct dbr_sts_char *)pbuffer; + dbr_char_t *pchar = &pvalue->value; + + printf("%2d %2d",pvalue->status,pvalue->severity); + if(count==1) printf("\tValue: "); + for (i = 0; i < count; i++,pchar++){ + if(count!=1 && (i%10 == 0)) printf("\n"); + printf("%u ", *pchar); + } + break; + } + case DBR_STS_LONG: + { + struct dbr_sts_long *pvalue + = (struct dbr_sts_long *)pbuffer; + dbr_long_t *plong = &pvalue->value; + printf("%2d %2d",pvalue->status,pvalue->severity); + if(count==1) printf("\tValue: "); + for (i = 0; i < count; i++,plong++){ + if(count!=1 && (i%10 == 0)) printf("\n"); + printf("%d ",*plong); + } + break; + } + case DBR_STS_DOUBLE: + { + struct dbr_sts_double *pvalue + = (struct dbr_sts_double *)pbuffer; + dbr_double_t *pdouble = &pvalue->value; + printf("%2d %2d",pvalue->status,pvalue->severity); + if(count==1) printf("\tValue: "); + for (i = 0; i < count; i++,pdouble++){ + if(count!=1 && (i%10 == 0)) printf("\n"); + printf("%6.4f ",(float)(*pdouble)); + } + break; + } + case DBR_TIME_STRING: + { + struct dbr_time_string *pvalue + = (struct dbr_time_string *) pbuffer; + + epicsTimeToStrftime(tsString,sizeof(tsString), + "%Y/%m/%d %H:%M:%S.%06f",&pvalue->stamp); + printf("%2d %2d",pvalue->status,pvalue->severity); + printf("\tTimeStamp: %s",tsString); + printf("\tValue: "); + printf("%s",pvalue->value); + break; + } + case DBR_TIME_ENUM: + { + struct dbr_time_enum *pvalue + = (struct dbr_time_enum *)pbuffer; + dbr_enum_t *pshort = &pvalue->value; + + epicsTimeToStrftime(tsString,sizeof(tsString), + "%Y/%m/%d %H:%M:%S.%06f",&pvalue->stamp); + printf("%2d %2d",pvalue->status,pvalue->severity); + printf("\tTimeStamp: %s",tsString); + if(count==1) printf("\tValue: "); + for (i = 0; i < count; i++,pshort++){ + if(count!=1 && (i%10 == 0)) printf("\n"); + printf("%d ",*pshort); + } + break; + } + case DBR_TIME_SHORT: + { + struct dbr_time_short *pvalue + = (struct dbr_time_short *)pbuffer; + dbr_short_t *pshort = &pvalue->value; + epicsTimeToStrftime(tsString,sizeof(tsString), + "%Y/%m/%d %H:%M:%S.%06f",&pvalue->stamp); + printf("%2d %2d", + pvalue->status, + pvalue->severity); + printf("\tTimeStamp: %s",tsString); + if(count==1) printf("\tValue: "); + for (i = 0; i < count; i++,pshort++){ + if(count!=1 && (i%10 == 0)) printf("\n"); + printf("%d ",*pshort); + } + break; + } + case DBR_TIME_FLOAT: + { + struct dbr_time_float *pvalue + = (struct dbr_time_float *)pbuffer; + dbr_float_t *pfloat = &pvalue->value; + + epicsTimeToStrftime(tsString,sizeof(tsString), + "%Y/%m/%d %H:%M:%S.%06f",&pvalue->stamp); + printf("%2d %2d",pvalue->status,pvalue->severity); + printf("\tTimeStamp: %s",tsString); + if(count==1) printf("\tValue: "); + for (i = 0; i < count; i++,pfloat++){ + if(count!=1 && (i%10 == 0)) printf("\n"); + printf("%6.4f ",*pfloat); + } + break; + } + case DBR_TIME_CHAR: + { + struct dbr_time_char *pvalue + = (struct dbr_time_char *)pbuffer; + dbr_char_t *pchar = &pvalue->value; + + epicsTimeToStrftime(tsString,sizeof(tsString), + "%Y/%m/%d %H:%M:%S.%06f",&pvalue->stamp); + printf("%2d %2d",pvalue->status,pvalue->severity); + printf("\tTimeStamp: %s",tsString); + if(count==1) printf("\tValue: "); + for (i = 0; i < count; i++,pchar++){ + if(count!=1 && (i%10 == 0)) printf("\n"); + printf("%d ",(short)(*pchar)); + } + break; + } + case DBR_TIME_LONG: + { + struct dbr_time_long *pvalue + = (struct dbr_time_long *)pbuffer; + dbr_long_t *plong = &pvalue->value; + + epicsTimeToStrftime(tsString,sizeof(tsString), + "%Y/%m/%d %H:%M:%S.%06f",&pvalue->stamp); + printf("%2d %2d",pvalue->status,pvalue->severity); + printf("\tTimeStamp: %s",tsString); + if(count==1) printf("\tValue: "); + for (i = 0; i < count; i++,plong++){ + if(count!=1 && (i%10 == 0)) printf("\n"); + printf("%d ",*plong); + } + break; + } + case DBR_TIME_DOUBLE: + { + struct dbr_time_double *pvalue + = (struct dbr_time_double *)pbuffer; + dbr_double_t *pdouble = &pvalue->value; + + epicsTimeToStrftime(tsString,sizeof(tsString), + "%Y/%m/%d %H:%M:%S.%06f",&pvalue->stamp); + printf("%2d %2d",pvalue->status,pvalue->severity); + printf("\tTimeStamp: %s",tsString); + if(count==1) printf("\tValue: "); + for (i = 0; i < count; i++,pdouble++){ + if(count!=1 && (i%10 == 0)) printf("\n"); + printf("%6.4f ",(float)(*pdouble)); + } + break; + } + case DBR_GR_SHORT: + { + struct dbr_gr_short *pvalue + = (struct dbr_gr_short *)pbuffer; + dbr_short_t *pshort = &pvalue->value; + printf("%2d %2d %.8s",pvalue->status,pvalue->severity, + pvalue->units); + printf("\n\t%8d %8d %8d %8d %8d %8d", + pvalue->upper_disp_limit,pvalue->lower_disp_limit, + pvalue->upper_alarm_limit,pvalue->upper_warning_limit, + pvalue->lower_warning_limit,pvalue->lower_alarm_limit); + if(count==1) printf("\tValue: "); + for (i = 0; i < count; i++,pshort++){ + if(count!=1 && (i%10 == 0)) printf("\n"); + printf("%d ",*pshort); + } + break; + } + case DBR_GR_FLOAT: + { + struct dbr_gr_float *pvalue + = (struct dbr_gr_float *)pbuffer; + dbr_float_t *pfloat = &pvalue->value; + printf("%2d %2d %.8s",pvalue->status,pvalue->severity, + pvalue->units); + printf(" %3d\n\t%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f", + pvalue->precision, + pvalue->upper_disp_limit,pvalue->lower_disp_limit, + pvalue->upper_alarm_limit,pvalue->upper_warning_limit, + pvalue->lower_warning_limit,pvalue->lower_alarm_limit); + if(count==1) printf("\tValue: "); + for (i = 0; i < count; i++,pfloat++){ + if(count!=1 && (i%10 == 0)) printf("\n"); + printf("%6.4f ",*pfloat); + } + break; + } + case DBR_GR_ENUM: + { + struct dbr_gr_enum *pvalue + = (struct dbr_gr_enum *)pbuffer; + printf("%2d %2d",pvalue->status, + pvalue->severity); + printf("\tValue: %d",pvalue->value); + if(pvalue->no_str>0) { + printf("\n\t%3d",pvalue->no_str); + for (i = 0; i < (unsigned) pvalue->no_str; i++) + printf("\n\t%.26s",pvalue->strs[i]); + } + break; + } + case DBR_CTRL_ENUM: + { + struct dbr_ctrl_enum *pvalue + = (struct dbr_ctrl_enum *)pbuffer; + printf("%2d %2d",pvalue->status, + pvalue->severity); + printf("\tValue: %d",pvalue->value); + if(pvalue->no_str>0) { + printf("\n\t%3d",pvalue->no_str); + for (i = 0; i < (unsigned) pvalue->no_str; i++) + printf("\n\t%.26s",pvalue->strs[i]); + } + break; + } + case DBR_GR_CHAR: + { + struct dbr_gr_char *pvalue + = (struct dbr_gr_char *)pbuffer; + dbr_char_t *pchar = &pvalue->value; + printf("%2d %2d %.8s",pvalue->status,pvalue->severity, + pvalue->units); + printf("\n\t%8d %8d %8d %8d %8d %8d", + pvalue->upper_disp_limit,pvalue->lower_disp_limit, + pvalue->upper_alarm_limit,pvalue->upper_warning_limit, + pvalue->lower_warning_limit,pvalue->lower_alarm_limit); + if(count==1) printf("\tValue: "); + for (i = 0; i < count; i++,pchar++){ + if(count!=1 && (i%10 == 0)) printf("\n"); + printf("%u ",*pchar); + } + break; + } + case DBR_GR_LONG: + { + struct dbr_gr_long *pvalue + = (struct dbr_gr_long *)pbuffer; + dbr_long_t *plong = &pvalue->value; + printf("%2d %2d %.8s",pvalue->status,pvalue->severity, + pvalue->units); + printf("\n\t%8d %8d %8d %8d %8d %8d", + pvalue->upper_disp_limit,pvalue->lower_disp_limit, + pvalue->upper_alarm_limit,pvalue->upper_warning_limit, + pvalue->lower_warning_limit,pvalue->lower_alarm_limit); + if(count==1) printf("\tValue: "); + for (i = 0; i < count; i++,plong++){ + if(count!=1 && (i%10 == 0)) printf("\n"); + printf("%d ",*plong); + } + break; + } + case DBR_GR_DOUBLE: + { + struct dbr_gr_double *pvalue + = (struct dbr_gr_double *)pbuffer; + dbr_double_t *pdouble = &pvalue->value; + printf("%2d %2d %.8s",pvalue->status,pvalue->severity, + pvalue->units); + printf(" %3d\n\t%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f", + pvalue->precision, + (float)(pvalue->upper_disp_limit), + (float)(pvalue->lower_disp_limit), + (float)(pvalue->upper_alarm_limit), + (float)(pvalue->upper_warning_limit), + (float)(pvalue->lower_warning_limit), + (float)(pvalue->lower_alarm_limit)); + if(count==1) printf("\tValue: "); + for (i = 0; i < count; i++,pdouble++){ + if(count!=1 && (i%10 == 0)) printf("\n"); + printf("%6.4f ",(float)(*pdouble)); + } + break; + } + case DBR_CTRL_SHORT: + { + struct dbr_ctrl_short *pvalue + = (struct dbr_ctrl_short *)pbuffer; + dbr_short_t *pshort = &pvalue->value; + printf("%2d %2d %.8s",pvalue->status,pvalue->severity, + pvalue->units); + printf("\n\t%8d %8d %8d %8d %8d %8d", + pvalue->upper_disp_limit,pvalue->lower_disp_limit, + pvalue->upper_alarm_limit,pvalue->upper_warning_limit, + pvalue->lower_warning_limit,pvalue->lower_alarm_limit); + printf(" %8d %8d", + pvalue->upper_ctrl_limit,pvalue->lower_ctrl_limit); + if(count==1) printf("\tValue: "); + for (i = 0; i < count; i++,pshort++){ + if(count!=1 && (i%10 == 0)) printf("\n"); + printf("%d ",*pshort); + } + break; + } + case DBR_CTRL_FLOAT: + { + struct dbr_ctrl_float *pvalue + = (struct dbr_ctrl_float *)pbuffer; + dbr_float_t *pfloat = &pvalue->value; + printf("%2d %2d %.8s",pvalue->status,pvalue->severity, + pvalue->units); + printf(" %3d\n\t%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f", + pvalue->precision, + pvalue->upper_disp_limit,pvalue->lower_disp_limit, + pvalue->upper_alarm_limit,pvalue->upper_warning_limit, + pvalue->lower_warning_limit,pvalue->lower_alarm_limit); + printf(" %8.3f %8.3f", + pvalue->upper_ctrl_limit,pvalue->lower_ctrl_limit); + if(count==1) printf("\tValue: "); + for (i = 0; i < count; i++,pfloat++){ + if(count!=1 && (i%10 == 0)) printf("\n"); + printf("%6.4f ",*pfloat); + } + break; + } + case DBR_CTRL_CHAR: + { + struct dbr_ctrl_char *pvalue + = (struct dbr_ctrl_char *)pbuffer; + dbr_char_t *pchar = &pvalue->value; + printf("%2d %2d %.8s",pvalue->status,pvalue->severity, + pvalue->units); + printf("\n\t%8d %8d %8d %8d %8d %8d", + pvalue->upper_disp_limit,pvalue->lower_disp_limit, + pvalue->upper_alarm_limit,pvalue->upper_warning_limit, + pvalue->lower_warning_limit,pvalue->lower_alarm_limit); + printf(" %8d %8d", + pvalue->upper_ctrl_limit,pvalue->lower_ctrl_limit); + if(count==1) printf("\tValue: "); + for (i = 0; i < count; i++,pchar++){ + if(count!=1 && (i%10 == 0)) printf("\n"); + printf("%4d ",(short)(*pchar)); + } + break; + } + case DBR_CTRL_LONG: + { + struct dbr_ctrl_long *pvalue + = (struct dbr_ctrl_long *)pbuffer; + dbr_long_t *plong = &pvalue->value; + printf("%2d %2d %.8s",pvalue->status,pvalue->severity, + pvalue->units); + printf("\n\t%8d %8d %8d %8d %8d %8d", + pvalue->upper_disp_limit,pvalue->lower_disp_limit, + pvalue->upper_alarm_limit,pvalue->upper_warning_limit, + pvalue->lower_warning_limit,pvalue->lower_alarm_limit); + printf(" %8d %8d", + pvalue->upper_ctrl_limit,pvalue->lower_ctrl_limit); + if(count==1) printf("\tValue: "); + for (i = 0; i < count; i++,plong++){ + if(count!=1 && (i%10 == 0)) printf("\n"); + printf("%d ",*plong); + } + break; + } + case DBR_CTRL_DOUBLE: + { + struct dbr_ctrl_double *pvalue + = (struct dbr_ctrl_double *)pbuffer; + dbr_double_t *pdouble = &pvalue->value; + printf("%2d %2d %.8s",pvalue->status,pvalue->severity, + pvalue->units); + printf(" %3d\n\t%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f", + pvalue->precision, + (float)(pvalue->upper_disp_limit), + (float)(pvalue->lower_disp_limit), + (float)(pvalue->upper_alarm_limit), + (float)(pvalue->upper_warning_limit), + (float)(pvalue->lower_warning_limit), + (float)(pvalue->lower_alarm_limit)); + printf(" %8.3f %8.3f", + (float)(pvalue->upper_ctrl_limit), + (float)(pvalue->lower_ctrl_limit)); + if(count==1) printf("\tValue: "); + for (i = 0; i < count; i++,pdouble++){ + if(count!=1 && (i%10 == 0)) printf("\n"); + printf("%6.6f ",(float)(*pdouble)); + } + break; + } + case DBR_STSACK_STRING: + { + struct dbr_stsack_string *pvalue + = (struct dbr_stsack_string *)pbuffer; + printf("%2d %2d",pvalue->status,pvalue->severity); + printf(" %2d %2d",pvalue->ackt,pvalue->acks); + printf(" %s",pvalue->value); + break; + } + case DBR_CLASS_NAME: + { + dbr_class_name_t * pvalue = + ( dbr_class_name_t * ) pbuffer; + printf ( "%s", *pvalue ); + break; + } + default: + printf ( + "unsupported by ca_dbrDump()" ); + break; + } + printf("\n"); } diff --git a/src/db/db_test.c b/src/db/db_test.c index 5abba820e..c2ae1242b 100644 --- a/src/db/db_test.c +++ b/src/db/db_test.c @@ -13,21 +13,18 @@ * Author: Bob Dalesio * Date: 4/15/88 */ -#include -#include -#include -#include +#include +#include +#include +#include -#include "dbDefs.h" -#include "errlog.h" -#include "db_access.h" +#include "dbDefs.h" +#include "errlog.h" +#include "cadef.h" #define epicsExportSharedSymbols -#include "db_access_routines.h" -#include "dbNotify.h" -#include "db_test.h" - -/* function declarations */ -static void print_returned(); +#include "db_access_routines.h" +#include "dbNotify.h" +#include "db_test.h" #define MAX_ELEMS 10 @@ -70,7 +67,7 @@ int epicsShareAPI gft(char *pname) if(db_get_field(paddr,i,tgf_buffer,number_elements,NULL)<0) printf("\t%s Failed\n",dbr_text[i]); else - print_returned(i,tgf_buffer,number_elements); + ca_dump_dbr (i,number_elements,tgf_buffer); } return(0); } @@ -114,7 +111,7 @@ int epicsShareAPI pft(char *pname,char *pvalue) printf(" No Elements: %ld\n",addr.no_elements); if (db_put_field(paddr,DBR_STRING,pvalue,1) < 0) printf("\n\t failed "); if (db_get_field(paddr,DBR_STRING,buffer,1,NULL) < 0) printf("\n\tfailed"); - else print_returned(DBR_STRING,buffer,1); + else ca_dump_dbr(DBR_STRING,1,buffer); if(addr.dbr_field_type<=DBF_STRING || addr.dbr_field_type==DBF_ENUM) return(0); if(sscanf(pvalue,"%hd",&shortvalue)==1) { @@ -122,21 +119,21 @@ int epicsShareAPI pft(char *pname,char *pvalue) printf("\n\t SHORT failed "); if (db_get_field(paddr,DBR_SHORT,buffer,1,NULL) < 0) printf("\n\t SHORT GET failed"); - else print_returned(DBR_SHORT,buffer,1); + else ca_dump_dbr(DBR_SHORT,1,buffer); } if(sscanf(pvalue,"%ld",&longvalue)==1) { if (db_put_field(paddr,DBR_LONG,&longvalue,1) < 0) printf("\n\t LONG failed "); if (db_get_field(paddr,DBR_LONG,buffer,1,NULL) < 0) printf("\n\t LONG GET failed"); - else print_returned(DBR_LONG,buffer,1); + else ca_dump_dbr(DBR_LONG,1,buffer); } if(sscanf(pvalue,"%f",&floatvalue)==1) { if (db_put_field(paddr,DBR_FLOAT,&floatvalue,1) < 0) printf("\n\t FLOAT failed "); if (db_get_field(paddr,DBR_FLOAT,buffer,1,NULL) < 0) printf("\n\t FLOAT GET failed"); - else print_returned(DBR_FLOAT,buffer,1); + else ca_dump_dbr(DBR_FLOAT,1,buffer); } if(sscanf(pvalue,"%f",&floatvalue)==1) { doublevalue=floatvalue; @@ -144,7 +141,7 @@ int epicsShareAPI pft(char *pname,char *pvalue) printf("\n\t DOUBLE failed "); if (db_get_field(paddr,DBR_DOUBLE,buffer,1,NULL) < 0) printf("\n\t DOUBLE GET failed"); - else print_returned(DBR_DOUBLE,buffer,1); + else ca_dump_dbr(DBR_DOUBLE,1,buffer); } if(sscanf(pvalue,"%hd",&shortvalue)==1) { charvalue=(unsigned char)shortvalue; @@ -152,25 +149,26 @@ int epicsShareAPI pft(char *pname,char *pvalue) printf("\n\t CHAR failed "); if (db_get_field(paddr,DBR_CHAR,buffer,1,NULL) < 0) printf("\n\t CHAR GET failed"); - else print_returned(DBR_CHAR,buffer,1); + else ca_dump_dbr(DBR_CHAR,1,buffer); } if(sscanf(pvalue,"%hd",&shortvalue)==1) { if (db_put_field(paddr,DBR_ENUM,&shortvalue,1) < 0) printf("\n\t ENUM failed "); if (db_get_field(paddr,DBR_ENUM,buffer,1,NULL) < 0) printf("\n\t ENUM GET failed"); - else print_returned(DBR_ENUM,buffer,1); + else ca_dump_dbr(DBR_ENUM,1,buffer); } printf("\n"); return(0); } - + +#if 0 /* * PRINT_RETURNED * * print out the values in a database access interface structure */ -static void print_returned(type,pbuffer,count) +static void print_returned(type,count,pbuffer) short type; char *pbuffer; short count; @@ -633,7 +631,8 @@ static void print_returned(type,pbuffer,count) } printf("\n"); } - +#endif + static void tpnCallback(putNotify *ppn) { struct dbAddr *pdbaddr = (struct dbAddr *)ppn->paddr; diff --git a/src/util/ca_test.c b/src/util/ca_test.c index 9d434051a..0dfefc49f 100644 --- a/src/util/ca_test.c +++ b/src/util/ca_test.c @@ -33,9 +33,8 @@ LOCAL int cagft(char *pname); LOCAL void printit(struct event_handler_args args); LOCAL int capft(char *pname, char *pvalue); LOCAL void verify_value(chid chan_id, chtype type); -LOCAL void print_returned(chtype type, const void *pbuffer, unsigned count); -static unsigned long outstanding; +static unsigned long outstanding; /* @@ -101,14 +100,23 @@ LOCAL int cagft(char *pname) /* * fetch as each type */ - for(i=0; i<=DBR_CTRL_DOUBLE; i++){ + for(i=0; i<=LAST_BUFFER_TYPE; i++){ if(ca_field_type(chan_id)==DBR_STRING) { if( (i!=DBR_STRING) && (i!=DBR_STS_STRING) && (i!=DBR_TIME_STRING) && (i!=DBR_GR_STRING) - && (i!=DBR_CTRL_STRING)) continue; - } + && (i!=DBR_CTRL_STRING)) { + continue; + } + } + /* ignore write only types */ + if ( + i == DBR_PUT_ACKT || + i == DBR_PUT_ACKS ) { + continue; + } + status = ca_array_get_callback( i, ca_element_count(chan_id), @@ -149,25 +157,18 @@ LOCAL int cagft(char *pname) /* * PRINTIT() */ -LOCAL void printit(struct event_handler_args args) +LOCAL void printit ( struct event_handler_args args ) { - if (args.status == ECA_NORMAL) { - print_returned( - args.type, - args.dbr, - args.count); + if ( args.status == ECA_NORMAL ) { + ca_dump_dbr ( args.type, args.count, args.dbr ); } else { - printf ("%s: err resp to get cb was \"%s\"\n", - __FILE__, ca_message(args.status)); + printf ( "%s\t%s\n", dbr_text[args.type], ca_message(args.status) ); } outstanding--; } - - - /* * capft * @@ -326,511 +327,3 @@ LOCAL void verify_value(chid chan_id, chtype type) outstanding++; } - - -/* - * PRINT_RETURNED - * - * print out the values in a database access interface structure - * - * switches over the range of CA data types and reports the value - */ -LOCAL void print_returned(chtype type, const void *pbuffer, unsigned count) -{ - unsigned i; - char tsString[50]; - - printf("%s\t",dbr_text[type]); - switch(type){ - case (DBR_STRING): - { - dbr_string_t *pString = (dbr_string_t *) pbuffer; - - for(i=0; istatus,pvalue->severity); - printf("\tValue: %s",pvalue->value); - break; - } - case (DBR_STS_ENUM): - { - struct dbr_sts_enum *pvalue - = (struct dbr_sts_enum *)pbuffer; - dbr_enum_t *pEnum = &pvalue->value; - printf("%2d %2d",pvalue->status,pvalue->severity); - if(count==1) printf("\tValue: "); - for (i = 0; i < count; i++,pEnum++){ - if(count!=1 && (i%10 == 0)) printf("\n"); - printf("%u ",*pEnum); - } - break; - } - case (DBR_STS_SHORT): - { - struct dbr_sts_short *pvalue - = (struct dbr_sts_short *)pbuffer; - dbr_short_t *pshort = &pvalue->value; - printf("%2d %2d",pvalue->status,pvalue->severity); - if(count==1) printf("\tValue: "); - for (i = 0; i < count; i++,pshort++){ - if(count!=1 && (i%10 == 0)) printf("\n"); - printf("%u ",*pshort); - } - break; - } - case (DBR_STS_FLOAT): - { - struct dbr_sts_float *pvalue - = (struct dbr_sts_float *)pbuffer; - dbr_float_t *pfloat = &pvalue->value; - printf("%2d %2d",pvalue->status,pvalue->severity); - if(count==1) printf("\tValue: "); - for (i = 0; i < count; i++,pfloat++){ - if(count!=1 && (i%10 == 0)) printf("\n"); - printf("%6.4f ",*pfloat); - } - break; - } - case (DBR_STS_CHAR): - { - struct dbr_sts_char *pvalue - = (struct dbr_sts_char *)pbuffer; - dbr_char_t *pchar = &pvalue->value; - - printf("%2d %2d",pvalue->status,pvalue->severity); - if(count==1) printf("\tValue: "); - for (i = 0; i < count; i++,pchar++){ - if(count!=1 && (i%10 == 0)) printf("\n"); - printf("%u ", *pchar); - } - break; - } - case (DBR_STS_LONG): - { - struct dbr_sts_long *pvalue - = (struct dbr_sts_long *)pbuffer; - dbr_long_t *plong = &pvalue->value; - printf("%2d %2d",pvalue->status,pvalue->severity); - if(count==1) printf("\tValue: "); - for (i = 0; i < count; i++,plong++){ - if(count!=1 && (i%10 == 0)) printf("\n"); - printf("%d ",*plong); - } - break; - } - case (DBR_STS_DOUBLE): - { - struct dbr_sts_double *pvalue - = (struct dbr_sts_double *)pbuffer; - dbr_double_t *pdouble = &pvalue->value; - printf("%2d %2d",pvalue->status,pvalue->severity); - if(count==1) printf("\tValue: "); - for (i = 0; i < count; i++,pdouble++){ - if(count!=1 && (i%10 == 0)) printf("\n"); - printf("%6.4f ",(float)(*pdouble)); - } - break; - } - case (DBR_TIME_STRING): - { - struct dbr_time_string *pvalue - = (struct dbr_time_string *) pbuffer; - - epicsTimeToStrftime(tsString,sizeof(tsString), - "%Y/%m/%d %H:%M:%S.%06f",&pvalue->stamp); - printf("%2d %2d",pvalue->status,pvalue->severity); - printf("\tTimeStamp: %s",tsString); - printf("\tValue: "); - printf("%s",pvalue->value); - break; - } - case (DBR_TIME_ENUM): - { - struct dbr_time_enum *pvalue - = (struct dbr_time_enum *)pbuffer; - dbr_enum_t *pshort = &pvalue->value; - - epicsTimeToStrftime(tsString,sizeof(tsString), - "%Y/%m/%d %H:%M:%S.%06f",&pvalue->stamp); - printf("%2d %2d",pvalue->status,pvalue->severity); - printf("\tTimeStamp: %s",tsString); - if(count==1) printf("\tValue: "); - for (i = 0; i < count; i++,pshort++){ - if(count!=1 && (i%10 == 0)) printf("\n"); - printf("%d ",*pshort); - } - break; - } - case (DBR_TIME_SHORT): - { - struct dbr_time_short *pvalue - = (struct dbr_time_short *)pbuffer; - dbr_short_t *pshort = &pvalue->value; - - epicsTimeToStrftime(tsString,sizeof(tsString), - "%Y/%m/%d %H:%M:%S.%06f",&pvalue->stamp); - printf("%2d %2d", - pvalue->status, - pvalue->severity); - printf("\tTimeStamp: %s",tsString); - if(count==1) printf("\tValue: "); - for (i = 0; i < count; i++,pshort++){ - if(count!=1 && (i%10 == 0)) printf("\n"); - printf("%d ",*pshort); - } - break; - } - case (DBR_TIME_FLOAT): - { - struct dbr_time_float *pvalue - = (struct dbr_time_float *)pbuffer; - dbr_float_t *pfloat = &pvalue->value; - - epicsTimeToStrftime(tsString,sizeof(tsString), - "%Y/%m/%d %H:%M:%S.%06f",&pvalue->stamp); - printf("%2d %2d",pvalue->status,pvalue->severity); - printf("\tTimeStamp: %s",tsString); - if(count==1) printf("\tValue: "); - for (i = 0; i < count; i++,pfloat++){ - if(count!=1 && (i%10 == 0)) printf("\n"); - printf("%6.4f ",*pfloat); - } - break; - } - case (DBR_TIME_CHAR): - { - struct dbr_time_char *pvalue - = (struct dbr_time_char *)pbuffer; - dbr_char_t *pchar = &pvalue->value; - - epicsTimeToStrftime(tsString,sizeof(tsString), - "%Y/%m/%d %H:%M:%S.%06f",&pvalue->stamp); - printf("%2d %2d",pvalue->status,pvalue->severity); - printf("\tTimeStamp: %s",tsString); - if(count==1) printf("\tValue: "); - for (i = 0; i < count; i++,pchar++){ - if(count!=1 && (i%10 == 0)) printf("\n"); - printf("%d ",(short)(*pchar)); - } - break; - } - case (DBR_TIME_LONG): - { - struct dbr_time_long *pvalue - = (struct dbr_time_long *)pbuffer; - dbr_long_t *plong = &pvalue->value; - - epicsTimeToStrftime(tsString,sizeof(tsString), - "%Y/%m/%d %H:%M:%S.%06f",&pvalue->stamp); - printf("%2d %2d",pvalue->status,pvalue->severity); - printf("\tTimeStamp: %s",tsString); - if(count==1) printf("\tValue: "); - for (i = 0; i < count; i++,plong++){ - if(count!=1 && (i%10 == 0)) printf("\n"); - printf("%d ",*plong); - } - break; - } - case (DBR_TIME_DOUBLE): - { - struct dbr_time_double *pvalue - = (struct dbr_time_double *)pbuffer; - dbr_double_t *pdouble = &pvalue->value; - - epicsTimeToStrftime(tsString,sizeof(tsString), - "%Y/%m/%d %H:%M:%S.%06f",&pvalue->stamp); - printf("%2d %2d",pvalue->status,pvalue->severity); - printf("\tTimeStamp: %s",tsString); - if(count==1) printf("\tValue: "); - for (i = 0; i < count; i++,pdouble++){ - if(count!=1 && (i%10 == 0)) printf("\n"); - printf("%6.4f ",(float)(*pdouble)); - } - break; - } - case (DBR_GR_SHORT): - { - struct dbr_gr_short *pvalue - = (struct dbr_gr_short *)pbuffer; - dbr_short_t *pshort = &pvalue->value; - printf("%2d %2d %.8s",pvalue->status,pvalue->severity, - pvalue->units); - printf("\n\t%8d %8d %8d %8d %8d %8d", - pvalue->upper_disp_limit,pvalue->lower_disp_limit, - pvalue->upper_alarm_limit,pvalue->upper_warning_limit, - pvalue->lower_warning_limit,pvalue->lower_alarm_limit); - if(count==1) printf("\tValue: "); - for (i = 0; i < count; i++,pshort++){ - if(count!=1 && (i%10 == 0)) printf("\n"); - printf("%d ",*pshort); - } - break; - } - case (DBR_GR_FLOAT): - { - struct dbr_gr_float *pvalue - = (struct dbr_gr_float *)pbuffer; - dbr_float_t *pfloat = &pvalue->value; - printf("%2d %2d %.8s",pvalue->status,pvalue->severity, - pvalue->units); - printf(" %3d\n\t%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f", - pvalue->precision, - pvalue->upper_disp_limit,pvalue->lower_disp_limit, - pvalue->upper_alarm_limit,pvalue->upper_warning_limit, - pvalue->lower_warning_limit,pvalue->lower_alarm_limit); - if(count==1) printf("\tValue: "); - for (i = 0; i < count; i++,pfloat++){ - if(count!=1 && (i%10 == 0)) printf("\n"); - printf("%6.4f ",*pfloat); - } - break; - } - case (DBR_GR_ENUM): - case (DBR_CTRL_ENUM): - { - struct dbr_gr_enum *pvalue - = (struct dbr_gr_enum *)pbuffer; - printf("%2d %2d",pvalue->status, - pvalue->severity); - printf("\tValue: %d",pvalue->value); - if(pvalue->no_str>0) { - printf("\n\t%3d",pvalue->no_str); - for (i = 0; i < (unsigned) pvalue->no_str; i++) - printf("\n\t%.26s",pvalue->strs[i]); - } - break; - } - case (DBR_GR_CHAR): - { - struct dbr_gr_char *pvalue - = (struct dbr_gr_char *)pbuffer; - dbr_char_t *pchar = &pvalue->value; - printf("%2d %2d %.8s",pvalue->status,pvalue->severity, - pvalue->units); - printf("\n\t%8d %8d %8d %8d %8d %8d", - pvalue->upper_disp_limit,pvalue->lower_disp_limit, - pvalue->upper_alarm_limit,pvalue->upper_warning_limit, - pvalue->lower_warning_limit,pvalue->lower_alarm_limit); - if(count==1) printf("\tValue: "); - for (i = 0; i < count; i++,pchar++){ - if(count!=1 && (i%10 == 0)) printf("\n"); - printf("%u ",*pchar); - } - break; - } - case (DBR_GR_LONG): - { - struct dbr_gr_long *pvalue - = (struct dbr_gr_long *)pbuffer; - dbr_long_t *plong = &pvalue->value; - printf("%2d %2d %.8s",pvalue->status,pvalue->severity, - pvalue->units); - printf("\n\t%8d %8d %8d %8d %8d %8d", - pvalue->upper_disp_limit,pvalue->lower_disp_limit, - pvalue->upper_alarm_limit,pvalue->upper_warning_limit, - pvalue->lower_warning_limit,pvalue->lower_alarm_limit); - if(count==1) printf("\tValue: "); - for (i = 0; i < count; i++,plong++){ - if(count!=1 && (i%10 == 0)) printf("\n"); - printf("%d ",*plong); - } - break; - } - case (DBR_GR_DOUBLE): - { - struct dbr_gr_double *pvalue - = (struct dbr_gr_double *)pbuffer; - dbr_double_t *pdouble = &pvalue->value; - printf("%2d %2d %.8s",pvalue->status,pvalue->severity, - pvalue->units); - printf(" %3d\n\t%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f", - pvalue->precision, - (float)(pvalue->upper_disp_limit), - (float)(pvalue->lower_disp_limit), - (float)(pvalue->upper_alarm_limit), - (float)(pvalue->upper_warning_limit), - (float)(pvalue->lower_warning_limit), - (float)(pvalue->lower_alarm_limit)); - if(count==1) printf("\tValue: "); - for (i = 0; i < count; i++,pdouble++){ - if(count!=1 && (i%10 == 0)) printf("\n"); - printf("%6.4f ",(float)(*pdouble)); - } - break; - } - case (DBR_CTRL_SHORT): - { - struct dbr_ctrl_short *pvalue - = (struct dbr_ctrl_short *)pbuffer; - dbr_short_t *pshort = &pvalue->value; - printf("%2d %2d %.8s",pvalue->status,pvalue->severity, - pvalue->units); - printf("\n\t%8d %8d %8d %8d %8d %8d", - pvalue->upper_disp_limit,pvalue->lower_disp_limit, - pvalue->upper_alarm_limit,pvalue->upper_warning_limit, - pvalue->lower_warning_limit,pvalue->lower_alarm_limit); - printf(" %8d %8d", - pvalue->upper_ctrl_limit,pvalue->lower_ctrl_limit); - if(count==1) printf("\tValue: "); - for (i = 0; i < count; i++,pshort++){ - if(count!=1 && (i%10 == 0)) printf("\n"); - printf("%d ",*pshort); - } - break; - } - case (DBR_CTRL_FLOAT): - { - struct dbr_ctrl_float *pvalue - = (struct dbr_ctrl_float *)pbuffer; - dbr_float_t *pfloat = &pvalue->value; - printf("%2d %2d %.8s",pvalue->status,pvalue->severity, - pvalue->units); - printf(" %3d\n\t%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f", - pvalue->precision, - pvalue->upper_disp_limit,pvalue->lower_disp_limit, - pvalue->upper_alarm_limit,pvalue->upper_warning_limit, - pvalue->lower_warning_limit,pvalue->lower_alarm_limit); - printf(" %8.3f %8.3f", - pvalue->upper_ctrl_limit,pvalue->lower_ctrl_limit); - if(count==1) printf("\tValue: "); - for (i = 0; i < count; i++,pfloat++){ - if(count!=1 && (i%10 == 0)) printf("\n"); - printf("%6.4f ",*pfloat); - } - break; - } - case (DBR_CTRL_CHAR): - { - struct dbr_ctrl_char *pvalue - = (struct dbr_ctrl_char *)pbuffer; - dbr_char_t *pchar = &pvalue->value; - printf("%2d %2d %.8s",pvalue->status,pvalue->severity, - pvalue->units); - printf("\n\t%8d %8d %8d %8d %8d %8d", - pvalue->upper_disp_limit,pvalue->lower_disp_limit, - pvalue->upper_alarm_limit,pvalue->upper_warning_limit, - pvalue->lower_warning_limit,pvalue->lower_alarm_limit); - printf(" %8d %8d", - pvalue->upper_ctrl_limit,pvalue->lower_ctrl_limit); - if(count==1) printf("\tValue: "); - for (i = 0; i < count; i++,pchar++){ - if(count!=1 && (i%10 == 0)) printf("\n"); - printf("%4d ",(short)(*pchar)); - } - break; - } - case (DBR_CTRL_LONG): - { - struct dbr_ctrl_long *pvalue - = (struct dbr_ctrl_long *)pbuffer; - dbr_long_t *plong = &pvalue->value; - printf("%2d %2d %.8s",pvalue->status,pvalue->severity, - pvalue->units); - printf("\n\t%8d %8d %8d %8d %8d %8d", - pvalue->upper_disp_limit,pvalue->lower_disp_limit, - pvalue->upper_alarm_limit,pvalue->upper_warning_limit, - pvalue->lower_warning_limit,pvalue->lower_alarm_limit); - printf(" %8d %8d", - pvalue->upper_ctrl_limit,pvalue->lower_ctrl_limit); - if(count==1) printf("\tValue: "); - for (i = 0; i < count; i++,plong++){ - if(count!=1 && (i%10 == 0)) printf("\n"); - printf("%d ",*plong); - } - break; - } - case (DBR_CTRL_DOUBLE): - { - struct dbr_ctrl_double *pvalue - = (struct dbr_ctrl_double *)pbuffer; - dbr_double_t *pdouble = &pvalue->value; - printf("%2d %2d %.8s",pvalue->status,pvalue->severity, - pvalue->units); - printf(" %3d\n\t%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f", - pvalue->precision, - (float)(pvalue->upper_disp_limit), - (float)(pvalue->lower_disp_limit), - (float)(pvalue->upper_alarm_limit), - (float)(pvalue->upper_warning_limit), - (float)(pvalue->lower_warning_limit), - (float)(pvalue->lower_alarm_limit)); - printf(" %8.3f %8.3f", - (float)(pvalue->upper_ctrl_limit), - (float)(pvalue->lower_ctrl_limit)); - if(count==1) printf("\tValue: "); - for (i = 0; i < count; i++,pdouble++){ - if(count!=1 && (i%10 == 0)) printf("\n"); - printf("%6.6f ",(float)(*pdouble)); - } - break; - } - } - printf("\n"); -} -