tdb.c File Reference

#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <ctype.h>
#include <math.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <dirent.h>
#include <assert.h>
#include <signal.h>
#include "common.h"

Include dependency graph for tdb.c:

Go to the source code of this file.

Defines

#define MAX_SENSOR_NUMBER   300
#define DO_COMPARISON_KW(__a, __i)

Functions

int ReadSensorList (void)
 read the sensor list file: sensor_list, the internal sensor list is cleared
char * ChannelName (char *sensor, float s)
 compute the channel name from the sensor and the sampling rate
char * TDBPath (int p, char *s)
 path name based on TDB information
void PrintStation (struct StationType *s)
void TDBAbortParsing (char *s, char *fn)
int TDBInit (void)
 data base initialization : read all stations
struct ChannelType * TDBGetChannel (char *sta, int channel, time_t when)
 search tdb for a station
int TDBUpdateHeader (struct InfoHeaderType *h)
 overwrite header information with TDB information

Variables

struct SensorType sensorEntry [MAX_SENSOR_NUMBER]
char ** tdbPaths = NULL
struct StationType * tdbStation = NULL
char * confKeyWord [] = { "dt", "dft", "tc", "stations", NULL }


Define Documentation

#define DO_COMPARISON_KW ( __a,
__i   ) 

Value:

if (0==strcmp(strcat(strcat(strcpy(tmp,tdbName),"_"),__a),kw)) \
                { \
                        if (1!=sscanf(line,"%*s %s",tdbPaths[__i])) \
                        { \
                                PrintError("error parsing %s for keyword '%s'\n", \
                                                conf,kw); \
                                exit(0); \
                        } \
                }

Referenced by TDBInit().

#define MAX_SENSOR_NUMBER   300

Definition at line 40 of file tdb.c.

Referenced by ChannelName(), and ReadSensorList().


Function Documentation

char* ChannelName ( char *  sensor,
float  s 
)

compute the channel name from the sensor and the sampling rate

Parameters:
sensor the sensor name
s the sampling rate

Definition at line 190 of file tdb.c.

References MAX_SENSOR_NUMBER, and PrintError.

Referenced by TDBUpdateHeader().

void PrintStation ( struct StationType *  s  ) 

Definition at line 320 of file tdb.c.

References MAX_OSIRIS_CHANNEL, PrintDebug, and time2str().

Referenced by TDBInit(), and TDBUpdateHeader().

Here is the call graph for this function:

int ReadSensorList ( void   ) 

read the sensor list file: sensor_list, the internal sensor list is cleared

Returns:
-1 on error, 0 if ok

Definition at line 136 of file tdb.c.

References MAX_SENSOR_NUMBER, PrintDebug, PrintLog, TDB_PATH_SENSORLIST, and TDBPath().

Referenced by TDBInit().

Here is the call graph for this function:

void TDBAbortParsing ( char *  s,
char *  fn 
)

Definition at line 341 of file tdb.c.

References PrintError, TDB_PATH_STATIONS, and tdbPaths.

Referenced by TDBInit().

struct ChannelType* TDBGetChannel ( char *  sta,
int  channel,
time_t  when 
) [read]

search tdb for a station

Parameters:
sta the station to look for
channel the channel number to look for
when the time of the information to find
Returns:
NULL if no information found, a pointer to the channel if found

Definition at line 704 of file tdb.c.

Referenced by TDBUpdateHeader().

int TDBInit ( void   ) 

data base initialization : read all stations

Parameters:
frame the frame to dump

Definition at line 352 of file tdb.c.

References __scandir(), ADD_CHANNEL_CODE, ADD_LOCATION_CODE, ADD_NETWORK_CODE, confKeyWord, DO_COMPARISON_KW, fileNameOptions, MAX_OSIRIS_CHANNEL, MyGetenv(), PrintDebug, PrintError, PrintLog, PrintStation(), ReadSensorList(), str2time(), TDB_PATH_LAST, TDB_PATH_SENSORLIST, TDB_PATH_STATIONS, TDBAbortParsing(), tdbName, and tdbPaths.

Referenced by ParseOptions().

Here is the call graph for this function:

char* TDBPath ( int  p,
char *  s 
)

path name based on TDB information

Parameters:
p the path to return the station we are working on, may be NULL
Returns:
the path, "." if no path can be defined

Definition at line 299 of file tdb.c.

References PrintError, TDB_PATH_LAST, TDB_PATH_SENSORLIST, tdbName, and tdbPaths.

Referenced by GetExtraTcorr(), GetFrameSkip(), GetInterpolatedShift(), MakeDtFileName(), and ReadSensorList().

int TDBUpdateHeader ( struct InfoHeaderType h  ) 

overwrite header information with TDB information

Parameters:
h the information header to change
Returns:
0 if ok, -1 if the statio was not found

Definition at line 725 of file tdb.c.

References Titan2SRType::base, InfoHeaderType::ch, InfoHeaderType::channel, ChannelName(), InfoHeaderType::correctedTime, Titan2SRType::div, InfoHeaderType::location, InfoHeaderType::network, PrintDebug, PrintError, PrintStation(), InfoHeaderType::sr, InfoHeaderType::station, TDBGetChannel(), and time2str().

Referenced by UpdateInfoHeader().

Here is the call graph for this function:


Variable Documentation

char* confKeyWord[] = { "dt", "dft", "tc", "stations", NULL }

Definition at line 132 of file tdb.c.

Referenced by TDBInit().

struct SensorType sensorEntry[MAX_SENSOR_NUMBER]

Initial value:

{
        { "STS1", "LP", 0, -1. },
        { "STS2", "LP", 0, -1. },
        { "STS2L", "LP", 0, -1. },
        { "STS1P", "MP", 0, -1. },
        { "STS2P", "MP", 0, -1. },
        { "STS2LP", "MP", 0, -1. },

        { "CMG5", "ACC", 0, -1. },
        { "CMG5HP", "ACC", 0, -1. },
        { "CMG3T", "LP", 0, -1. },
        { "CMG3E", "LP", 0, -1. },
        { "CMG40T", "LP", 0, -1. },

        { "EST", "ACC", 0, -1. },

        { "LE3D1S", "CP", 0, -1. },
        { "LE3D5S", "CP", 0, -1. },
        { "LE3D20S", "LP", 0, -1. },

        { "L22", "CP", 0, -1. },
        { "L4C", "CP", 0, -1. },

        { "SDJ", "CP", 0, -1. },
        { "SDJ5S", "CP", 0, -1. },

        
        { "", "", 0, -1. }
}

Definition at line 74 of file tdb.c.

char** tdbPaths = NULL

Definition at line 128 of file tdb.c.

Referenced by TDBAbortParsing(), TDBInit(), and TDBPath().

struct StationType* tdbStation = NULL

Definition at line 130 of file tdb.c.


Generated on Tue Jul 22 23:11:57 2008 for Titan2Reader by  doxygen 1.5.6