This program reads the signal specifications of the record named as its argument:
1 #include <stdio.h> 2 #include <ecg/db.h> 3 4 main(argc, argv) 5 int argc; 6 char *argv[]; 7 { 8 static DB_Siginfo s[DB_MAXSIG]; 9 int i, nsig; 10 11 if (argc < 2) { 12 fprintf(stderr, "usage: %s record\n", argv[0]); 13 exit(1); 14 } 15 nsig = isigopen(argv[1], s, DB_MAXSIG); 16 if (nsig < 1) exit(2); 17 printf("Record %s\n", argv[1]); 18 printf("Starting time: %s\n", timstr(0L)); 19 printf("Sampling frequency: %g Hz\n", sampfreq(argv[1])); 20 printf("%d signals\n", nsig); 21 for (i = 0; i < nsig; i++) { 22 printf("Group %d, Signal %d:\n", s[i].group, i); 23 printf(" File: %s\n", s[i].fname); 24 printf(" Description: %s\n", s[i].desc); 25 printf(" Gain: "); 26 if (s[i].gain == 0.) 27 printf("uncalibrated; assume %g", DEFGAIN); 28 else printf("%g", s[i].gain); 29 printf(" adu/%s\n", s[i].units ? s[i].units : "mV"); 30 printf(" Initial value: %d\n", s[i].initval); 31 printf(" Storage format: %d\n", s[i].fmt); 32 printf(" I/O: "); 33 if (s[i].bsize == 0) printf("can be unbuffered\n"); 34 else printf("%d-byte blocks\n", s[i].bsize); 35 printf(" ADC resolution: %d bits\n", s[i].adcres); 36 printf(" ADC zero: %d\n", s[i].adczero); 37 if (s[i].nsamp > 0L) { 38 printf(" Length: %s (%ld sample intervals)\n", 39 timstr(s[i].nsamp), s[i].nsamp); 40 printf(" Checksum: %d\n", s[i].cksum); 41 } 42 else printf(" Length undefined\n"); 43 } 44 exit(0); 45 }
Notes:
DB_MAXSIG
signals, so we allocate enough
DB_Siginfo
objects to accommodate them all.
argv[1]
, is the record name. The
number of readable signals is nsig
. This program will give
specifications for each of them, but not for any signals that are named
in the `header' file but are not readable. If nsig
< 1,
isigopen
will print an error message; in this case the program
can't do anything useful, so it exits.
timstr
with an argument of zero (here written `0L'
to emphasize to the compiler that the argument is a long
integer)
will obtain the starting time of the record. If no starting time is
defined, timstr
will return "0:00:00
".
gain
is interpreted.
units
field is NULL, the physical units are assumed to be
millivolts ("mV").
bsize
is zero, I/O can be performed in blocks of any reasonable
size; otherwise it must be performed in blocks of exactly the specified
bsize
.
timstr
in line 39 is positive, it is interpreted as a time
interval. The checksum is defined only if the record length is
defined.
Go to the first, previous, next, last section, table of contents.