
#include <shareLib.h>
#define DB_TEXT_GLBLSOURCE 

#include "chandata.h"

#include <alarmString.h>

chandata *pchandata;

void caGetInfo();
extern int getopt();

void main(argc,argv)
int argc;
char **argv;
{
char *st,pvname[NAME_LENGTH];
	st = pvname; 

printf("\nEnter PV_name or quit\n\n");

READPV:	printf("PV? : "); 
	st = gets(pvname); 
	if (st == NULL) exit(1); 
	if (*st != EOF && *st != NULL) {
	if(*st == 'q' || *st == 'Q') {
			 exit(0); 
			}
	st = &pvname[new_string(st)]; 
		if (strlen(st) > 1) {
		caGetInfo(st);
		}
	}
	goto READPV;
}

void caGetInfo(pvname) 
char *pvname;
{
struct dbr_ctrl_double dbr;
int status;

printf("pvname=%s#\n",pvname);
   status = ca_find_dev(pvname,pchandata);

        if (pchandata->state  != cs_conn ) return;
        if (pchandata->type > DBR_STRING) {
	status = ca_get(DBR_CTRL_DOUBLE,pchandata->chid,&dbr);
        ca_pend_io(1.);
	ca_check_return_code(status);
	if (status == ECA_NORMAL) {
	printf("%-30s ",pvname);
	printf("%10.2f ",dbr.value);
	printf("%-9s ",alarmStatusString[dbr.status]);
	printf("%-12s",alarmSeverityString[dbr.severity]);
	printf("%10.2f ",dbr.upper_disp_limit);
	printf("%10.2f ",dbr.lower_disp_limit);
	printf("%s\n ",dbr.units);
		}
	}
	else printf("*** wrong type of record entered ***\n");

}

