Commit f1107dc9 authored by Matteo Quintiliani's avatar Matteo Quintiliani

Delayed messages 'Time-SeriesChannels'


git-svn-id: file:///home/quintiliani/svncopy/nmxptool/trunk@925 3cd66e75-5955-46cb-a940-c26e5fc5497d
parent ef3d2106
...@@ -11,7 +11,7 @@ m4_define([major_version], [1]) ...@@ -11,7 +11,7 @@ m4_define([major_version], [1])
m4_define([minor_version], [2]) m4_define([minor_version], [2])
m4_define([micro_version], [1]) m4_define([micro_version], [1])
# Comment build_version for stable release # Comment build_version for stable release
m4_define([build_version], [beta2]) m4_define([build_version], [beta3])
m4_ifdef([build_version], [ m4_ifdef([build_version], [
m4_define([version], m4_define([version],
...@@ -238,7 +238,7 @@ AC_FUNC_MALLOC ...@@ -238,7 +238,7 @@ AC_FUNC_MALLOC
AC_FUNC_MKTIME AC_FUNC_MKTIME
AC_FUNC_SELECT_ARGTYPES AC_FUNC_SELECT_ARGTYPES
AC_FUNC_STRERROR_R AC_FUNC_STRERROR_R
AC_CHECK_FUNCS([gethostbyname inet_ntoa memset select socket strcasecmp strchr strdup strerror strtol]) AC_CHECK_FUNCS([gethostbyname gettimeofday inet_ntoa memset select socket strcasecmp strchr strdup strerror strtol])
AC_CHECK_FUNCS([timegm], [], [ AC_CHECK_FUNCS([timegm], [], [
AC_CHECK_FUNCS([getenv setenv unsetenv tzset], AC_CHECK_FUNCS([getenv setenv unsetenv tzset],
[], [],
......
...@@ -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.72 2008-03-07 17:30:54 mtheo Exp $ * $Id: nmxp.c,v 1.73 2008-03-18 13:52:57 mtheo Exp $
* *
*/ */
...@@ -19,6 +19,10 @@ ...@@ -19,6 +19,10 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#ifdef HAVE_GETTIMEOFDAY
#include <sys/time.h>
#endif
#ifdef HAVE_ARPA_INET_H #ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
...@@ -72,7 +76,7 @@ int nmxp_receiveChannelList(int isock, NMXP_CHAN_LIST **pchannelList) { ...@@ -72,7 +76,7 @@ int nmxp_receiveChannelList(int isock, NMXP_CHAN_LIST **pchannelList) {
} }
int nmxp_sendAddTimeSeriesChannel(int isock, NMXP_CHAN_LIST_NET *channelList, int32_t shortTermCompletion, int32_t out_format, NMXP_BUFFER_FLAG buffer_flag) { int nmxp_sendAddTimeSeriesChannel_raw(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);
...@@ -110,6 +114,65 @@ int nmxp_sendAddTimeSeriesChannel(int isock, NMXP_CHAN_LIST_NET *channelList, in ...@@ -110,6 +114,65 @@ int nmxp_sendAddTimeSeriesChannel(int isock, NMXP_CHAN_LIST_NET *channelList, in
return ret; return ret;
} }
int nmxp_sendAddTimeSeriesChannel(int isock, NMXP_CHAN_LIST_NET *channelList, int32_t shortTermCompletion, int32_t out_format, NMXP_BUFFER_FLAG buffer_flag) {
static int i = 0;
static int first_time = 1;
static struct timeval last_tp_now;
/* Empiric constant values TODO */
const int n_channel = 9;
const int n_usec = 250000; /* 1/4 second */
int j;
int ret = 0;
NMXP_CHAN_LIST_NET split_channelList;
long diff_usec;
struct timeval tp_now;
#ifdef HAVE_GETTIMEOFDAY
gettimeofday(&tp_now, NULL);
#else
TODO gettimeofday not found
#endif
if(i < channelList->number) {
if(first_time) {
diff_usec = n_usec + 1;
first_time = 0;
last_tp_now.tv_sec = 0;
last_tp_now.tv_usec = 0;
} else {
diff_usec = (tp_now.tv_sec - last_tp_now.tv_sec) * 1000000;
diff_usec += (tp_now.tv_usec - last_tp_now.tv_usec);
}
if(diff_usec >= n_usec) {
/* while(ret == 0 && i < channelList->number) { */
split_channelList.number = 0;
while(split_channelList.number < n_channel && i < channelList->number) {
split_channelList.channel[split_channelList.number].key = channelList->channel[i].key;
/* Not necessary, but it could help for debugging */
strcpy(split_channelList.channel[split_channelList.number].name, channelList->channel[i].name);
split_channelList.number++;
i++;
}
if(split_channelList.number > 0) {
nmxp_log(NMXP_LOG_WARN, NMXP_LOG_D_ANY,
"Added %d channels (%d):", split_channelList.number, diff_usec);
for(j=0; j < split_channelList.number; j++) {
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, " %s", NMXP_LOG_STR(split_channelList.channel[j].name));
}
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "\n");
ret = nmxp_sendAddTimeSeriesChannel_raw(isock, &split_channelList, shortTermCompletion, out_format, buffer_flag);
}
/* } */
last_tp_now.tv_sec = tp_now.tv_sec;
last_tp_now.tv_usec = tp_now.tv_usec;
}
}
return ret;
}
NMXP_DATA_PROCESS *nmxp_receiveData(int isock, NMXP_CHAN_LIST_NET *channelList, const char *network_code, int timeoutsec, int *recv_errno ) { NMXP_DATA_PROCESS *nmxp_receiveData(int isock, NMXP_CHAN_LIST_NET *channelList, const char *network_code, int timeoutsec, int *recv_errno ) {
NMXP_MSG_SERVER type; NMXP_MSG_SERVER type;
......
...@@ -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.149 2008-03-07 17:32:20 mtheo Exp $ * $Id: nmxptool.c,v 1.150 2008-03-18 13:52:57 mtheo Exp $
* *
*/ */
...@@ -950,6 +950,7 @@ int main (int argc, char **argv) { ...@@ -950,6 +950,7 @@ int main (int argc, char **argv) {
} }
#endif #endif
nmxp_sendAddTimeSeriesChannel(naqssock, channelList_subset, params.stc, params.rate, (params.flag_buffered)? NMXP_BUFFER_YES : NMXP_BUFFER_NO);
} /* End main PDS loop */ } /* End main PDS loop */
......
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