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
MaxTolerableLatency 120
NetworkCode XX
DefaultNetworkCode IV
Channel BOB.HH?
Channel ES.BOB.HH?
Channel MN.TIR.HH?
Channel MDI.HH?
Channel DOI.HH?
Channel SALO.HH?
......
......@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* 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);
* \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
......@@ -1136,7 +1136,7 @@ int nmxp_sendAddTimeSeriesChannel(int isock, NMXP_CHAN_LIST *channelList, int32_
* \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
......
......@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* 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
* \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().
......@@ -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.
*
*/
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
......@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* 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 {
} 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 */
typedef struct {
int32_t key;
char name[12];
} NMXP_CHAN_KEY;
/*! \brief Max number of channels */
#define MAX_N_CHAN 1000
/*! \brief Channel list */
typedef struct {
int32_t number;
......@@ -105,9 +117,10 @@ typedef struct {
/*! \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] 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!
*
......@@ -115,13 +128,13 @@ typedef struct {
* \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.
*
* \param station_dot_channel STA.CHAN format
* \param pattern STA.?HZ or STA.H?Z or STA.HH? or STA.?H? or ....
* \param net_dot_station_dot_channel NET.STA.CHAN format (NET. is optional)
* \param pattern N1.STA.?HZ or N2.STA.H?Z or STA.HH? or STA.?H? or ....
*
* \retval 1 for match
* \retval 0 for no match
......@@ -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
*
*/
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);
* \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
......@@ -163,7 +176,7 @@ int nmxp_chan_lookupKeyIndex(int32_t key, NMXP_CHAN_LIST *channelList);
* \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.
......@@ -184,13 +197,14 @@ NMXP_CHAN_LIST *nmxp_chan_getType(NMXP_CHAN_LIST *channelList, NMXP_DATATYPE dat
* \param channelList Channel list.
* \param dataType Type of channel.
* \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!
*
* \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
......@@ -214,7 +228,7 @@ void nmxp_chan_sortByName(NMXP_CHAN_LIST *channelList);
* \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);
......
......@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* 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) {
}
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;
int32_t buffer_length = 16 + (4 * channelList->number);
char *buffer = malloc(buffer_length);
......@@ -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;
void *buffer = NULL;
int32_t length;
......
......@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* 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
}
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 pKey = 0;
......@@ -248,6 +248,7 @@ NMXP_DATA_PROCESS *nmxp_processDecompressedData(char* buffer_data, int length_da
char station_code[20];
char channel_code[20];
char network_code[20];
static NMXP_DATA_PROCESS pd;
......@@ -274,15 +275,17 @@ NMXP_DATA_PROCESS *nmxp_processDecompressedData(char* buffer_data, int length_da
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_data_init(&pd);
pd.key = pKey;
if(network_code) {
if(network_code[0] != 0) {
strcpy(pd.network, network_code);
} else {
strcpy(pd.network, network_code_default);
}
if(station_code[0] != 0) {
strncpy(pd.station, station_code, STATION_LENGTH);
......@@ -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;
double pTime = 0.0;
......@@ -318,6 +321,7 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data
char station_code[20];
char channel_code[20];
char network_code[20];
static NMXP_DATA_PROCESS pd;
......@@ -442,7 +446,7 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data
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));
}
......@@ -451,8 +455,10 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data
nmxp_data_init(&pd);
pd.key = pKey;
if(network_code) {
if(network_code[0] != 0) {
strcpy(pd.network, network_code);
} else {
strcpy(pd.network, network_code_default);
}
if(station_code[0] != 0) {
strncpy(pd.station, station_code, STATION_LENGTH);
......
......@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* 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 @@
#include <string.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;
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;
channel_code[0] = 0;
/* validate pattern channel */
sta_code_tmp = strdup(station_dot_channel);
if( (cha_code_tmp = strchr(sta_code_tmp, '.')) == NULL ) {
nmxp_log(1, 0, "Name %s is not in STA.CHAN format!\n", station_dot_channel);
network_code[0] = 0;
tmp_name = strdup(net_dot_station_dot_channel);
/* count '.' */
i=0;
while(i < strlen(tmp_name) && !errors) {
if(tmp_name[i] == '.') {
if(!period1) {
period1 = tmp_name+i;
} else if(!period2) {
period2 = tmp_name+i;
} else {
if(cha_code_tmp) {
*cha_code_tmp++ = '\0';
strcpy(station_code, sta_code_tmp);
strcpy(channel_code, cha_code_tmp);
free(sta_code_tmp);
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 {
/* STA.CHAN */
*period1++ = '\0';
strcpy(station_code, tmp_name);
strcpy(channel_code, period1);
}
} else {
nmxp_log(1, 0, "Name %s is not in STA.CHAN format! Channel is missing?\n", station_dot_channel);
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 {
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;
......@@ -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
*/
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 i, l;
char sta_pattern[20];
char cha_pattern[20];
char net_pattern[20];
char sta_sdc[20];
char *cha_sdc;
/* 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);
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);
i = 0;
while(i < l && ret != -1) {
......@@ -106,9 +150,9 @@ int nmxp_chan_match(const char *station_dot_channel, char *pattern)
i++;
}
strcpy(sta_sdc, station_dot_channel);
strcpy(sta_sdc, net_dot_station_dot_channel);
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;
}
if(cha_sdc) {
......@@ -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 ret = -1;
......@@ -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;
static char ret[12];
......@@ -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 *ret_channelList = NULL;
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_NET *ret_channelList = NULL;
int istalist, ista;
char sta_chan_code_pattern[100];
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;
istalist = 0;
......@@ -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) {
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);
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++;
}
}
......@@ -283,7 +333,7 @@ void nmxp_chan_sortByName(NMXP_CHAN_LIST *channelList) {
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 i_chan = 0;
......
* 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
start_retry = 60
shutdown_wait = 10
......
......@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* 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 @@
#include "seedlink_plugin.h"
#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
typedef struct {
......@@ -68,7 +70,7 @@ NMXPTOOL_PARAMS params;
int naqssock = 0;
FILE *outfile = NULL;
NMXP_CHAN_LIST *channelList = NULL;
NMXP_CHAN_LIST *channelList_subset = NULL;
NMXP_CHAN_LIST_NET *channelList_subset = NULL;
NMXPTOOL_CHAN_SEQ *channelListSeq = NULL;
#ifdef HAVE_LIBMSEED
......@@ -98,7 +100,7 @@ int main (int argc, char **argv) {
int ret;
char filename[500];
char station_code[20], channel_code[20];
char station_code[20], channel_code[20], network_code[20];
NMXP_DATA_PROCESS *pd;
......@@ -174,7 +176,7 @@ int main (int argc, char **argv) {
/* Get list of available channels and get a subset list of params.channels */
channelList = nmxp_getAvailableChannelList(params.hostname, params.portnumberpds, NMXP_DATA_TIMESERIES);
channelList_subset = nmxp_chan_subset(channelList, NMXP_DATA_TIMESERIES, params.channels);
channelList_subset = nmxp_chan_subset(channelList, NMXP_DATA_TIMESERIES, params.channels, CURRENT_NETWORK);
/* Check if some channel already exists */
if(channelList_subset->number <= 0) {
......@@ -205,11 +207,11 @@ int main (int argc, char **argv) {
msr_list_chan[i_chan] = msr_init(NULL);
/* Separate station_code and channel_code */
if(nmxp_chan_cpy_sta_chan(channelList_subset->channel[i_chan].name, station_code, channel_code)) {
if(nmxp_chan_cpy_sta_chan(channelList_subset->channel[i_chan].name, station_code, channel_code, network_code)) {
nmxp_log(0, 1, "%s.%s.%s\n", CURRENT_NETWORK, station_code, channel_code);
nmxp_log(0, 1, "%s.%s.%s\n", NETCODE_OR_CURRENT_NETWORK, station_code, channel_code);
strcpy(msr_list_chan[i_chan]->network, CURRENT_NETWORK);
strcpy(msr_list_chan[i_chan]->network, NETCODE_OR_CURRENT_NETWORK);
strcpy(msr_list_chan[i_chan]->station, station_code);
strcpy(msr_list_chan[i_chan]->channel, channel_code);
......@@ -297,11 +299,19 @@ int main (int argc, char **argv) {
if(params.flag_writefile) {
/* Open output file */
sprintf(filename, "%s.%s_%s_%s.nmx",
CURRENT_NETWORK,
if(nmxp_chan_cpy_sta_chan(channelList_subset->channel[i_chan].name, station_code, channel_code, network_code)) {
sprintf(filename, "%s.%s.%s_%s_%s.nmx",
NETCODE_OR_CURRENT_NETWORK,
station_code,
channel_code,
str_start_time,
str_end_time);
} else {
sprintf(filename, "%s_%s_%s.nmx",
channelList_subset->channel[i_chan].name,
str_start_time,
str_end_time);
}
outfile = fopen(filename, "w");
if(!outfile) {
......@@ -312,11 +322,19 @@ int main (int argc, char **argv) {
#ifdef HAVE_LIBMSEED
if(params.flag_writeseed) {
/* Open output Mini-SEED file */
sprintf(data_seed.filename_mseed, "%s.%s_%s_%s.miniseed",
CURRENT_NETWORK,
if(nmxp_chan_cpy_sta_chan(channelList_subset->channel[i_chan].name, station_code, channel_code, network_code)) {
sprintf(data_seed.filename_mseed, "%s.%s.%s_%s_%s.miniseed",
NETCODE_OR_CURRENT_NETWORK,
station_code,
channel_code,
str_start_time,
str_end_time);
} else {
sprintf(filename, "%s_%s_%s.miniseed",
channelList_subset->channel[i_chan].name,
str_start_time,
str_end_time);
}
data_seed.outfile_mseed = fopen(data_seed.filename_mseed, "w");
if(!data_seed.outfile_mseed) {
......@@ -329,11 +347,11 @@ int main (int argc, char **argv) {
/* Compute SNCL line */
/* Separate station_code_old_way and channel_code_old_way */
if(nmxp_chan_cpy_sta_chan(channelList_subset->channel[i_chan].name, station_code, channel_code)) {
if(nmxp_chan_cpy_sta_chan(channelList_subset->channel[i_chan].name, station_code, channel_code, network_code)) {
/* Write SNCL line */
fprintf(outfile, "%s.%s.%s.%s\n",
station_code,
CURRENT_NETWORK,
NETCODE_OR_CURRENT_NETWORK,
channel_code,
(params.location)? params.location : "");
}
......@@ -347,7 +365,7 @@ int main (int argc, char **argv) {
while(ret == NMXP_SOCKET_OK && type != NMXP_MSG_READY) {
/* Process a packet and return value in NMXP_DATA_PROCESS structure */
pd = nmxp_processCompressedData(buffer, length, channelList_subset, CURRENT_NETWORK);
pd = nmxp_processCompressedData(buffer, length, channelList_subset, NETCODE_OR_CURRENT_NETWORK);
nmxp_data_trim(pd, params.start_time, params.end_time, 0);
/* Log contents of last packet */
......@@ -519,7 +537,7 @@ int main (int argc, char **argv) {
}
/* Get a subset of channel from arguments */
channelList_subset = nmxp_chan_subset(channelList, NMXP_DATA_TIMESERIES, params.channels);
channelList_subset = nmxp_chan_subset(channelList, NMXP_DATA_TIMESERIES, params.channels, CURRENT_NETWORK);
/* PDS Step 4: Send a Request Pending (optional) */
......@@ -555,10 +573,22 @@ int main (int argc, char **argv) {
}
#endif
#ifdef TEST_FOR_DOD
/*
struct timeval timeo;
timeo.tv_sec = 0;
timeo.tv_usec = 0;
if (setsockopt(naqssock, SOL_SOCKET, SO_RCVTIMEO, &timeo, sizeof(timeo)) < 0) {
perror("setsockopt SO_RCVTIMEO");
}
*/
#endif
while(exitpdscondition) {
/* Process Compressed or Decompressed Data */
pd = nmxp_receiveData(naqssock, channelList_subset, CURRENT_NETWORK);
pd = nmxp_receiveData(naqssock, channelList_subset, NETCODE_OR_CURRENT_NETWORK);
/* Log contents of last packet */
if(params.flag_logdata) {
......
......@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it
*
* $Id: nmxptool_getoptlong.c,v 1.32 2007-10-06 17:26:06 mtheo Exp $
* $Id: nmxptool_getoptlong.c,v 1.33 2007-10-07 14:11:03 mtheo Exp $
*
*/
......@@ -124,14 +124,16 @@ Usage: %s -H hostname --listchannels [...]\n\
nmxp_log(NMXP_LOG_NORM_NO, 0, "\
Arguments:\n\
-H, --hostname=HOST Nanometrics hostname.\n\
-C, --channels=LIST Channel list STA1.HH?,STA2.??Z,...\n\
-C, --channels=LIST Channel list NET.STA.CHAN (NET. is optional)\n\
N1.STA1.HH?,N2.STA2.??Z,STA3.?H?,...\n\
NET is used only for output!\n\
\n");
nmxp_log(NMXP_LOG_NORM_NO, 0, "\
Other arguments:\n\
-P, --portpds=PORT NaqsServer port number (default %d).\n\
-D, --portdap=PORT DataServer port number (default %d).\n\
-N, --network=NET Declare Network code for all stations (default '%s').\n\
-N, --network=NET Default Network code for stations without value. (default '%s').\n\
-L, --location=LOC Location code for writing file.\n\
-v, --verbose Be verbose.\n\
-g, --logdata Print info about data.\n\
......@@ -169,7 +171,7 @@ DAP Arguments:\n\
where:\n\
<date> = yyyy/mm/dd | yyy.jjj\n\
<time> = hh:mm:ss | hh:mm\n\
-t, --interval=SECs Interval from start_time.\n\
-t, --interval=SECs Time interval from start_time.\n\
-d, --delay=SECs Receive continuosly data with delay [%d..%d].\n\
-u, --username=USER DataServer username.\n\
-p, --password=PASS DataServer password.\n\
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment