Classes | |
| struct | signal_conv_t |
| Data unit conversion structure. More... | |
| struct | chan_req_t |
| Channel request/status entry. More... | |
| struct | daq_t |
| NDS1/2 client status structure. More... | |
| struct | daq_channel_t |
| Channel description structure. More... | |
| #define | HEADER_LEN 16 |
| typedef daq_block_header | daq_block_t |
| enum | nds_version { nds_try = 0, nds_v1 = 1, nds_v2 = 2 } |
| int | daq_clear_channel_list (daq_t *daq) |
| Clear the channel list. | |
| int | daq_connect (daq_t *daq, const char *host, int port, enum nds_version version) |
| Make a connection to the NDS1 server. | |
| int | daq_disconnect (daq_t *daq) |
| Disconnect from the server. | |
| const char * | daq_get_channel_addr (daq_t *daq, const char *channel) |
| Get a pointer to the data for the specified channel. | |
| char * | daq_get_channel_data (daq_t *daq, const char *channel, char *data) |
| Copy channel data. | |
| int | daq_get_data_length (daq_t *daq, const char *channel) |
| Get the channel data length. | |
| chan_req_t * | daq_get_channel_status (daq_t *daq, const char *channel) |
| Get a pointer to channel data. | |
| int | daq_get_scaled_data (daq_t *daq, const char *channel, float *data) |
| Calibrate and copy channel data. | |
| void | daq_init_channel (daq_channel_t *chan, const char *name, enum chantype ctype, double rate, daq_data_t dtype) |
Initialize a daq_channel_t structure. | |
| int | daq_recv_block_num (daq_t *daq) |
| Receive block number. | |
| int | daq_recv_block (daq_t *daq) |
| Receive a data block. | |
| int | daq_recv_next (daq_t *daq) |
| Receive a data block. | |
| int | daq_recv_shutdown (daq_t *daq) |
| Close the client connection. | |
| int | daq_recv_channels (daq_t *daq, daq_channel_t *channel, int num_channels, int *num_channels_received) |
| Get a list of online channels. | |
| int | daq_recv_channel_list (daq_t *daq, daq_channel_t *channel, int num_channels, int *num_channels_received, time_t gps, enum chantype type) |
| Get a list of channels. | |
| long | daq_recv_id (daq_t *daq) |
| Receive an ID. | |
| int | daq_recv_source_list (daq_t *daq, char *sources, size_t max_len, time_t gps, long *str_len) |
| Get a list of source frames. | |
| int | daq_request_channel (daq_t *daq, const char *name, enum chantype type, double rate) |
| Add a channel to the request list. | |
| int | daq_request_channel_from_chanlist (daq_t *daq, daq_channel_t *channel) |
| Add a channel to the request list. | |
| int | daq_request_data (daq_t *daq, time_t start, time_t end, time_t dt) |
| Get requested data. | |
| int | daq_send (daq_t *daq, const char *command) |
| send a command string. | |
| int | daq_startup (void) |
| Initialize nds1/nds2 client subsystems. | |
| const char * | daq_strerror (int errornum) |
| determine English equivalent of return code. | |
| typedef enum chantype | chantype_t |
| Channel type code enumerator. | |
| enum | chantype { cUnknown, cOnline, cRaw, cRDS, cSTrend, cMTrend, cTestPoint } |
| Channel type code enumerator. More... | |
| #define HEADER_LEN 16 |
Block header structure length.
| typedef enum chantype chantype_t |
Channel type code enumerator.
Define channel types. The channel types are used to distinguish the requested source of the data.
| typedef struct daq_block_header daq_block_t |
Block header data type
| enum chantype |
Channel type code enumerator.
Define channel types. The channel types are used to distinguish the requested source of the data.
| enum nds_version |
| int daq_clear_channel_list | ( | daq_t * | daq | ) |
Clear the channel list.
Zero the number of requested channels. The number of allocates channel requests is not affected.
| daq | Pointer to client status structure. |
| int daq_connect | ( | daq_t * | daq, | |
| const char * | host, | |||
| int | port, | |||
| enum nds_version | version | |||
| ) |
Make a connection to the NDS1 server.
Connect to the DAQD server on the host identified by `ip' address. A socket is created using a socket() function call. The host address is found using the gethostbyname() function and a connection is established. The server is then asked for the protocol version and revision with "version;" and "revision;" commands. The version/revision are saved in the client structure.
| daq | Client status structure/ | |
| host | Server host name string. | |
| port | Server port number. | |
| version | NDS version (nds_v1 or nds_v2). |
| int daq_disconnect | ( | daq_t * | daq | ) |
Disconnect from the server.
Disconnect from the server by sending a "quit;" command and close the socket file descriptor.
| daq | Pointer to client status structure. |
| const char* daq_get_channel_addr | ( | daq_t * | daq, | |
| const char * | channel | |||
| ) |
Get a pointer to the data for the specified channel.
Get a pointer to the data block from a specified channel name. Note that the returned address is in the daqd temporary buffer. It is likely that the data will be replaced during the next call to the daq_recv_next and possible that the data for the requested channel will be in a different location after the next request. If an error occurred in fetching the data, the returned pointer is NULL and the error code is stored in the daq->err_num.
| daq | Pointer to client status structure. | |
| channel | Pointer to null terminated channel name string. |
| char* daq_get_channel_data | ( | daq_t * | daq, | |
| const char * | channel, | |||
| char * | data | |||
| ) |
Copy channel data.
Copy the data from a specified channel name to the target address. The target buffer must be large enough for the full data record. If the requested data are not available a NULL pointer is returned and the error code is stored in daq->err_num.
| daq | Pointer to client status structure. | |
| channel | Pointer to null terminated channel name string. | |
| data | pointer to a buffer to receive channel data. |
| chan_req_t* daq_get_channel_status | ( | daq_t * | daq, | |
| const char * | channel | |||
| ) |
Get a pointer to channel data.
Get a pointer specified channel request/status block.
| daq | Pointer to client status structure. | |
| channel | Pointer to null terminated channel name string. |
| int daq_get_data_length | ( | daq_t * | daq, | |
| const char * | channel | |||
| ) |
Get the channel data length.
Get the number of bytes of data retrieved for the specified channel.
| daq | Pointer to client status structure. | |
| channel | Pointer to null terminated channel name string. |
| int daq_get_scaled_data | ( | daq_t * | daq, | |
| const char * | channel, | |||
| float * | data | |||
| ) |
Calibrate and copy channel data.
Copy the data from a specified channel name to the target address. The data are converted to floats and scaled according to the linear transform specified by the NDS server. Complex data are not copied converted or scaled. The number of output data words is returned. It is up to the user to insure that the output array is large enough to accommodate the data.
| daq | Pointer to client status structure. | |
| channel | Pointer to null terminated channel name string. | |
| data | pointer to a buffer to receive calibrated channel data. |
| void daq_init_channel | ( | daq_channel_t * | chan, | |
| const char * | name, | |||
| enum chantype | ctype, | |||
| double | rate, | |||
| daq_data_t | dtype | |||
| ) |
Initialize a daq_channel_t structure.
Initialize a daq_channel_t structure with the specified data. If the channel type is _unknown and the name contains a trend channel suffix (e.g. .mean ) the type will be reset to a trend type in accordance with the specified rate. Trend channels are assigned a rate and data_type appropriate to the trend type. If a trend-type channel does not have an appropriate suffix, ".mean" is appended to the channel name.
| chan | Pointer to structure to be initialized | |
| name | Channel name | |
| ctype | Channel type code | |
| rate | Sample rate | |
| dtype | Data type. |
| int daq_recv_block | ( | daq_t * | daq | ) |
Receive a data block.
Receive one data block (data channel samples). A transmission buffer is allocated as needed and its pointer is assigned to `daq->tb'. The block size is assigned to `daq->tb_size'. A zero length block consists of the block header and no data. It is sent by the server when it fails to find the data for the GPS second, specified in the block header (Note: this can only happen for the off-line data request). If channel reconfiguration has occurred, the server sends a special reconfiguration data block. For the client it means he needs to reread channel data conversion variables and status from the *daq structure.
| daq | Pointer to client status structure. |
| int daq_recv_block_num | ( | daq_t * | daq | ) |
Receive block number.
Receive a data block number or zero for online data.
| daq | Pointer to client status structure. |
| int daq_recv_channel_list | ( | daq_t * | daq, | |
| daq_channel_t * | channel, | |||
| int | num_channels, | |||
| int * | num_channels_received, | |||
| time_t | gps, | |||
| enum chantype | type | |||
| ) |
Get a list of channels.
Get a list of channel names and information. A list of all channels available at the specified time and of the specified type is returned. A GPS time of zero indicates currently available channels. A type code of cUnknown (0) gives all channel types available at the specified gps time. Note that this will produce a list with multiple channel entries with identical names. The number of channels returned in *num_channels_received is the total number of channels available from the server and may exceed the number of channels for which space has been allocated. In fact, an efficient way to find out how much space is needed for the channel list is to call daq_recv_channel_list with num_channels set to zero and the channel list pointer set to NULL.
cOnline is requested, the function returns DAQD_VERSION_MISMATCH and *num_channels_received is set to zero. | daq | Pointer to client status structure. | |
| channel | List of daq_channel structures to receive information. | |
| num_channels | Number of channel structures allocated. | |
| num_channels_received | Pointer to integer to receive number of channels defined on server (may exceed num_channels ). | |
| gps | validity time (or zero for current channels) | |
| type | Limit list to specified type. |
| int daq_recv_channels | ( | daq_t * | daq, | |
| daq_channel_t * | channel, | |||
| int | num_channels, | |||
| int * | num_channels_received | |||
| ) |
Get a list of online channels.
Get a list of online channel names and information. daq_recv_channels requests the channel information as appropriate for the server version. All channel data are then copied into the list. This function is included to allow backward compatibility with the classic nds interface and is implemented with a call to daq_recv_channel_list. See the documentation for daq_recv_channel_list for further details.
| daq | Pointer to client status structure. | |
| channel | List of daq_channel structures to receive information. | |
| num_channels | Number of channel structures allocated. | |
| num_channels_received | Number of channels defined. |
| long daq_recv_id | ( | daq_t * | daq | ) |
Receive an ID.
Receive an eight-digit hex ID.
| daq | Pointer to client status structure. |
| int daq_recv_next | ( | daq_t * | daq | ) |
Receive a data block.
Receive one data block, handle all additional protocol, e.g. channel reconfiguration, and swap bytes according to channel list. Data are stored in the internal buffer. For NDS2 requests, the request list is updated with data length, offset, data type and status of each channel. For NDS1 the request list is updated with the inferred lengths and offsets.
| daq | Pointer to client status structure. |
| int daq_recv_shutdown | ( | daq_t * | daq | ) |
Close the client connection.
Close the data connection socket and free the allocated buffers (conversion list and transmission buffer).
| daq | Pointer to client status structure. |
| int daq_recv_source_list | ( | daq_t * | daq, | |
| char * | sources, | |||
| size_t | max_len, | |||
| time_t | gps, | |||
| long * | str_len | |||
| ) |
Get a list of source frames.
Get a list of channel sources for the requested channels at the specified gps time. A GPS time of zero indicates currently available channels.
| daq | Pointer to client status structure. | |
| sources | List of daq_channel structures to receive information. | |
| max_len | Pre-allocated string length. | |
| gps | validity time (or zero for current channels) | |
| str_len | Output string length pointer. |
Add a channel to the request list.
Add the specified channel to the request list. If the type is set to the default value (cUnknown or 0), the channel type will be inferred from the channel name and sample rate as described in the documentation of daq_init_channel. A zero sample rate results in the full-bandwidth data of the specified type.
| daq | Pointer to client status structure. | |
| name | Pointer to null terminated name string. | |
| type | Channel type. | |
| rate | Requested sampling rate (in Hz). |
| int daq_request_channel_from_chanlist | ( | daq_t * | daq, | |
| daq_channel_t * | channel | |||
| ) |
Add a channel to the request list.
Add the specified channel to the request list. The channel name data type, sample rate, etc are copied from the channel list entry.
| daq | Pointer to client status structure. | |
| channel | Pointer channel list entry. |
| int daq_request_data | ( | daq_t * | daq, | |
| time_t | start, | |||
| time_t | end, | |||
| time_t | dt | |||
| ) |
Get requested data.
Request data for all channels added to the list for the specified interval and stride width. Data are recived from the start time to the end time in strides of dt seconds. An online data request is made if the start time is zero and only online channels are specified. Online request end times may be specified either as an absolute GPS or as a total data length in seconds (if end is greater than the current time). Note that the NDS1 protocol ignores the stride length specifier.
| daq | Pointer to client status structure. | |
| start | Start time (GPS) or 0 for online data. | |
| end | End time (GPS). | |
| dt | Time stride. |
| int daq_send | ( | daq_t * | daq, | |
| const char * | command | |||
| ) |
send a command string.
Send a null-terminated command string to the server. Then read and return a response code.
| daq | Pointer to client status structure. | |
| command | Null terminated command text string. |
| int daq_startup | ( | void | ) |
Initialize nds1/nds2 client subsystems.
System initialization.
| const char* daq_strerror | ( | int | errornum | ) |
determine English equivalent of return code.
Return string equivalent to a return code.
| errornum | error return code. |
1.4.7