/*************************************************************************** SIA - system for advanced seismic data analysis Copyright (c) 1995-2003, I. B. Morozov ****************************************************************************/ //#define DEBUG // uncomment this to enable debugging printouts, if any #include "sia_module.C.h" #include "templrd.h" boolean TEMPLRD::proc( int count ) { // if 'count' is out of range, return FAIL (meainng no output done) // change this condition to something more meaningful! if ( count < 0 ) return FAIL; // need to determine the number of records per trace // and the number of samples per record int nr=1, // these are just arbitrary values for an example ns=111; // create a new trace ensemble ENSEMBLE *e = SIA.output()->add_ensemble(); if ( e ) { // for each value of 'key', create a trace (2-D in this case) for ( int k=0; k < key.length; k++ ) { TRACE *t = e->add_trace(ns,nr); if ( t ) { // read the trace data for ( int i=0; i < t->num_records(); i++ ) { DATA_SAMPLE *d = t->data_start(i); // beginning of record number #i // put the values in array d[] ... } } } e->close(); // close the ensemble (set LASTTRC header = 1 ) return OK; // OK means the trace is ready to be picked up from the output } return FAIL; // FAIL (FALSE) means "wait for more input data" or // "quit" if no more data is going to be loaded } /*========================================================================== Process phase - called every time the system tries to produce an output (e.g., when there is a trace in the input gather) ==========================================================================*/ boolean TEMPLRD::process() { /*--------------------------------------------------------------- If there is a trace at the input, pass it to the output, otherwise read a new trace and output it. Return OK if a trace was added to tyhe output gather. _count s incremented if a trace is loaded ---------------------------------------------------------------*/ return SIA.input()->pass_trace(SIA.output()) ? OK : proc(_count++); } boolean TEMPLRD::operation( int type, int instr, const char *param ) { if ( param ) // param string should contain the number of requested trace { switch ( instr ) { case MODULE_OP_RESET : _count=atoi(param); break; case MODULE_OP_START : case MODULE_OP_EXEC : return proc(atoi(param)); // load the requested trace } return OK; } return FAIL; }