- Main Page
- Classes
- Files
- Related Pages

# include/nmxp_data.h

Go to the documentation of this file.

    00001
    00014 #ifndef NMXP_DATA_H
    00015 #define NMXP_DATA_H 1
    00016
    00017 #include <stdint.h>
    00018 #include <stdio.h>
    00019 #include <time.h>
    00020
    00021
    00023 typedef struct {
    00024     struct tm t;
    00025     uint32_t d;
    00026 } NMXP_TM_T;
    00027
    00028
    00029
    00031 #define NMX_SIGNATURE 0x7abcde0f
    00032
    00034 #define NMXP_DATA_IS_LEAP(yr)     ( yr%400==0 || (yr%4==0 && yr%100!=0) )
    00035
    00036
    00038 typedef enum {
    00039     NMXP_SHUTDOWN_NORMAL                = 1,
    00040     NMXP_SHUTDOWN_ERROR                 = 2,
    00041     NMXP_SHUTDOWN_TIMEOUT               = 3
    00042 } NMXP_SHUTDOWN_REASON;
    00043
    00045 typedef enum {
    00046    NMXP_MSG_CONNECT                     = 100,
    00047    NMXP_MSG_REQUESTPENDING              = 110,
    00048    NMXP_MSG_CANCELREQUEST               = 205,
    00049    NMXP_MSG_TERMINATESUBSCRIPTION       = 200,
    00050
    00051    NMXP_MSG_ADDTIMESERIESCHANNELS       = 120,
    00052    NMXP_MSG_ADDSOHCHANNELS              = 121,
    00053    NMXP_MSG_ADDSERIALCHANNELS           = 124,
    00054    NMXP_MSG_ADDTRIGGERCHANNELS          = 122,
    00055    NMXP_MSG_ADDEVENTS                   = 123,
    00056
    00057    NMXP_MSG_REMOVETIMESERIESCHANNELS    = 130,
    00058    NMXP_MSG_REMOVESOHCHANNELS           = 131,
    00059    NMXP_MSG_REMOVESERIALCHANNELS        = 134,
    00060    NMXP_MSG_REMOVETRIGGERCHANNELS       = 132,
    00061    NMXP_MSG_REMOVEEVENTS                = 133,
    00062
    00063    NMXP_MSG_CONNECTREQUEST              = 206,
    00064    NMXP_MSG_CHANNELLISTREQUEST          = 209,
    00065    NMXP_MSG_PRECISLISTREQUEST           = 203,
    00066    NMXP_MSG_CHANNELINFOREQUEST          = 226,
    00067    NMXP_MSG_DATASIZEREQUEST             = 229,
    00068    NMXP_MSG_DATAREQUEST                 = 227,
    00069    NMXP_MSG_TRIGGERREQUEST              = 231,
    00070    NMXP_MSG_EVENTREQUEST                = 232
    00071
    00072 } NMXP_MSG_CLIENT;
    00073
    00075 typedef enum {
    00076     NMXP_MSG_CHANNELLIST                = 150,
    00077     NMXP_MSG_ERROR                      = 190,
    00078     NMXP_MSG_COMPRESSED                 = 1,
    00079     NMXP_MSG_DECOMPRESSED               = 4,
    00080     NMXP_MSG_TRIGGER                    = 5,
    00081     NMXP_MSG_EVENT                      = 6,
    00082
    00083     NMXP_MSG_READY                      = 208,
    00084     NMXP_MSG_PRECISLIST                 = 253,
    00085     NMXP_MSG_CHANNELHEADER              = 256,
    00086     NMXP_MSG_DATASIZE                   = 257,
    00087     NMXP_MSG_NAQSEVENT                  = 260,
    00088     NMXP_MSG_NAQSTRIGGER                = 259
    00089
    00090 } NMXP_MSG_SERVER;
    00091
    00092
    00094 typedef struct {
    00095     int32_t signature;
    00096     int32_t type;
    00097     int32_t length;
    00098 } NMXP_MESSAGE_HEADER;
    00099
    00100
    00102 #define NETWORK_LENGTH 10
    00103
    00105 #define STATION_LENGTH 10
    00106
    00108 #define CHANNEL_LENGTH 10
    00109
    00111 typedef struct {
    00112     int32_t key;
    00113     char network[NETWORK_LENGTH];
    00114     char station[STATION_LENGTH];
    00115     char channel[CHANNEL_LENGTH];
    00116     int32_t packet_type;
    00117     int32_t x0;
    00118     int32_t xn;
    00119     int32_t x0n_significant;
    00120     int32_t oldest_seq_no;
    00121     int32_t seq_no;
    00122     double time;
    00123     void *buffer;
    00124     int32_t length;
    00125     int *pDataPtr;
    00126     int32_t nSamp;
    00127     int32_t sampRate;
    00128 } NMXP_DATA_PROCESS;
    00129
    00130
    00132 typedef struct {
    00133     char srcname[50];
    00134     FILE *outfile_mseed;
    00135     char filename_mseed[500];
    00136 } NMXP_DATA_SEED;
    00137
    00143 int nmxp_data_init(NMXP_DATA_PROCESS *pd);
    00144
    00145
    00159 int nmxp_data_unpack_bundle (int32_t *outdata, unsigned char *indata, int32_t *prev);
    00160
    00161
    00162 /* \brief Value for parameter exclude_bitmap in the function nmxp_data_trim() */
    00163 #define NMXP_DATA_TRIM_EXCLUDE_FIRST 2
    00164
    00165 /* \brief Value for parameter exclude_bitmap in the function nmxp_data_trim() */
    00166 #define NMXP_DATA_TRIM_EXCLUDE_LAST  4
    00167
    00170 int nmxp_data_to_str(char *out_str, double time_d);
    00171
    00172
    00185 int nmxp_data_trim(NMXP_DATA_PROCESS *pd, double trim_start_time, double trim_end_time, unsigned char exclude_bitmap);
    00186
    00187
    00191 time_t nmxp_data_gmtime_now();
    00192
    00193
    00199 double nmxp_data_latency(NMXP_DATA_PROCESS *pd);
    00200
    00201
    00208 int nmxp_data_log(NMXP_DATA_PROCESS *pd, int flag_sample);
    00209
    00210
    00215 int nmxp_data_parse_date(const char *pstr_date, NMXP_TM_T *ret_tmt);
    00216
    00217
    00222 double nmxp_data_tm_to_time(NMXP_TM_T *tmt);
    00223
    00224
    00230 int nmxp_data_seed_init(NMXP_DATA_SEED *data_seed);
    00231
    00232
    00244 int nmxp_data_msr_pack(NMXP_DATA_PROCESS *pd, NMXP_DATA_SEED *data_seed, void *pmsr);
    00245
    00246
    00252 void nmxp_data_swap_2b (int16_t *in);
    00253
    00254
    00260 void nmxp_data_swap_3b (unsigned char *in);
    00261
    00262
    00268 void nmxp_data_swap_4b (int32_t *in);
    00269
    00270
    00276 void nmxp_data_swap_8b (double *in);
    00277
    00278
    00287 int nmxp_data_bigendianhost ();
    00288
    00289
    00290 #endif
    00291