Commit 6bb17e40 authored by Matteo Quintiliani's avatar Matteo Quintiliani

Earthworm management in DAP flow


git-svn-id: file:///home/quintiliani/svncopy/nmxptool/trunk@660 3cd66e75-5955-46cb-a940-c26e5fc5497d
parent 36803ea8
...@@ -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.114 2008-01-17 13:46:46 mtheo Exp $ * $Id: nmxptool.c,v 1.115 2008-01-17 13:58:37 mtheo Exp $
* *
*/ */
...@@ -42,6 +42,8 @@ ...@@ -42,6 +42,8 @@
#include "seedlink_plugin.h" #include "seedlink_plugin.h"
#endif #endif
#define TIMES_FLOW_EXIT 100
#define DAP_CONDITION(params_struct) ( params_struct.start_time != 0.0 || params_struct.delay > 0 ) #define DAP_CONDITION(params_struct) ( params_struct.start_time != 0.0 || params_struct.delay > 0 )
#define CURRENT_NETWORK ( (params.network)? params.network : DEFAULT_NETWORK ) #define CURRENT_NETWORK ( (params.network)? params.network : DEFAULT_NETWORK )
...@@ -171,6 +173,7 @@ int main (int argc, char **argv) { ...@@ -171,6 +173,7 @@ int main (int argc, char **argv) {
if(params.ew_configuration_file) { if(params.ew_configuration_file) {
#ifdef HAVE_EARTHWORMOBJS #ifdef HAVE_EARTHWORMOBJS
nmxp_log_init(nmxptool_ew_logit_msg, nmxptool_ew_logit_err); nmxp_log_init(nmxptool_ew_logit_msg, nmxptool_ew_logit_err);
nmxptool_ew_configure(argv, &params); nmxptool_ew_configure(argv, &params);
...@@ -179,6 +182,7 @@ int main (int argc, char **argv) { ...@@ -179,6 +182,7 @@ int main (int argc, char **argv) {
if(nmxptool_check_params(&params) != 0) { if(nmxptool_check_params(&params) != 0) {
return 1; return 1;
} }
#endif #endif
} else { } else {
...@@ -284,6 +288,12 @@ int main (int argc, char **argv) { ...@@ -284,6 +288,12 @@ int main (int argc, char **argv) {
channelList = NULL; channelList = NULL;
} }
#ifdef HAVE_EARTHWORMOBJS
if(params.ew_configuration_file) {
nmxptool_ew_attach();
}
#endif
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_CONNFLOW, "Starting comunication.\n"); nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_CONNFLOW, "Starting comunication.\n");
times_flow = 0; times_flow = 0;
...@@ -504,6 +514,12 @@ int main (int argc, char **argv) { ...@@ -504,6 +514,12 @@ int main (int argc, char **argv) {
} }
#endif #endif
#ifdef HAVE_EARTHWORMOBJS
if(params.ew_configuration_file) {
nmxptool_ew_nmx2ew(pd);
}
#endif
if(params.flag_writefile && outfile) { if(params.flag_writefile && outfile) {
/* Write buffer to the output file */ /* Write buffer to the output file */
if(outfile && buffer && length > 0) { if(outfile && buffer && length > 0) {
...@@ -563,6 +579,23 @@ int main (int argc, char **argv) { ...@@ -563,6 +579,23 @@ int main (int argc, char **argv) {
} }
#ifdef HAVE_EARTHWORMOBJS
if(params.ew_configuration_file) {
/* Check if we are being asked to terminate */
if( nmxptool_ew_check_flag_terminate() ) {
logit ("t", "nmxptool terminating on request\n");
nmxptool_ew_send_error(NMXPTOOL_EW_ERR_TERMREQ);
exitdapcondition = 0;
times_flow = TIMES_FLOW_EXIT;
}
/* Check if we need to send heartbeat message */
nmxptool_ew_send_heartbeat_if_needed();
}
#endif
} /* END while(exitdapcondition) */ } /* END while(exitdapcondition) */
/* DAP Step 8: Send a Terminate message (optional) */ /* DAP Step 8: Send a Terminate message (optional) */
...@@ -666,12 +699,6 @@ int main (int argc, char **argv) { ...@@ -666,12 +699,6 @@ int main (int argc, char **argv) {
// TODO // TODO
exitpdscondition = 1; exitpdscondition = 1;
#ifdef HAVE_EARTHWORMOBJS
if(params.ew_configuration_file) {
nmxptool_ew_attach();
}
#endif
skip_current_packet = 0; skip_current_packet = 0;
while(exitpdscondition) { while(exitpdscondition) {
...@@ -834,12 +861,6 @@ int main (int argc, char **argv) { ...@@ -834,12 +861,6 @@ int main (int argc, char **argv) {
save_channel_states(); save_channel_states();
#ifdef HAVE_EARTHWORMOBJS
if(params.ew_configuration_file) {
nmxptool_ew_detach();
}
#endif
#ifdef HAVE_LIBMSEED #ifdef HAVE_LIBMSEED
if(params.flag_writeseed && data_seed.outfile_mseed) { if(params.flag_writeseed && data_seed.outfile_mseed) {
/* Close output Mini-SEED file */ /* Close output Mini-SEED file */
...@@ -865,11 +886,17 @@ int main (int argc, char **argv) { ...@@ -865,11 +886,17 @@ int main (int argc, char **argv) {
if(params.interval == DEFAULT_INTERVAL_INFINITE) { if(params.interval == DEFAULT_INTERVAL_INFINITE) {
times_flow++; times_flow++;
} else { } else {
times_flow = 100; times_flow = TIMES_FLOW_EXIT;
} }
} }
#ifdef HAVE_EARTHWORMOBJS
if(params.ew_configuration_file) {
nmxptool_ew_detach();
}
#endif
#ifdef HAVE_LIBMSEED #ifdef HAVE_LIBMSEED
if(*msr_list_chan) { if(*msr_list_chan) {
for(i_chan = 0; i_chan < channelList_subset->number; i_chan++) { for(i_chan = 0; i_chan < channelList_subset->number; i_chan++) {
...@@ -1057,6 +1084,7 @@ static void clientShutdown(int sig) { ...@@ -1057,6 +1084,7 @@ static void clientShutdown(int sig) {
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Program interrupted!\n"); nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Program interrupted!\n");
flushing_raw_data_stream(); flushing_raw_data_stream();
save_channel_states(); save_channel_states();
if(params.flag_writefile && outfile) { if(params.flag_writefile && outfile) {
......
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