Commit fddf6828 authored by Matteo Quintiliani's avatar Matteo Quintiliani

Added functions nmxp_chan_print_channelList_with_match() and...

Added functions nmxp_chan_print_channelList_with_match() and nmxp_meta_chan_print_with_match() for printing channel using a Channel List pattern


git-svn-id: file:///home/quintiliani/svncopy/nmxptool/trunk@1107 3cd66e75-5955-46cb-a940-c26e5fc5497d
parent 560ba288
......@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it
*
* $Id: nmxp_chan.h,v 1.23 2008-03-05 10:21:12 mtheo Exp $
* $Id: nmxp_chan.h,v 1.24 2008-07-21 22:41:24 mtheo Exp $
*
*/
......@@ -231,6 +231,15 @@ void nmxp_chan_sortByName(NMXP_CHAN_LIST *channelList);
void nmxp_chan_print_channelList(NMXP_CHAN_LIST *channelList);
/*! Print channel information using channel pattern list
*
* \param channelList Channel List
* \param sta_chan_list Channel pattern list
*
*/
void nmxp_chan_print_channelList_with_match(NMXP_CHAN_LIST *channelList, char *sta_chan_list);
/*! Print channel information
*
* \param channelList Channel List
......@@ -253,5 +262,7 @@ NMXP_META_CHAN_LIST *nmxp_meta_chan_set_network(NMXP_META_CHAN_LIST *chan_list,
void nmxp_meta_chan_print(NMXP_META_CHAN_LIST *chan_list);
void nmxp_meta_chan_print_with_match(NMXP_META_CHAN_LIST *chan_list, char *sta_chan_list);
#endif
......@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it
*
* $Id: nmxp_chan.c,v 1.40 2008-03-28 13:21:24 mtheo Exp $
* $Id: nmxp_chan.c,v 1.41 2008-07-21 22:41:24 mtheo Exp $
*
*/
......@@ -413,6 +413,58 @@ void nmxp_chan_print_channelList(NMXP_CHAN_LIST *channelList) {
}
void nmxp_chan_print_channelList_with_match(NMXP_CHAN_LIST *channelList, char *sta_chan_list) {
int chan_number = 0;
int i_chan = 0;
int ret_match = 0;
int istalist, ista;
char sta_chan_code_pattern[100];
if(channelList) {
chan_number = channelList->number;
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_CHANNEL, "%04d channels:\n", chan_number);
for (i_chan = 0; i_chan < chan_number; i_chan++)
{
if(sta_chan_list) {
ret_match = 0;
istalist = 0;
while(sta_chan_list[istalist] != sep_chan_list && sta_chan_list[istalist] != 0 && ret_match == 0) {
/* Build sta_chan_code_pattern from sta_chan_list */
ista = 0;
while(sta_chan_list[istalist] != sep_chan_list && sta_chan_list[istalist] != 0) {
sta_chan_code_pattern[ista++] = sta_chan_list[istalist++];
}
sta_chan_code_pattern[ista] = 0;
if(sta_chan_list[istalist] == sep_chan_list) {
istalist++;
}
ret_match = nmxp_chan_match(channelList->channel[i_chan].name, sta_chan_code_pattern);
}
} else {
ret_match = 1;
}
if(ret_match == 1) {
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "%04d %12d %6s%c%-11s\n",
i_chan+1,
channelList->channel[i_chan].key,
" ",
' ',
NMXP_LOG_STR(channelList->channel[i_chan].name));
}
}
} else {
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CHANNEL, "Channel list is NULL.\n");
}
}
void nmxp_chan_print_netchannelList(NMXP_CHAN_LIST_NET *channelList) {
int chan_number = channelList->number;
int i_chan = 0;
......@@ -609,4 +661,61 @@ void nmxp_meta_chan_print(NMXP_META_CHAN_LIST *chan_list) {
}
void nmxp_meta_chan_print_with_match(NMXP_META_CHAN_LIST *chan_list, char *sta_chan_list) {
NMXP_META_CHAN_LIST *iter = chan_list;
char str_start_time[200], str_end_time[200];
int i_chan = 0;
int ret_match = 0;
int istalist, ista;
char sta_chan_code_pattern[100];
str_start_time[0] = 0;
str_end_time[0] = 0;
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_CHANNEL, "nmxp_meta_chan_print()\n");
while(iter != NULL) {
nmxp_data_to_str(str_start_time, iter->start_time);
nmxp_data_to_str(str_end_time, iter->end_time);
if(sta_chan_list) {
ret_match = 0;
istalist = 0;
while(sta_chan_list[istalist] != sep_chan_list && sta_chan_list[istalist] != 0 && ret_match == 0) {
/* Build sta_chan_code_pattern from sta_chan_list */
ista = 0;
while(sta_chan_list[istalist] != sep_chan_list && sta_chan_list[istalist] != 0) {
sta_chan_code_pattern[ista++] = sta_chan_list[istalist++];
}
sta_chan_code_pattern[ista] = 0;
if(sta_chan_list[istalist] == sep_chan_list) {
istalist++;
}
ret_match = nmxp_chan_match(iter->name, sta_chan_code_pattern);
}
} else {
ret_match = 1;
}
if(ret_match == 1) {
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "%04d %12d %6s%c%-11s (%s - %s)\n",
i_chan+1,
iter->key,
NMXP_LOG_STR(iter->network),
(strcmp(iter->network, "")==0)? ' ' : '.',
NMXP_LOG_STR(iter->name),
NMXP_LOG_STR(str_start_time),
NMXP_LOG_STR(str_end_time)
);
}
iter = iter->next;
i_chan++;
}
}
......@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it
*
* $Id: nmxptool.c,v 1.195 2008-04-24 08:08:24 mtheo Exp $
* $Id: nmxptool.c,v 1.196 2008-07-21 22:41:24 mtheo Exp $
*
*/
......@@ -99,6 +99,7 @@ NMXP_CHAN_LIST *channelList = NULL;
NMXP_CHAN_LIST_NET *channelList_subset = NULL;
NMXP_CHAN_LIST_NET *channelList_subset_waste = NULL;
NMXPTOOL_CHAN_SEQ *channelList_Seq = NULL;
NMXP_META_CHAN_LIST *meta_channelList = NULL;
int n_func_pd = 0;
int (*p_func_pd[NMXP_MAX_FUNC_PD]) (NMXP_DATA_PROCESS *);
......@@ -228,14 +229,20 @@ int main (int argc, char **argv) {
/* List available channels on server */
if(params.flag_listchannels) {
nmxp_meta_chan_print(nmxp_getMetaChannelList(params.hostname, params.portnumberdap, NMXP_DATA_TIMESERIES, params.flag_request_channelinfo, params.datas_username, params.datas_password, &channelList, nmxptool_sigcondition_read));
meta_channelList = nmxp_getMetaChannelList(params.hostname, params.portnumberdap, NMXP_DATA_TIMESERIES, params.flag_request_channelinfo, params.datas_username, params.datas_password, &channelList, nmxptool_sigcondition_read);
/* nmxp_meta_chan_print(meta_channelList); */
nmxp_meta_chan_print_with_match(meta_channelList, params.channels);
return 1;
} else if(params.flag_listchannelsnaqs) {
channelList = nmxp_getAvailableChannelList(params.hostname, params.portnumberpds, NMXP_DATA_TIMESERIES, nmxptool_sigcondition_read);
nmxp_chan_print_channelList(channelList);
/* nmxp_chan_print_channelList(channelList); */
nmxp_chan_print_channelList_with_match(channelList, params.channels);
return 1;
}
......
......@@ -7,7 +7,7 @@
* Istituto Nazionale di Geofisica e Vulcanologia - Italy
* quintiliani@ingv.it
*
* $Id: nmxptool_getoptlong.c,v 1.102 2008-07-15 14:11:58 mtheo Exp $
* $Id: nmxptool_getoptlong.c,v 1.103 2008-07-21 22:41:24 mtheo Exp $
*
*/
......@@ -129,7 +129,7 @@ void nmxptool_usage(struct option long_options[])
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "\
\n\
Usage: %s -H hostname -l | -L\n\
Usage: %s -H hostname [ -C channellist ] -l | -L \n\
Print list of the available Time Series channels\n\
on DataServer and NaqsServer respectively.\n\
\n",
......
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