nds2-client - ClientAdministrator  0.16.8
 All Functions Typedefs Enumerations Enumerator Groups Pages
daqc.h
1 /* -*- tab-width:8 c-basic-offset:4 indent-tabs-mode:nil -*- */
2 /* set vi: ts=8:softtabstop=4,shiftwidth=4,expandtab */
3 
4 /*
5  * Data acquisition daemon access
6  */
7 #ifndef DAQC_H
8 #define DAQC_H
9 
10 #if __cplusplus
11 extern "C" {
12 #endif /* __cplusplus */
13 
14 #include "channel.h"
15 
16 typedef int int4_type;
17 typedef unsigned int uint4_type;
18 
19 #define DAQD_PROTOCOL_VERSION 12
20 #define DAQD_PROTOCOL_REVISION 0
21 
22 #define DAQD_PORT 31200
23 
24 struct sockaddr_in;
25 
26 struct signal_conv1;
27 
28 struct daq_private_;
29 
137 {
138 
140  nds_try = 0,
141 
143  nds_v1 = 1,
144 
146  nds_v2 = 2
147 };
148 
149 /* pieces of the communication protocol */
150 
153 #define HEADER_LEN 16
154 
157 typedef struct daq_block_header daq_block_t;
158 
163 struct signal_conv_
164 {
167  float signal_gain;
168 
171  float signal_slope;
172 
175  float signal_offset;
176 
179  char signal_units[ MAX_SIGNAL_UNIT_LENGTH ]; /* Engineering units */
180 };
181 
182 typedef struct signal_conv_ signal_conv_t;
183 
190 struct chan_req_
191 {
193  char* name;
194 
196  enum chantype type;
197 
200  double rate;
201 
208  daq_data_t data_type;
209 
212  uint4_type offset;
213 
219  int status;
220 
223  signal_conv_t s;
224 };
225 
226 typedef struct chan_req_ chan_req_t;
227 
232 struct daq_
233 {
237  enum nds_version nds_versn;
238 
241  uint4_type num_chan_request;
242 
245  uint4_type num_chan_alloc;
246 
249  chan_req_t* chan_req_list;
250 
254  int blocks;
255 
259  daq_block_t* tb;
260 
263  size_t tb_size;
264 
268  struct signal_conv1* s;
269 
273  int s_size;
274 
277  int nds1_ver;
278 
281  int nds1_rev;
282 
285  void* auth_ctx;
286 
289  int err_num;
290 
293  struct daq_private_* conceal;
294 };
295 
296 typedef struct daq_ daq_t;
297 
303 struct daq_channel_
304 {
307  char name[ MAX_LONG_CHANNEL_NAME_LENGTH + 1 ]; /* Channel name */
308 
312  double rate;
313 
316  int tpnum;
317 
323  enum chantype type;
324 
327  int bps;
328 
331  int chNum;
332 
335  daq_data_t data_type;
336 
339  signal_conv_t s;
340 };
341 
342 typedef struct daq_channel_ daq_channel_t;
343 
344 /* Channel Group interface (Version 1 Only)
345  */
346 
352 struct daq_channel_group_
353 {
356  int group_num;
359  char name[ MAX_CHANNEL_NAME_LENGTH + 1 ];
360 };
361 
362 typedef struct daq_channel_group_ daq_channel_group_t;
363 
370 DLL_EXPORT int daq_clear_channel_list( daq_t* daq );
371 
385 DLL_EXPORT int
386 daq_connect( daq_t* daq, const char* host, int port, enum nds_version version );
387 
394 DLL_EXPORT void daq_destroy( daq_t* daq );
395 
402 DLL_EXPORT int daq_disconnect( daq_t* daq );
403 
416 DLL_EXPORT const char* daq_get_channel_addr( daq_t* daq, const char* channel );
417 
428 DLL_EXPORT char*
429 daq_get_channel_data( daq_t* daq, const char* channel, char* data );
430 
437 DLL_EXPORT int daq_get_data_length( daq_t* daq, const char* channel );
438 
445 DLL_EXPORT chan_req_t* daq_get_channel_status( daq_t* daq,
446  const char* channel );
447 
456 DLL_EXPORT int
457 daq_get_last_message( daq_t* daq, char* buf, size_t max_len, int* len );
458 
471 DLL_EXPORT int
472 daq_get_scaled_data( daq_t* daq, const char* channel, float* data );
473 
479 DLL_EXPORT void daq_init( daq_t* daq );
480 
495 DLL_EXPORT void daq_init_channel( daq_channel_t* chan,
496  const char* name,
497  enum chantype ctype,
498  double rate,
499  daq_data_t dtype );
500 
506 DLL_EXPORT int daq_is_connected( daq_t* daq );
507 
513 DLL_EXPORT int daq_recv_block_num( daq_t* daq );
514 
533 DLL_EXPORT int daq_recv_block( daq_t* daq );
534 
545 DLL_EXPORT int daq_recv_next( daq_t* daq );
546 
553 DLL_EXPORT int daq_recv_shutdown( daq_t* daq );
554 
568 DLL_EXPORT int daq_recv_channels( daq_t* daq,
569  daq_channel_t* channel,
570  int num_channels,
571  int* num_channels_received );
572 
589 DLL_EXPORT int daq_recv_channel_hash(
590  daq_t* daq, void* hash, int* length, time_t gps, enum chantype type );
591 
610 DLL_EXPORT int daq_recv_hash_by_pattern( daq_t* daq,
611  void* hash,
612  int* length,
613  time_t gps,
614  enum chantype type,
615  const char* pat );
616 
644 DLL_EXPORT int daq_recv_channel_list( daq_t* daq,
645  daq_channel_t* channel,
646  int num_channels,
647  int* num_channels_received,
648  time_t gps,
649  enum chantype type );
650 
684 DLL_EXPORT int daq_recv_channels_by_pattern( daq_t* daq,
685  daq_channel_t* channel,
686  int num_channels,
687  int* num_channels_received,
688  time_t gps,
689  enum chantype type,
690  const char* pat );
691 
704 DLL_EXPORT int
705 daq_recv_epoch_list( daq_t* daq, char* epochs, size_t max_len, int* str_len );
706 
712 DLL_EXPORT long daq_recv_id( daq_t* daq );
713 
726 DLL_EXPORT int daq_recv_source_data(
727  daq_t* daq, char* sources, size_t max_len, time_t gps, long* str_len );
728 
741 DLL_EXPORT int daq_recv_source_list(
742  daq_t* daq, char* sources, size_t max_len, time_t gps, long* str_len );
743 
756 DLL_EXPORT int daq_request_channel( daq_t* daq,
757  const char* name,
758  enum chantype type,
759  double rate );
760 
768 DLL_EXPORT int daq_request_channel_from_chanlist( daq_t* daq,
769  daq_channel_t* channel );
770 
779 DLL_EXPORT int daq_request_check( daq_t* daq, time_t start, time_t end );
780 
803 DLL_EXPORT int
804 daq_request_data( daq_t* daq, time_t start, time_t end, time_t dt );
805 
813 DLL_EXPORT int daq_send( daq_t* daq, const char* command );
814 
829 DLL_EXPORT int daq_set_epoch( daq_t* daq, const char* epoch );
830 
835 DLL_EXPORT int daq_startup( void );
836 
842 DLL_EXPORT const char* daq_strerror( int errornum );
843 
849 DLL_EXPORT uint4_type daq_get_block_secs( daq_t* daq );
850 
856 DLL_EXPORT uint4_type daq_get_block_gps( daq_t* daq );
857 
863 DLL_EXPORT uint4_type daq_get_block_gpsn( daq_t* daq );
864 
870 DLL_EXPORT uint4_type daq_get_block_seq_num( daq_t* daq );
871 
876 DLL_EXPORT char* daq_get_block_data( daq_t* daq );
877 
884 #if __cplusplus
885 }
886 #endif /* __cplusplus */
887 
888 #endif /* DAQC_H */
DLL_EXPORT const char * daq_get_channel_addr(daq_t *daq, const char *channel)
Get a pointer to the data for the specified channel.
Definition: daqc_access.c:1131
DLL_EXPORT int daq_is_connected(daq_t *daq)
Test for connected server.
Definition: daqc_access.c:1576
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.
Definition: daqc_access.c:951
DLL_EXPORT int daq_request_channel_from_chanlist(daq_t *daq, daq_channel_t *channel)
Add a channel to the request list.
Definition: daqc_access.c:1057
DLL_EXPORT int daq_request_check(daq_t *daq, time_t start, time_t end)
Check requested data.
Definition: daqc_access.c:1282
DLL_EXPORT int daq_set_epoch(daq_t *daq, const char *epoch)
Set the default epoch.
Definition: daqc_access.c:1333
DLL_EXPORT int daq_recv_block_num(daq_t *daq)
Receive block number.
Definition: daqc_access.c:575
nds_version
Definition: daqc.h:136
DLL_EXPORT uint4_type daq_get_block_secs(daq_t *daq)
Definition: daqc_internal.c:494
DLL_EXPORT int daq_recv_epoch_list(daq_t *daq, char *epochs, size_t max_len, int *str_len)
Get a list of epochs.
Definition: daqc_access.c:905
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.
Definition: daqc_access.c:839
Definition: daqc.h:143
DLL_EXPORT int daq_request_data(daq_t *daq, time_t start, time_t end, time_t dt)
Get requested data.
Definition: daqc_access.c:1304
Definition: daqc.h:140
Definition: daqc.h:146
DLL_EXPORT char * daq_get_channel_data(daq_t *daq, const char *channel, char *data)
Copy channel data.
Definition: daqc_access.c:1150
DLL_EXPORT void daq_init(daq_t *daq)
Initialize a daq_t structure.
Definition: daqc_access.c:1516
DLL_EXPORT uint4_type daq_get_block_seq_num(daq_t *daq)
Definition: daqc_internal.c:525
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.
Definition: daqc_access.c:813
DLL_EXPORT int daq_get_scaled_data(daq_t *daq, const char *channel, float *data)
Calibrate and copy channel data.
Definition: daqc_access.c:1207
DLL_EXPORT int daq_clear_channel_list(daq_t *daq)
Clear the channel list.
Definition: daqc_access.c:1085
DLL_EXPORT uint4_type daq_get_block_gpsn(daq_t *daq)
Definition: daqc_internal.c:514
DLL_EXPORT int daq_connect(daq_t *daq, const char *host, int port, enum nds_version version)
Make a connection to an NDS server.
Definition: daqc_access.c:212
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.
Definition: daqc_access.c:866
chantype
Channel type code enumerator.
Definition: channel.h:28
DLL_EXPORT uint4_type daq_get_block_gps(daq_t *daq)
Definition: daqc_internal.c:503
DLL_EXPORT long daq_recv_id(daq_t *daq)
Receive an ID.
Definition: daqc_access.c:931
DLL_EXPORT int daq_startup(void)
Initialize nds1/nds2 client subsystems.
Definition: daqc_access.c:1463
DLL_EXPORT int daq_recv_shutdown(daq_t *daq)
Close the client connection.
Definition: daqc_access.c:752
DLL_EXPORT char * daq_get_block_data(daq_t *daq)
Definition: daqc_internal.c:533
DLL_EXPORT int daq_request_channel(daq_t *daq, const char *name, enum chantype type, double rate)
Add a channel to the request list.
Definition: daqc_access.c:1040
DLL_EXPORT int daq_send(daq_t *daq, const char *command)
send a command string.
Definition: daqc_access.c:335
DLL_EXPORT int daq_disconnect(daq_t *daq)
Disconnect from the server.
Definition: daqc_access.c:174
DLL_EXPORT int daq_recv_next(daq_t *daq)
Receive a data block.
Definition: daqc_access.c:592
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.
Definition: daqc_access.c:973
DLL_EXPORT const char * daq_strerror(int errornum)
determine English equivalent of return code.
Definition: daqc_access.c:1351
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.
Definition: daqc_access.c:1540
struct daq_block_header daq_block_t
Definition: daqc.h:157
DLL_EXPORT int daq_get_last_message(daq_t *daq, char *buf, size_t max_len, int *len)
Get the last message.
Definition: daqc_access.c:1170
DLL_EXPORT chan_req_t * daq_get_channel_status(daq_t *daq, const char *channel)
Get a pointer to channel data.
Definition: daqc_access.c:1102
DLL_EXPORT int daq_recv_block(daq_t *daq)
Receive a data block.
Definition: daqc_access.c:438
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.
Definition: daqc_access.c:791
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.
Definition: daqc_access.c:778
DLL_EXPORT int daq_get_data_length(daq_t *daq, const char *channel)
Get the channel data length.
Definition: daqc_access.c:1120
DLL_EXPORT void daq_destroy(daq_t *daq)
Close and delete all client status structure elements.
Definition: daqc_access.c:265