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

Earthworm management in DAP flow


git-svn-id: file:///home/quintiliani/svncopy/nmxptool/trunk@660 3cd66e75-5955-46cb-a940-c26e5fc5497d
parent 36803ea8
Loading
Loading
Loading
Loading
+42 −14
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
 * 	Istituto Nazionale di Geofisica e Vulcanologia - Italy
 *	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 @@
#include "seedlink_plugin.h"
#endif

#define TIMES_FLOW_EXIT 100

#define DAP_CONDITION(params_struct) ( params_struct.start_time != 0.0 || params_struct.delay > 0 )

#define CURRENT_NETWORK ( (params.network)? params.network : DEFAULT_NETWORK )
@@ -171,6 +173,7 @@ int main (int argc, char **argv) {
    if(params.ew_configuration_file) {

#ifdef HAVE_EARTHWORMOBJS

	nmxp_log_init(nmxptool_ew_logit_msg, nmxptool_ew_logit_err);

	nmxptool_ew_configure(argv, &params);
@@ -179,6 +182,7 @@ int main (int argc, char **argv) {
	if(nmxptool_check_params(&params) != 0) {
	    return 1;
	}

#endif

    } else {
@@ -284,6 +288,12 @@ int main (int argc, char **argv) {
	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");

    times_flow = 0;
@@ -504,6 +514,12 @@ int main (int argc, char **argv) {
			}
#endif

#ifdef HAVE_EARTHWORMOBJS
			if(params.ew_configuration_file) {
			    nmxptool_ew_nmx2ew(pd);
			}
#endif

			if(params.flag_writefile  &&  outfile) {
			    /* Write buffer to the output file */
			    if(outfile && buffer && length > 0) {
@@ -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) */

	/* DAP Step 8: Send a Terminate message (optional) */
@@ -666,12 +699,6 @@ int main (int argc, char **argv) {
	// TODO
	exitpdscondition = 1;

#ifdef HAVE_EARTHWORMOBJS
	if(params.ew_configuration_file) {
	    nmxptool_ew_attach();
	}
#endif

	skip_current_packet = 0;

	while(exitpdscondition) {
@@ -834,12 +861,6 @@ int main (int argc, char **argv) {

	save_channel_states();

#ifdef HAVE_EARTHWORMOBJS
	if(params.ew_configuration_file) {
	    nmxptool_ew_detach();
	}
#endif

#ifdef HAVE_LIBMSEED
	if(params.flag_writeseed  &&  data_seed.outfile_mseed) {
	    /* Close output Mini-SEED file */
@@ -865,10 +886,16 @@ int main (int argc, char **argv) {
    if(params.interval == DEFAULT_INTERVAL_INFINITE) {
	times_flow++;
    } else {
	times_flow = 100;
	times_flow = TIMES_FLOW_EXIT;
    }

    }

#ifdef HAVE_EARTHWORMOBJS
	if(params.ew_configuration_file) {
	    nmxptool_ew_detach();
	}
#endif

#ifdef HAVE_LIBMSEED
    if(*msr_list_chan) {
@@ -1057,6 +1084,7 @@ static void clientShutdown(int sig) {
    nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Program interrupted!\n");

    flushing_raw_data_stream();

    save_channel_states();

    if(params.flag_writefile  &&  outfile) {