• Antelope Release 5.9 Mac OS X 10.13.2 2019-05-01

 

NAME

pktchannelpipe_new, pktchannelpipe_free, pktchannelpipe_push, pktchannelpipe_flush - time-ordered buffer for ORB waveform channel packets

SYNOPSIS

#include "brttpkt.h"
#include "tr.h"
#include "Pkt.h"
#include "stock.h"

PktChannelPipe *pktchannelpipe_new (Tbl *channels_select,
			Tbl *channels_reject, int maxpkts,
			int (*callback) (void *pvt, PktChannel **pktchan,
				int queue_code, double gaptime),
			void *pvt)

int pktchannelpipe_free (PktChannelPipe *pcp)

int pktchannelpipe_push (PktChannelPipe *pcp, char *srcname,
			double pkttime, char *pkt, int nbytes)

int pktchannelpipe_flush (PktChannelPipe *pcp)

DESCRIPTION

These routines provide a time-ordered queue for buffering waveform data channels in near real time as they appear on an ORB.

pktchannelpipe_new creates a new packet channel pipe object and returns a pointer to the object. This pointer is used as a handle for subsequent operations. The channels_select and channels_reject tables should contain lists of SEED net_sta_chan[_loc] expressions for selecting and rejecting channels to be processed. If channels_select is NULL, then all channels are selected and if channels_reject is NULL, then no channels are rejected. An optional maxpkts size of the queue can be specified in each of the entries in the channels_select table as an integer value after the SEED channel expressions separated by white space. The default maximum size in packets of the channel queues is specified by maxpkts. Note that maxpkts can be set to 0 in which case there is no buffering and each packet channel is processed as soon as it is received. When a particular packet channel is ready for processing, a user supplied callback function, callback, is called with the following syntax:


int callback (void *pvt, PktChannel **pktchan, int queue_code, double gaptime)

The private pointer, pvt, specified in pktchannelpipe_new, is passed back to callback. A pointer to a PktChannel structure, *pktchan, is also set. This is the channel packet for processing. This structure is allocated by the pktchannelpipe object methods and is a safe copy that can be used by the application program. It is the responsibility of the application program to free the memory associated with this Packet Channel structure or a memory leak will occur. The disposition of the channel packet as it is popped off of the time-ordered queue is specified by queue_code which will be set to one of the following:

pktchannelpipe_free frees all resources associated with a packet channel pipe object.

pktchannelpipe_push is used to push the waveform channels in an ORB packet onto a particular packet channel pipe object. The srcname, pkttime, pkt and nbytes are those as returned from orbreap (see orbreap(3)). Whenever contiguous data is found, or the time-ordered queues become full and have to be pruned, the use supplied callback function is automatically called.

pktchannelpipe_flush flushes out any PktChannel structures, through the user supplied callback function, that are currently held in the time-ordered queues.

RETURN VALUES

pktchannelpipe_new returns a packet channel pipe object handle (pointer to a PktChhanelPipe structure) or NULL if there is an error. If there is an error, then messages are left on the error register.

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.

LIBRARY

-lbrttpkt $(ORBLIBS)

SEE ALSO

trdefaults(5), orbreap(3)

AUTHOR

Danny Harvey
Printer icon