versadac  1
versadac - Scalable Recorder Firmware
dre_hmgr.h
1 /*****************************************************************************
2 FILE : dre_hmgr.h
3 AUTHOR : Dave Storey
4 SYSTEM : GNU C++ for ARM
5 DESCRIPTION : Data Recording Engine history manager class declaration
6 *****************************************************************************/
7 
8 #ifndef __DRE_HMGR_H
9 #define __DRE_HMGR_H
10 
11 #include "dre_hist.h"
12 
13 #include <types.h>
14 #include <stdio.h>
15 
16 // The DRE max path length
17 #define DRE_HMGR_PATH_MAX 256
18 
19 extern unsigned char ftpArchivingFileLost;
20 extern unsigned char mediaArchivingFileLost;
21 
22 class DreFile;
23 
25 {
26 public:
27 
28  DreHistMgr(uint32 z_uInstr, sint32 z_nMemSizeGuide,
29  const char *z_szDirectory, bool z_bUseSubdirs = FALSE);
30  ~DreHistMgr();
31 
32  DRE_SLICE_T *appendSlice(DRE_SLICE_T *z_pSlice, bool z_bSkip,
33  double z_dStartTime,
34  uc_char * z_szGroupName,
35  uc_char *z_szBatchName,
36  sint32 z_nTzRawOffset);
37  DRE_SLICE_T *appendSlice(uint8 z_uGroup, bool z_bSkip,
38  double z_dStartTime,
39  uc_char * z_szGroupName,
40  uc_char *z_szBatchName,
41  sint32 z_nTzRawOffset);
42 
43  char* constructFilename( DRE_SLICE_T *z_pSlice, uint8 z_uGroup,
44  uc_char *z_szGroupName,
45  uc_char *z_szBatchName,
46  sint32 z_nTzRawOffset);
47 
48  static char* convertToValidFileName(char *z_szFileName);
49 
50  bool checkTruncation();
51  bool deleteEarliest(DRE_GROUP_HIST_T *z_pGroupHist, bool z_bForce = FALSE);
52  void emptyGroup(uint8 z_uGroup);
53  bool emptyAllGroups();
54  DRE_SLICE_T *latestSlice(uint8 z_uGroup);
55  static void logFileError(char *z_szFormat, char *z_szPath);
56  void markGroupRecording(uint8 z_uGroup, bool z_bRecording);
57  void printSummary(); // Print out a summary of the history
58  void setArchiveAttributes(FILE *z_pF, DRE_SLICE_T *z_pSlice);
59  void setArchiveAttributesActiveSlices();
60  void setMemSizeGuide(sint32 z_nSize);
61 
62  // Public methods for test use:
63 
64  void erase(uint32 z_uInitSeq = 0); // Erase whole history, set initial seqno
65  bool verify(uint32 z_uGroup, uint32 z_uSeqNo, uint32 z_uSize,
66  uint32 z_uByteSum, uint32 z_uShiftXor); // Verify file
67 
68  DRE_INSTR_HIST_T *getHistory(){return &m_History;}
69  static bool parseNumber(char *z_p, uint8 z_uDigits, uint32 *z_puValue);
70 
71 protected:
72 
73 
74 private:
75 
76  uint32 m_uInstr; // The instrument number
77  sint32 m_nMemSizeGuide; // The memory size guide
78  const char *m_szDirectory; // The directory for history files
79  bool m_bUseSubdirs; // Whether to use subdirectories
80  uint32 m_uInitSeqNo; // Initial slice sequence number to use
81  DRE_INSTR_HIST_T m_History; // The instrument history
82 
83  //Private methods
84  bool checkAndAddFile(char *z_szPath, char *z_szName,
85  char *z_szEnd);
86  void clear(bool z_bErase);
87  DRE_GROUP_HIST_T *locateGroupHist(uint8 z_uGroup);
88  bool removeFile(DRE_SLICE_T *z_pSlice);
89 };
90 
91 
92 #endif // __DRE_HMGR_H
Definition: dre_hist.h:19
Definition: dre_file.h:20
Definition: dre_hist.h:35
Definition: dre_hmgr.h:24
Definition: dre_hist.h:54