versadac  1
versadac - Scalable Recorder Firmware
uhh_grouphist.h
1 /*****************************************************************************
2 FILE : U H H _ G R O U P H I S T . H
3 VERSION : $Id: uhh_grouphist.h 4938 2006-10-10 14:20:18Z martinto $
4 AUTHOR : Dave Storey
5 SYSTEM : Gnu C++
6 DESCRIPTION : UHH Group history class and related structures
7 *****************************************************************************/
8 
9 #if !defined __UHH_GROUPHIST_H
10 #define __UHH_GROUPHIST_H
11 
12 #include "uhh_filelist.h"
13 #include "uhh_histhdr.h"
14 #include "uhh_seghdr.h"
15 #include <float.h>
16 
17 
18 // The only reason that slices and segments are classes rather than structs
19 // is so that memory management can be kept neat via destructors.
20 
21 
22 // SLICE
23 
24 
25 // Slice states: the life cycle is:
26 //
27 // New -+->Premature -+-> Active -+-> Closed ------------+-> Deleted
28 // | | | |
29 // >------------->----------->-----------> Invalid -+
30 //
31 // The meaning of the states is
32 //
33 // NEW File not yet investigated.
34 // PREMATURE File exists, but is not yet usable, e.g. header is incomplete.
35 // ACTIVE File is usable, and may still be being written to.
36 // CLOSED File will have no more data written to it.
37 // DELETED The file has been deleted by the Data Recorder Engine.
38 // INVALID The file exists, but something's wrong with it.
39 //
40 // Notes:
41 // The INVALID state is not always set when a format error is encountered,
42 // only when this is deemed to render the whole file unusable.
43 
44 #define UHH_SLICE_STATE_NEW 0
45 #define UHH_SLICE_STATE_PREMATURE 1
46 #define UHH_SLICE_STATE_ACTIVE 2
47 #define UHH_SLICE_STATE_CLOSED 3
48 #define UHH_SLICE_STATE_INVALID 4
49 #define UHH_SLICE_STATE_DELETED 5
50 
51 
52 class UhhSlice : public UhhHeap
53 {
54 public:
55  class UhhSegment *m_pSeg; // The segment this slice belongs to
56  UhhSlice *m_pEarlier; // Earlier slice in same segment, 0 if none
57  UhhSlice *m_pLater; // Later slice in same segment, 0 if none
58  char *m_szFileName; // The file name for this slice
59  sint32 m_nSeqNo; // Sequence number
60  sint32 m_nState; // State - see above
61 
62  // The following are all measured in ticks
63  double m_dTixStart; // Start pseudo-time
64  double m_dTixLeader; // Duration of leader, as specified in file
65  double m_dTixHead; // Start of leader time, as actually used
66  double m_dTixEnd; // End pseudo-time
67  double m_dTixTrailer; // Duration of trailer, as specified in file
68  double m_dTixTail; // End of trailer time, as actually used
69  double m_dTixOffset; // Pseudo-time offset (pseudo-time - clock time)
70 
71  sint32 m_nTimeSeg; // Time segment
72 
73  bool m_bHasLeader; // True if the leader is to be made use of
74  bool m_bHasTrailer; // True if the trailer is to be made use of
75  bool m_bIsFirst; // True if this is the first slice in the history
76  bool m_bIsLast; // True if this is the last slice in the history
77 
78  sint32 m_nUhhSeqNo; // Uhh compatibility seq no
79 
80  // Useful info to avoid re-reading from file
81  sint32 m_nFileLen; // File length
82  sint32 m_nLastRDR; // Seek index to last Reference Data Record
83  sint32 m_lLastMsg; // Seek index to last Message Record, zero if no messages
84  bool m_bEndRecord; // Whether the file has an end record
85 
86  sint32 m_nRecStatus; // Recording status during this slice
87  sint32 m_nRecStatusAfter; // Recording status after this slice;
88 
89  ~UhhSlice();
90 };
91 
92 
93 // SEGMENT
94 
95 class UhhSegment : public UhhHeap
96 {
97 public:
98  class UhhGroupHist *m_pGroupHist;
99  UhhSegment *m_pEarlier;
100  UhhSegment *m_pLater;
101  UhhSlice *m_pSliEarliest;
102  UhhSlice *m_pSliLatest;
103  sint32 m_nSlices;
104 
105  UhhSegHdr *m_pSegHdr;
106 
107  ~UhhSegment();
108 };
109 
110 
111 // Time (in ticks) limits (generally used to mean 'unknown')
112 
113 #define UHH_TIX_MAX (DBL_MAX)
114 #define UHH_TIX_MIN (DBL_MIN)
115 
116 class UhhNavMgr;
117 
118 class UhhGroupHist : public UhhHeap
119 {
120 public:
121  UhhGroupHist(UhhNavMgr *z_pNavMgr, char *z_szDirectory, sint32 z_nInstrument,
122  sint32 z_nUhhSeqNoMin, sint32 z_nUhhSeqNoMax, sint32 z_nGroup);
123  ~UhhGroupHist();
124 
125  double clockTix(double z_dTix);
126  void dumpSummary();
127  bool match(char *z_szDirectory, sint32 z_nInstrument,
128  sint32 z_nUhhSeqNoMin, sint32 z_nUhhSeqNoMax, sint32 z_nGroup);
129  bool refresh();
130  double subtractClock(double z_dTix, double z_dClock);
131 
132 
133  // PUBLIC MEMBERS
134 
135  // Members used by navigator manager
136  UhhGroupHist *m_pNext; // Used to make list of histories
137  sint32 m_nLinks; // Number of navigators linked to this history
138  sint32 m_nSusps; // Number of navigators in the suspended state
139 
140  char *m_szDirectory;
141  UhhHistHdr *m_pHistHdr;
142 
143  double m_dTixHead, m_dTixHeadSNP, m_dTixTail;
144  sint32 m_nFinalRecStatus;
145 
146  // Segments list
147  UhhSegment *m_pSegEarliest;
148  UhhSegment *m_pSegLatest;
149  sint32 m_nSegments;
150 
151 private:
152  UhhNavMgr *m_pNavMgr;
153 
154  sint32 m_anMatchMin[UHH_FILENAME_GROUP_COMPONENT+1];
155  sint32 m_anMatchMax[UHH_FILENAME_GROUP_COMPONENT+1];
156 
157  // PRIVATE METHODS
158 
159  void clear();
160  void sliceAddTixOffset(UhhSlice *z_pSlice, double z_dOffset);
161  void sliceIncludeLeader(UhhSlice *z_pSlice, bool z_bInclude);
162  void sliceIncludeTrailer(UhhSlice *z_pSlice, bool z_bInclude);
163 };
164 
165 #endif
Definition: uhh_navmgr.h:20
Definition: uhh_seghdr.h:116
Definition: uhh_grouphist.h:95
Definition: uhh_histhdr.h:14
Definition: uhh_grouphist.h:118
Definition: uhh_heap.h:31
Definition: uhh_grouphist.h:52