/* file: db.h G. Moody 13 June 1983 Last revised: 10 March 1994 dblib 9.0 DB library type, constant, structure, and function interface definitions Copyright (C) Massachusetts Institute of Technology 1994. All rights reserved. */ #ifndef db_DB_H /* avoid multiple definitions */ #define db_DB_H /* Determine what type of compiler is being used. */ #ifdef __STDC__ /* true for ANSI C compilers only */ #define db_PROTO /* function prototypes will be needed */ #endif #ifdef __cplusplus /* true for some C++ compilers */ #define db_CPP #define db_PROTO #endif #ifdef c_plusplus /* true for some other C++ compilers */ #define db_CPP #define db_PROTO #endif #ifndef db_PROTO /* should be true for K&R C compilers only */ #define db_KRC #define signed #endif /* Simple data types */ typedef int DB_Sample; /* units are adus */ typedef long DB_Time; /* units are sample intervals */ typedef long DB_Date; /* units are days */ typedef double DB_Frequency; /* units are Hz (samples/second/signal) */ typedef double DB_Gain; /* units are adus per physical unit */ typedef unsigned int DB_Group; /* signal group number */ typedef unsigned int DB_Signal; /* signal number */ typedef unsigned int DB_Annotator; /* annotator number */ /* Array sizes */ #define DB_MAXANN 2 /* maximum number of input or output annotators */ #define DB_MAXSIG 16 /* maximum number of input or output signals */ #define DB_MAXSPF 4 /* maximum number of samples per signal per frame */ /* DB_anninfo '.stat' values */ #define READ 0 /* standard input annotation file */ #define WRITE 1 /* standard output annotation file */ #define AHA_READ 2 /* AHA-format input annotation file */ #define AHA_WRITE 3 /* AHA-format output annotation file */ /* DB_siginfo '.fmt' values FMT_LIST is suitable as an initializer for a static array; it lists all of the legal values for the format field in a DB_siginfo structure. fmt meaning 8 8-bit first differences 16 16-bit 2's complement amplitudes, low byte first 61 16-bit 2's complement amplitudes, high byte first 80 8-bit offset binary amplitudes 160 16-bit offset binary amplitudes 212 2 12-bit amplitudes bit-packed in 3 bytes 310 3 10-bit amplitudes bit-packed in 4 bytes */ #define FMT_LIST {8, 16, 61, 80, 160, 212, 310} #define NFMTS 7 /* number of items in FMT_LIST */ /* Default signal specifications */ #define DEFFREQ 250.0 /* default sampling frequency (Hz) */ #define DEFGAIN 200.0 /* default value for gain (adu/physical unit) */ #define DEFRES 12 /* default value for ADC resolution (bits) */ /* getvec operating modes */ #define DB_LOWRES 0 /* return one sample per signal per frame */ #define DB_HIGHRES 1 /* return each sample of oversampled signals, duplicating samples of other signals */ /* calinfo '.caltype' values AC_COUPLED and DC_COUPLED are used in combination with the pulse shape definitions below to characterize calibration pulses. */ #define AC_COUPLED 0 /* AC coupled signal */ #define DC_COUPLED 1 /* DC coupled signal */ #define CAL_SQUARE 2 /* square wave pulse */ #define CAL_SINE 4 /* sine wave pulse */ #define CAL_SAWTOOTH 6 /* sawtooth pulse */ #define CAL_UNDEF 8 /* undefined pulse shape */ /* Structure definitions */ struct DB_siginfo { /* signal information structure */ char *fname; /* filename of signal file */ char *desc; /* signal description */ char *units; /* physical units (mV unless otherwise specified) */ DB_Gain gain; /* gain (ADC units/physical unit, 0: uncalibrated) */ DB_Sample initval; /* initial value (that of sample number 0) */ DB_Group group; /* signal group number */ int fmt; /* format (8, 16, etc.) */ int spf; /* samples per frame (>1 for oversampled signals) */ int bsize; /* block size (for character special files only) */ int adcres; /* ADC resolution in bits */ int adczero; /* ADC output given 0 VDC input */ int baseline; /* ADC output given 0 physical units input */ long nsamp; /* number of samples (0: unspecified) */ int cksum; /* 16-bit checksum of all samples */ }; struct DB_calinfo { /* calibration information structure */ double low; /* low level of calibration pulse in physical units */ double high; /* high level of calibration pulse in physical units */ double scale; /* customary plotting scale (physical units per cm) */ char *sigtype; /* signal type */ char *units; /* physical units */ int caltype; /* calibration pulse type (see definitions above) */ }; struct DB_anninfo { /* annotator information structure */ char *name; /* annotator name */ int stat; /* file type/access code (READ, WRITE, etc.) */ }; struct DB_ann { /* annotation structure */ DB_Time time; /* annotation time, in sample intervals from the beginning of the record */ char anntyp; /* annotation type (< ACMAX, see */ signed char subtyp; /* annotation subtype */ signed char chan; /* channel number */ signed char num; /* annotator number */ char *aux; /* pointer to auxiliary information */ }; /* Composite data types */ typedef struct DB_siginfo DB_Siginfo; typedef struct DB_calinfo DB_Calinfo; typedef struct DB_anninfo DB_Anninfo; typedef struct DB_ann DB_Annotation; /* Function types */ /* Specify C linkage for C++ compilers. */ #ifdef db_CPP extern "C" { #endif /* Define function prototypes for ANSI C compilers and C++ compilers */ #ifdef db_PROTO extern int annopen(char *record, DB_Anninfo *aiarray, unsigned int nann); extern int isigopen(char *record, DB_Siginfo *siarray, int nsig); extern int osigopen(char *record, DB_Siginfo *siarray, unsigned int nsig); extern int osigfopen(DB_Siginfo *siarray, unsigned int nsig); extern int dbinit(char *record, DB_Anninfo *aiarray, unsigned int nann, DB_Siginfo *siarray, unsigned int nsig); extern void setgvmode(int mode); extern int getvec(DB_Sample *vector); extern int getframe(DB_Sample *vector); extern int putvec(DB_Sample *vector); extern int getann(DB_Annotator a, DB_Annotation *annot); extern int ungetann(DB_Annotator a, DB_Annotation *annot); extern int putann(DB_Annotator a, DB_Annotation *annot); extern int isigsettime(DB_Time t); extern int isgsettime(DB_Group g, DB_Time t); extern int iannsettime(DB_Time t); extern char *ecgstr(int annotation_code); extern int strecg(char *annotation_mnemonic_string); extern int setecgstr(int annotation_code, char *annotation_mnemonic_string); extern char *annstr(int annotation_code); extern int strann(char *annotation_mnemonic_string); extern int setannstr(int annotation_code, char *annotation_mnemonic_string); extern char *anndesc(int annotation_code); extern int setanndesc(int annotation_code, char *annotation_description); extern char *timstr(DB_Time t); extern char *mstimstr(DB_Time t); extern DB_Time strtim(char *time_string); extern char *datstr(DB_Date d); extern DB_Date strdat(char *date_string); extern int adumuv(DB_Signal s, DB_Sample a); extern DB_Sample muvadu(DB_Signal s, int microvolts); extern double aduphys(DB_Signal s, DB_Sample a); extern DB_Sample physadu(DB_Signal s, double v); extern int calopen(char *calibration_filename); extern int getcal(char *description, char *units, DB_Calinfo *cal); extern int putcal(DB_Calinfo *cal); extern int newcal(char *calibration_filename); extern void flushcal(void); extern char *getinfo(char *record); extern int putinfo(char *info); extern int newheader(char *record); extern int setheader(char *record, DB_Siginfo *siarray, unsigned int nsig); extern void dbquit(void); extern DB_Frequency sampfreq(char *record); extern int setsampfreq(DB_Frequency sampling_frequency); extern DB_Frequency getcfreq(void); extern void setcfreq(DB_Frequency counter_frequency); extern double getbasecount(void); extern void setbasecount(double count); extern int setbasetime(char *time_string); extern void dbquiet(void); extern void dbverbose(void); extern char *dberror(void); extern void setdb(char *database_path_string); extern char *getdb(void); extern int setibsize(int input_buffer_size); extern int setobsize(int output_buffer_size); extern char *dbfile(char *file_type, char *record); extern void dbflush(void); #endif #ifdef db_CPP } #endif #ifdef db_KRC /* declare only function return types for K&R C compilers */ extern int annopen(), isigopen(), osigopen(), dbinit(), getvec(), getframe(), putvec(), getann(), ungetann(), putann(), isigsettime(), isgsettime(), iannsettime(), strecg(), setecgstr(), strann(), setannstr(), setanndesc(), adumuv(), newheader(), setheader(), setsampfreq(), setbasetime(), putinfo(), setibsize(), setobsize(), calopen(), getcal(), putcal(), newcal(); extern DB_Sample muvadu(), physadu(); extern char *ecgstr(), *annstr(), *anndesc(), *timstr(), *mstimstr(), *datstr(), *getdb(), *getinfo(), *dberror(), *dbfile(); extern DB_Time strtim(); extern DB_Date strdat(); extern void setgvmode(), dbquit(), dbquiet(), dbverbose(), setdb(), dbflush(), setcfreq(), setbasecount(), flushcal(); extern DB_Frequency sampfreq(), getcfreq(); extern double aduphys(), getbasecount(); #endif /* Definitions for compatibility with DB applications written to use earlier versions of this header file. At least some of these are incompatible with Solaris. Newly-written code should not use these definitions, since they may be removed in future versions of the DB library. */ #ifndef SOLARIS #define Sample DB_Sample #define SITime DB_Time #define Date DB_Date #define Frequency DB_Frequency #define Gain DB_Gain #define Group DB_Group #define Signal DB_Signal #define Annotator DB_Annotator #define MAXSIG DB_MAXSIG #define MAXANN DB_MAXANN #define siginfo DB_siginfo #define calinfo DB_calinfo #define anninfo DB_anninfo #define ann DB_ann #define Siginfo DB_Siginfo #define Calinfo DB_Calinfo #define Anninfo DB_Anninfo #define Annotation DB_Annotation #endif /* Remove local preprocessor definitions. */ #ifdef db_PROTO #undef db_PROTO #endif #ifdef db_CPP #undef db_CPP #endif #ifdef db_KRC #undef db_KRC #undef signed #endif #endif