Go to the first, previous, next, last section, table of contents.


putvec

int putvec(DB_Sample *vector)

Return:

>0
Success: the returned value is the number of output signals (the number of entries in vector that were written)
0
Slew rate too high for one or more signals (difference format only; the DC level(s) will be corrected as soon as the slew rate permits)
-1
Failure: write error

This function writes a sample to each input signal. The caller should fill an array of DB_Samples with the samples and pass a pointer to this array to putvec. (The length of the array must be no less than the number of output signals, as given to osigfopen or osigopen; this number must never exceed DB_MAXSIG, defined in `<ecg/db.h>'.) On entry, vector[i] contains the next sample from signal i. For example, this modified version of the previous example (see section getvec) copies the first ten samples of each available input signal:

#include <ecg/db.h>

main()
{
    int i, nsig;
    DB_Sample v[DB_MAXSIG];
    static DB_Siginfo s[DB_MAXSIG];

    if ((nsig = isigopen("100s", s, DB_MAXSIG)) < 1 ||
        osigopen("8l", s, nsig) < 1)
        exit(1);
    for (i = 0; i < 10; i++)
        if (getvec(v) < 0 || putvec(v) < 0)
            break;
    dbquit();
    exit(0);
}

All programs that write signals or annotations must invoke dbquit to close the output files properly (see section dbquit). This example uses record `8l' (see section Piped and Local Records) for the output signal specifications; the output signal files will be named `data0' and `data1' in the current directory. The array of DB_Siginfo structures is declared static, a practice that is recommended for all arrays and data structures of any substantial size, to avoid run-time stack overflow. Several of the example programs in chapter 6 illustrate the use of putvec; for example, see section Example 6: A Differentiator.


Go to the first, previous, next, last section, table of contents.



George B. Moody (george@hstbme.mit.edu)