Commit 62476cb3 authored by Matteo Quintiliani's avatar Matteo Quintiliani

Added function saving_channel_states()


git-svn-id: file:///home/quintiliani/svncopy/nmxptool/trunk@554 3cd66e75-5955-46cb-a940-c26e5fc5497d
parent 3e3828b0
......@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it
*
* $Id: nmxptool.c,v 1.94 2007-12-16 16:02:49 mtheo Exp $
* $Id: nmxptool.c,v 1.95 2007-12-16 17:12:35 mtheo Exp $
*
*/
......@@ -61,6 +61,7 @@ static void clientShutdown(int sig);
static void clientDummyHandler(int sig);
#endif
static void saving_channel_states();
static void flushing_raw_data_stream();
#ifdef HAVE_LIBMSEED
......@@ -709,6 +710,7 @@ int main (int argc, char **argv) {
/* Flush raw data stream for each channel */
flushing_raw_data_stream();
saving_channel_states();
#ifdef HAVE_EARTHWORMOBJS
if(params.ew_configuration_file) {
......@@ -767,6 +769,39 @@ int main (int argc, char **argv) {
static void saving_channel_states() {
int to_cur_chan;
char last_time_str[30];
char raw_last_sample_time_str[30];
char state_line_str[1000];
FILE *fstatefile = fopen(params.statefile, "w");
if(fstatefile == NULL) {
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "Unable to write channel states into %s!\n", params.statefile);
}
/* Save state for each channel */
// if(params.stc == -1)
to_cur_chan = 0;
while(to_cur_chan < channelList_subset->number) {
nmxp_data_to_str(last_time_str, channelListSeq[to_cur_chan].last_time);
nmxp_data_to_str(raw_last_sample_time_str, channelListSeq[to_cur_chan].raw_stream_buffer.last_sample_time);
sprintf(state_line_str, "%-14s %16.4f %s %16.4f %s",
channelList_subset->channel[to_cur_chan].name,
channelListSeq[to_cur_chan].last_time, last_time_str,
channelListSeq[to_cur_chan].raw_stream_buffer.last_sample_time, raw_last_sample_time_str
);
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_CHANNEL, "%s\n", state_line_str);
if(fstatefile) {
fprintf(fstatefile, "%s\n", state_line_str);
}
to_cur_chan++;
}
if(fstatefile) {
fclose(fstatefile);
}
}
static void flushing_raw_data_stream() {
int to_cur_chan;
......@@ -789,6 +824,7 @@ static void clientShutdown(int sig) {
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_ANY, "Program interrupted!\n");
flushing_raw_data_stream();
saving_channel_states();
if(params.flag_writefile && outfile) {
/* Close output file */
......
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