#include "orb.h" #include "Pkt.h" #include "brttpkt.h" #include "brttfilter.h" Chantraceproc *chantraceproc_new (double latency); int chantraceproc_free (Chantraceproc *cp); int chantraceproc_addchan (Chantraceproc *cp, char *netstachan, int (*callback)(), void *pvt, double tstart, double tend, double latency, int apply_calib); int chantraceproc_process (Chantraceproc *cp, int orb);
chantraceproc_new creates a new channel trace process object and returns a pointer to the channel trace process structure. This pointer is used as a handle for subsequent operations. latency specifies a group maximum latency in seconds. If the latency between the most recent packet from any of the data channels in the group relative to the requested end time of another channel is greater than this number, then the buffer for the late channel will be processed and cleared.
A channel trace process object is freed with chantraceproc_free.
The channels to be processed are specified through one or more calls to chantraceproc_addchan. netstachan specifies the network-station-channel code in the form netexpr_staexpr_chanexpr. Regular UNIX expressions can be used for each of the network, station and channel specifiers. As data packets are read, each channel will be compared against these expressions to look for matches. The waveform trace time window is specified by tstart and tend. The maximum latency in seconds to wait for out of time order data packets is specified by latency. If apply_calib is set to 0, then the calib values within each data packet header will not be applied to the sample values, otherwise the data packet calib value are applied. When a particular channel trace buffer is full, the user supplied callback function, callback, is called with the following syntax:
int callback (void *pvt, char *netstachan, Chantracebuf *buf);
The private pointer passed to chantraceproc_addchan, pvt, is passed back to callback along with the particular net_sta_chan code in netstachan. The channel trace buffer, ready for processing, is given by buf.
Once a channel trace process object has been created, with chantraceproc_new, and configured, with one or more calls to chantraceproc_addchan, then chantraceproc_process is called to cause an ORB, specified by orb, to be read and data packets to be unstuffed and fed to the appropriate channel trace buffers. As the buffers fill, the callback funtion is called for each. chantraceproc_process will return when all of the requested channel time windows have been read and processed. Note that the ORB must be properly positioned with an appropriate call to orbafter before a call to chantraceproc_process.
Everything else returns 0 if OK or -1 if there is an error. If there is an error, then messages are left on the error register.
chantracebuf(3) orbafter(3)