1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#ifndef __DADA_PWC_MAIN_H
#define __DADA_PWC_MAIN_H
/* ************************************************************************
dada_pwc_main_t - a struct and associated routines for creation and
execution of a dada primary write client main loop
************************************************************************ */
#include "dada_pwc.h"
#include "multilog.h"
#include "ipcio.h"
#define DADA_XFER_NORMAL 0
#define DADA_XFER_ENDING 1
#define DADA_OBS_ENDING 2
#ifdef __cplusplus
extern "C" {
#endif
typedef struct dada_pwc_main {
/*! The primary write client control connection */
dada_pwc_t* pwc;
/*! The status and error logging interface */
multilog_t* log;
/*! The Data Block interface */
ipcio_t* data_block;
/*! The Header Block interface */
ipcbuf_t* header_block;
/*! Pointer to the function that starts data transfer */
time_t (*start_function) (struct dada_pwc_main*, time_t utc);
/*! Pointer to the function that returns a data buffer */
void* (*buffer_function) (struct dada_pwc_main*, int64_t* size);
/*! Pointer to the function that fills data buffer with data */
int64_t (*block_function) (struct dada_pwc_main*, void* data,
uint64_t size, uint64_t block_id);
/*! Pointer to the function that stops data transfer */
int (*stop_function) (struct dada_pwc_main*);
/*! Pointer to the function that handles data transfer error*/
int (*error_function) (struct dada_pwc_main*);
/*! Pointer to the function that checks header validity */
int (*header_valid_function) (struct dada_pwc_main*);
/*! Pointer to the function that checks whether a new xfer is pending*/
int (*xfer_pending_function) (struct dada_pwc_main*);
/*! Pointer to the function that starts a new xfer*/
uint64_t (*new_xfer_function) (struct dada_pwc_main*);
/*! Additional context information */
void* context;
/*! The current command from the PWC control connection */
dada_pwc_command_t command;
/*! the unique header for this primary write client */
char* header;
/*! the size of the header */
unsigned header_size;
/*! verbosity level */
int verbose;
/*! flag to determine if we have a valid header */
int header_valid;
} dada_pwc_main_t;
/*! Create a new DADA primary write client main loop */
dada_pwc_main_t* dada_pwc_main_create ();
/*! Destroy a DADA primary write client main loop */
void dada_pwc_main_destroy (dada_pwc_main_t* pwcm);
/*! Run the DADA primary write client main loop */
int dada_pwc_main (dada_pwc_main_t* pwcm);
/*! process error value, and set state accordingly */
void dada_pwc_main_process_error(dada_pwc_main_t* pwcm, int rval);
/*! handle a change of xfer */
int64_t dada_pwc_main_process_xfer(dada_pwc_main_t* pwcm, uint64_t buf_bytes,
uint64_t bytes_this_xfer);
#ifdef __cplusplus
}
#endif
#endif