Commit 8682f6c5 authored by Matteo Quintiliani's avatar Matteo Quintiliani

Added network code for channel specification


git-svn-id: file:///home/quintiliani/svncopy/nmxptool/trunk@420 3cd66e75-5955-46cb-a940-c26e5fc5497d
parent 7891ee19
...@@ -19,9 +19,10 @@ nmxpport 28000 # Port number of the NaqsServer server ...@@ -19,9 +19,10 @@ nmxpport 28000 # Port number of the NaqsServer server
MaxTolerableLatency 120 MaxTolerableLatency 120
NetworkCode XX DefaultNetworkCode IV
Channel BOB.HH? Channel ES.BOB.HH?
Channel MN.TIR.HH?
Channel MDI.HH? Channel MDI.HH?
Channel DOI.HH? Channel DOI.HH?
Channel SALO.HH? Channel SALO.HH?
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy * Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it * quintiliani@ingv.it
* *
* $Id: nmxp.h,v 1.38 2007-10-03 13:38:27 mtheo Exp $ * $Id: nmxp.h,v 1.39 2007-10-07 14:11:23 mtheo Exp $
* *
*/ */
...@@ -1123,7 +1123,7 @@ int nmxp_receiveChannelList(int isock, NMXP_CHAN_LIST **pchannelList); ...@@ -1123,7 +1123,7 @@ int nmxp_receiveChannelList(int isock, NMXP_CHAN_LIST **pchannelList);
* \retval SOCKET_ERROR on error * \retval SOCKET_ERROR on error
* *
*/ */
int nmxp_sendAddTimeSeriesChannel(int isock, NMXP_CHAN_LIST *channelList, int32_t shortTermCompletion, int32_t out_format, NMXP_BUFFER_FLAG buffer_flag); int nmxp_sendAddTimeSeriesChannel(int isock, NMXP_CHAN_LIST_NET *channelList, int32_t shortTermCompletion, int32_t out_format, NMXP_BUFFER_FLAG buffer_flag);
/*! \brief Receive Compressed or Decompressed Data message from a socket and launch func_processData() on the extracted data /*! \brief Receive Compressed or Decompressed Data message from a socket and launch func_processData() on the extracted data
...@@ -1136,7 +1136,7 @@ int nmxp_sendAddTimeSeriesChannel(int isock, NMXP_CHAN_LIST *channelList, int32_ ...@@ -1136,7 +1136,7 @@ int nmxp_sendAddTimeSeriesChannel(int isock, NMXP_CHAN_LIST *channelList, int32_
* \retval NULL on error * \retval NULL on error
* *
*/ */
NMXP_DATA_PROCESS *nmxp_receiveData(int isock, NMXP_CHAN_LIST *channelList, const char *network_code); NMXP_DATA_PROCESS *nmxp_receiveData(int isock, NMXP_CHAN_LIST_NET *channelList, const char *network_code);
/*! \brief Sends the message "ConnectRequest" on a socket /*! \brief Sends the message "ConnectRequest" on a socket
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy * Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it * quintiliani@ingv.it
* *
* $Id: nmxp_base.h,v 1.22 2007-09-11 14:06:12 mtheo Exp $ * $Id: nmxp_base.h,v 1.23 2007-10-07 14:11:23 mtheo Exp $
* *
*/ */
...@@ -145,7 +145,7 @@ int nmxp_receiveMessage(int isock, NMXP_MSG_SERVER *type, void **buffer, int32_t ...@@ -145,7 +145,7 @@ int nmxp_receiveMessage(int isock, NMXP_MSG_SERVER *type, void **buffer, int32_t
* \return Return a pointer to static struct NMXP_DATA_PROCESS. * \return Return a pointer to static struct NMXP_DATA_PROCESS.
* *
*/ */
NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data, NMXP_CHAN_LIST *channelList, const char *network_code); NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data, NMXP_CHAN_LIST_NET *channelList, const char *network_code);
/*! \brief Process decompressed Data message by function func_processData(). /*! \brief Process decompressed Data message by function func_processData().
...@@ -158,7 +158,7 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data ...@@ -158,7 +158,7 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data
* \return Return a pointer to static struct NMXP_DATA_PROCESS. * \return Return a pointer to static struct NMXP_DATA_PROCESS.
* *
*/ */
NMXP_DATA_PROCESS *nmxp_processDecompressedData(char* buffer_data, int length_data, NMXP_CHAN_LIST *channelList, const char *network_code); NMXP_DATA_PROCESS *nmxp_processDecompressedData(char* buffer_data, int length_data, NMXP_CHAN_LIST_NET *channelList, const char *network_code);
#endif #endif
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy * Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it * quintiliani@ingv.it
* *
* $Id: nmxp_chan.h,v 1.20 2007-09-07 07:08:30 mtheo Exp $ * $Id: nmxp_chan.h,v 1.21 2007-10-07 14:11:23 mtheo Exp $
* *
*/ */
...@@ -34,15 +34,27 @@ typedef enum { ...@@ -34,15 +34,27 @@ typedef enum {
} NMXP_META_CHAN_LIST_SORT_TYPE; } NMXP_META_CHAN_LIST_SORT_TYPE;
/*! \brief Max number of channels */
#define MAX_N_CHAN 2000
/*! \brief The key/name info for one channel */
typedef struct {
int32_t key;
char name[24];
} NMXP_CHAN_KEY_NET;
/*! \brief Channel list */
typedef struct {
int32_t number;
NMXP_CHAN_KEY_NET channel[MAX_N_CHAN];
} NMXP_CHAN_LIST_NET;
/*! \brief The key/name info for one channel */ /*! \brief The key/name info for one channel */
typedef struct { typedef struct {
int32_t key; int32_t key;
char name[12]; char name[12];
} NMXP_CHAN_KEY; } NMXP_CHAN_KEY;
/*! \brief Max number of channels */
#define MAX_N_CHAN 1000
/*! \brief Channel list */ /*! \brief Channel list */
typedef struct { typedef struct {
int32_t number; int32_t number;
...@@ -105,9 +117,10 @@ typedef struct { ...@@ -105,9 +117,10 @@ typedef struct {
/*! \brief Copy station code and channel code from name /*! \brief Copy station code and channel code from name
* *
* \param station_dot_channel string containing STA.CHAN * \param net_dot_station_dot_channel string containing NET.STA.CHAN where NET. is optional
* \param[out] station_code Pointer to string for station code * \param[out] station_code Pointer to string for station code
* \param[out] channel_code Pointer to string for char code * \param[out] channel_code Pointer to string for channel code
* \param[out] network_code Pointer to string for station code
* *
* \warning Parametes can not be NULL! * \warning Parametes can not be NULL!
* *
...@@ -115,13 +128,13 @@ typedef struct { ...@@ -115,13 +128,13 @@ typedef struct {
* \retval 0 on error * \retval 0 on error
* *
*/ */
int nmxp_chan_cpy_sta_chan(const char *station_dot_channel, char *station_code, char *channel_code); int nmxp_chan_cpy_sta_chan(const char *net_dot_station_dot_channel, char *station_code, char *channel_code, char *network_code);
/*! \brief Match station_dot_channel against pattern, treating errors as no match. /*! \brief Match station_dot_channel against pattern, treating errors as no match.
* *
* \param station_dot_channel STA.CHAN format * \param net_dot_station_dot_channel NET.STA.CHAN format (NET. is optional)
* \param pattern STA.?HZ or STA.H?Z or STA.HH? or STA.?H? or .... * \param pattern N1.STA.?HZ or N2.STA.H?Z or STA.HH? or STA.?H? or ....
* *
* \retval 1 for match * \retval 1 for match
* \retval 0 for no match * \retval 0 for no match
...@@ -129,7 +142,7 @@ int nmxp_chan_cpy_sta_chan(const char *station_dot_channel, char *station_code, ...@@ -129,7 +142,7 @@ int nmxp_chan_cpy_sta_chan(const char *station_dot_channel, char *station_code,
* \retval -2 on error for invalid station_dot_channel * \retval -2 on error for invalid station_dot_channel
* *
*/ */
int nmxp_chan_match(const char *station_dot_channel, char *pattern); int nmxp_chan_match(const char *net_dot_station_dot_channel, char *pattern);
...@@ -152,7 +165,7 @@ int nmxp_chan_lookupKey(char* name, NMXP_CHAN_LIST *channelList); ...@@ -152,7 +165,7 @@ int nmxp_chan_lookupKey(char* name, NMXP_CHAN_LIST *channelList);
* \return Index of channel with key. -1 on error. * \return Index of channel with key. -1 on error.
* *
*/ */
int nmxp_chan_lookupKeyIndex(int32_t key, NMXP_CHAN_LIST *channelList); int nmxp_chan_lookupKeyIndex(int32_t key, NMXP_CHAN_LIST_NET *channelList);
/*! \brief Looks up a channel name in the list using a key /*! \brief Looks up a channel name in the list using a key
...@@ -163,7 +176,7 @@ int nmxp_chan_lookupKeyIndex(int32_t key, NMXP_CHAN_LIST *channelList); ...@@ -163,7 +176,7 @@ int nmxp_chan_lookupKeyIndex(int32_t key, NMXP_CHAN_LIST *channelList);
* \return Name of channel with key. NULL on error. * \return Name of channel with key. NULL on error.
* *
*/ */
char *nmxp_chan_lookupName(int32_t key, NMXP_CHAN_LIST *channelList); char *nmxp_chan_lookupName(int32_t key, NMXP_CHAN_LIST_NET *channelList);
/*! \brief Looks up a channel with specified data type. /*! \brief Looks up a channel with specified data type.
...@@ -184,13 +197,14 @@ NMXP_CHAN_LIST *nmxp_chan_getType(NMXP_CHAN_LIST *channelList, NMXP_DATATYPE dat ...@@ -184,13 +197,14 @@ NMXP_CHAN_LIST *nmxp_chan_getType(NMXP_CHAN_LIST *channelList, NMXP_DATATYPE dat
* \param channelList Channel list. * \param channelList Channel list.
* \param dataType Type of channel. * \param dataType Type of channel.
* \param sta_chan_list String list of item STA.CHAN, separeted by comma. * \param sta_chan_list String list of item STA.CHAN, separeted by comma.
* \param network_code_default Default Network code
* *
* \return Channel list with specified dataType. It will need to be freed! * \return Channel list with specified dataType. It will need to be freed!
* *
* \warning Returned value will need to be freed! * \warning Returned value will need to be freed!
* *
*/ */
NMXP_CHAN_LIST *nmxp_chan_subset(NMXP_CHAN_LIST *channelList, NMXP_DATATYPE dataType, char *sta_chan_list); NMXP_CHAN_LIST_NET *nmxp_chan_subset(NMXP_CHAN_LIST *channelList, NMXP_DATATYPE dataType, char *sta_chan_list, const char *network_code_default);
/*! Sort list by channel key /*! Sort list by channel key
...@@ -214,7 +228,7 @@ void nmxp_chan_sortByName(NMXP_CHAN_LIST *channelList); ...@@ -214,7 +228,7 @@ void nmxp_chan_sortByName(NMXP_CHAN_LIST *channelList);
* \param channelList Channel List * \param channelList Channel List
* *
*/ */
void nmxp_chan_print_channelList(NMXP_CHAN_LIST *channelList); void nmxp_chan_print_channelList(NMXP_CHAN_LIST_NET *channelList);
void nmxp_meta_chan_free(NMXP_META_CHAN_LIST **chan_list); void nmxp_meta_chan_free(NMXP_META_CHAN_LIST **chan_list);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy * Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it * quintiliani@ingv.it
* *
* $Id: nmxp.c,v 1.48 2007-10-04 20:34:30 mtheo Exp $ * $Id: nmxp.c,v 1.49 2007-10-07 14:11:23 mtheo Exp $
* *
*/ */
...@@ -61,7 +61,7 @@ int nmxp_receiveChannelList(int isock, NMXP_CHAN_LIST **pchannelList) { ...@@ -61,7 +61,7 @@ int nmxp_receiveChannelList(int isock, NMXP_CHAN_LIST **pchannelList) {
} }
int nmxp_sendAddTimeSeriesChannel(int isock, NMXP_CHAN_LIST *channelList, int32_t shortTermCompletion, int32_t out_format, NMXP_BUFFER_FLAG buffer_flag) { int nmxp_sendAddTimeSeriesChannel(int isock, NMXP_CHAN_LIST_NET *channelList, int32_t shortTermCompletion, int32_t out_format, NMXP_BUFFER_FLAG buffer_flag) {
int ret; int ret;
int32_t buffer_length = 16 + (4 * channelList->number); int32_t buffer_length = 16 + (4 * channelList->number);
char *buffer = malloc(buffer_length); char *buffer = malloc(buffer_length);
...@@ -100,7 +100,7 @@ int nmxp_sendAddTimeSeriesChannel(int isock, NMXP_CHAN_LIST *channelList, int32_ ...@@ -100,7 +100,7 @@ int nmxp_sendAddTimeSeriesChannel(int isock, NMXP_CHAN_LIST *channelList, int32_
} }
NMXP_DATA_PROCESS *nmxp_receiveData(int isock, NMXP_CHAN_LIST *channelList, const char *network_code) { NMXP_DATA_PROCESS *nmxp_receiveData(int isock, NMXP_CHAN_LIST_NET *channelList, const char *network_code) {
NMXP_MSG_SERVER type; NMXP_MSG_SERVER type;
void *buffer = NULL; void *buffer = NULL;
int32_t length; int32_t length;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy * Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it * quintiliani@ingv.it
* *
* $Id: nmxp_base.c,v 1.32 2007-10-05 12:54:35 mtheo Exp $ * $Id: nmxp_base.c,v 1.33 2007-10-07 14:11:23 mtheo Exp $
* *
*/ */
...@@ -234,7 +234,7 @@ int nmxp_receiveMessage(int isock, NMXP_MSG_SERVER *type, void **buffer, int32_t ...@@ -234,7 +234,7 @@ int nmxp_receiveMessage(int isock, NMXP_MSG_SERVER *type, void **buffer, int32_t
} }
NMXP_DATA_PROCESS *nmxp_processDecompressedData(char* buffer_data, int length_data, NMXP_CHAN_LIST *channelList, const char *network_code) NMXP_DATA_PROCESS *nmxp_processDecompressedData(char* buffer_data, int length_data, NMXP_CHAN_LIST_NET *channelList, const char *network_code_default)
{ {
int32_t netInt = 0; int32_t netInt = 0;
int32_t pKey = 0; int32_t pKey = 0;
...@@ -248,6 +248,7 @@ NMXP_DATA_PROCESS *nmxp_processDecompressedData(char* buffer_data, int length_da ...@@ -248,6 +248,7 @@ NMXP_DATA_PROCESS *nmxp_processDecompressedData(char* buffer_data, int length_da
char station_code[20]; char station_code[20];
char channel_code[20]; char channel_code[20];
char network_code[20];
static NMXP_DATA_PROCESS pd; static NMXP_DATA_PROCESS pd;
...@@ -274,15 +275,17 @@ NMXP_DATA_PROCESS *nmxp_processDecompressedData(char* buffer_data, int length_da ...@@ -274,15 +275,17 @@ NMXP_DATA_PROCESS *nmxp_processDecompressedData(char* buffer_data, int length_da
pDataPtr[idx] = netInt; pDataPtr[idx] = netInt;
} }
if(!nmxp_chan_cpy_sta_chan(nmxp_chan_lookupName(pKey, channelList), station_code, channel_code)) { if(!nmxp_chan_cpy_sta_chan(nmxp_chan_lookupName(pKey, channelList), station_code, channel_code, network_code)) {
nmxp_log(1,0, "Channel name not in STN.CHAN format: %s\n", nmxp_chan_lookupName(pKey, channelList)); nmxp_log(1,0, "Channel name not in STN.CHAN format: %s\n", nmxp_chan_lookupName(pKey, channelList));
} }
nmxp_data_init(&pd); nmxp_data_init(&pd);
pd.key = pKey; pd.key = pKey;
if(network_code) { if(network_code[0] != 0) {
strcpy(pd.network, network_code); strcpy(pd.network, network_code);
} else {
strcpy(pd.network, network_code_default);
} }
if(station_code[0] != 0) { if(station_code[0] != 0) {
strncpy(pd.station, station_code, STATION_LENGTH); strncpy(pd.station, station_code, STATION_LENGTH);
...@@ -308,7 +311,7 @@ NMXP_DATA_PROCESS *nmxp_processDecompressedData(char* buffer_data, int length_da ...@@ -308,7 +311,7 @@ NMXP_DATA_PROCESS *nmxp_processDecompressedData(char* buffer_data, int length_da
} }
NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data, NMXP_CHAN_LIST *channelList, const char *network_code) NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data, NMXP_CHAN_LIST_NET *channelList, const char *network_code_default)
{ {
int32_t pKey = 0; int32_t pKey = 0;
double pTime = 0.0; double pTime = 0.0;
...@@ -318,6 +321,7 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data ...@@ -318,6 +321,7 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data
char station_code[20]; char station_code[20];
char channel_code[20]; char channel_code[20];
char network_code[20];
static NMXP_DATA_PROCESS pd; static NMXP_DATA_PROCESS pd;
...@@ -442,7 +446,7 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data ...@@ -442,7 +446,7 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data
pSampRate = this_sample_rate; pSampRate = this_sample_rate;
if(!nmxp_chan_cpy_sta_chan(nmxp_chan_lookupName(pKey, channelList), station_code, channel_code)) { if(!nmxp_chan_cpy_sta_chan(nmxp_chan_lookupName(pKey, channelList), station_code, channel_code, network_code)) {
nmxp_log(1,0, "Channel name not in STN.CHAN format: %s\n", nmxp_chan_lookupName(pKey, channelList)); nmxp_log(1,0, "Channel name not in STN.CHAN format: %s\n", nmxp_chan_lookupName(pKey, channelList));
} }
...@@ -451,8 +455,10 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data ...@@ -451,8 +455,10 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data
nmxp_data_init(&pd); nmxp_data_init(&pd);
pd.key = pKey; pd.key = pKey;
if(network_code) { if(network_code[0] != 0) {
strcpy(pd.network, network_code); strcpy(pd.network, network_code);
} else {
strcpy(pd.network, network_code_default);
} }
if(station_code[0] != 0) { if(station_code[0] != 0) {
strncpy(pd.station, station_code, STATION_LENGTH); strncpy(pd.station, station_code, STATION_LENGTH);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy * Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it * quintiliani@ingv.it
* *
* $Id: nmxp_chan.c,v 1.21 2007-09-07 07:08:30 mtheo Exp $ * $Id: nmxp_chan.c,v 1.22 2007-10-07 14:11:23 mtheo Exp $
* *
*/ */
...@@ -17,31 +17,59 @@ ...@@ -17,31 +17,59 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
int nmxp_chan_cpy_sta_chan(const char *station_dot_channel, char *station_code, char *channel_code) { int nmxp_chan_cpy_sta_chan(const char *net_dot_station_dot_channel, char *station_code, char *channel_code, char *network_code) {
int ret = 0; int ret = 0;
char *sta_code_tmp, *cha_code_tmp; int errors = 0;
int i;
char *period1 = NULL, *period2 = NULL;
char *tmp_name = NULL;
if(net_dot_station_dot_channel || station_code || channel_code || network_code) {
if(station_dot_channel || station_code || channel_code) {
station_code[0] = 0; station_code[0] = 0;
channel_code[0] = 0; channel_code[0] = 0;
network_code[0] = 0;
/* validate pattern channel */
sta_code_tmp = strdup(station_dot_channel); tmp_name = strdup(net_dot_station_dot_channel);
if( (cha_code_tmp = strchr(sta_code_tmp, '.')) == NULL ) { /* count '.' */
nmxp_log(1, 0, "Name %s is not in STA.CHAN format!\n", station_dot_channel); i=0;
} else { while(i < strlen(tmp_name) && !errors) {
if(cha_code_tmp) { if(tmp_name[i] == '.') {
*cha_code_tmp++ = '\0'; if(!period1) {
strcpy(station_code, sta_code_tmp); period1 = tmp_name+i;
strcpy(channel_code, cha_code_tmp); } else if(!period2) {
free(sta_code_tmp); period2 = tmp_name+i;
ret = 1; } else {
errors++;
}
}
i++;
}
if(!errors && period1) {
ret = 1;
if(period2) {
/* NET.STA.CHAN */
*period1++ = '\0';
*period2++ = '\0';
strcpy(network_code, tmp_name);
strcpy(station_code, period1);
strcpy(channel_code, period2);
} else { } else {
nmxp_log(1, 0, "Name %s is not in STA.CHAN format! Channel is missing?\n", station_dot_channel); /* STA.CHAN */
*period1++ = '\0';
strcpy(station_code, tmp_name);
strcpy(channel_code, period1);
} }
} else {
nmxp_log(1, 0, "Name %s is not in NET.STA.CHAN format! (NET. is optional)\n", net_dot_station_dot_channel);
} }
if(tmp_name) {
free(tmp_name);
}
} else { } else {
nmxp_log(1, 0, "Some parameter is NULL in nmxp_chan_cpy_sta_chan().\n", station_dot_channel); nmxp_log(1, 0, "Some parameter is NULL in nmxp_chan_cpy_sta_chan().\n", net_dot_station_dot_channel);
} }
return ret; return ret;
...@@ -55,21 +83,37 @@ int nmxp_chan_cpy_sta_chan(const char *station_dot_channel, char *station_code, ...@@ -55,21 +83,37 @@ int nmxp_chan_cpy_sta_chan(const char *station_dot_channel, char *station_code,
* *
* return 1 for match, 0 for no match, -1 on error for invalid pattern, -2 on error for invalid station_dot_channel * return 1 for match, 0 for no match, -1 on error for invalid pattern, -2 on error for invalid station_dot_channel
*/ */
int nmxp_chan_match(const char *station_dot_channel, char *pattern) int nmxp_chan_match(const char *net_dot_station_dot_channel, char *pattern)
{ {
int ret = 0; int ret = 0;
int i, l; int i, l;
char sta_pattern[20]; char sta_pattern[20];
char cha_pattern[20]; char cha_pattern[20];
char net_pattern[20];
char sta_sdc[20]; char sta_sdc[20];
char *cha_sdc; char *cha_sdc;
/* validate pattern channel */ /* validate pattern channel */
if(!nmxp_chan_cpy_sta_chan(pattern, sta_pattern, cha_pattern)) { if(!nmxp_chan_cpy_sta_chan(pattern, sta_pattern, cha_pattern, net_pattern)) {
nmxp_log(1, 0, "Channel pattern %s is not in STA.CHAN format!\n", pattern); nmxp_log(1, 0, "Channel pattern %s is not in STA.CHAN format!\n", pattern);
return -1; return -1;
} }
l = strlen(net_pattern);
i = 0;
while(i < l && ret != -1) {
if( !(
(net_pattern[i] >= 'A' && net_pattern[i] <= 'Z')
|| (net_pattern[i] >= 'a' && net_pattern[i] <= 'z')
|| (net_pattern[i] >= '0' && net_pattern[i] <= '9')
)
) {
nmxp_log(1, 0, "Channel pattern %s has not valid NET format!\n", pattern);
return -1;
}
i++;
}
l = strlen(sta_pattern); l = strlen(sta_pattern);
i = 0; i = 0;
while(i < l && ret != -1) { while(i < l && ret != -1) {
...@@ -106,9 +150,9 @@ int nmxp_chan_match(const char *station_dot_channel, char *pattern) ...@@ -106,9 +150,9 @@ int nmxp_chan_match(const char *station_dot_channel, char *pattern)
i++; i++;
} }
strcpy(sta_sdc, station_dot_channel); strcpy(sta_sdc, net_dot_station_dot_channel);
if( (cha_sdc = strchr(sta_sdc, '.')) == NULL ) { if( (cha_sdc = strchr(sta_sdc, '.')) == NULL ) {
nmxp_log(1, 0, "Channel %s is not in STA.CHAN format!\n", station_dot_channel); nmxp_log(1, 0, "Channel %s is not in STA.CHAN format!\n", net_dot_station_dot_channel);
return -2; return -2;
} }
if(cha_sdc) { if(cha_sdc) {
...@@ -150,7 +194,7 @@ int nmxp_chan_lookupKey(char* name, NMXP_CHAN_LIST *channelList) ...@@ -150,7 +194,7 @@ int nmxp_chan_lookupKey(char* name, NMXP_CHAN_LIST *channelList)
} }
int nmxp_chan_lookupKeyIndex(int32_t key, NMXP_CHAN_LIST *channelList) int nmxp_chan_lookupKeyIndex(int32_t key, NMXP_CHAN_LIST_NET *channelList)
{ {
int i_chan = 0; int i_chan = 0;
int ret = -1; int ret = -1;
...@@ -168,7 +212,7 @@ int nmxp_chan_lookupKeyIndex(int32_t key, NMXP_CHAN_LIST *channelList) ...@@ -168,7 +212,7 @@ int nmxp_chan_lookupKeyIndex(int32_t key, NMXP_CHAN_LIST *channelList)
} }
char *nmxp_chan_lookupName(int32_t key, NMXP_CHAN_LIST *channelList) char *nmxp_chan_lookupName(int32_t key, NMXP_CHAN_LIST_NET *channelList)
{ {
int i_chan = 0; int i_chan = 0;
static char ret[12]; static char ret[12];
...@@ -213,13 +257,16 @@ NMXP_CHAN_LIST *nmxp_chan_getType(NMXP_CHAN_LIST *channelList, NMXP_DATATYPE dat ...@@ -213,13 +257,16 @@ NMXP_CHAN_LIST *nmxp_chan_getType(NMXP_CHAN_LIST *channelList, NMXP_DATATYPE dat
} }
NMXP_CHAN_LIST *nmxp_chan_subset(NMXP_CHAN_LIST *channelList, NMXP_DATATYPE dataType, char *sta_chan_list) { NMXP_CHAN_LIST_NET *nmxp_chan_subset(NMXP_CHAN_LIST *channelList, NMXP_DATATYPE dataType, char *sta_chan_list, const char *network_code_default) {
NMXP_CHAN_LIST *ret_channelList = NULL; NMXP_CHAN_LIST_NET *ret_channelList = NULL;
int istalist, ista; int istalist, ista;
char sta_chan_code_pattern[100]; char sta_chan_code_pattern[100];
int i_chan, ret_match; int i_chan, ret_match;
char network_code[20];
char station_code[20];
char channel_code[20];
ret_channelList = (NMXP_CHAN_LIST *) malloc(sizeof(NMXP_CHAN_LIST)); ret_channelList = (NMXP_CHAN_LIST_NET *) malloc(sizeof(NMXP_CHAN_LIST_NET));
ret_channelList->number = 0; ret_channelList->number = 0;
istalist = 0; istalist = 0;
...@@ -240,6 +287,9 @@ NMXP_CHAN_LIST *nmxp_chan_subset(NMXP_CHAN_LIST *channelList, NMXP_DATATYPE data ...@@ -240,6 +287,9 @@ NMXP_CHAN_LIST *nmxp_chan_subset(NMXP_CHAN_LIST *channelList, NMXP_DATATYPE data
if(i_chan != -1 && getDataTypeFromKey(channelList->channel[i_chan].key) == dataType) { if(i_chan != -1 && getDataTypeFromKey(channelList->channel[i_chan].key) == dataType) {
ret_channelList->channel[ret_channelList->number].key = channelList->channel[i_chan].key; ret_channelList->channel[ret_channelList->number].key = channelList->channel[i_chan].key;
strcpy(ret_channelList->channel[ret_channelList->number].name, channelList->channel[i_chan].name); strcpy(ret_channelList->channel[ret_channelList->number].name, channelList->channel[i_chan].name);
nmxp_chan_cpy_sta_chan(sta_chan_code_pattern, station_code, channel_code, network_code);
sprintf(ret_channelList->channel[ret_channelList->number].name, "%s.%s",
(network_code[0] != 0)? network_code : network_code_default, channelList->channel[i_chan].name);
ret_channelList->number++; ret_channelList->number++;
} }
} }
...@@ -283,7 +333,7 @@ void nmxp_chan_sortByName(NMXP_CHAN_LIST *channelList) { ...@@ -283,7 +333,7 @@ void nmxp_chan_sortByName(NMXP_CHAN_LIST *channelList) {
qsort (channelList->channel, channelList->number, sizeof (NMXP_CHAN_KEY), chan_name_compare); qsort (channelList->channel, channelList->number, sizeof (NMXP_CHAN_KEY), chan_name_compare);
} }
void nmxp_chan_print_channelList(NMXP_CHAN_LIST *channelList) { void nmxp_chan_print_channelList(NMXP_CHAN_LIST_NET *channelList) {
int chan_number = channelList->number; int chan_number = channelList->number;
int i_chan = 0; int i_chan = 0;
......
* template: #template# * template: #template#
plugin nmxptool_#statid# cmd="#pkgroot#/bin/nmxptool -H #srcaddr# -P #srcport# -S -1 -N #netid# -C #statid#.HH? -k" plugin nmxptool_#statid# cmd="#pkgroot#/bin/nmxptool -H #srcaddr# -P #srcport# -S -1 -C #netid#.#statid#.HH? -k"
timeout = 600 timeout = 600
start_retry = 60 start_retry = 60
shutdown_wait = 10 shutdown_wait = 10
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy * Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it * quintiliani@ingv.it
* *
* $Id: nmxptool.c,v 1.82 2007-10-06 15:34:00 mtheo Exp $ * $Id: nmxptool.c,v 1.83 2007-10-07 14:11:03 mtheo Exp $
* *
*/ */
...@@ -36,7 +36,9 @@ ...@@ -36,7 +36,9 @@
#include "seedlink_plugin.h" #include "seedlink_plugin.h"
#endif #endif
#define CURRENT_NETWORK (params.network)? params.network : DEFAULT_NETWORK #define CURRENT_NETWORK ( (params.network)? params.network : DEFAULT_NETWORK )
#define NETCODE_OR_CURRENT_NETWORK ( (network_code[0] != 0)? network_code : CURRENT_NETWORK )
#define GAP_TOLLERANCE 0.001 #define GAP_TOLLERANCE 0.001
typedef struct { typedef struct {
...@@ -68,7 +70,7 @@ NMXPTOOL_PARAMS params; ...@@ -68,7 +70,7 @@ NMXPTOOL_PARAMS params;
int naqssock = 0; int naqssock = 0;
FILE *outfile = NULL; FILE *outfile = NULL;
NMXP_CHAN_LIST *channelList = NULL; NMXP_CHAN_LIST *channelList = NULL;
NMXP_CHAN_LIST *channelList_subset = NULL; NMXP_CHAN_LIST_NET *channelList_subset = NULL;
NMXPTOOL_CHAN_SEQ *channelListSeq = NULL; NMXPTOOL_CHAN_SEQ *channelListSeq = NULL;
#ifdef HAVE_LIBMSEED #ifdef HAVE_LIBMSEED
...@@ -98,7 +100,7 @@ int main (int argc, char **argv) { ...@@ -98,7 +100,7 @@ int main (int argc, char **argv) {
int ret; int ret;
char filename[500]; char filename[500];
char station_code[20], channel_code[20]; char station_code[20], channel_code[20], network_code[20];
NMXP_DATA_PROCESS *pd; NMXP_DATA_PROCESS *pd;
...@@ -174,7 +176,7 @@ int main (int argc, char **argv) { ...@@ -174,7 +176,7 @@ int main (int argc, char **argv) {
/* Get list of available channels and get a subset list of params.channels */ /* Get list of available channels and get a subset list of params.channels */
channelList = nmxp_getAvailableChannelList(params.hostname, params.portnumberpds, NMXP_DATA_TIMESERIES); channelList = nmxp_getAvailableChannelList(params.hostname, params.portnumberpds, NMXP_DATA_TIMESERIES);