versadac  1
versadac - Scalable Recorder Firmware
am_history.h
1 /*****************************************************************************
2 FILE : am_history.h
3 VERSION : $Id: am_history.h 4938 2006-10-10 14:20:18Z martinto $
4 AUTHOR : Sandra Herring
5 SYSTEM : GNU C++ for Power PC
6 DESCRIPTION : Header file for the Archive file class
7 *****************************************************************************/
8 
9 #if !defined(__AM_HISTORY_H)
10 #define __AM_HISTORY_H
11 
12 #if !defined(__AM_HISTORYSTREAM_H)
13 #include "am_historystream.h"
14 #endif
15 
16 #if !defined(__AM_HISTORYHDR_H)
17 #include "am_historyhdr.h"
18 #endif
19 
20 #if !defined(__AM_HISTORYDATA_H)
21 #include "am_historydata.h"
22 #endif
23 
24 #if !defined(__AM_HISTORYTEXT_H)
25 #include "am_historytext.h"
26 #endif
27 
28 #if !defined(__AM_HISTORYBATCHHDR_H)
29 #include "am_historybatchhdr.h"
30 #endif
31 
32 #if !defined(__AM_HISTORYBATCHSTART_H)
33 #include "am_historybatchstart.h"
34 #endif
35 
36 #if !defined(__AM_HISTORYBATCHSTOP_H)
37 #include "am_historybatchstop.h"
38 #endif
39 
40 #if !defined(__AM_HISTORYPVCONFL_H)
41 #include "am_historypvconfl.h"
42 #endif
43 
44 #if !defined(__AM_HISTORYEND_H)
45 #include "am_historyend.h"
46 #endif
47 
48 #if !defined(__AM_CSV_H)
49 #include "am_csvstream.h"
50 #endif
51 
52 class AM_Archiver;
53 
55 {
56  public :
57 
58 /*------------------------------------------------------------------------------
59 FUNCTION : AM_History constructor
60 ARGUMENTS : None.
61 ------------------------------------------------------------------------------*/
62  AM_History();
63 
64 /*------------------------------------------------------------------------------
65 FUNCTION : AM_History destructor
66 ------------------------------------------------------------------------------*/
67  ~AM_History();
68 
69 /*------------------------------------------------------------------------------
70 FUNCTION : AM_History getStream
71 DESCRIPTION : Accessor method to return the input reader.
72 ARGUMENTS : None.
73 RETURN : Input stream.
74 NOTES :
75 ------------------------------------------------------------------------------*/
76  AM_HistoryStream & getStream();
77 
78 /*------------------------------------------------------------------------------
79 FUNCTION : AM_History::scanFileInfo
80 DESCRIPTION : service to read in timespan and configuration data from an open archive
81  stream.
82 ARGUMENTS : Handle to input archive stream.
83 RETURN : TRUE if file processed successfully, otherwise FALSE.
84 NOTES :
85 ------------------------------------------------------------------------------*/
86  bool scanFileInfo( FILE * historyFp,
87  uint32 activeSliceSize,
88  bool * pStopArchive,
89  char * pFirstBatchName,
90  struct tm * pFirstBatchStartTime,
91  struct tm * pFirstBatchStopTime );
92 
93 /*------------------------------------------------------------------------------
94 FUNCTION : AM_History::generateCsv
95 DESCRIPTION : service to output spreadsheet format from a recorder data file.
96 ARGUMENTS : historyFp Handle to input archive stream.
97  historyPath Name of history file (for debug purposes only)
98  historyFileTime Timestamp to put on output files
99  activeSliceSize Amount of the history file that can be read.
100  0xFFFFFFFF if all of it.
101  userName Username for remote login
102  password Password for remote login
103  dirName Where CSV files to go
104  pSetup CSV options and translation setup
105  maxFileSize Maximum size of an output file. 0xFFFFFFFF if unlimited.
106  archiver Route manager
107 RETURN : TRUE if file processed successfully, otherwise FALSE.
108 NOTES :
109 ------------------------------------------------------------------------------*/
110  bool generateCsv( FILE * historyFp,
111  char * historyPath,
112  uint32 historyFileTime,
113  uint32 activeSliceSize,
114  const char * serverName,
115  const char * userName,
116  const char * password,
117  const char * dirName,
118  AM_CsvSetup * pSetup,
119  uint32 maxFileSize,
120  AM_Archiver * pArchiver );
121 
122  private :
123  sint32 scanRecord( uint32 activeSliceSize,
124  uint8 pass,
125  sint32 * pRecId = NULL,
126  char ** ppBatchName = NULL,
127  char * pBatchName = NULL,
128  time_t * pBatchStartTime = NULL,
129  time_t * pBatchStopTime = NULL );
130 
131  void startPass( long endOfHeaderPos,
132  char ** ppBatchName,
133  char * pBatchName,
134  time_t * pBatchStartTime,
135  time_t * pBatchStopTime );
136 
137  bool createCsvFile(AM_CsvStream * pStream,
138  const char * groupName,
139  const char * pBatchName,
140  time_t startTime,
141  char * retFileName,
142  char ** pRetFileNameEndTime,
143  int * pSocket,
144  int * pFd,
145  FILE ** ppFile,
146  AM_Archiver & archiver );
147 
148  void closeCsvFile( AM_CsvStream * pStream,
149  const char * dirName,
150  const char * fileName,
151  char * pFileNameEndTime,
152  time_t endTime,
153  uint32 historyFileTime,
154  int * pSocket,
155  int * pFd,
156  FILE ** ppFile );
157 
158  char * csvFileNameTime( time_t timestamp,
159  char * pRetFileNameTime,
160  AM_TimeFormatter & timeFormatter );
161 
162  char * csvFileName(
163  const char * groupName,
164  const char * pBatchName,
165  time_t batchStartTime,
166  time_t batchStopTime,
167  char * retFileName,
168  char ** pRetFileNameEndTime,
169  AM_TimeFormatter & timeFormatter );
170 
171  time_t latestTime();
172 
173  private :
174  AM_HistoryStream m_InStream;
175  LinkedList<AM_HistoryPVConfig> m_PointConfigs;
176  AM_HistoryPVConfigListWalker m_ChannelWalker;
177  AM_HistoryPVConfigListWalker m_DvWalker;
178  AM_HistoryPVConfigListWalker m_TotaliserWalker;
179  AM_HistoryPVConfigListWalker m_CounterWalker;
180  AM_HistoryPVConfigListWalker *m_pConfigWalkers[4];
181  AM_HistoryHeader m_Header;
182  AM_HistoryData m_Data;
183  AM_HistoryText m_Text;
184  AM_HistoryBatchHeader m_BatchHeader;
185  AM_HistoryBatchStart m_BatchStart;
186  AM_HistoryBatchStop m_BatchStop;
187  AM_HistoryEnd m_End;
188  uint16 m_NoOfPoints;
189  uint16 m_ConfigsRemaining;
190 
191 }; // class AM_History
192 
193 
194 // inline services for class AM_History
195 
196 /*------------------------------------------------------------------------------
197 FUNCTION : AM_History getStream
198 DESCRIPTION : Accessor method to return the input reader.
199 ARGUMENTS : None.
200 RETURN : Input stream.
201 NOTES :
202 ------------------------------------------------------------------------------*/
203 inline AM_HistoryStream & AM_History::getStream()
204 {
205  return m_InStream;
206 }
207 
208 #endif
209 
Definition: am_historyend.h:17
Definition: am_history.h:54
Definition: am_historystream.h:23
Definition: am_historybatchhdr.h:22
Definition: am_historybatchstop.h:20
Definition: am_csvstream.h:49
Definition: am_historytext.h:32
Definition: am_archiver.h:90
Definition: am_historydata.h:30
Definition: am_csvstream.h:62
Definition: am_historypvconfl.h:26
Definition: am_historyhdr.h:28
Definition: am_historybatchstart.h:20
Definition: am_timeformatter.h:21