INFO: The new Git default branch name is "main". Details here: https://about.gitlab.com/blog/2021/03/10/new-git-default-branch-name/

Commit 00ce7168 authored by Matteo Quintiliani's avatar Matteo Quintiliani
Browse files

max_pdlist_items depends on maxlatency value


git-svn-id: file:///home/quintiliani/svncopy/nmxptool/trunk@320 3cd66e75-5955-46cb-a940-c26e5fc5497d
parent a6583952
......@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it
*
* $Id: nmxp.h,v 1.35 2007-09-12 14:11:02 mtheo Exp $
* $Id: nmxp.h,v 1.36 2007-09-20 16:32:44 mtheo Exp $
*
*/
......@@ -135,6 +135,7 @@ typedef struct {
int32_t last_seq_no_sent;
double last_sample_time;
int32_t max_pdlist_items;
double max_tollerable_latency;
int32_t n_pdlist;
NMXP_DATA_PROCESS **pdlist; /* Array for pd queue */
} NMXP_RAW_STREAM_DATA;
......@@ -301,7 +302,7 @@ int nmxp_raw_stream_seq_no_compare(const void *a, const void *b);
* \param max_pdlist_items value of max number of items in array
*
*/
void nmxp_raw_stream_init(NMXP_RAW_STREAM_DATA *raw_stream_buffer, int32_t max_pdlist_items);
void nmxp_raw_stream_init(NMXP_RAW_STREAM_DATA *raw_stream_buffer, int32_t max_tollerable_latency);
/*! \brief Free fields inside a NMXP_RAW_STREAM_DATA structure
......
......@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it
*
* $Id: nmxp.c,v 1.45 2007-09-17 13:00:05 mtheo Exp $
* $Id: nmxp.c,v 1.46 2007-09-20 16:32:44 mtheo Exp $
*
*/
......@@ -508,12 +508,15 @@ int nmxp_raw_stream_seq_no_compare(const void *a, const void *b)
return ret;
}
void nmxp_raw_stream_init(NMXP_RAW_STREAM_DATA *raw_stream_buffer, int32_t max_pdlist_items) {
void nmxp_raw_stream_init(NMXP_RAW_STREAM_DATA *raw_stream_buffer, int32_t max_tollerable_latency) {
int j;
raw_stream_buffer->last_seq_no_sent = -1;
raw_stream_buffer->last_sample_time = -1.0;
raw_stream_buffer->max_pdlist_items = max_pdlist_items;
/* TODO
* Suppose a packet can contain 1/4 secs of data */
raw_stream_buffer->max_tollerable_latency = max_tollerable_latency;
raw_stream_buffer->max_pdlist_items = max_tollerable_latency * 4;
raw_stream_buffer->n_pdlist = 0;
raw_stream_buffer->pdlist = (NMXP_DATA_PROCESS **) malloc (raw_stream_buffer->max_pdlist_items * sizeof(NMXP_DATA_PROCESS *));
for(j=0; j<raw_stream_buffer->max_pdlist_items; j++) {
......@@ -573,9 +576,12 @@ int nmxp_raw_stream_manage(NMXP_RAW_STREAM_DATA *p, NMXP_DATA_PROCESS *a_pd, int
p->last_sample_time = pd->time;
nmxp_log(0, 1, "First time nmxp_raw_stream_manage().\n");
}
latency = nmxp_data_latency(p->pdlist[0]);
/* Add pd and sort array */
if(p->n_pdlist >= p->max_pdlist_items) {
if(p->n_pdlist >= p->max_pdlist_items
|| latency >= p->max_tollerable_latency) {
/* Supposing p->pdlist is ordered,
* handle the first item and over write it.
*/
......@@ -584,9 +590,9 @@ int nmxp_raw_stream_manage(NMXP_RAW_STREAM_DATA *p, NMXP_DATA_PROCESS *a_pd, int
latency = nmxp_data_latency(p->pdlist[0]);
nmxp_data_to_str(str_time, p->pdlist[0]->time);
if( seq_no_diff > 0) {
nmxp_log(NMXP_LOG_WARN, 0, "Force handling packet %s.%s.%d.%d (%s - %.2f sec.) time_diff %.2fs lat. %.1fs!\n",
nmxp_log(NMXP_LOG_WARN, 0, "Force handling packet %s.%s.%d.%d (%s - %.2f sec.) time_diff %.2fs n_pdlist %d lat. %.1fs!\n",
p->pdlist[0]->station, p->pdlist[0]->channel, p->pdlist[0]->seq_no, p->pdlist[0]->packet_type, str_time,
(double) p->pdlist[0]->nSamp / (double) p->pdlist[0]->sampRate, time_diff, latency);
(double) p->pdlist[0]->nSamp / (double) p->pdlist[0]->sampRate, time_diff, p->n_pdlist, latency);
for(i_func_pd=0; i_func_pd<n_func_pd; i_func_pd++) {
(*p_func_pd[i_func_pd])(p->pdlist[0]);
}
......
......@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it
*
* $Id: nmxptool.c,v 1.63 2007-09-20 13:47:22 mtheo Exp $
* $Id: nmxptool.c,v 1.64 2007-09-20 16:32:44 mtheo Exp $
*
*/
......@@ -165,7 +165,7 @@ int main (int argc, char **argv) {
channelListSeq[i_chan].significant = 0;
channelListSeq[i_chan].last_time = 0.0;
channelListSeq[i_chan].x_1 = 0;
nmxp_raw_stream_init(&(channelListSeq[i_chan].raw_stream_buffer), params.max_pdlist_items);
nmxp_raw_stream_init(&(channelListSeq[i_chan].raw_stream_buffer), params.max_tollerable_latency);
}
#ifdef HAVE_LIBMSEED
......
......@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it
*
* $Id: nmxptool_getoptlong.c,v 1.19 2007-09-20 09:40:56 mtheo Exp $
* $Id: nmxptool_getoptlong.c,v 1.20 2007-09-20 16:32:44 mtheo Exp $
*
*/
......@@ -37,7 +37,7 @@ const NMXPTOOL_PARAMS NMXPTOOL_PARAMS_DEFAULT =
DEFAULT_RATE,
NULL,
DEFAULT_DELAY,
DEFAULT_MAX_PDLIST_ITEMS,
DEFAULT_MAX_TOLLERABLE_LATENCY,
0,
0,
0,
......@@ -150,12 +150,14 @@ PDS arguments:\n\
0 is for original sample rate and decompressed data.\n\
>0 is for specified sample rate and decompressed data.\n\
-b, --buffered Request also recent packets into the past.\n\
-n, --npackets=NUM Number of packets contained into the buffer (default %d).\n\
Usable only with --stc=-1\n\
-M, --maxlatency=SECs Max tollerable latency (default %d) [%d..%d].\n\
Last option is usable only with --stc=-1\n\
\n\
",
DEFAULT_STC,
DEFAULT_MAX_PDLIST_ITEMS
DEFAULT_MAX_TOLLERABLE_LATENCY,
DEFAULT_MAX_TOLLERABLE_LATENCY_MINIMUM,
DEFAULT_MAX_TOLLERABLE_LATENCY_MAXIMUM
);
nmxptool_author_support();
......@@ -195,7 +197,7 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
{"delay", required_argument, 0, 'd'},
{"username", required_argument, 0, 'u'},
{"password", required_argument, 0, 'p'},
{"npackets", required_argument, 0, 'n'},
{"maxlatency", required_argument, 0, 'M'},
/* Following are flags */
{"verbose", no_argument, 0, 'v'},
{"logdata", no_argument, 0, 'g'},
......@@ -235,7 +237,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:d:u:p:n:vgbliwhV";
char optstr[100] = "H:P:D:C:N:L:S:R:s:e:d:u:p:M:vgbliwhV";
#ifdef HAVE_LIBMSEED
strcat(optstr, "m");
......@@ -327,9 +329,9 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
params->datas_password = optarg;
break;
case 'n':
params->max_pdlist_items = atoi(optarg);
nmxp_log(0, 0, "Max_number_of_packets %d.\n", params->max_pdlist_items);
case 'M':
params->max_tollerable_latency = atoi(optarg);
nmxp_log(0, 0, "Max_tollerable_latency %d\n", params->max_tollerable_latency);
break;
#ifdef HAVE___SRC_SEEDLINK_PLUGIN_C
......@@ -443,12 +445,17 @@ int nmxptool_check_params(NMXPTOOL_PARAMS *params) {
} else if(params->delay < 0) {
ret = -1;
nmxp_log(NMXP_LOG_NORM_NO, 0, "<delay> has to be greater than zero.\n");
} else if( params->stc == -1 && (params->max_pdlist_items < 10 || params->max_pdlist_items > 100)) {
} else if( params->stc == -1
&& (params->max_tollerable_latency < DEFAULT_MAX_TOLLERABLE_LATENCY_MINIMUM ||
params->max_tollerable_latency > DEFAULT_MAX_TOLLERABLE_LATENCY_MAXIMUM)) {
ret = -1;
nmxp_log(NMXP_LOG_NORM_NO, 0, "<npackets> has to be within [10..100].\n");
} else if( params->stc != -1 && params->max_pdlist_items > 0) {
nmxp_log(NMXP_LOG_WARN, 0, "<npackets> ignored since not defined --stc=-1.\n");
nmxp_log(NMXP_LOG_NORM_NO, 0, "<maxlatency> has to be within [%d..%d].\n",
DEFAULT_MAX_TOLLERABLE_LATENCY_MINIMUM,
DEFAULT_MAX_TOLLERABLE_LATENCY_MAXIMUM);
} else if( params->stc != -1 && params->max_tollerable_latency > 0) {
nmxp_log(NMXP_LOG_WARN, 0, "<maxlatency> ignored since not defined --stc=-1.\n");
}
return ret;
}
......@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it
*
* $Id: nmxptool_getoptlong.h,v 1.11 2007-09-16 21:38:51 mtheo Exp $
* $Id: nmxptool_getoptlong.h,v 1.12 2007-09-20 16:32:44 mtheo Exp $
*
*/
......@@ -23,7 +23,9 @@
#define DEFAULT_STC -1
#define DEFAULT_RATE -1
#define DEFAULT_DELAY 0
#define DEFAULT_MAX_PDLIST_ITEMS 50
#define DEFAULT_MAX_TOLLERABLE_LATENCY 300
#define DEFAULT_MAX_TOLLERABLE_LATENCY_MINIMUM 60
#define DEFAULT_MAX_TOLLERABLE_LATENCY_MAXIMUM 600
/*! \brief Struct that stores information about parameter of the program */
......@@ -42,7 +44,7 @@ typedef struct {
int32_t rate;
char *plugin_slink;
int32_t delay;
int32_t max_pdlist_items;
int32_t max_tollerable_latency;
int flag_writeseed;
int flag_verbose;
int flag_listchannels;
......
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