• Antelope Release 5.10 Linux CentOS release 7.6.1810 (Core) 3.10.0 2020-05-12

 

NAME

pktrepackage_create, pktrepackage_put, pktrepackage_put_pktchan, pktrepackage_flush - ORB packet repackaging utility

SYNOPSIS

#include "brttpkt.h"

PktRepackage *pktrepackage_create (double twin, char *suffix, char *subcode,
      int orb, int (*flush_callback) (void *user_data), void *flush_callback_user_data)

int pktrepackage_put (PktRepackage *buf,
      char *net, char *sta, char *chan, char *loc,
      double time, double dt, double calib,
      double calper, char *segtype, int nsamp, int *data, int isfloat)

int pktrepackage_put_pktchan (PktRepackage *buf, PktChannel *pktchan)

int pktrepackage_flush (PktRepackage *buf)

DESCRIPTION

These routines provide a utility for repackaging groups of single channel waveform segments into arbitrarily multiplexed ORB waveform packets with arbitrary time durations.

pktrepackage_create creates a new PktRepackage object and returns a pointer to the object instance. This pointer is used as a handle for subsequent operations. The output packets will nominally be twin seconds in duration. The output packets will have format specified by suffix which will also appear in the ORB srcname. An additional srcname subcode can be specified by subcode. The output packets are written to the ORB specified by orb which should be previously opened for writing. flush_callback specifies an optional (NULL for no callback) user callback function that is called whenever a buffer is full and needs to be flushed to the output ORB. The callback function is called with the following syntax:


int flush_callback (void *userdata)

The private pointer passed to pktrepackage_create, flush_callback_user_data, is passed back to flush_callback.

pktrepackage_put will put a single continguous channel of waveform data into the buffer specified by buf. net, sta, chan and loc are the SEED codes associated with the waveform segment. time, samprate, nsamp, calib, calper and segtype are the same as those fields in the PktChannel structure. The waveform data array is specified by data, which is normally of type int. If data is in 4-byte floating format, then the isfloat flag must be set.

pktrepackage_put_pktchan will put a single continguous channel of waveform data into the buffer specified by buf. This is a convenience routine when the data is already contained within a PktChannel structure, specified by pktchan.

pktrepackage_flush will force flushing of the buffer specified by buf. This will cause any data not already pushed to the output ORB to be immediately written even if the current ORB packet buffer is not full.

RETURN VALUES

pktrepackage_create returns a PktRepackage process handle (pointer to a PktRepackage structure) or NULL if there is an error.

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.

FLUSHING RULES

This utility will attempt to buffer in both channel and time domains until either the time window of the data being put into the buffer exceeds twin, or the input time acts in a non-uniform manner, or the application calls pktrepackage_flush. In order for the repacking to work effectively, it is important that the data being buffered arrives in time order. Any abnormal time behavior, such as the time backing up or time tears will cause the current buffer to be immediately flushed and a new buffer to start accumulating. It is the duty of the application programmer to insure that individual channel input packets are all of the same data type (int or float) and that the suffix is appropriate for the data being buffered (e.g. suffix should be flt for floating data, only a single channel should be buffered if the suffix is GENC, etc.).

LIBRARY

-lbrttpkt $(ORBLIBS)

AUTHOR

Danny Harvey
Printer icon