My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
archiver.h
1 #ifndef archiver_h
2 #define archiver_h
3 
4 #include <pthread.h>
5 
6 #include "genericcontrol.h"
7 #include "genericregs.h"
8 #include "list.h"
9 #include "netbuf.h"
10 #include "regset.h"
11 
12 #include "gcp/util/common/RegDescription.h"
13 
14 namespace gcp {
15  namespace control {
16  class ArchiverWriter;
17  }
18 }
19 
20 /*
21  * Register frames will be maintained in objects of the following type.
22  * Callers must acquire the guard mutex before attempting to access
23  * the frame buffer.
24  */
25 typedef struct {
26  pthread_mutex_t guard; /* The mutual exlusion guard of the frame */
27  int guard_ok; /* True after initializing 'guard' */
28  pthread_cond_t start; /* When the archiver has finished saving */
29  /* the latest integration, it will set */
30  /* the 'integrate' flag to 1 and signal */
31  /* the 'start' condition variable */
32  int start_ok; /* True after initializing 'start' */
33  int integrate; /* See the documentation of 'start' */
34  unsigned nframe; /* The number of frames to accumulate per */
35  /* integration. */
36  unsigned count; /* The number of frames accumulated during */
37  /* an ongoing integration */
38  bool newFrame; /* True if we should begin a new frame
39  on the next half-second boundary */
40  unsigned currFrameSeq; /* The sequence number associated with
41  the current frame */
42  unsigned lastFrameSeq; /* The sequence number associated with
43  the current frame */
44  ArrayMap *arraymap; /* The array map of this experiment */
45  RegRawData *frame; /* The frame being integrated or copied */
46  unsigned int* features; /* A pointer to the frame.features register */
47  /* in frame[] */
48  unsigned int* markSeq; /* A pointer to the frame.mark_seq register */
49  /* in frame[] */
50  unsigned int lastSeq; /* The value of *mark_seq when the last */
51  /* frame was saved to disk. */
52 } FrameBuffer;
53 
54 /*
55  * An object of the following type is used to hold the state of
56  * the archiver thread.
57  */
58 struct Archiver {
59  ControlProg *cp; /* The state-object of the control program */
60  gcp::util::Pipe *pipe; /* An externally allocated control-input pipe */
61  ListMemory *list_mem; /* Memory for allocating lists and their nodes */
62  List *clients; /* The list of connected clients */
63  CcPipeMsg ccmsg; /* A control client message container to use */
64  /* for sending status messages to clients in */
65  /* the clients list. */
66  char *dir; /* The directory in which to place new archive */
67  /* files. */
68  char *path; /* The pathname of the current archive file */
69  FILE *fp; /* The file-pointer attached to 'path' */
70  FrameBuffer fb; /* The integration frame buffer */
71  gcp::control::NetBuf *net; /* The network buffer of the output frame */
72  int filter; /* If true only record frames that contain */
73  /* feature markers. */
74  int file_size; /* The number of frames to record before */
75  /* starting a new archive file, or 0 if */
76  /* no limit is desired. */
77  int nrecorded; /* The number of frames recorded in the */
78  /* current file. */
79  struct {
80  int pending;
81  unsigned seq;
82  } tv_offset;
83 
85 };
86 
87 Archiver *cp_Archiver(ControlProg *cp);
88 
89 int get_reg_info(Archiver *arc, short iregmap, short board, short block,
90  short index, unsigned int *val);
91 
92 unsigned int* arc_find_reg(Archiver *arc, char* regmap, char* board,
93  char* name);
94 
95 double* arcFindActualReg(Archiver *arc, char* regmap);
96 
97 int chdir_archiver(Archiver *arc, char *dir);
98 int open_arcfile(Archiver *arc, char *dir);
99 void flush_arcfile(Archiver *arc);
100 void close_arcfile(Archiver *arc);
101 int arc_send_ccmsg(Archiver *arc, gcp::util::Pipe *client, const char *fmt, ...);
102 
103 double getRegVal(Archiver *arc, gcp::util::RegDescription& regDesc);
104 
105 #endif
Definition: archiver.h:58
Definition: netbuf.h:42
Definition: archiver.h:25
Definition: genericcontrol.c:708
Definition: Pipe.h:42
Definition: ArchiverWriter.h:16
Definition: list.c:12
Definition: genericcontrol.h:973
Definition: RegDescription.h:26
Definition: list.h:48
Definition: regdata.h:16
Definition: arraymap.h:177