ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CframeV1.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CframeV1.C
1 /*
2 ** CframeV1.C
3 **
4 ** Author: $Author: phnxbld $
5 ** Date: $Date: 2009/09/19 14:34:27 $
6 **
7 ** $Log: CframeV1.C,v $
8 ** Revision 1.2 2009/09/19 14:34:27 phnxbld
9 ** fix compiler warning
10 **
11 ** Revision 1.1.1.1 2000/07/21 01:51:10 purschke
12 ** mlp -- adding the new automakified "basic" module to CVS.
13 **
14 **
15 ** Revision 1.3 1998/12/11 22:01:58 markacs
16 ** (stephen markacs) adding log into cvs tags
17 **
18 */
19 #include "CframeV1.h"
20 
21 /*
22 ** makeFrameHdrV1 makes a Version 1 frame header. It takes the address pointed to by
23 ** the frame_ptr passed to it, clears the right amount of space for the header
24 ** (sets all bytes to 0), sets the frameMark, hdrVersion, hdrLength, and
25 ** frameLength fields to the appropriate values for an empty Version 1 header,
26 ** sets the dataType, frameType and sourceId fields to the values passes to it,
27 ** and copies the alignment block from the location pointed to by the
28 ** alignment pointer passed to it.
29 */
30 VALUE_ret makeFrameHdrV1 (PHDWORD* frame_ptr, UINT maxFrameLen, UINT dataType,
31  UINT frameType, UINT sourceId)
32 {
33  if (maxFrameLen < currentFrameHdrLength) return valueFailure;
34 
35  dwordClear (frame_ptr, currentFrameHdrLength);
36 
37  setFrameMark(frame_ptr,currentFrameMark);
40 
41  setDataType(frame_ptr, dataType);
42  setFrameType(frame_ptr, frameType);
43  setSourceId(frame_ptr, sourceId);
46 
47  return 0;
48 }
49 
51 {
52  PHDWORD dataLength = getFrameLength(frame_ptr)
53  - getFrameHdrLength(frame_ptr)
54  - getFrameErrorLengthV1(frame_ptr)
55  - getFrameHistoryLengthV1(frame_ptr)
56  - getFramePaddingV1(frame_ptr) ;
57 
58  if (dataLength > getFrameLength(frame_ptr) )
59  {
61  return valueFailure;
62  }
63  else
64  {
66  return dataLength;
67  }
68 }
69 
70 /* set bits in the frame status word */
71 VALUE_ret orFrameStatusV1 (FRAME_ptr frame_ptr, UINT statusBits)
72 {
73  UINT status;
74  /*
75  ** Make sure intended bits fit within field length
76  */
77  if ((statusBits & ((1<<STATUS_NUM_BITS)-1)) == statusBits)
78  {
79  status = getBitsMACRO(frame_ptr, STATUS_OFFSET_OF_DWORD,
81  status|=statusBits;
82  setBitsMACRO(frame_ptr,
86  status );
87  return status;
88  }
89  else
90  {
92  return valueFailure;
93  }
94 }
95 
96 
97 
99 {
100  UINT newLength = getFrameHistoryLengthV1(frame_ptr) + newDwords;
101 
102  /*
103  ** Make sure it fits in the current field size
104  */
105  if (newLength > maxSwordValue)
106  {
107  setFrameError(FORMAT_ERR_HISTORY_OVERFLOW, frame_ptr, newDwords);
108  return valueFailure;
109  }
110  else
111  {
112  setBitsMACRO(frame_ptr,
116  newLength );
117  setFrameSuccess();
118  return newLength;
119  }
120 }
121 
122 
123 
125 {
126  UINT newLength = getFrameErrorLengthV1(frame_ptr) + newDwords;
127 
128  /*
129  ** Make sure it fits in the current field size
130  */
131  if (newLength > maxSwordValue)
132  {
133  setFrameError(FORMAT_ERR_ERROR_OVERFLOW, frame_ptr, newDwords);
134  return valueFailure;
135  }
136  else
137  {
138  setBitsMACRO(frame_ptr,
142  newLength );
143  setFrameSuccess();
144  return newLength;
145  }
146 }
147 
148 
149