Commit 30cda35f authored by Matteo Quintiliani's avatar Matteo Quintiliani

Added PRIVATE DATA STREAM subscription protocol


git-svn-id: file:///home/quintiliani/svncopy/nmxptool/trunk@108 3cd66e75-5955-46cb-a940-c26e5fc5497d
parent e9a47714
......@@ -81,6 +81,9 @@ int main (int argc, char **argv) {
}
/* TODO condition starting DAP */
if(params.start_time != 0 && params.end_time != 0) {
/* ************************************************************** */
/* Start subscription protocol "DATA ACCESS PROTOCOL" version 1.0 */
/* ************************************************************** */
......@@ -248,6 +251,61 @@ int main (int argc, char **argv) {
/* End subscription protocol "DATA ACCESS PROTOCOL" version 1.0 */
/* ************************************************************ */
} else {
/* ************************************************************* */
/* Start subscription protocol "PRIVATE DATA STREAM" version 1.4 */
/* ************************************************************* */
/* PDS Step 1: Open a socket */
naqssock = nmxp_openSocket(params.hostname, params.portnumberpds);
if(naqssock == NMXP_SOCKET_ERROR) {
return 1;
}
/* PDS Step 2: Send a Connect */
if(nmxp_sendConnect(naqssock) != NMXP_SOCKET_OK) {
printf("Error on sendConnect()\n");
return 1;
}
/* PDS Step 3: Receive ChannelList */
if(nmxp_receiveChannelList(naqssock, &channelList) != NMXP_SOCKET_OK) {
printf("Error on receiveChannelList()\n");
return 1;
}
/* Get a subset of channel from arguments */
channelList_subset = nmxp_chan_subset(channelList, NMXP_DATA_TIMESERIES, params.channels);
/* PDS Step 4: Send a Request Pending (optional) */
/* PDS Step 5: Send AddChannels */
/* Request Data */
nmxp_sendAddTimeSeriesChannel(naqssock, channelList_subset, params.stc, params.rate, (params.flag_buffered)? NMXP_BUFFER_YES : NMXP_BUFFER_NO);
/* PDS Step 6: Repeat until finished: receive and handle packets */
while(1) {
/* Process Compressed or Decompressed Data */
nmxp_receiveData(naqssock, channelList_subset, &nmxp_data_log);
}
/* PDS Step 7: Send Terminate Subscription */
nmxp_sendTerminateSubscription(naqssock, NMXP_SHUTDOWN_NORMAL, "Good Bye!");
/* PDS Step 8: Close the socket */
nmxp_closeSocket(naqssock);
/* *********************************************************** */
/* End subscription protocol "PRIVATE DATA STREAM" version 1.4 */
/* *********************************************************** */
}
return 0;
}
......
......@@ -338,13 +338,8 @@ int nmxptool_check_params(NMXPTOOL_PARAMS *params) {
} else if(params->channels == NULL) {
ret = -1;
printf("<STA.CHAN> is required!\n");
} else if(params->start_time == 0) {
ret = -1;
printf("<start_time> is required!\n");
} else if(params->end_time == 0) {
ret = -1;
printf("<end_time> is required!\n");
} else if (params->start_time >= params->end_time) {
} else if(params->start_time != 0 && params->end_time != 0
&& params->start_time >= params->end_time) {
ret = -1;
printf("<start_time> is less than <end_time>!\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