Commit e9a47714 authored by Matteo Quintiliani's avatar Matteo Quintiliani

Added parameters from nmxp_pds


git-svn-id: file:///home/quintiliani/svncopy/nmxptool/trunk@107 3cd66e75-5955-46cb-a940-c26e5fc5497d
parent a9eda782
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
#include "config.h" #include "config.h"
#ifdef HAVE___SRC_PLUGIN_H #ifdef HAVE___SRC_SEEDLINK_PLUGIN_H
#include "plugin.h" #include "seedlink_plugin.h"
#endif #endif
...@@ -32,7 +32,7 @@ int main (int argc, char **argv) { ...@@ -32,7 +32,7 @@ int main (int argc, char **argv) {
NMXP_DATA_PROCESS *pd; NMXP_DATA_PROCESS *pd;
NMXP_DAP_PARAMS params; NMXPTOOL_PARAMS params;
#ifdef HAVE_LIBMSEED #ifdef HAVE_LIBMSEED
/* Mini-SEED variables */ /* Mini-SEED variables */
...@@ -185,7 +185,7 @@ int main (int argc, char **argv) { ...@@ -185,7 +185,7 @@ int main (int argc, char **argv) {
} }
#endif #endif
#ifdef HAVE___SRC_PLUGIN_C #ifdef HAVE___SRC_SEEDLINK_PLUGIN_C
/* Send data to SeedLink Server */ /* Send data to SeedLink Server */
if(params.flag_writeseedlink) { if(params.flag_writeseedlink) {
......
...@@ -8,11 +8,11 @@ ...@@ -8,11 +8,11 @@
#include "nmxptool_getoptlong.h" #include "nmxptool_getoptlong.h"
const NMXP_DAP_PARAMS NMXP_DAP_PARAMS_DEFAULT = const NMXPTOOL_PARAMS NMXPTOOL_PARAMS_DEFAULT =
{ {
NULL, NULL,
28002, DEFAULT_PORT_DAP,
28000, DEFAULT_PORT_PDS,
NULL, NULL,
NULL, NULL,
NULL, NULL,
...@@ -20,6 +20,9 @@ const NMXP_DAP_PARAMS NMXP_DAP_PARAMS_DEFAULT = ...@@ -20,6 +20,9 @@ const NMXP_DAP_PARAMS NMXP_DAP_PARAMS_DEFAULT =
0, 0,
NULL, NULL,
NULL, NULL,
DEFAULT_STC,
DEFAULT_RATE,
0,
0, 0,
0, 0,
0, 0,
...@@ -30,38 +33,54 @@ const NMXP_DAP_PARAMS NMXP_DAP_PARAMS_DEFAULT = ...@@ -30,38 +33,54 @@ const NMXP_DAP_PARAMS NMXP_DAP_PARAMS_DEFAULT =
void nmxptool_usage(struct option long_options[]) void nmxptool_usage(struct option long_options[])
{ {
printf("\ printf("\
%s %s, Nanometrics Data Access Protocol 1.0 tool\n\n\ %s %s, Nanometrics tool (Data Access Protocol 1.0, Private Data Stream 1.4)\n\n\
Usage: %s -H hostname -C channellist -s date -e date [...]\n\ Usage: %s -H hostname --listchannels [...]\n\
%s -H hostname --listchannels [...]\n\ Receive list of available channels on the host\n\
\n\
%s -H hostname -C channellist [...]\n\
Receive data by PDS\n\
\n\
%s -H hostname -C channellist -s DATE -e DATE [...]\n\
Receive data by DAP\n\
\n\ \n\
Required arguments:\n\ Arguments:\n\
-H, --hostname=HOST Nanometrics hostname.\n\ -H, --hostname=HOST Nanometrics hostname.\n\
-C, --channels=LIST Channel list STA1.CHAN1,STA2.CHAN2,...\n\ -C, --channels=LIST Channel list STA1.CHAN1,STA2.CHAN2,...\n\
-s, --start_time=DATE Start time in date format.\n\ -s, --start_time=DATE Start time in date format. ONLY DAP.\n\
-e, --end_time=DATE End time in date format.\n\ -e, --end_time=DATE End time in date format. ONLY DAP.\n\
\n\ \n\
DATE can be in formats:\n\ DATE can be in formats:\n\
<date>,<time> | <date>\n\ <date>,<time> | <date>\n\
where:\n\ where:\n\
<date> = yyyy/mm/dd | yyy.jjj\n\ <date> = yyyy/mm/dd | yyy.jjj\n\
<time> = hh:mm:ss | hh:mm\n\ <time> = hh:mm:ss | hh:mm\n\
\n\ \n",
PACKAGE_NAME, PACKAGE_VERSION,
PACKAGE_NAME,
PACKAGE_NAME,
PACKAGE_NAME
);
printf("\
Optional arguments:\n\ Optional arguments:\n\
-P, --portpds=PORT NaqsServer port number (default 28000).\n\ -P, --portpds=PORT NaqsServer port number (default %d).\n\
-D, --portdap=PORT DataServer port number (default 28002).\n\ -D, --portdap=PORT DataServer port number (default %d).\n\
-N, --network=NET Network code for writing file (default %s).\n\ -N, --network=NET Network code for writing file (default %s).\n\
-L, --location=LOC Location code for writing file.\n\ -L, --location=LOC Location code for writing file.\n\
-u, --username=USER DataServer username.\n\ -S, --stc=SECs Short-term-completion (default %d secs). ONLY PDS.\n\
-p, --password=PASS DataServer password.\n\ -R, --rate=HZ Receive decompressed data with specified sample rate. ONLY PDS.\n\
-u, --username=USER DataServer username. ONLY DAP.\n\
-p, --password=PASS DataServer password. ONLY DAP.\n\
\n\ \n\
Flags:\n\ Flags:\n\
-v, --verbose Be verbose.\n\ -v, --verbose Be verbose.\n\
-q, --quiet Quiet (almost no output).\n\ -q, --quiet Quiet (almost no output).\n\
-b, --buffered Receive recent packets into the past. ONLY PDS.\n\
-l, --listchannels Output list of channel available on NaqsServer.\n", -l, --listchannels Output list of channel available on NaqsServer.\n",
PACKAGE_NAME, PACKAGE_VERSION, DEFAULT_PORT_PDS,
PACKAGE_NAME, DEFAULT_PORT_DAP,
PACKAGE_NAME, DEFAULT_NETWORK,
DEFAULT_NETWORK DEFAULT_STC
); );
#ifdef HAVE_LIBMSEED #ifdef HAVE_LIBMSEED
...@@ -72,11 +91,10 @@ Flags:\n\ ...@@ -72,11 +91,10 @@ Flags:\n\
printf("\ printf("\
-w, --writefile Write received data to a file.\n"); -w, --writefile Write received data to a file.\n");
#ifdef HAVE___SRC_PLUGIN_C #ifdef HAVE___SRC_SEEDLINK_PLUGIN_C
printf("\ printf("\
-k, --seedlink Send received data to SeedLink (SL-plugin).\n"); -k, --seedlink Send received data to SeedLink (SL-plugin).\n");
#endif #endif
printf("\n\ printf("\n\
-h, --help Print this help.\n\ -h, --help Print this help.\n\
\n\ \n\
...@@ -96,7 +114,7 @@ Mail bug reports and suggestions to <%s>.\n", ...@@ -96,7 +114,7 @@ Mail bug reports and suggestions to <%s>.\n",
} }
int nmxptool_getopt_long(int argc, char **argv, NMXP_DAP_PARAMS *params) int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
{ {
struct option long_options[] = struct option long_options[] =
{ {
...@@ -112,6 +130,8 @@ int nmxptool_getopt_long(int argc, char **argv, NMXP_DAP_PARAMS *params) ...@@ -112,6 +130,8 @@ int nmxptool_getopt_long(int argc, char **argv, NMXP_DAP_PARAMS *params)
{"channels", required_argument, 0, 'C'}, {"channels", required_argument, 0, 'C'},
{"network", required_argument, 0, 'N'}, {"network", required_argument, 0, 'N'},
{"location", required_argument, 0, 'L'}, {"location", required_argument, 0, 'L'},
{"stc", required_argument, 0, 'S'},
{"rate", required_argument, 0, 'R'},
{"start_time", required_argument, 0, 's'}, {"start_time", required_argument, 0, 's'},
{"end_time", required_argument, 0, 'e'}, {"end_time", required_argument, 0, 'e'},
{"username", required_argument, 0, 'u'}, {"username", required_argument, 0, 'u'},
...@@ -119,12 +139,13 @@ int nmxptool_getopt_long(int argc, char **argv, NMXP_DAP_PARAMS *params) ...@@ -119,12 +139,13 @@ int nmxptool_getopt_long(int argc, char **argv, NMXP_DAP_PARAMS *params)
/* Following are flags */ /* Following are flags */
{"verbose", no_argument, 0, 'v'}, {"verbose", no_argument, 0, 'v'},
{"quiet", no_argument, 0, 'q'}, {"quiet", no_argument, 0, 'q'},
{"buffered", no_argument, 0, 'b'},
{"listchannels", no_argument, 0, 'l'}, {"listchannels", no_argument, 0, 'l'},
#ifdef HAVE_LIBMSEED #ifdef HAVE_LIBMSEED
{"writeseed", no_argument, 0, 'm'}, {"writeseed", no_argument, 0, 'm'},
#endif #endif
{"writefile", no_argument, 0, 'w'}, {"writefile", no_argument, 0, 'w'},
#ifdef HAVE___SRC_PLUGIN_C #ifdef HAVE___SRC_SEEDLINK_PLUGIN_C
{"seedlink", no_argument, 0, 'k'}, {"seedlink", no_argument, 0, 'k'},
#endif #endif
{"help", no_argument, 0, 'h'}, {"help", no_argument, 0, 'h'},
...@@ -150,15 +171,15 @@ int nmxptool_getopt_long(int argc, char **argv, NMXP_DAP_PARAMS *params) ...@@ -150,15 +171,15 @@ int nmxptool_getopt_long(int argc, char **argv, NMXP_DAP_PARAMS *params)
/* init params */ /* init params */
memcpy(params, &NMXP_DAP_PARAMS_DEFAULT, sizeof(NMXP_DAP_PARAMS_DEFAULT)); memcpy(params, &NMXPTOOL_PARAMS_DEFAULT, sizeof(NMXPTOOL_PARAMS_DEFAULT));
char optstr[100] = "H:P:D:C:N:L:s:e:u:p:vqlwh"; char optstr[100] = "H:P:D:C:N:L:S:R:s:e:u:p:vqblwh";
#ifdef HAVE_LIBMSEED #ifdef HAVE_LIBMSEED
strcat(optstr, "m"); strcat(optstr, "m");
#endif #endif
#ifdef HAVE___SRC_PLUGIN_C #ifdef HAVE___SRC_SEEDLINK_PLUGIN_C
strcat(optstr, "k"); strcat(optstr, "k");
#endif #endif
...@@ -207,6 +228,14 @@ int nmxptool_getopt_long(int argc, char **argv, NMXP_DAP_PARAMS *params) ...@@ -207,6 +228,14 @@ int nmxptool_getopt_long(int argc, char **argv, NMXP_DAP_PARAMS *params)
params->location = optarg; params->location = optarg;
break; break;
case 'S':
params->stc = atoi(optarg);
break;
case 'R':
params->rate = atoi(optarg);
break;
case 's': case 's':
if(nmxp_data_parse_date(optarg, &tmp_tm) == -1) { if(nmxp_data_parse_date(optarg, &tmp_tm) == -1) {
// MESSAGE ERROR // MESSAGE ERROR
...@@ -239,6 +268,10 @@ int nmxptool_getopt_long(int argc, char **argv, NMXP_DAP_PARAMS *params) ...@@ -239,6 +268,10 @@ int nmxptool_getopt_long(int argc, char **argv, NMXP_DAP_PARAMS *params)
params->flag_verbose = 0; params->flag_verbose = 0;
break; break;
case 'b':
params->flag_buffered = 0;
break;
case 'l': case 'l':
params->flag_listchannels = 1; params->flag_listchannels = 1;
break; break;
...@@ -253,7 +286,7 @@ int nmxptool_getopt_long(int argc, char **argv, NMXP_DAP_PARAMS *params) ...@@ -253,7 +286,7 @@ int nmxptool_getopt_long(int argc, char **argv, NMXP_DAP_PARAMS *params)
params->flag_writefile = 1; params->flag_writefile = 1;
break; break;
#ifdef HAVE___SRC_PLUGIN_C #ifdef HAVE___SRC_SEEDLINK_PLUGIN_C
case 'k': case 'k':
params->flag_writeseedlink = 1; params->flag_writeseedlink = 1;
break; break;
...@@ -291,7 +324,7 @@ int nmxptool_getopt_long(int argc, char **argv, NMXP_DAP_PARAMS *params) ...@@ -291,7 +324,7 @@ int nmxptool_getopt_long(int argc, char **argv, NMXP_DAP_PARAMS *params)
} }
int nmxptool_check_params(NMXP_DAP_PARAMS *params) { int nmxptool_check_params(NMXPTOOL_PARAMS *params) {
int ret = 0; int ret = 0;
if(params->hostname == NULL) { if(params->hostname == NULL) {
......
#ifndef NMXP_DAP_GETLONG_H #ifndef NMXPTOOL_GETLONG_H
#define NMXP_DAP_GETLONG_H 1 #define NMXPTOOL_GETLONG_H 1
#include <getopt.h> #include <getopt.h>
#include <stdint.h> #include <stdint.h>
#define DEFAULT_NETWORK "XX" #define DEFAULT_NETWORK "XX"
#define DEFAULT_PORT_DAP 28002
#define DEFAULT_PORT_PDS 28000
#define DEFAULT_STC 30
#define DEFAULT_RATE -1
/*! \brief Struct that stores information about parameter of the program */ /*! \brief Struct that stores information about parameter of the program */
typedef struct { typedef struct {
...@@ -18,18 +23,21 @@ typedef struct { ...@@ -18,18 +23,21 @@ typedef struct {
uint32_t end_time; uint32_t end_time;
char *datas_username; char *datas_username;
char *datas_password; char *datas_password;
int stc;
int rate;
int flag_writeseed; int flag_writeseed;
int flag_verbose; int flag_verbose;
int flag_listchannels; int flag_listchannels;
int flag_writefile; int flag_writefile;
int flag_writeseedlink; int flag_writeseedlink;
} NMXP_DAP_PARAMS; int flag_buffered;
} NMXPTOOL_PARAMS;
/*! \brief Print the usage of paramters */ /*! \brief Print the usage of paramters */
void nmxptool_usage(struct option long_options[]); void nmxptool_usage(struct option long_options[]);
/*! \brief Calls getopt_long and set struct NMXP_DAP_PARAMS /*! \brief Calls getopt_long and set struct NMXPTOOL_PARAMS
* *
* \param argc * \param argc
* \param argv * \param argv
...@@ -39,17 +47,17 @@ void nmxptool_usage(struct option long_options[]); ...@@ -39,17 +47,17 @@ void nmxptool_usage(struct option long_options[]);
* \retval >0 Number of errors. * \retval >0 Number of errors.
* *
*/ */
int nmxptool_getopt_long(int argc, char **argv, NMXP_DAP_PARAMS *params); int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params);
/*! \brief Check semantyc of values in struct NMXP_DAP_PARAMS /*! \brief Check semantyc of values in struct NMXPTOOL_PARAMS
* *
* \param params Struct to validate. * \param params Struct to validate.
* *
* \retval 0 on success. * \retval 0 on success.
* \retval -1 on error. * \retval -1 on error.
*/ */
int nmxptool_check_params(NMXP_DAP_PARAMS *params); int nmxptool_check_params(NMXPTOOL_PARAMS *params);
#endif #endif
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