Commit e436b212 authored by Matteo Quintiliani's avatar Matteo Quintiliani

Added param for requesting channel info


git-svn-id: file:///home/quintiliani/svncopy/nmxptool/trunk@187 3cd66e75-5955-46cb-a940-c26e5fc5497d
parent 63aeb00a
......@@ -270,7 +270,7 @@ NMXP_CHAN_LIST *nmxp_getAvailableChannelList(char * hostname, int portnum, NMXP_
* \warning Returned value will need to be freed.
*
*/
NMXP_META_CHAN_LIST *nmxp_getMetaChannelList(char * hostname, int portnum, NMXP_DATATYPE datatype);
NMXP_META_CHAN_LIST *nmxp_getMetaChannelList(char * hostname, int portnum, NMXP_DATATYPE datatype, int flag_request_channelinfo);
#endif
......@@ -311,7 +311,7 @@ NMXP_CHAN_LIST *nmxp_getAvailableChannelList(char * hostname, int portnum, NMXP_
}
NMXP_META_CHAN_LIST *nmxp_getMetaChannelList(char * hostname, int portnum, NMXP_DATATYPE datatype) {
NMXP_META_CHAN_LIST *nmxp_getMetaChannelList(char * hostname, int portnum, NMXP_DATATYPE datatype, int flag_request_channelinfo) {
int naqssock;
NMXP_CHAN_PRECISLIST *precisChannelList = NULL;
NMXP_CHAN_LIST *channelList = NULL;
......@@ -322,6 +322,7 @@ NMXP_META_CHAN_LIST *nmxp_getMetaChannelList(char * hostname, int portnum, NMXP_
char *datas_username = NULL, *datas_password = NULL;
int ret_sock;
NMXP_MSG_SERVER type;
void *buffer = NULL;
uint32_t length;
......@@ -374,7 +375,9 @@ NMXP_META_CHAN_LIST *nmxp_getMetaChannelList(char * hostname, int portnum, NMXP_
for(i = 0; i < channelList->number; i++) {
channelList->channel[i].key = ntohl(channelList->channel[i].key);
nmxp_meta_chan_add(&chan_list, channelList->channel[i].key, channelList->channel[i].name, 0, 0, NULL);
if(getDataTypeFromKey(channelList->channel[i].key) == datatype) {
nmxp_meta_chan_add(&chan_list, channelList->channel[i].key, channelList->channel[i].name, 0, 0, NULL);
}
}
/* Receive Message */
......@@ -424,28 +427,30 @@ NMXP_META_CHAN_LIST *nmxp_getMetaChannelList(char * hostname, int portnum, NMXP_
}
for(iter = chan_list; iter != NULL; iter = iter->next) {
if(flag_request_channelinfo) {
for(iter = chan_list; iter != NULL; iter = iter->next) {
if(getDataTypeFromKey(iter->key) == NMXP_DATA_TIMESERIES && getChannelNumberFromKey(iter->key) == 0) {
/* DAP Step 5: Send Data Request */
channelInfoRequestBody.key = htonl(iter->key);
channelInfoRequestBody.ignored = htonl(0);
nmxp_sendMessage(naqssock, NMXP_MSG_CHANNELINFOREQUEST, &channelInfoRequestBody, sizeof(NMXP_MSGBODY_CHANNELINFOREQUEST));
if(getChannelNumberFromKey(iter->key) == 0) {
/* DAP Step 5: Send Data Request */
channelInfoRequestBody.key = htonl(iter->key);
channelInfoRequestBody.ignored = htonl(0);
nmxp_sendMessage(naqssock, NMXP_MSG_CHANNELINFOREQUEST, &channelInfoRequestBody, sizeof(NMXP_MSGBODY_CHANNELINFOREQUEST));
/* DAP Step 6: Receive Data until receiving a Ready message */
ret_sock = nmxp_receiveMessage(naqssock, &type, &buffer, &length);
nmxp_log(0, 1, "ret_sock = %d, type = %d, length = %d\n", ret_sock, type, length);
/* DAP Step 6: Receive Data until receiving a Ready message */
ret_sock = nmxp_receiveMessage(naqssock, &type, &buffer, &length);
nmxp_log(0, 1, "ret_sock = %d, type = %d, length = %d\n", ret_sock, type, length);
while(ret_sock == NMXP_SOCKET_OK && type != NMXP_MSG_READY) {
channelInfo = buffer;
channelInfo->key = ntohl(channelInfo->key);
while(ret_sock == NMXP_SOCKET_OK && type != NMXP_MSG_READY) {
channelInfo = buffer;
channelInfo->key = ntohl(channelInfo->key);
if(!nmxp_meta_chan_set_network(chan_list, channelInfo->key, channelInfo->network)) {
nmxp_log(1, 0, "Key %d (%d) not found for %s!\n", iter->key, channelInfo->key, iter->name);
if(!nmxp_meta_chan_set_network(chan_list, channelInfo->key, channelInfo->network)) {
nmxp_log(1, 0, "Key %d (%d) not found for %s!\n", iter->key, channelInfo->key, iter->name);
}
/* Receive Message */
ret_sock = nmxp_receiveMessage(naqssock, &type, &buffer, &length);
nmxp_log(0, 1, "ret_sock = %d, type = %d, length = %d\n", ret_sock, type, length);
}
/* Receive Message */
ret_sock = nmxp_receiveMessage(naqssock, &type, &buffer, &length);
nmxp_log(0, 1, "ret_sock = %d, type = %d, length = %d\n", ret_sock, type, length);
}
}
}
......
......@@ -130,7 +130,7 @@ int main (int argc, char **argv) {
// TOREMOVE
// nmxp_chan_print_channelList(channelList);
nmxp_getMetaChannelList(params.hostname, params.portnumberdap, NMXP_DATA_TIMESERIES);
nmxp_getMetaChannelList(params.hostname, params.portnumberdap, NMXP_DATA_TIMESERIES, params.flag_request_channelinfo);
return 1;
}
......
......@@ -30,6 +30,7 @@ const NMXPTOOL_PARAMS NMXPTOOL_PARAMS_DEFAULT =
0,
0,
0,
0,
0
};
......@@ -67,6 +68,7 @@ Other arguments:\n\
-v, --verbose Be verbose.\n\
-g, --logdata Print info about data.\n\
-l, --listchannels Output list of channel available on NaqsServer.\n\
-i, --channelinfo Output list of channel available on NaqsServer and channelinfo.\n\
",
DEFAULT_PORT_PDS,
DEFAULT_PORT_DAP,
......@@ -165,6 +167,7 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
{"logdata", no_argument, 0, 'g'},
{"buffered", no_argument, 0, 'b'},
{"listchannels", no_argument, 0, 'l'},
{"channelinfo", no_argument, 0, 'i'},
#ifdef HAVE_LIBMSEED
{"writeseed", no_argument, 0, 'm'},
#endif
......@@ -197,7 +200,7 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
/* init params */
memcpy(params, &NMXPTOOL_PARAMS_DEFAULT, sizeof(NMXPTOOL_PARAMS_DEFAULT));
char optstr[100] = "H:P:D:C:N:L:S:R:s:e:d:u:p:vgblwh";
char optstr[100] = "H:P:D:C:N:L:S:R:s:e:d:u:p:vgbliwh";
#ifdef HAVE_LIBMSEED
strcat(optstr, "m");
......@@ -312,6 +315,10 @@ int nmxptool_getopt_long(int argc, char **argv, NMXPTOOL_PARAMS *params)
params->flag_listchannels = 1;
break;
case 'i':
params->flag_request_channelinfo = 1;
break;
#ifdef HAVE_LIBMSEED
case 'm':
params->flag_writeseed = 1;
......
......@@ -31,6 +31,7 @@ typedef struct {
int flag_writeseed;
int flag_verbose;
int flag_listchannels;
int flag_request_channelinfo;
int flag_writefile;
int flag_slink;
int flag_buffered;
......
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