Commit ba09355f authored by Matteo Quintiliani's avatar Matteo Quintiliani

Adapted call for nmxp_log() and modified means of option -v


git-svn-id: file:///home/quintiliani/svncopy/nmxptool/trunk@472 3cd66e75-5955-46cb-a940-c26e5fc5497d
parent 599989ac
......@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it
*
* $Id: nmxptool.c,v 1.87 2007-11-21 13:12:49 mtheo Exp $
* $Id: nmxptool.c,v 1.88 2007-11-22 11:13:05 mtheo Exp $
*
*/
......@@ -140,7 +140,7 @@ int main (int argc, char **argv) {
#endif
/* Default is normal output */
nmxp_log(-1, 0);
nmxp_log(NMXP_LOG_SET, NMXP_LOG_D_NULL);
/* Initialize params from argument values */
if(nmxptool_getopt_long(argc, argv, &params) != 0) {
......@@ -167,9 +167,7 @@ int main (int argc, char **argv) {
return 1;
}
if(params.flag_verbose) {
nmxp_log(-1, 2);
}
nmxp_log(NMXP_LOG_SET, params.verbose_level);
/* List available channels on server */
if(params.flag_listchannels) {
......@@ -191,12 +189,12 @@ int main (int argc, char **argv) {
/* Check if some channel already exists */
if(channelList_subset->number <= 0) {
nmxp_log(NMXP_LOG_ERR, 0, "Channels not found!\n");
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CHANNEL, "Channels not found!\n");
return 1;
} else {
nmxp_chan_print_channelList(channelList_subset);
nmxp_log(NMXP_LOG_NORM, 1, "Init channelListSeq.\n");
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_CHANNEL, "Init channelListSeq.\n");
/* init channelListSeq */
channelListSeq = (NMXPTOOL_CHAN_SEQ *) malloc(sizeof(NMXPTOOL_CHAN_SEQ) * channelList_subset->number);
......@@ -209,19 +207,19 @@ int main (int argc, char **argv) {
}
#ifdef HAVE_LIBMSEED
nmxp_log(NMXP_LOG_NORM, 1, "Init mini-SEED record list.\n");
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_EXTRA, "Init mini-SEED record list.\n");
/* Init mini-SEED record list */
for(i_chan = 0; i_chan < channelList_subset->number; i_chan++) {
nmxp_log(NMXP_LOG_NORM, 1, "Init mini-SEED record for %s\n", channelList_subset->channel[i_chan].name);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_EXTRA, "Init mini-SEED record for %s\n", channelList_subset->channel[i_chan].name);
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, network_code)) {
nmxp_log(NMXP_LOG_NORM, 1, "%s.%s.%s\n", NETCODE_OR_CURRENT_NETWORK, station_code, channel_code);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_EXTRA, "%s.%s.%s\n", NETCODE_OR_CURRENT_NETWORK, station_code, channel_code);
strcpy(msr_list_chan[i_chan]->network, NETCODE_OR_CURRENT_NETWORK);
strcpy(msr_list_chan[i_chan]->station, station_code);
......@@ -231,7 +229,7 @@ int main (int argc, char **argv) {
msr_list_chan[i_chan]->encoding = DE_STEIM1; /* Steim 1 compression */
} else {
nmxp_log(NMXP_LOG_ERR, 0, "Channels %s error in format!\n");
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CHANNEL, "Channels %s error in format!\n");
return 1;
}
......@@ -246,7 +244,7 @@ int main (int argc, char **argv) {
channelList = NULL;
}
nmxp_log(NMXP_LOG_NORM, 1, "Starting comunication.\n");
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_CONNFLOW, "Starting comunication.\n");
/* TODO condition starting DAP or PDS */
if( (params.start_time != 0 && params.end_time != 0)
......@@ -265,25 +263,25 @@ int main (int argc, char **argv) {
/* DAP Step 1: Open a socket */
if( (naqssock = nmxp_openSocket(params.hostname, params.portnumberdap)) == NMXP_SOCKET_ERROR) {
nmxp_log(NMXP_LOG_ERR, 0, "Error opening socket!\n");
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CONNFLOW, "Error opening socket!\n");
return 1;
}
/* DAP Step 2: Read connection time */
if(nmxp_readConnectionTime(naqssock, &connection_time) != NMXP_SOCKET_OK) {
nmxp_log(NMXP_LOG_ERR, 0, "Error reading connection time from server!\n");
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CONNFLOW, "Error reading connection time from server!\n");
return 1;
}
/* DAP Step 3: Send a ConnectRequest */
if(nmxp_sendConnectRequest(naqssock, params.datas_username, params.datas_password, connection_time) != NMXP_SOCKET_OK) {
nmxp_log(NMXP_LOG_ERR, 0, "Error sending connect request!\n");
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CONNFLOW, "Error sending connect request!\n");
return 1;
}
/* DAP Step 4: Wait for a Ready message */
if(nmxp_waitReady(naqssock) != NMXP_SOCKET_OK) {
nmxp_log(NMXP_LOG_ERR, 0, "Error waiting Ready message!\n");
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CONNFLOW, "Error waiting Ready message!\n");
return 1;
}
......@@ -291,7 +289,7 @@ int main (int argc, char **argv) {
while(exitdapcondition) {
nmxp_log(NMXP_LOG_NORM, 1, "start_time = %d - end_time = %d\n", params.start_time, params.end_time);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_EXTRA, "start_time = %d - end_time = %d\n", params.start_time, params.end_time);
/* Start loop for sending requests */
i_chan=0;
......@@ -327,7 +325,7 @@ int main (int argc, char **argv) {
outfile = fopen(filename, "w");
if(!outfile) {
nmxp_log(NMXP_LOG_ERR, 0, "Can not to open file %s!", filename);
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_EXTRA, "Can not to open file %s!", filename);
}
}
......@@ -350,7 +348,7 @@ int main (int argc, char **argv) {
data_seed.outfile_mseed = fopen(data_seed.filename_mseed, "w");
if(!data_seed.outfile_mseed) {
nmxp_log(NMXP_LOG_ERR, 0, "Can not to open file %s!", data_seed.filename_mseed);
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_EXTRA, "Can not to open file %s!", data_seed.filename_mseed);
}
}
#endif
......@@ -372,7 +370,7 @@ int main (int argc, char **argv) {
/* DAP Step 6: Receive Data until receiving a Ready message */
ret = nmxp_receiveMessage(naqssock, &type, &buffer, &length, 0, &recv_errno);
nmxp_log(NMXP_LOG_NORM, 1, "ret = %d, type = %d\n", ret, type);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_CONNFLOW, "ret = %d, type = %d\n", ret, type);
while(ret == NMXP_SOCKET_OK && type != NMXP_MSG_READY) {
......@@ -396,7 +394,7 @@ int main (int argc, char **argv) {
if(nmxptool_check_and_log_gap(pd->time, channelListSeq[cur_chan].last_time, GAP_TOLLERANCE, pd->station, pd->channel)) {
channelListSeq[cur_chan].x_1 = 0;
nmxp_data_to_str(str_pd_time, pd->time);
nmxp_log(NMXP_LOG_WARN, 0, "%s.%s x0 set to zero at %s!\n", pd->station, pd->channel, str_pd_time);
nmxp_log(NMXP_LOG_WARN, NMXP_LOG_D_EXTRA, "%s.%s x0 set to zero at %s!\n", pd->station, pd->channel, str_pd_time);
}
}
}
......@@ -440,7 +438,7 @@ int main (int argc, char **argv) {
/* Receive Data */
ret = nmxp_receiveMessage(naqssock, &type, &buffer, &length, 0, &recv_errno);
nmxp_log(NMXP_LOG_NORM, 1, "ret = %d, type = %d\n", ret, type);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_CONNFLOW, "ret = %d, type = %d\n", ret, type);
}
if(params.flag_writefile && outfile) {
......@@ -467,7 +465,7 @@ int main (int argc, char **argv) {
if(time_to_sleep >= 0) {
sleep(time_to_sleep);
} else {
nmxp_log(NMXP_LOG_ERR, 0, "time to sleep %dsec.\n", time_to_sleep);
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CONNFLOW, "time to sleep %d sec.\n", time_to_sleep);
sleep(3);
}
params.start_time = params.end_time;
......@@ -566,9 +564,9 @@ int main (int argc, char **argv) {
data_seed.outfile_mseed = fopen(data_seed.filename_mseed, "w");
if(!data_seed.outfile_mseed) {
nmxp_log(NMXP_LOG_ERR, 0, "Can not to open file %s!", data_seed.filename_mseed);
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_EXTRA, "Can not to open file %s!", data_seed.filename_mseed);
} else {
nmxp_log(NMXP_LOG_NORM, 1, "Opened file %s!\n", data_seed.filename_mseed);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_EXTRA, "Opened file %s!\n", data_seed.filename_mseed);
}
}
#endif
......@@ -592,7 +590,7 @@ int main (int argc, char **argv) {
// TODO
exitpdscondition = 1;
} else {
nmxp_log(NMXP_LOG_ERR, 0, "Error receiving data. pd=%p recv_errno=%d\n", pd, recv_errno);
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CONNFLOW, "Error receiving data. pd=%p recv_errno=%d\n", pd, recv_errno);
exitpdscondition = 0;
}
......@@ -623,7 +621,7 @@ int main (int argc, char **argv) {
timeout_for_channel = nmxp_data_gmtime_now() - channelListSeq[to_cur_chan].last_time_call_raw_stream;
if(channelListSeq[to_cur_chan].last_time_call_raw_stream != 0
&& timeout_for_channel >= params.timeoutrecv) {
nmxp_log(NMXP_LOG_WARN, 0, "Timeout for channel %s (%d sec.)\n",
nmxp_log(NMXP_LOG_WARN, NMXP_LOG_D_DOD, "Timeout for channel %s (%d sec.)\n",
channelList_subset->channel[to_cur_chan].name, timeout_for_channel);
nmxp_raw_stream_manage(&(channelListSeq[to_cur_chan].raw_stream_buffer), NULL, p_func_pd, n_func_pd);
channelListSeq[to_cur_chan].last_time_call_raw_stream = nmxp_data_gmtime_now();
......@@ -643,7 +641,7 @@ int main (int argc, char **argv) {
if(nmxptool_check_and_log_gap(pd->time, channelListSeq[cur_chan].last_time, GAP_TOLLERANCE, pd->station, pd->channel)) {
channelListSeq[cur_chan].x_1 = 0;
nmxp_data_to_str(str_pd_time, pd->time);
nmxp_log(NMXP_LOG_WARN, 0, "%s.%s x0 set to zero at %s!\n", pd->station, pd->channel, str_pd_time);
nmxp_log(NMXP_LOG_WARN, NMXP_LOG_D_EXTRA, "%s.%s x0 set to zero at %s!\n", pd->station, pd->channel, str_pd_time);
}
}
}
......@@ -764,7 +762,7 @@ static void flushing_raw_data_stream() {
if(params.stc == -1) {
to_cur_chan = 0;
while(to_cur_chan < channelList_subset->number) {
nmxp_log(NMXP_LOG_WARN, 0, "Flushing data for channel %s\n",
nmxp_log(NMXP_LOG_WARN, NMXP_LOG_D_ANY, "Flushing data for channel %s\n",
channelList_subset->channel[to_cur_chan].name);
nmxp_raw_stream_manage(&(channelListSeq[to_cur_chan].raw_stream_buffer), NULL, p_func_pd, n_func_pd);
to_cur_chan++;
......@@ -775,7 +773,7 @@ static void flushing_raw_data_stream() {
/* Do any needed cleanup and exit */
static void clientShutdown(int sig) {
nmxp_log(NMXP_LOG_NORM, 0, "Program interrupted!\n");
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Program interrupted!\n");
flushing_raw_data_stream();
......@@ -854,7 +852,7 @@ int nmxptool_write_miniseed(NMXP_DATA_PROCESS *pd) {
ret = nmxp_data_msr_pack(pd, &data_seed, msr_list_chan[cur_chan]);
} else {
nmxp_log(NMXP_LOG_ERR, 0, "Key %d not found in channelList_subset!\n", pd->key);
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CHANNEL, "Key %d not found in channelList_subset!\n", pd->key);
}
return ret;
}
......@@ -865,7 +863,7 @@ int nmxptool_print_seq_no(NMXP_DATA_PROCESS *pd) {
char str_time[200];
nmxp_data_to_str(str_time, pd->time);
nmxp_log(NMXP_LOG_NORM_NO, 0, "Process %s.%s.%s %2d %d %d %s %dpts lat. %.1fs\n",
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "Process %s.%s.%s %2d %d %d %s %dpts lat. %.1fs\n",
pd->network,
pd->station,
pd->channel,
......@@ -902,10 +900,10 @@ int nmxptool_check_and_log_gap(double time1, double time2, const double gap_toll
nmxp_data_to_str(str_time1, time1);
nmxp_data_to_str(str_time2, time2);
if(gap > gap_tollerance) {
nmxp_log(NMXP_LOG_ERR, 0, "Gap %.2f sec. for %s.%s from %s to %s!\n", gap, station, channel, str_time2, str_time1);
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_GAP, "Gap %.2f sec. for %s.%s from %s to %s!\n", gap, station, channel, str_time2, str_time1);
ret = 1;
} else if (gap < -gap_tollerance) {
nmxp_log(NMXP_LOG_ERR, 0, "Overlap %.2f sec. for %s.%s from %s to %s!\n", gap, station, channel, str_time1, str_time2);
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_GAP, "Overlap %.2f sec. for %s.%s from %s to %s!\n", gap, station, channel, str_time1, str_time2);
ret = 1;
}
return ret;
......
......@@ -355,11 +355,7 @@ int nmxptool_ew_proc_configfile (char * configfile, NMXPTOOL_PARAMS *params) {
}
else if (k_its ("Verbosity")) {
if(k_int() != 0) {
params->flag_verbose = 1;
} else {
params->flag_verbose = 0;
}
params->verbose_level = k_int();
}
else if (k_its ("NmxpHost")) {
......
......@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it
*
* $Id: nmxptool_getoptlong.c,v 1.38 2007-11-21 14:07:37 mtheo Exp $
* $Id: nmxptool_getoptlong.c,v 1.39 2007-11-22 11:13:05 mtheo Exp $
*
*/
......@@ -40,6 +40,7 @@ const NMXPTOOL_PARAMS NMXPTOOL_PARAMS_DEFAULT =
DEFAULT_DELAY,
DEFAULT_MAX_TOLERABLE_LATENCY,
DEFAULT_TIMEOUTRECV,
DEFAULT_VERBOSE_LEVEL,
NULL,
0,
0,
......@@ -47,13 +48,12 @@ const NMXPTOOL_PARAMS NMXPTOOL_PARAMS_DEFAULT =
0,
0,
0,
0,
0
};
void nmxptool_author_support() {
nmxp_log(NMXP_LOG_NORM_NO, 0, "\
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "\
Matteo Quintiliani - Istituto Nazionale di Geofisica e Vulcanologia - Italy\n\
Mail bug reports and suggestions to <%s>.\n",
PACKAGE_BUGREPORT
......@@ -62,7 +62,7 @@ Mail bug reports and suggestions to <%s>.\n",
void nmxptool_version() {
nmxp_log(NMXP_LOG_NORM_NO, 0, "\
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "\
%s %s, Nanometrics tool based on %s, build %d\n\
(Data Access Protocol 1.0, Private Data Stream 1.4)\n",
PACKAGE_NAME, PACKAGE_VERSION,
......@@ -74,28 +74,28 @@ void nmxptool_version() {
}
void nmxptool_supports() {
nmxp_log(NMXP_LOG_NORM_NO, 0, "\
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "\
Support for: libmseed ");
#ifdef HAVE_LIBMSEED
nmxp_log(NMXP_LOG_NORM_NO, 0, "YES");
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "YES");
#else
nmxp_log(NMXP_LOG_NORM_NO, 0, "NO");
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "NO");
#endif
nmxp_log(NMXP_LOG_NORM_NO, 0, ", SeedLink ");
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, ", SeedLink ");
#ifdef HAVE___SRC_SEEDLINK_PLUGIN_C
nmxp_log(NMXP_LOG_NORM_NO, 0, "YES");
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "YES");
#else
nmxp_log(NMXP_LOG_NORM_NO, 0, "NO");
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "NO");
#endif
nmxp_log(NMXP_LOG_NORM_NO, 0, ", Earthworm ");
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, ", Earthworm ");
#ifdef HAVE_EARTHWORMOBJS
nmxp_log(NMXP_LOG_NORM_NO, 0, "YES");
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "YES");
#else
nmxp_log(NMXP_LOG_NORM_NO, 0, "NO");
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "NO");
#endif
nmxp_log(NMXP_LOG_NORM_NO, 0, ".\n");
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, ".\n");
}
......@@ -103,7 +103,7 @@ void nmxptool_usage(struct option long_options[])
{
nmxptool_version();
nmxp_log(NMXP_LOG_NORM_NO, 0, "\
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "\
\n\
Usage: %s -H hostname --listchannels\n\
Print list of available channels on DataServer.\n\
......@@ -117,13 +117,13 @@ Usage: %s -H hostname --listchannels\n\
\n", PACKAGE_NAME, PACKAGE_NAME, PACKAGE_NAME, PACKAGE_NAME);
#ifdef HAVE_EARTHWORMOBJS
nmxp_log(NMXP_LOG_NORM_NO, 0, "\
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "\
%s nmxptool.d\n\
Run as earthworm module receiving data from NaqServer by PDS.\n\
\n", PACKAGE_NAME);
#endif
nmxp_log(NMXP_LOG_NORM_NO, 0, "\
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "\
Arguments:\n\
-H, --hostname=HOST Nanometrics hostname.\n\
-C, --channels=LIST Channel list NET.STA.CHAN (NET. is optional)\n\
......@@ -131,42 +131,57 @@ Arguments:\n\
NET is used only for output!\n\
\n");
nmxp_log(NMXP_LOG_NORM_NO, 0, "\
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "\
Other arguments:\n\
-P, --portpds=PORT NaqsServer port number (default %d).\n\
-D, --portdap=PORT DataServer port number (default %d).\n\
-N, --network=NET Default Network code. (default '%s').\n\
-L, --location=LOC Location code for writing file.\n\
-v, --verbose Be verbose.\n\
-v, --verbose=level Be verbose. level is a bitmap:\n\
%d Packet, %d Channel, %d Raw Stream,\n\
%d CRC32, %d Connection flow,\n\
%d Packet Management, %d Extra, %d Date,\n\
%d Gap, %d DOD, %d All messages.\n\
-g, --logdata Print info about data.\n\
",
DEFAULT_PORT_PDS,
DEFAULT_PORT_DAP,
DEFAULT_NETWORK
DEFAULT_NETWORK,
NMXP_LOG_D_PACKET,
NMXP_LOG_D_CHANNEL,
NMXP_LOG_D_RAWSTREAM,
NMXP_LOG_D_CRC,
NMXP_LOG_D_CONNFLOW,
NMXP_LOG_D_PACKETMAN,
NMXP_LOG_D_EXTRA,
NMXP_LOG_D_DATE,
NMXP_LOG_D_GAP,
NMXP_LOG_D_DOD,
NMXP_LOG_D_ANY
);
#ifdef HAVE_LIBMSEED
nmxp_log(NMXP_LOG_NORM_NO, 0, "\
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "\
-m, --writeseed Pack received data in Mini-SEED records\n\
and write to a file.\n");
#endif
nmxp_log(NMXP_LOG_NORM_NO, 0, "\
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "\
-w, --writefile Dump received data to a file.\n");
#ifdef HAVE___SRC_SEEDLINK_PLUGIN_C
nmxp_log(NMXP_LOG_NORM_NO, 0, "\
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "\
-k, --slink=plug_name Send received data to SeedLink as a plug-in.\n\
plug_name is set by SeisComP daemon.\n\
INTO THE FILE seedlink.in, THIS OPTION MUST BE\n\
THE LAST WITHOUT ADDING VALUE FOR plug_name!\n");
#endif
nmxp_log(NMXP_LOG_NORM_NO, 0, "\
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "\
-V, --version Print tool version.\n\
-h, --help Print this help.\n\
\n");
nmxp_log(NMXP_LOG_NORM_NO, 0, "\
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "\
DAP Arguments:\n\
-s, --start_time=DATE Start time in date format.\n\
-e, --end_time=DATE End time in date format.\n\
......@@ -186,7 +201,7 @@ DAP Arguments:\n\
DEFAULT_DELAY_MINIMUM,
DEFAULT_DELAY_MAXIMUM);
nmxp_log(NMXP_LOG_NORM_NO, 0, "\
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "\
PDS arguments:\n\
-S, --stc=SECs Short-term-completion (default %d).\n\
-1 is for Raw Stream, no short-term completion.\n\
......@@ -224,7 +239,7 @@ PDS arguments:\n\
if(long_options) {
int i=0;
while(long_options[i].name) {
nmxp_log(NMXP_LOG_NORM_NO, 0, "%s %d %d %d %c\n", long_options[i].name, long_options[i].has_arg, (long_options[i].flag)? *(long_options[i].flag) : 0, long_options[i].val, long_options[i].val);
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_EXTRA, "%s %d %d %d %c\n", long_options[i].name, long_options[i].has_arg, (long_options[i].flag)? *(long_options[i].flag) : 0, long_options[i].val, long_options[i].val);
i++;
}
}
......@@ -258,8 +273,8 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
{"password", required_argument, 0, 'p'},
{"maxlatency", required_argument, 0, 'M'},
{"timeoutrecv", required_argument, 0, 'T'},
{"verbose", required_argument, 0, 'v'},
/* Following are flags */
{"verbose", no_argument, 0, 'v'},
{"logdata", no_argument, 0, 'g'},
{"buffered", no_argument, 0, 'b'},
{"listchannels", no_argument, 0, 'l'},
......@@ -297,7 +312,7 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
/* init params */
memcpy(params, &NMXPTOOL_PARAMS_DEFAULT, sizeof(NMXPTOOL_PARAMS_DEFAULT));
char optstr[100] = "H:P:D:C:N:L:S:R:s:e:t:d:u:p:M:T:vgbliwhV";
char optstr[100] = "H:P:D:C:N:L:S:R:s:e:t:d:u:p:M:T:v:gbliwhV";
#ifdef HAVE_LIBMSEED
strcat(optstr, "m");
......@@ -328,7 +343,7 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
if(one_time_option[c] > 1) {
ret_errors++;
nmxp_log(NMXP_LOG_NORM_NO, 0, "Replicated option -%c (value %s)\n", c, optarg);
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "Replicated option -%c (value %s)\n", c, optarg);
} else {
switch (c)
{
......@@ -336,10 +351,10 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
/* If this option set a flag, do nothing else now. */
if (long_options[option_index].flag != 0)
break;
nmxp_log(NMXP_LOG_NORM_NO, 0, "option %s", long_options[option_index].name);
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "option %s", long_options[option_index].name);
if (optarg)
nmxp_log(NMXP_LOG_NORM_NO, 0, " with arg %s", optarg);
nmxp_log(NMXP_LOG_NORM_NO, 0, "\n");
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, " with arg %s", optarg);
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "\n");
break;
case 'H':
......@@ -368,7 +383,7 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
case 'S':
params->stc = atoi(optarg);
nmxp_log(NMXP_LOG_NORM, 0, "Short-Term-Completion %d.\n", params->stc);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Short-Term-Completion %d.\n", params->stc);
break;
case 'R':
......@@ -411,18 +426,23 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
case 'M':
params->max_tolerable_latency = atoi(optarg);
nmxp_log(NMXP_LOG_NORM, 0, "Max_tolerable_latency %d\n", params->max_tolerable_latency);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Max_tolerable_latency %d\n", params->max_tolerable_latency);
break;
case 'T':
if(1) {
nmxp_log(NMXP_LOG_WARN, 0, "Time-out is currently disabled!\n");
nmxp_log(NMXP_LOG_WARN, NMXP_LOG_D_ANY, "Time-out is currently disabled!\n");
} else {
params->timeoutrecv = atoi(optarg);
nmxp_log(NMXP_LOG_NORM, 0, "Time-out receiving %d\n", params->timeoutrecv);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Time-out receiving %d\n", params->timeoutrecv);
}
break;
case 'v':
params->verbose_level = atoi(optarg);
break;
#ifdef HAVE___SRC_SEEDLINK_PLUGIN_C
case 'k':
params->flag_slink = 1;
......@@ -430,10 +450,6 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
break;
#endif
case 'v':
params->flag_verbose = 1;
break;
case 'g':
params->flag_logdata = 1;
break;
......@@ -488,9 +504,9 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
{
ret_errors += optind;
nmxp_log(NMXP_LOG_NORM_NO, 0, "non-option ARGV-elements: ");
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "non-option ARGV-elements: ");
while (optind < argc)
nmxp_log(NMXP_LOG_NORM_NO, 0, "%s ", argv[optind++]);
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "%s ", argv[optind++]);
putchar ('\n');
}
......@@ -510,58 +526,58 @@ int nmxptool_check_params(NMXPTOOL_PARAMS *params) {
/* Do nothing */
} else if(params->hostname == NULL) {
ret = -1;
nmxp_log(NMXP_LOG_NORM_NO, 0, "<hostname> is required!\n");
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "<hostname> is required!\n");
} else if(params->flag_listchannels) {
/* Do nothing */
} else if(params->hostname == NULL) {
ret = -1;
nmxp_log(NMXP_LOG_NORM_NO, 0, "<hostname> is required!\n");
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "<hostname> is required!\n");
} else if(params->channels == NULL) {
ret = -1;
nmxp_log(NMXP_LOG_NORM_NO, 0, "<STA.CHAN> is required!\n");
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "<STA.CHAN> is required!\n");
} else if(params->start_time == 0 && params->end_time != 0) {
ret = -1;
nmxp_log(NMXP_LOG_NORM_NO, 0, "<end_time> has to be used with <start_time>!\n");
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "<end_time> has to be used with <start_time>!\n");
} else if(params->start_time != 0 && params->end_time == 0) {
ret = -1;
nmxp_log(NMXP_LOG_NORM_NO, 0, "<start_time> has to be used with <end_time> or <interval>!\n");
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "<start_time> has to be used with <end_time> or <interval>!\n");
} else if(params->start_time != 0 && params->interval != 0 && params->end_time != 0) {
ret = -1;
nmxp_log(NMXP_LOG_NORM_NO, 0, "<end_time> and <interval> are exclusives!\n");
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "<end_time> and <interval> are exclusives!\n");
} else if(params->start_time != 0 && params->end_time != 0
&& params->start_time >= params->end_time) {
ret = -1;
nmxp_log(NMXP_LOG_NORM_NO, 0, "<start_time> is less than <end_time>!\n");
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "<start_time> is less than <end_time>!\n");
} else if(params->stc < DEFAULT_STC_MINIMUM || params->stc > DEFAULT_STC_MAXIMUM) {
ret = -1;
nmxp_log(NMXP_LOG_NORM_NO, 0, "<stc> has to be in the interval [%d..%d] secs.\n",
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "<stc> has to be in the interval [%d..%d] secs.\n",
DEFAULT_STC_MINIMUM, DEFAULT_STC_MAXIMUM);
} else if(params->stc == -1 && params->rate != DEFAULT_RATE) {
ret = -1;
nmxp_log(NMXP_LOG_NORM_NO, 0, "<rate> has to be equal to -1 when <stc> is equal to -1 (Raw Stream).\n");
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "<rate> has to be equal to -1 when <stc> is equal to -1 (Raw Stream).\n");
} else if(params->delay > 0 && params->start_time != 0 && params->end_time != 0) {
ret = -1;
nmxp_log(NMXP_LOG_NORM_NO, 0, "<delay> can not be used with options <start_time> and <end_time>.\n");
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "<delay> can not be used with options <start_time> and <end_time>.\n");
} else if( params->delay != DEFAULT_DELAY &&
(params->delay < DEFAULT_DELAY_MINIMUM || params->delay > DEFAULT_DELAY_MAXIMUM) ) {
ret = -1;
nmxp_log(NMXP_LOG_NORM_NO, 0, "<delay> has to be in the interval [%d..%d] secs.\n",
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "<delay> has to be in the interval [%d..%d] secs.\n",
DEFAULT_DELAY_MINIMUM, DEFAULT_DELAY_MAXIMUM);
} else if(params->rate < DEFAULT_RATE_MINIMUM || params->rate > DEFAULT_RATE_MAXIMUM) {
ret = -1;
nmxp_log(NMXP_LOG_NORM_NO, 0, "<rate> has to be in the interval [%d..%d].\n",
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "<rate> has to be in the interval [%d..%d].\n",
DEFAULT_RATE_MINIMUM, DEFAULT_RATE_MAXIMUM);
} else if(params->rate != -1 && params->start_time != 0 && params->end_time != 0) {
ret = -1;
nmxp_log(NMXP_LOG_NORM_NO, 0, "<rate> can not be used with options <start_time> and <end_time>.\n");
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "<rate> can not be used with options <start_time> and <end_time>.\n");
} else if(params->flag_buffered != 0 && params->start_time != 0 && params->end_time != 0) {
ret = -1;
nmxp_log(NMXP_LOG_NORM_NO, 0, "<buffered> can not be used with options <start_time> and <end_time>.\n");
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "<buffered> can not be used with options <start_time> and <end_time>.\n");
} else if( params->stc == -1
&& (params->max_tolerable_latency < DEFAULT_MAX_TOLERABLE_LATENCY_MINIMUM ||
params->max_tolerable_latency > DEFAULT_MAX_TOLERABLE_LATENCY_MAXIMUM)) {
ret = -1;
nmxp_log(NMXP_LOG_NORM_NO, 0, "<maxlatency> has to be within [%d..%d].\n",
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "<maxlatency> has to be within [%d..%d].\n",
DEFAULT_MAX_TOLERABLE_LATENCY_MINIMUM,
DEFAULT_MAX_TOLERABLE_LATENCY_MAXIMUM);
} else if( params->stc == -1
......@@ -569,20 +585,20 @@ int nmxptool_check_params(NMXPTOOL_PARAMS *params) {
params->timeoutrecv > DEFAULT_TIMEOUTRECV_MAXIMUM)) {
if(params->timeoutrecv != 0) {
ret = -1;
nmxp_log(NMXP_LOG_NORM_NO, 0, "<timeoutrecv> has to be within [%d..%d] or equal to zero for not time-out.\n",
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "<timeoutrecv> has to be within [%d..%d] or equal to zero for not time-out.\n",
DEFAULT_TIMEOUTRECV_MINIMUM,
DEFAULT_TIMEOUTRECV_MAXIMUM);
}
} else if( params->stc != -1 && params->max_tolerable_latency > 0 ){
nmxp_log(NMXP_LOG_WARN, 0, "<maxlatency> ignored since not defined --stc=-1.\n");
nmxp_log(NMXP_LOG_WARN, NMXP_LOG_D_ANY, "<maxlatency> ignored since not defined --stc=-1.\n");
} else if(params->stc != -1 && params->timeoutrecv > 0) {
params->timeoutrecv = 0;
nmxp_log(NMXP_LOG_WARN, 0, "<timeoutrecv> ignored since not defined --stc=-1.\n");
nmxp_log(NMXP_LOG_WARN, NMXP_LOG_D_ANY, "<timeoutrecv> ignored since not defined --stc=-1.\n");
}
/*
if( params->stc == -1 ) {
nmxp_log(NMXP_LOG_WARN, 0, "<maxlatency> is equal to %d sec.\n", params->max_tolerable_latency);
nmxp_log(NMXP_LOG_WARN, NMXP_LOG_D_ANY, "<maxlatency> is equal to %d sec.\n", params->max_tolerable_latency);
}
*/
......
......@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it
*
* $Id: nmxptool_getoptlong.h,v 1.20 2007-11-21 11:04:56 mtheo Exp $
* $Id: nmxptool_getoptlong.h,v 1.21 2007-11-22 11:13:05 mtheo Exp $
*
*/
......@@ -43,6 +43,8 @@
#define DEFAULT_TIMEOUTRECV_MINIMUM 10
#define DEFAULT_TIMEOUTRECV_MAXIMUM 300
#define DEFAULT_VERBOSE_LEVEL NMXP_LOG_D_NULL
/*! \brief Struct that stores information about parameter of the program */
typedef struct {
......@@ -63,9 +65,9 @@ typedef struct {
int32_t delay;
int32_t max_tolerable_latency;
int32_t timeoutrecv;
int32_t verbose_level;
char *ew_configuration_file;
int flag_writeseed;
int flag_verbose;
int flag_listchannels;
int flag_request_channelinfo;
int flag_writefile;
......
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