versadac  1
versadac - Scalable Recorder Firmware
dre_msg.h
1 /*****************************************************************************
2 FILE : dre_msg.h
3 AUTHOR : Dave Storey
4 SYSTEM : GNU C++ for Power PC
5 DESCRIPTION : Data Recording Engine queue message definitions
6  Specification: DEV1198 5.2.4
7 *****************************************************************************/
8 
9 #ifndef __DRE_MSG_H
10 #define __DRE_MSG_H
11 
12 #include "stdtypes.h"
13 #include "dre_uhh.h"
14 
15 class fb_dre;
16 
17 // Message types - first field of the corresponding message structure.
18 
19 // Messages specific to a group
20 #define DRE_MSG_SAMPLE 0
21 #define DRE_MSG_ALARMS 1
22 #define DRE_MSG_MESSAGE 2
23 #define DRE_MSG_BATCH_START 3
24 #define DRE_MSG_BATCH_STOP 4
25 #define DRE_MSG_SYNC 5
26 #define DRE_MSG_RECSTATUS 6
27 
28 // Top bit is set if the message is not specific to a group
29 #define DRE_MSG_NON_GROUP 0x80
30 
31 // Non group specific messages
32 #define DRE_MSG_LOST_DATA (DRE_MSG_NON_GROUP | 0)
33 #define DRE_MSG_STOP (DRE_MSG_NON_GROUP | 1)
34 #define DRE_MSG_DETACH (DRE_MSG_NON_GROUP | 2)
35 #define DRE_MSG_KILL (DRE_MSG_NON_GROUP | 3)
36 #define DRE_MSG_TESTMODE (DRE_MSG_NON_GROUP | 4) // Test use only
37 #define DRE_MSG_ERASE (DRE_MSG_NON_GROUP | 5) // Test use only
38 #define DRE_MSG_SIZES (DRE_MSG_NON_GROUP | 6) // Test use only
39 #define DRE_MSG_PRT_HIST (DRE_MSG_NON_GROUP | 7) // Test use only
40 #define DRE_MSG_VERIFY (DRE_MSG_NON_GROUP | 8) // Test use only
41 #define DRE_MSG_ERASEALL (DRE_MSG_NON_GROUP | 9)
42 
43 
44 struct DRE_MSG_T // Generic message, to access message type & possibly group
45 {
46  uint8 uMsgType;
47  uint16 uSerialNumber;
48  uint8 uGroup; // Always present if uMsgType & DRE_MSG_NON_GROUP is zero
49 };
50 
51 struct DRE_HIST_HDR_T // History header
52 {
53  uint8 uMsgType;
54  uint16 uSerialNumber;
55  uint32 uInstrType;
56  uint8 auMacAddr[6];
57  uint16 uBaseYear;
58  uint8 uTicksPerSec;
59 };
60 
61 
62 // This structure held in DRE_INST_HDR_T not sent as a message to the dre queue
63 struct DRE_SEG_HDR_T // Segment header (includes some start record info)
64 {
65  // Maintain compatiblity with message structues
66  uint8 uMsgType;
67  uint16 uSerialNumber;
68 
69  uint8 uGroup;
70  uint8 uRecStatus;
71  double dTime;
72  double dLeader;
73  sint32 nTimeSeg;
74  uint16 uSamplesPerFlush;
75  uint32 uUpdatePeriodA;
76  uint32 uUpdatePeriodB;
77  bool bUpdatePeriodBActive;
78 
79  bool bMinmax;
80 
81  uc_char acSwVersion[DRE_UHH_SW_VERSION_L + 1];
82  uint8 uNameProperties;
83  uc_char acInstrName[DRE_UHH_INSTR_NAME_L + 1];
84  uc_char acGroupName[DRE_UHH_GROUP_NAME_L + 1];
85  uc_char acBatchName[DRE_UHH_BATCH_NAME_L + 1];
86  uint8 uTrendUnits;
87  uc_char acLanguage[DRE_UHH_LANGUAGE_L + 1];
88  uc_char acCountry[DRE_UHH_COUNTRY_L + 1];
89  uc_char acTzId[DRE_UHH_TIMEZONE_ID_L + 1];
90  sint32 nTzRawOffset;
91  uc_char aacTzRule[2][DRE_UHH_TIMEZONE_RULE_L + 1];
92  uint8 uTzDstUse;
93  uint8 uGridType;
94  uint8 uGridDivsOrDecades;
95  uint8 uGridDivsMinor;
96  uint8 uGridScaleType;
97  double dGridSpanLo;
98  double dGridSpanHi;
99  float fGridZoneLo;
100  float fGridZoneHi;
101  double dGridSpanLoB;
102  double dGridSpanHiB;
103  float fGridZoneLoB;
104  float fGridZoneHiB;
105  uint16 uNumPts;
106  uint8 auPtTypes[1]; // Extends to uNumPts
107 };
108 
109 
110 struct DRE_MSG_AB_BLOCK_T // A/B data, used within point header
111 {
112  double dSpanLo;
113  double dSpanHi;
114  float fZoneLo;
115  float fZoneHi;
116  uint8 uColour;
117  uint8 uScaleType;
118  uint8 uScaleDivsMajor;
119 };
120 
121 
122 // This structure held in DRE_INST_HDR_T not sent as a message to the dre queue
123 struct DRE_PT_HDR_T // Point header
124 {
125  // Maintain compatiblity with message structues
126  uint8 uMsgType;
127  uint16 uSerialNumber;
128 
129  uint8 uGroup;
130  uint8 uPtType;
131  uint16 uChanNo;
132  uint8 uChanType;
133  DRE_MSG_AB_BLOCK_T aAbPars[2];
134  bool bPvDouble;
135  uint8 uPvBytes;
136  double dPvOffset;
137  uint8 uPvFmt;
138  uint8 uPvDecPl;
139  uc_char acDescriptor[DRE_UHH_PT_DESCRIPTOR_L + 1];
140  uc_char acUnits[DRE_UHH_PT_UNITS_L + 1];
141  uc_char acActive[DRE_UHH_PT_ACTIVE_L + 1];
142  uc_char acInactive[DRE_UHH_PT_INACTIVE_L + 1];
143  uint8 aAbScaleDivsMinor[2];
144  uint8 uNumAlms;
145  uint8 auAlmType[1]; // Extends to uNumAlms by m_uMaxMsgSize
146 };
147 
148 
149 struct DRE_MSG_PV_ETC_T // PV and associated data
150 {
151  double dValue;
152  uint8 uStatus;
153  uint8 uBoolData; // Colour A/B, zone A/B, etc.
154 };
155 
157 {
158  double dTime; // start time for batch
159  sint32 nTimeSeg; // corresponding time segment
160  bool bNameByBatch; // true if file-names should use the batcb name
161 
162  uc_char acActionedBy[DRE_UHH_BATCH_ACTIONED_BY_L + 1];
163 
164  uint8 uNoOfFields; // declares the number of batch fields in use
165 
166  // NB When descriptors are placed in this message they are packed together
167  // to reduce the queue overhead and so cannot be de-referenced directly
168  uc_char acFieldDescriptors[DRE_UHH_MAX_BATCH_FIELDS][DRE_UHH_BATCH_FIELD_DESC_L + 1];
169  uc_char acFieldData[DRE_UHH_MAX_BATCH_FIELDS][DRE_UHH_BATCH_FIELD_DATA_L + 1];
170 };
171 
172 struct DRE_BATCH_HDR_T // batch header - start or continuation
173 {
174  // Maintain compatiblity with message structues
175  uint8 uMsgType;
176  uint16 uSerialNumber;
177 
178  uint8 uGroup;
179  uint8 uStart; // 1 = indicates batch start, 0 = continuation
180  struct DRE_MSG_BATCH_DATA_T data;
181 };
182 
183 struct DRE_MSG_BATCH_START_T // batch start trigger
184 {
185  uint8 uMsgType;
186  uint16 uSerialNumber;
187  uint8 uGroup;
188 
189  struct DRE_MSG_BATCH_DATA_T data;
190 };
191 
192 struct DRE_MSG_BATCH_STOP_T // batch stop trigger
193 {
194  uint8 uMsgType;
195  uint16 uSerialNumber;
196  uint8 uGroup;
197 
198  double dTime; // stop time for batch
199 
200  uc_char acActionedBy[DRE_UHH_BATCH_ACTIONED_BY_L + 1];
201 };
202 
203 
204 struct DRE_REF_PV_T // Reference PV values, sent after headers
205 {
206  // Maintain compatiblity with message structues
207  uint8 uMsgType;
208  uint16 uSerialNumber;
209 
210  uint8 uGroup;
211  DRE_MSG_PV_ETC_T aPvEtc[1]; // Extends to number of points in group
212  // (*2 if minmax)
213 };
214 
215 
216 struct DRE_REF_ALM_T // Reference alarm statuses, sent after ref PVs
217 {
218  // Maintain compatiblity with message structues
219  uint8 uMsgType;
220  uint16 uSerialNumber;
221 
222  uint8 uGroup;
223  uint8 auStatus[1]; // Extends to total number of alarms in group
224 };
225 
226 struct DRE_INST_HDR_T // Instrument header structure, used to send
227  // critical data from the function block to the task
228 {
229  uint32 uLock;
230  uint16 uNumGps;
231  uint16 uNumPts;
232  uint16 uSerialNumber;
233  DRE_HIST_HDR_T histHdr;
234  bool *pGroups;
235  DRE_BATCH_HDR_T **ppBatchHdr;
236  DRE_PT_HDR_T **ppPtHdr;
237  DRE_REF_ALM_T **ppRefAlm;
238  DRE_REF_PV_T **ppRefPV;
239  DRE_SEG_HDR_T **ppSegHdr;
240  fb_dre *pDreBlock;
241  bool bAnyRecording;
242 };
243 
244 
245 struct DRE_MSG_SAMPLE_T // Sample
246 {
247  uint8 uMsgType;
248  uint16 uSerialNumber;
249  uint8 uGroup;
250  double dTime;
251  DRE_MSG_PV_ETC_T aPvEtc[1]; // Extends to number of points in group
252  // (*2 if minmax)
253 };
254 
255 
256 struct DRE_MSG_ALARMS_T // Change of alarm status(es)
257 {
258  uint8 uMsgType;
259  uint16 uSerialNumber;
260  uint8 uGroup;
261  double dTime;
262  uint8 auStatus[1]; // Extends to total number of alarms in group
263 };
264 
265 
266 struct DRE_MSG_MESSAGE_T // Message
267 {
268  uint8 uMsgType;
269  uint16 uSerialNumber;
270  uint8 uGroup;
271  double dTime;
272  double dLeader; // Needed when message triggers recording to restart
273  uint16 uNumBytes;
274  uint8 auData[1]; // Extends to uNumBytes
275 };
276 
277 
278 struct DRE_MSG_SYNC_T // Sync headers
279 {
280  uint8 uMsgType;
281  uint16 uSerialNumber;
282  uint8 uGroup;
283 };
284 
285 
286 // Recording statuses
287 // NB Numeric order IS important: any increase of status is transmitted at the
288 // start of a time slot, any decrease at the end.
289 #define DRE_RECSTATUS_NOT_RECORDING 0 // Not configured to record
290 #define DRE_RECSTATUS_DISABLED 1 // disabled (audit trail disabled)
291 #define DRE_RECSTATUS_MSGSONLY 2 // disabled (audit trail enabled)
292 #define DRE_RECSTATUS_ENABLED 3 // normal recording
293 
294 // Not to be used as a status in the DRE itself, only for the icon display
295 #define DRE_RECSTATUS_PAUSED 4 // temporarily disabled via job, paused
296 
298 {
299  uint8 uMsgType;
300  uint16 uSerialNumber;
301  uint8 uGroup;
302  double dTime;
303  double dLeader; // Time since last sample (possibly not recorded)
304  uint8 uRecStatus; // New recording status, as listed above
305 };
306 
307 
308 struct DRE_MSG_LOST_DATA_T // Lost data
309 {
310  uint8 uMsgType;
311 };
312 
313 
314 struct DRE_MSG_STOP_T // Stop recording
315 {
316  uint8 uMsgType;
317  uint16 uSerialNumber;
318  double dTime;
319 };
320 
321 
322 struct DRE_MSG_DETACH_T // Detach DRE task
323 {
324  uint8 uMsgType;
325 };
326 
327 
328 struct DRE_MSG_KILL_T // Kill DRE task
329 {
330  uint8 uMsgType;
331 };
332 
333 
334 struct DRE_MSG_TESTMODE_T // Test mode (test use only)
335 {
336  uint8 uMsgType;
337  uint16 uSerialNumber;
338  uint32 uMode;
339 };
340 
341 
342 struct DRE_MSG_ERASE_T // Erase history (test use only)
343 {
344  uint8 uMsgType;
345  uint16 uSerialNumber;
346  uint32 uInitSeq;
347 };
348 
349 
350 struct DRE_MSG_SIZES_T // Set guide sizes (test use only)
351 {
352  uint8 uMsgType;
353  uint16 uSerialNumber;
354  uint32 uMem;
355  uint32 uFile;
356  uint32 uBlock;
357 };
358 
359 
360 struct DRE_MSG_PRT_HIST_T // Print history summary (test use only)
361 {
362  uint8 uMsgType;
363 };
364 
365 
366 struct DRE_MSG_VERIFY_T // Verify file (test use only)
367 {
368  uint8 uMsgType;
369  uint16 uSerialNumber;
370  uint32 uGroup;
371  uint32 uSeqNo;
372  uint32 uSize;
373  uint32 uByteSum;
374  uint32 uShiftXor;
375  uint8 *puStatus; // Set to FAIL if test fails
376 };
377 
378 
379 struct DRE_MSG_ERASEALL_T // Erase all groups.
380 {
381  uint8 uMsgType;
382  bool bWaitForReboot;
383  volatile sint32 *pResult;
384 };
385 
386 #endif
Definition: dre_msg.h:256
Definition: dre_msg.h:297
Definition: dre_msg.h:51
Definition: dre_msg.h:334
Definition: dre_msg.h:172
Definition: dre_msg.h:360
Definition: dre_msg.h:183
Definition: dre_msg.h:123
Definition: dre_msg.h:245
Definition: dre_msg.h:216
Definition: dre_msg.h:110
Definition: dre_msg.h:342
Definition: dre_msg.h:149
Definition: dre_msg.h:44
Definition: dre_msg.h:308
Definition: dre_msg.h:366
Definition: dre_msg.h:322
Definition: dre_msg.h:328
Definition: dre_msg.h:314
Definition: dre_msg.h:204
Definition: dre_msg.h:350
Definition: dre_msg.h:379
Definition: dre_msg.h:63
Definition: dre_msg.h:192
Definition: fb_dre.h:46
Definition: dre_msg.h:266
Definition: dre_msg.h:156
Definition: dre_msg.h:226
Definition: dre_msg.h:278