EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CframeV1.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CframeV1.h
1 /*
2 ** CframeV1.h
3 **
4 ** Author: $Author: purschke $
5 ** Date: $Date: 2000/07/21 01:51:10 $
6 **
7 ** $Log: CframeV1.h,v $
8 ** Revision 1.1.1.1 2000/07/21 01:51:10 purschke
9 ** mlp -- adding the new automakified "basic" module to CVS.
10 **
11 **
12 ** Revision 1.9 1999/05/17 19:47:06 markacs
13 ** (stephen) added findNextError and whole indirection chain
14 **
15 ** Revision 1.8 1999/04/16 20:12:10 markacs
16 ** (stephen) fixing findFrameErrorStart, findFrameHistoryStart, adjustFrameLength to deal correctly with padding
17 **
18 ** Revision 1.7 1999/04/13 18:27:37 markacs
19 ** (stephen) put history block access in
20 **
21 ** Revision 1.6 1998/12/16 15:40:51 markacs
22 ** (stephen markacs) changes to rawFormat code to stop using bool,true,false
23 **
24 ** Revision 1.5 1998/12/11 22:01:12 markacs
25 ** (stephen markacs) adding log into cvs tags
26 **
27 */
28 /*
29 ** CframeV1.h
30 **
31 ** Now contains combination of old CframeV1.h and CframeV1.C.
32 ** This change was made to allow inlining
33 **
34 ** The layout of the file is as follows:
35 **
36 ** (1) definition of version-dependent field parameters
37 ** (2) includes of phenixOnline.h, etc.
38 ** (3) prototypes of functions defined later in this file
39 ** (4) include of Cframe.h
40 ** (5) defintion of V1 functions
41 **
42 **
43 ** For additional comments, see Cframe.h
44 **
45 */
46 
47 #ifndef _CFRAMEV1_
48 #define _CFRAMEV1_
49 
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53 
54 #include "phenixOnline.h"
55 #include "formatError.h"
56 #include "framePublic.h"
57 #include "frameV1Public.h"
58 #include "frameHdrV1.h"
59 #include "Cframe.h"
60 
61 /*
62 ** Function prototype definitions
63 ** ============================================================
64 */
65 
71 
74 
79 
84 
87 
95 
99 
102 
107 
108 /* note: the following three are not referenced by indirection
109  from outside */
113 
115 
116 /*
117 ** Inlined routines
118 ** ============================================================
119 */
120 
121 /* Check to see if this can really be a valid V1 header
122 */
124 {
125  if (getFrameHdrLength(frame_ptr) == V1_FRAMEHDR_LENGTH) {
126  setFrameSuccess();
127  return TRUE;
128  }
129  else {
131  return FALSE;
132  }
133 }
134 
135 
136 /* Check to see if this is an empty frame.
137 */
139 {
140  return getFrameHdrLength(frame_ptr) == getFrameLength(frame_ptr);
141 }
142 
143 
145 {
146  return getBitsMACRO(frame_ptr,
149  PADDING_MASK );
150 }
151 
152 
154 {
155  return getBitsMACRO(frame_ptr,
158  SOURCE_ID_MASK );
159 }
160 
161 
163 {
164  return getBitsMACRO(frame_ptr,
167  DATA_TYPE_MASK );
168 }
169 
170 
172 {
173  return getBitsMACRO(frame_ptr,
176  FRAME_TYPE_MASK );
177 }
178 
179 
181 {
182  return getBitsMACRO(frame_ptr,
185  STATUS_MASK );
186 }
187 
188 
190 {
191  return getBitsMACRO(frame_ptr,
195 }
196 
197 
199 {
200  return getBitsMACRO(frame_ptr,
204 }
205 
206 
208 {
209  return getBitsMACRO(frame_ptr,
213 }
214 
215 
216 /* Return pointer to start of error block in frame
217 */
219 {
220  return frame_ptr + getFrameLength(frame_ptr)
221  - getFrameErrorLengthV1(frame_ptr)
222  - getFramePadding(frame_ptr);
223 }
224 
225 
226 /* Return pointer to start of history block in frame
227 */
229 {
230  return frame_ptr + getFrameLength(frame_ptr)
231  - getFrameErrorLengthV1(frame_ptr)
232  - getFrameHistoryLengthV1(frame_ptr)
233  - getFramePadding(frame_ptr);
234 }
235 
236 
237 /* Return pointer to start of alignment block */
239 {
240  return frame_ptr + ALIGN_OFFSET_OF_DWORD;
241 }
242 
244 {
245  setBitsMACRO(frame_ptr,
248  PADDING_MASK,
249  numPadDwords );
250  return TRUE;
251 }
252 
253 
254 /*
255 ** Adjust the size of the data block in the frame header.
256 **
257 ** Note: this routine is only intended to change an explicit
258 ** size that appears in a header. For V1 frames no such
259 ** field is present so we simply return the current data
260 ** block size.
261 */
262 
264 {
265  UINT currentDataLength = getFrameDataLengthV1 (frame_ptr);
266 
267  if (currentDataLength == valueFailure)
268  return valueFailure;
269  else
270  return currentDataLength + newDwords;
271 }
272 
274 {
275 #ifndef DCM_CHECK
276  if (dataType > maxByteValue) return FALSE;
277 #endif
278  setBitsMACRO(frame_ptr,
282  dataType );
283  return TRUE;
284 }
285 
286 
288 {
289 #ifndef DCM_CHECK
290  if (frameType > maxByteValue) return FALSE;
291 #endif
292  setBitsMACRO(frame_ptr,
296  frameType );
297  return TRUE;
298 }
299 
300 
302 {
303 #ifndef DCM_CHECK
304  if (sourceId > maxSwordValue) return FALSE;
305 #endif
306  setBitsMACRO(frame_ptr,
310  sourceId );
311  return TRUE;
312 }
313 
314 
316 {
317 #ifndef DCM_CHECK
318  if (historyLength > maxSwordValue) return FALSE;
319 #endif
320  setBitsMACRO(frame_ptr,
324  historyLength );
325  return TRUE;
326 }
327 
328 
330 {
331 #ifndef DCM_CHECK
332  if (errorLength > maxSwordValue) return FALSE;
333 #endif
334  setBitsMACRO(frame_ptr,
338  errorLength );
339  return TRUE;
340 }
341 
342 
344 {
345 #ifndef DCM_CHECK
346  if (alignLength > maxByteValue) return FALSE;
347 #endif
348  setBitsMACRO(frame_ptr,
352  alignLength );
353  return TRUE;
354 }
355 
357 {
358 #ifndef DCM_CHECK
359  if (status > maxSwordValue) return FALSE;
360 #endif
361  setBitsMACRO(frame_ptr,
364  STATUS_MASK,
365  status );
366  return TRUE;
367 }
368 
369 
370 INLINE_D VALUE_ret getAlignBlockV1 (FRAME_ptr frame_ptr, PHDWORD* alignDestination,
371  UINT maxNumDwords)
372 {
373  UINT alignLength = getFrameAlignLength(frame_ptr);
374  if (maxNumDwords < alignLength) return valueFailure;
375  dwordCopy(alignDestination, (frame_ptr+ALIGN_OFFSET_OF_DWORD), alignLength);
376  return alignLength;
377 }
378 
379 
381  UINT numDwords)
382 {
383  UINT alignLength = getFrameAlignLength(frame_ptr);
384  if (numDwords != alignLength) return FALSE;
385  dwordCopy((frame_ptr+ALIGN_OFFSET_OF_DWORD), alignSource, alignLength);
386  return TRUE;
387 }
388 
389 /* get entry in history block by entry index, where indices count
390  from THE BOTTOM */
391 
393 {
394  UINT historyLength = getFrameHistoryLength(frame_ptr);
395  if (index>=historyLength) return valueFailure;
396  return *(findFrameHistoryStart(frame_ptr)+(historyLength-index-1));
397 }
398 
400 {
401  return (historyEntry&0xf0000000)>>28;
402 }
403 
405 {
406  return (historyEntry&0x0fff0000)>>16;
407 }
408 
410 {
411  return historyEntry&0x0000ffff;
412 }
413 
415 {
416  return getStageFromHistoryEntryV1(getHistoryEntryV1(frame_ptr,index));
417 }
418 
420 {
421  return getSourceIndexFromHistoryEntryV1(getHistoryEntryV1(frame_ptr,index));
422 }
423 
425 {
426  return getStatusFromHistoryEntryV1(getHistoryEntryV1(frame_ptr,index));
427 }
428 
430 {
431  if (thisError < findFrameErrorStart(frame_ptr) ||
432  thisError > findFrameEnd(frame_ptr) ) return ptrFailure;
433  PHDWORD errorType = *thisError;
434  FRAME_ptr temp_ptr;
435  switch (errorType)
436  {
437  case 1111573574: temp_ptr = thisError+3; break; // "BADF" : bad frame
438  case 1296651078: temp_ptr = thisError+2; break; // "MISF" : missing frame
439  case 1111573584: temp_ptr = thisError+4; break; // "BADP" : bad packet
440  case 1296651088: temp_ptr = thisError+3; break; // "MISP" : missing packet
441  case 1430537542: temp_ptr = thisError+(*(thisError+1)); break; // "UDEF" : undefined error
442  default: return ptrFailure;
443  }
444  if (temp_ptr > findFrameEnd(frame_ptr)) return ptrFailure;
445  return temp_ptr;
446 }
447 
448 #ifdef __cplusplus
449 }
450 #endif
451 
452 #endif /* end of ifndef _CFRAMEV1_ */
453 
454 
455 
456 
457 
458 
459 
460 
461 
462 
463 
464