Nanometrics Protocol Library. More...
#include "nmxp_base.h"#include "nmxp_crc32.h"#include "nmxp_memory.h"
Go to the source code of this file.
Classes | |
| struct | NMXP_CONNECT_REQUEST |
| Body of ConnectRequest message. More... | |
| struct | NMXP_DATA_REQUEST |
| Body of DataRequest message. More... | |
| struct | NMXP_RAW_STREAM_DATA |
Defines | |
| #define | NMXP_H 1 |
| #define | NMXP_MAX_MSCHAN_MSEC 15000 |
| #define | NMXP_MAX_SIZE_USERNAME 12 |
| #define | NMXP_MAX_FUNC_PD 10 |
| #define | TIME_TOLLERANCE 0.001 |
Enumerations | |
| enum | NMXP_BUFFER_FLAG { NMXP_BUFFER_NO = 0, NMXP_BUFFER_YES = 1 } |
Flag for buffered packets. More... | |
Functions | |
| int | nmxp_sendConnect (int isock) |
| Sends the message "Connect" on a socket. | |
| int | nmxp_sendTerminateSubscription (int isock, NMXP_SHUTDOWN_REASON reason, char *message) |
| Sends the message "TerminateSubscription" on a socket. | |
| int | nmxp_receiveChannelList (int isock, NMXP_CHAN_LIST **pchannelList) |
| Receive message "NMXP_CHAN_LIST" from a socket. | |
| int | nmxp_sendAddTimeSeriesChannel (int isock, NMXP_CHAN_LIST_NET *channelList, int32_t shortTermCompletion, int32_t out_format, NMXP_BUFFER_FLAG buffer_flag, int n_channel, int n_usec, int flag_restart) |
| Sends the message "AddTimeSeriesChannels" on a socket. | |
| NMXP_DATA_PROCESS * | nmxp_receiveData (int isock, NMXP_CHAN_LIST_NET *channelList, const char *network_code, int timeoutsec, int *recv_errno) |
| Receive Compressed or Decompressed Data message from a socket and launch func_processData() on the extracted data. | |
| int | nmxp_sendConnectRequest (int isock, char *naqs_username, char *naqs_password, int32_t connection_time) |
| Sends the message "ConnectRequest" on a socket. | |
| int | nmxp_readConnectionTime (int isock, int32_t *connection_time) |
| Read connection time from a socket. | |
| int | nmxp_waitReady (int isock) |
| Wait the message "Ready" from a socket. | |
| int | nmxp_sendDataRequest (int isock, int32_t key, int32_t start_time, int32_t end_time) |
| Sends the message "DataRequest" on a socket. | |
| NMXP_CHAN_LIST * | nmxp_getAvailableChannelList (char *hostname, int portnum, NMXP_DATATYPE datatype, int(*func_cond)(void)) |
| Get the list of available channels from a server. | |
| NMXP_META_CHAN_LIST * | nmxp_getMetaChannelList (char *hostname, int portnum, NMXP_DATATYPE datatype, int flag_request_channelinfo, char *datas_username, char *datas_password, NMXP_CHAN_LIST **pchannelList, int(*func_cond)(void)) |
| Get the list of the start and end time for the available data for each channel. | |
| int | nmxp_raw_stream_seq_no_compare (const void *a, const void *b) |
| Base function for qsort() in order to sort an array of pointers to pointers to NMXP_DATA_PROCESS. | |
| void | nmxp_raw_stream_init (NMXP_RAW_STREAM_DATA *raw_stream_buffer, int32_t max_tolerable_latency, int timeoutrecv) |
| Allocate and initialize fields inside a NMXP_RAW_STREAM_DATA structure. | |
| void | nmxp_raw_stream_free (NMXP_RAW_STREAM_DATA *raw_stream_buffer) |
| Free fields inside a NMXP_RAW_STREAM_DATA structure. | |
| int | nmxp_raw_stream_manage (NMXP_RAW_STREAM_DATA *p, NMXP_DATA_PROCESS *a_pd, int(*p_func_pd[NMXP_MAX_FUNC_PD])(NMXP_DATA_PROCESS *), int n_func_pd) |
| Execute a list of functions on an chronological ordered array of NMXP_DATA_PROCESS structures. | |
| int | nmxp_raw_stream_manage_flush (NMXP_RAW_STREAM_DATA *p, int(*p_func_pd[NMXP_MAX_FUNC_PD])(NMXP_DATA_PROCESS *), int n_func_pd) |
| Execute a list of functions on remaining NMXP_DATA_PROCESS structures. | |
Nanometrics Protocol Library.
Author: Matteo Quintiliani Istituto Nazionale di Geofisica e Vulcanologia - Italy quintiliani@ingv.it
| #define NMXP_H 1 |
| #define NMXP_MAX_MSCHAN_MSEC 15000 |
| #define NMXP_MAX_SIZE_USERNAME 12 |
| #define NMXP_MAX_FUNC_PD 10 |
| #define TIME_TOLLERANCE 0.001 |
| enum NMXP_BUFFER_FLAG |
| int nmxp_sendConnect | ( | int | isock | ) |
Sends the message "Connect" on a socket.
| isock | A descriptor referencing the socket. |
| SOCKET_OK | on success | |
| SOCKET_ERROR | on error |
| int nmxp_sendTerminateSubscription | ( | int | isock, | |
| NMXP_SHUTDOWN_REASON | reason, | |||
| char * | message | |||
| ) |
Sends the message "TerminateSubscription" on a socket.
| isock | A descriptor referencing the socket. | |
| reason | Reason for the shutdown. | |
| message | String message. It could be NULL. |
| SOCKET_OK | on success | |
| SOCKET_ERROR | on error |
| int nmxp_receiveChannelList | ( | int | isock, | |
| NMXP_CHAN_LIST ** | pchannelList | |||
| ) |
Receive message "NMXP_CHAN_LIST" from a socket.
| isock | A descriptor referencing the socket. | |
| [out] | pchannelList | List of channels. It will need to be freed! |
| SOCKET_OK | on success | |
| SOCKET_ERROR | on error |
| int nmxp_sendAddTimeSeriesChannel | ( | int | isock, | |
| NMXP_CHAN_LIST_NET * | channelList, | |||
| int32_t | shortTermCompletion, | |||
| int32_t | out_format, | |||
| NMXP_BUFFER_FLAG | buffer_flag, | |||
| int | n_channel, | |||
| int | n_usec, | |||
| int | flag_restart | |||
| ) |
Sends the message "AddTimeSeriesChannels" on a socket.
| isock | A descriptor referencing the socket. | |
| channelList | List of channel. | |
| shortTermCompletion | Short-term-completion time = s, 1<= s <= 300 seconds. | |
| out_format | Output format. -1 Compressed packets. 0 Uncompressed packets. 0 < out_format, requested output sample rate. | |
| buffer_flag | Server will send or not buffered packets. | |
| n_channel | number of channels to add any time | |
| n_usec | frequency to add remaining channels (microseconds) | |
| flag_restart | reset index for requesting channels. In general, first time 1, then 0. |
| SOCKET_OK | on success | |
| SOCKET_ERROR | on error |
| NMXP_DATA_PROCESS* nmxp_receiveData | ( | int | isock, | |
| NMXP_CHAN_LIST_NET * | channelList, | |||
| const char * | network_code, | |||
| int | timeoutsec, | |||
| int * | recv_errno | |||
| ) |
Receive Compressed or Decompressed Data message from a socket and launch func_processData() on the extracted data.
| isock | A descriptor referencing the socket. | |
| channelList | Channel list. | |
| network_code | Network code. It can be NULL. | |
| timeoutsec | Time-out in seconds | |
| [out] | recv_errno | errno value after recv() |
| Pointer | to the structure NMXP_DATA_PROCESS on success | |
| NULL | on error |
| int nmxp_sendConnectRequest | ( | int | isock, | |
| char * | naqs_username, | |||
| char * | naqs_password, | |||
| int32_t | connection_time | |||
| ) |
Sends the message "ConnectRequest" on a socket.
| isock | A descriptor referencing the socket. | |
| naqs_username | User name (maximum 11 characters), zero terminated. | |
| naqs_password | Password. | |
| connection_time | Time that the connection was opened. |
| SOCKET_OK | on success | |
| SOCKET_ERROR | on error |
| int nmxp_readConnectionTime | ( | int | isock, | |
| int32_t * | connection_time | |||
| ) |
Read connection time from a socket.
| isock | A descriptor referencing the socket. | |
| [out] | connection_time | Time in epoch. |
| SOCKET_OK | on success | |
| SOCKET_ERROR | on error |
| int nmxp_waitReady | ( | int | isock | ) |
Wait the message "Ready" from a socket.
| isock | A descriptor referencing the socket. |
| SOCKET_OK | on success | |
| SOCKET_ERROR | on error |
| int nmxp_sendDataRequest | ( | int | isock, | |
| int32_t | key, | |||
| int32_t | start_time, | |||
| int32_t | end_time | |||
| ) |
Sends the message "DataRequest" on a socket.
| isock | A descriptor referencing the socket. | |
| key | Channel key for which data are requested. | |
| start_time | Start time of the interval for which data are requested. Epoch time. | |
| end_time | End time of the interval for which data are requested. Epoch time. |
| SOCKET_OK | on success | |
| SOCKET_ERROR | on error |
| NMXP_CHAN_LIST* nmxp_getAvailableChannelList | ( | char * | hostname, | |
| int | portnum, | |||
| NMXP_DATATYPE | datatype, | |||
| int(*)(void) | func_cond | |||
| ) |
Get the list of available channels from a server.
| hostname | host name | |
| portnum | port number | |
| datatype | Type of data contained in the channel. | |
| func_cond | Pointer to function for exit condition from loop. |
| NMXP_META_CHAN_LIST* nmxp_getMetaChannelList | ( | char * | hostname, | |
| int | portnum, | |||
| NMXP_DATATYPE | datatype, | |||
| int | flag_request_channelinfo, | |||
| char * | datas_username, | |||
| char * | datas_password, | |||
| NMXP_CHAN_LIST ** | pchannelList, | |||
| int(*)(void) | func_cond | |||
| ) |
Get the list of the start and end time for the available data for each channel.
| hostname | host name. | |
| portnum | port number. | |
| datatype | Type of data contained in the channel. | |
| datas_username | DataServer user name. | |
| datas_password | DataServer password. | |
| flag_request_channelinfo | Request information about Network. | |
| [out] | pchannelList | pointer to a pointer of channel list. |
| func_cond | Pointer to function for exit condition from loop. |
| int nmxp_raw_stream_seq_no_compare | ( | const void * | a, | |
| const void * | b | |||
| ) |
Base function for qsort() in order to sort an array of pointers to pointers to NMXP_DATA_PROCESS.
| a | pointer to a pointer to NMXP_DATA_PROCESS | |
| b | pointer to a pointer to NMXP_DATA_PROCESS |
| void nmxp_raw_stream_init | ( | NMXP_RAW_STREAM_DATA * | raw_stream_buffer, | |
| int32_t | max_tolerable_latency, | |||
| int | timeoutrecv | |||
| ) |
Allocate and initialize fields inside a NMXP_RAW_STREAM_DATA structure.
| raw_stream_buffer | pointer to NMXP_RAW_STREAM_DATA struct to initialize | |
| max_tolerable_latency | Max tolerable latency | |
| timeoutrecv | value of time-out within receving packets |
| void nmxp_raw_stream_free | ( | NMXP_RAW_STREAM_DATA * | raw_stream_buffer | ) |
Free fields inside a NMXP_RAW_STREAM_DATA structure.
| raw_stream_buffer | pointer to NMXP_RAW_STREAM_DATA struct to initialize |
| int nmxp_raw_stream_manage | ( | NMXP_RAW_STREAM_DATA * | p, | |
| NMXP_DATA_PROCESS * | a_pd, | |||
| int(*[])(NMXP_DATA_PROCESS *) | NMXP_MAX_FUNC_PD, | |||
| int | n_func_pd | |||
| ) |
Execute a list of functions on an chronological ordered array of NMXP_DATA_PROCESS structures.
| p | pointer to NMXP_RAW_STREAM_DATA | |
| a_pd | pointer to NMXP_DATA_PROCESS struct to insert into the array | |
| p_func_pd | array of functions to execute on a single item NMXP_DATA_PROCESS | |
| n_func_pd | number of functions into the array p_func_pd |
| int nmxp_raw_stream_manage_flush | ( | NMXP_RAW_STREAM_DATA * | p, | |
| int(*[])(NMXP_DATA_PROCESS *) | NMXP_MAX_FUNC_PD, | |||
| int | n_func_pd | |||
| ) |
Execute a list of functions on remaining NMXP_DATA_PROCESS structures.
| p | pointer to NMXP_RAW_STREAM_DATA | |
| p_func_pd | array of functions to execute on a single item NMXP_DATA_PROCESS | |
| n_func_pd | number of functions into the array p_func_pd |
1.6.2