#define DB_TEXT_GLBLSOURCE
#include <tsDefs.h>

#include "chandata.h"
extern chandata *pchandata;
struct dbr_gr_enum dbr;


extern void get_pbuff(long n,char **pbuff,char *buff);
void get_pbuff(long n,char **pbuff,char *buff)
{
int i;
	pbuff = (char **)calloc(sizeof(char *),n);
	for (i=0;i<n;i++)  *(pbuff+i) = (char *)(buff+i*40);
}


extern void caSearch(long n,char **pvName,long *ret);
void caSearch(long n,char **pvName,long *ret)
{
 int noName,err;
  extern int ca_search_list(int,char **);
  noName = n;
  err = ca_search_list(noName,pvName); 
  *ret = err;
} 

extern void caSearchList(long n,char **pvName,int *ret);
void caSearchList(long n,char **pvName,int *ret)
{
 int noName,err;
  extern void ca_get_error_array(int,char **,int *);
  noName = n;
  ca_get_error_array(noName,pvName,ret); 
} 

extern void caput(long n,char **name,double *val);
void caput(long n,char **name,double *val)
{
  extern void ca_put_double_array(int,char **,double *);
  ca_put_double_array(n,name,val); 
} 

extern void caget(long n,char **name,double *val);
void caget(long n,char **name,double *val)
{
  extern void ca_get_double_array(int,char **,double *);
  ca_get_double_array(n,name,val); 
} 

extern void cagetString(long n,char **name,char **val);
void cagetString(long n,char **name,char **val)
{
  extern void ca_get_string_array(int,char **,char **);
  ca_get_string_array(n,name,val); 
} 

extern void caputString(long n,char **name,char **val);
void caputString(long n,char **name,char **val)
{
  extern void ca_put_string_array(int,char **,char **);
  ca_put_string_array(n,name,val); 
} 

extern void cagetAll(long n,char **name,double *val);
void cagetAll(long n,char **name,double *val)
{
  extern void ca_get_all_double_array(int,char **,double *);
  ca_get_all_double_array(n,name,val); 
} 

extern void cagetCount(char *name,int *val,long n);
void cagetCount(char *name,int *val,long n)
{
  extern int ca_get_count(char *);
  *val = ca_get_count(name); 
} 

extern void cagetWave(char *name,double *val,long n);
void cagetWave(char *name,double *val,long n)
{
  extern int ca_get_wave_form(char *,double *);
  ca_get_wave_form(name,val); 
} 

extern void caputWave(char *name,double *val,long n);
void caputWave(char *name,double *val,long n)
{
int no;
  extern int ca_put_wave_form(char *,int,double *);
  no = n;
  ca_put_wave_form(name,no,val); 
} 


extern void caMonitorAdd(long n,char **pvName,int *ret);
void caMonitorAdd(long n,char **pvName,int *ret)
{
 int noName,err;
  extern void ca_get_error_array(int,char **,int *);
  extern void ca_monitor_add_event_array(int,char **);
  noName = n;
  ca_monitor_add_event_array(noName,pvName); 
  ca_get_error_array(noName,pvName,ret); 
} 

extern void caMonitorClear(long n,char **pvName,int *ret);
void caMonitorClear(long n,char **pvName,int *ret)
{
 int noName,err;
  extern void ca_get_error_array(int,char **,int *);
  extern void ca_monitor_clear_event_array(int,char **);
  noName = n;
  ca_monitor_clear_event_array(noName,pvName); 
  ca_get_error_array(noName,pvName,ret); 
} 

extern void caMonitorGetEvent(long n,char **pvName,int *ret);
void caMonitorGetEvent(long n,char **pvName,int *ret)
{
 int noName,err;
  extern void ca_monitor_get_event_array(int,char **,int *);
  noName = n;
  ca_monitor_get_event_array(noName,pvName,ret); 
} 

extern void caTimeStamp(char *name,char *ts);
void caTimeStamp(char *name,char *ts)
{
TS_STAMP stamp;
  extern int ca_find_dev(char *,chandata *);
  extern void ca_monitor_add_event(chandata *);
  ca_find_dev(name,pchandata);
  if (pchandata->evid == NULL) ca_monitor_add_event(pchandata);
  stamp = pchandata->stamp;
  tsStampToText(&stamp,TS_TEXT_MONDDYYYY,ts);
} 



/*
x = ["cha:scan1.P1PV","cha:scan1.P2PV","cha:scan1.P3PV","cha:scan1.P4PV",
"cha:scan1.D1PV","cha:scan1.D2PV","cha:scan1.D3PV","cha:scan1.D4PV",
"cha:scan1.D5PV","cha:scan1.D6PV","cha:scan1.D7PV","cha:scan1.D8PV",
"cha:scan1.D9PV","cha:scan1.DAPV","cha:scan1.DBPV","cha:scan1.DCPV",
"cha:scan1.DDPV","cha:scan1.DEPV","cha:scan1.DFPV"]
*/
