00001 #ifndef _GLOBAL_AMP_H 00002 #define _GLOBAL_AMP_H 00003 /*---------------------------------------------------------------------------*/ 00004 00005 00006 #include <trace_buf.h> /* TRACE_STA_LEN, TRACE_CHAN_LEN, TRACE_NET_LEN, TRACE_LOC_LEN */ 00007 #include <earthworm_defs.h> /* for amp types */ 00008 #include <global_msg.h> /* for return codes */ 00009 00010 00011 /*---------------------------------------------------------------------------*/ 00012 00013 00014 /* ========================================================================== 00015 ** SIZE DEFINES AND LIMITS 00016 ** ========================================================================= */ 00017 00018 /* Global Amp 01 00019 ** 00020 ** <author> <sequence_number> <version> <station> <comp> <net> <loc> <pick_time> <magnitude_type> <amplitude> <associated_period> 00021 ** 00022 ** 001002003 sssssssssssssss vv ssssss cccccccc nnnnnnnn llllllll yyyymmddhhmmss.sss T aaaaaaaaaaaaa.aa pppppppppppp.ppp 00023 ** \n 00024 ** \0 00025 ** 1 2 3 4 5 6 7 8 9 0 1 2 00026 ** 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901 00027 */ 00028 00029 #define GLOBAL_AMP_MAXBUFSIZE (118 + BUFF_OVERRUN_SIZE) 00030 00031 typedef char GLOBAL_AMP_BUFFER[GLOBAL_AMP_MAXBUFSIZE+1]; 00032 00033 00034 typedef struct GLOBAL_AMP_MSG 00035 { 00036 short version; /* only set using InitGlobalAmp() or StringToAmp() */ 00037 MSG_LOGO logo; 00038 long sequence; /* pick sequence number */ 00039 char station[TRACE_STA_LEN]; 00040 char channel[TRACE_CHAN_LEN]; 00041 char network[TRACE_NET_LEN]; 00042 char location[TRACE_LOC_LEN]; 00043 char amp_time[19]; 00044 AMPLITUDE_TYPE amptype; 00045 double adcounts; /* a/d counts */ 00046 double period; /* seconds */ 00047 } GLOBAL_AMP_STRUCT; 00048 00049 00050 00051 /* ========================================================================== 00052 ** FUNCTION PROTOTYPES 00053 ** ========================================================================= */ 00054 00055 00056 /* InitGlobalAmp 00057 ** 00058 ** Used to initialize, including allocate working memory for 00059 ** a global amp message struct. 00060 ** 00061 ** PARAMETER: 00062 ** p_struct -- pointer to structure to contain the message information 00063 ** 00064 ** RETURNS: 00065 ** GLOBAL_MSG_SUCCESS 00066 ** GLOBAL_MSG_NULLSTRUCT = structure pointer is NULL 00067 */ 00068 GLOBAL_MSG_STATUS InitGlobalAmp( GLOBAL_AMP_STRUCT * p_struct ); 00069 00070 00071 00072 00073 /* WriteAmpToBuffer 00074 ** 00075 ** Writes a global amp message structure to a buffer. 00076 ** 00077 ** PARAMETERS: 00078 ** p_struct -- the source structure 00079 ** p_buffer -- the target buffer 00080 ** (on successful return, buffer will be null-terminated) 00081 ** p_length -- the available buffer size 00082 ** 00083 ** RETURNS: 00084 ** GLOBAL_MSG_SUCCESS 00085 ** GLOBAL_MSG_NULLSTRUCT = structure pointer is NULL 00086 ** GLOBAL_MSG_VERSINVALID = invalid message version 00087 ** GLOBAL_MSG_BADPARAM = buffer pointer is NULL 00088 ** GLOBAL_MSG_TOOSMALL = buffer not large enough to contain message 00089 ** (may be partly written anyway) 00090 ** GLOBAL_MSG_DEFINESMALL = max buffer size too small for normal write 00091 */ 00092 GLOBAL_MSG_STATUS WriteAmpToBuffer( GLOBAL_AMP_STRUCT * p_struct, char * p_buffer, unsigned int p_length ); 00093 00094 00095 00096 /* StringToAmp 00097 ** 00098 ** Parses any global amp message from a supplied string. 00099 ** 00100 ** RETURNS: 00101 ** GLOBAL_MSG_SUCCESS 00102 ** GLOBAL_MSG_NULLSTRUCT = structure pointer is NULL 00103 ** GLOBAL_MSG_VERSINVALID = invalid message version 00104 ** GLOBAL_MSG_BADPARAM = string pointer is NULL 00105 ** GLOBAL_MSG_FORMATERROR = invalid string format 00106 ** 00107 */ 00108 GLOBAL_MSG_STATUS StringToAmp( GLOBAL_AMP_STRUCT * p_struct, char * p_string ); 00109 00110 00111 #endif 00112