nds2-client - ClientAdministrator
0.16.8
|
enum | chantype { cUnknown, cOnline, cRaw, cRDS, cSTrend, cMTrend, cTestPoint, cStatic, cSimData } |
Channel type code enumerator. More... | |
typedef enum chantype | chantype_t |
Channel type code enumerator. More... | |
enum | nds_version { nds_try = 0, nds_v1 = 1, nds_v2 = 2 } |
typedef struct daq_block_header | daq_block_t |
DLL_EXPORT int | daq_clear_channel_list (daq_t *daq) |
Clear the channel list. More... | |
DLL_EXPORT int | daq_connect (daq_t *daq, const char *host, int port, enum nds_version version) |
Make a connection to an NDS server. More... | |
DLL_EXPORT void | daq_destroy (daq_t *daq) |
Close and delete all client status structure elements. More... | |
DLL_EXPORT int | daq_disconnect (daq_t *daq) |
Disconnect from the server. More... | |
DLL_EXPORT const char * | daq_get_channel_addr (daq_t *daq, const char *channel) |
Get a pointer to the data for the specified channel. More... | |
DLL_EXPORT char * | daq_get_channel_data (daq_t *daq, const char *channel, char *data) |
Copy channel data. More... | |
DLL_EXPORT int | daq_get_data_length (daq_t *daq, const char *channel) |
Get the channel data length. More... | |
DLL_EXPORT chan_req_t * | daq_get_channel_status (daq_t *daq, const char *channel) |
Get a pointer to channel data. More... | |
DLL_EXPORT int | daq_get_last_message (daq_t *daq, char *buf, size_t max_len, int *len) |
Get the last message. More... | |
DLL_EXPORT int | daq_get_scaled_data (daq_t *daq, const char *channel, float *data) |
Calibrate and copy channel data. More... | |
DLL_EXPORT void | daq_init (daq_t *daq) |
Initialize a daq_t structure. More... | |
DLL_EXPORT 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. More... | |
DLL_EXPORT int | daq_is_connected (daq_t *daq) |
Test for connected server. More... | |
DLL_EXPORT int | daq_recv_block_num (daq_t *daq) |
Receive block number. More... | |
DLL_EXPORT int | daq_recv_block (daq_t *daq) |
Receive a data block. More... | |
DLL_EXPORT int | daq_recv_next (daq_t *daq) |
Receive a data block. More... | |
DLL_EXPORT int | daq_recv_shutdown (daq_t *daq) |
Close the client connection. More... | |
DLL_EXPORT int | daq_recv_channels (daq_t *daq, daq_channel_t *channel, int num_channels, int *num_channels_received) |
Get a list of online channels. More... | |
DLL_EXPORT int | daq_recv_channel_hash (daq_t *daq, void *hash, int *length, time_t gps, enum chantype type) |
Get a channel list hash. More... | |
DLL_EXPORT int | daq_recv_hash_by_pattern (daq_t *daq, void *hash, int *length, time_t gps, enum chantype type, const char *pat) |
Get a channel list hash. More... | |
DLL_EXPORT 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. More... | |
DLL_EXPORT int | daq_recv_channels_by_pattern (daq_t *daq, daq_channel_t *channel, int num_channels, int *num_channels_received, time_t gps, enum chantype type, const char *pat) |
Get a list of channels. More... | |
DLL_EXPORT int | daq_recv_epoch_list (daq_t *daq, char *epochs, size_t max_len, int *str_len) |
Get a list of epochs. More... | |
DLL_EXPORT long | daq_recv_id (daq_t *daq) |
Receive an ID. More... | |
DLL_EXPORT int | daq_recv_source_data (daq_t *daq, char *sources, size_t max_len, time_t gps, long *str_len) |
Get a list of source frames. More... | |
DLL_EXPORT 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. More... | |
DLL_EXPORT int | daq_request_channel (daq_t *daq, const char *name, enum chantype type, double rate) |
Add a channel to the request list. More... | |
DLL_EXPORT int | daq_request_channel_from_chanlist (daq_t *daq, daq_channel_t *channel) |
Add a channel to the request list. More... | |
DLL_EXPORT int | daq_request_check (daq_t *daq, time_t start, time_t end) |
Check requested data. More... | |
DLL_EXPORT int | daq_request_data (daq_t *daq, time_t start, time_t end, time_t dt) |
Get requested data. More... | |
DLL_EXPORT int | daq_send (daq_t *daq, const char *command) |
send a command string. More... | |
DLL_EXPORT int | daq_set_epoch (daq_t *daq, const char *epoch) |
Set the default epoch. More... | |
DLL_EXPORT int | daq_startup (void) |
Initialize nds1/nds2 client subsystems. More... | |
DLL_EXPORT const char * | daq_strerror (int errornum) |
determine English equivalent of return code. More... | |
DLL_EXPORT uint4_type | daq_get_block_secs (daq_t *daq) |
DLL_EXPORT uint4_type | daq_get_block_gps (daq_t *daq) |
DLL_EXPORT uint4_type | daq_get_block_gpsn (daq_t *daq) |
DLL_EXPORT uint4_type | daq_get_block_seq_num (daq_t *daq) |
DLL_EXPORT char * | daq_get_block_data (daq_t *daq) |
#define | HEADER_LEN 16 |
This module defines the NDS2 API. The C-functions provide a backward- compatible low level interface that may be used with either version of the NDS. These may used to implement the client server protocol defined elsewhere, e.g. classic NDS protocol or NDS protocol. A second high level interface is new to the API. This allows the user to make the server requests to either version of the NDS and without knowledge of the server protocol.
#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 |
DLL_EXPORT int daq_clear_channel_list | ( | daq_t * | daq | ) |
Clear the channel list.
Zero the number of requested channels. The number of allocated channel requests is not affected.
daq | Pointer to client status structure. |
DLL_EXPORT int daq_connect | ( | daq_t * | daq, |
const char * | host, | ||
int | port, | ||
enum nds_version | version | ||
) |
Make a connection to an NDS 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). |
DLL_EXPORT void daq_destroy | ( | daq_t * | daq | ) |
Close and delete all client status structure elements.
daq_destroy closes all open sockets and deletes all member elements of the specified daq_t structure. This function is safe for cleaning up a connection after a fatal error.
daq | Pointer to client status structure. |
DLL_EXPORT 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. |
DLL_EXPORT char* daq_get_block_data | ( | daq_t * | daq | ) |
Return starting address of the data in the block.
daq | Pointer to client status structure. |
DLL_EXPORT uint4_type daq_get_block_gps | ( | daq_t * | daq | ) |
Return time stamp second field of the first sample in the block
daq | Pointer to client status structure. |
DLL_EXPORT uint4_type daq_get_block_gpsn | ( | daq_t * | daq | ) |
Return time stamp nano-second field of the first sample in the block
daq | Pointer to client status structure. |
DLL_EXPORT uint4_type daq_get_block_secs | ( | daq_t * | daq | ) |
Return the number of seconds spanned by the data in the block.
daq | Pointer to client status structure. |
DLL_EXPORT uint4_type daq_get_block_seq_num | ( | daq_t * | daq | ) |
Return the block sequence number; shows if any blocks were dropped.
daq | Pointer to client status structure. |
DLL_EXPORT 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. |
DLL_EXPORT 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. |
DLL_EXPORT 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. |
DLL_EXPORT 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. |
DLL_EXPORT int daq_get_last_message | ( | daq_t * | daq, |
char * | buf, | ||
size_t | max_len, | ||
int * | len | ||
) |
Get the last message.
Last error message from the server.
daq | Pointer to client status structure. |
buf | Buffer to receive null terminated message string. |
max_len | length of buf. |
len | pointer to int to receive length of message. |
DLL_EXPORT 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. |
DLL_EXPORT void daq_init | ( | daq_t * | daq | ) |
Initialize a daq_t structure.
All elements of a specified daq_t
structure are set to their NULL values.
daq | Pointer to client status structure. |
DLL_EXPORT 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. |
DLL_EXPORT int daq_is_connected | ( | daq_t * | daq | ) |
Test for connected server.
Test whether the socket is connected.
daq | Pointer to client status structure. |
DLL_EXPORT 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. |
DLL_EXPORT 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. |
DLL_EXPORT int daq_recv_channel_hash | ( | daq_t * | daq, |
void * | hash, | ||
int * | length, | ||
time_t | gps, | ||
enum chantype | type | ||
) |
Get a channel list hash.
Get a channel list hash for the specified channel type and gps time. The gps and type parameters are interpreted exactly as for the daq_recv_channel_list() function. The preliminary hash code implementation is a crc-32 so the length of the hash buffer must be at least 4 bytes. If the hashing scheme changes a longer buffer may be required.
daq | Pointer to client status structure. |
hash | Pointer to a buffer to receive the hash code. |
length | Pointer to integer that on entry contains the length of the hash buffer and on return contains the length of the receved hash code. |
gps | validity time (or zero for current channels) |
type | Limit hash to include only channels of the specified type. |
DLL_EXPORT 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 | List only channels of the specified type. |
DLL_EXPORT 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. |
DLL_EXPORT int daq_recv_channels_by_pattern | ( | daq_t * | daq, |
daq_channel_t * | channel, | ||
int | num_channels, | ||
int * | num_channels_received, | ||
time_t | gps, | ||
enum chantype | type, | ||
const char * | pat | ||
) |
Get a list of channels.
Get a list of channel names and information. A list of all channels matching the specified pattern 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. The pattern bash-like channel name template used to select the channels to be matched. A null string will match all channel names.. Note that this function may 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. Wild-card pattern matching is not currently implemented on the server, althoug an emty string will match all channel names and a non-empty will match achannel with exactly the specified name. 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 | List only channels of the specified type. |
pat | Channel list pattern. |
DLL_EXPORT int daq_recv_epoch_list | ( | daq_t * | daq, |
char * | epochs, | ||
size_t | max_len, | ||
int * | str_len | ||
) |
Get a list of epochs.
Get a list of epoch names and their gps time ranges. The list is returned into a user defined character buffer of spcified length. The number of bytes of data received is returned in a integer length variable specified by the user. The epoch list is a string with blank separated field of the form "\<epoch-name>=\<gps-start>-\<gps-stop>"
.
daq | Pointer to client status structure. |
epochs | Character buffer to receive the epoch definition list. |
max_len | Length (in bytes) of the allocated buffer. |
str_len | Pointer to int to be filled with string length in bytes. |
DLL_EXPORT int daq_recv_hash_by_pattern | ( | daq_t * | daq, |
void * | hash, | ||
int * | length, | ||
time_t | gps, | ||
enum chantype | type, | ||
const char * | pat | ||
) |
Get a channel list hash.
Get a channel list hash for the specified channel type and gps time and channel name pattern. The gps, type and pattern parameters are interpreted exactly as for the daq_recv_channels_by_pattern() function. The preliminary hash code implementation is a crc-32 so the length of the hash buffer must be at least 4 bytes. If the hashing scheme changes a longer buffer may be required. This function is implemented only for nds2 clients.
daq | Pointer to client status structure. |
hash | Pointer to a buffer to receive the hash code. |
length | Pointer to integer that on entry contains the length of the hash buffer and on return contains the length of the receved hash code. |
gps | validity time (or zero for current channels) |
type | Limit hash to include only channels of the specified type. |
pat | Channel name pattern. |
DLL_EXPORT long daq_recv_id | ( | daq_t * | daq | ) |
Receive an ID.
Receive an eight-digit hex ID.
daq | Pointer to client status structure. |
DLL_EXPORT 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. |
DLL_EXPORT 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. |
DLL_EXPORT int daq_recv_source_data | ( | 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. |
DLL_EXPORT 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. |
DLL_EXPORT int daq_request_channel | ( | daq_t * | daq, |
const char * | name, | ||
enum chantype | type, | ||
double | rate | ||
) |
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). |
DLL_EXPORT 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. |
DLL_EXPORT int daq_request_check | ( | daq_t * | daq, |
time_t | start, | ||
time_t | end | ||
) |
Check requested data.
Request a check on the data status for all channels added to the list for the specified interval.
daq | Pointer to client status structure. |
start | GPS start time or 0 for online data. |
end | GPS end time (see note for NDS1 protocol). |
DLL_EXPORT 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 received 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).
dt=end-start
and may be specified either as a non-zero end-time or if end=0
, as a dt interval. If the requested data span is longer than an arbitrary maximum (typically 32s) data will be sent in strides of the maximum length. daq | Pointer to client status structure. |
start | GPS start time or 0 for online data. |
end | GPS end time (see note for NDS1 protocol). |
dt | Time stride (see note for NDS1 protocol). |
DLL_EXPORT 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. |
DLL_EXPORT int daq_set_epoch | ( | daq_t * | daq, |
const char * | epoch | ||
) |
Set the default epoch.
Set the default epoch for this transaction. The epoch may be defined in any of the following ways.
daq | Pointer to client status structure. |
epoch | Pointer to epoch string. |
Set the default epoch for this session.
DLL_EXPORT int daq_startup | ( | void | ) |
Initialize nds1/nds2 client subsystems.
System initialization.
DLL_EXPORT const char* daq_strerror | ( | int | errornum | ) |
determine English equivalent of return code.
Return string equivalent to a return code.
errornum | error return code. |