Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CpacketV1.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CpacketV1.h
1 /*
2 ** CpacketV1.h
3 **
4 ** Author: $Author: phnxbld $
5 ** Date: $Date: 2009/09/19 14:34:09 $
6 **
7 ** $Log: CpacketV1.h,v $
8 ** Revision 1.2 2009/09/19 14:34:09 phnxbld
9 ** add parenthesis to take care of operator precedence
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.5 1998/12/11 22:01:13 markacs
16 ** (stephen markacs) adding log into cvs tags
17 **
18 */
19 /*
20 ** CpacketV1.h
21 **
22 ** These are the version one routines for accessing and modifying
23 ** the version dependent data in the packet header.
24 */
25 
26 #ifndef _CPACKETV1_
27 #define _CPACKETV1_
28 /*
29 ** Use C linkage
30 */
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 #include "phenixOnline.h"
36 #include "packetPublic.h"
37 #include "packetV1Public.h"
38 #include "packetHdrV1.h"
39 #include "formatError.h"
40 #include "dataBlock.h"
41 
43 
48 
50 
61 
66 
68 
79 
80 /*
81 ** Check to see if this is an empty packet.
82 */
84 {
85  return getPacketHdrLength(packet_ptr) == getPacketLength (packet_ptr);
86 }
87 
89 {
90 
91  PHDWORD dataLength;
92  if (getPacketStructure(packet_ptr) == Unstructured)
93  {
94 
95  int factor = 4 / getUnstructPacketWordSize(packet_ptr);
96 
97  dataLength = factor * ( getPacketLength(packet_ptr)
98  - getPacketHdrLength(packet_ptr)
99  - getPacketErrorLength(packet_ptr)
100  - getPacketDebugLength(packet_ptr) )
101  - getPacketPadding(packet_ptr);
102 
103  return dataLength;
104 
105  }
106 
107  dataLength = getPacketLength(packet_ptr) - getPacketHdrLength(packet_ptr) -
108  getPacketErrorLength(packet_ptr) - getPacketDebugLength(packet_ptr) -
109  getPacketPadding(packet_ptr);
110  return dataLength;
111 }
112 
114 {
115  return getBitsMACRO(packet_ptr, DEBUG_LENGTH_OFFSET_OF_DWORD,
117 }
118 
120 {
124 }
125 
127 {
128  return getBitsMACRO(packet_ptr, PACKET_PADDING_OFFSET_OF_DWORD,
130 }
131 
133 {
134  UINT errorBlockLength = getPacketV1ErrorLength(packet_ptr);
135  return calcNumErrorsV1 (errorBlockLength);
136 }
137 
139 {
140  return getWordMACRO(packet_ptr, ID_OFFSET_OF_DWORD);
141 }
142 
144 {
145  return getBitsMACRO(packet_ptr, STRUCTURE_OFFSET_OF_DWORD,
147 }
148 
150 {
151  return getBitsMACRO(packet_ptr, PACKET_STATUS_OFFSET_OF_DWORD,
153 }
154 
156 {
157  return getBitsMACRO(packet_ptr, DESCR_LENGTH_OFFSET_OF_DWORD,
159 }
160 
162 {
163  return getBitsMACRO(packet_ptr, ENDIANISM_OFFSET_OF_DWORD,
165 }
166 
168 {
169  UINT status;
170  if ((inBits & ((1<<PACKET_STATUS_NUM_BITS)-1)) == inBits) {
171  status = getBitsMACRO(packet_ptr, PACKET_STATUS_OFFSET_OF_DWORD,
173  status|=inBits;
176  PACKET_STATUS_MASK, status);
177  return status;
178  }
179  else {
181  return valueFailure;
182  }
183 }
184 
185 /*
186 ** Update the length of the data block in the header. In V1 packets, this is a NOOP
187 */
189 {
190  return getPacketV1DataLength(packet_ptr);
191 }
192 
194 {
195  UINT debugLength = getPacketV1DebugLength (packet_ptr);
196  if (debugLength == valueFailure)
197  return valueFailure;
198  else {
199  UINT newLength = debugLength + addLength;
200  setPacketV1DebugLength(packet_ptr, debugLength);
201  return newLength;
202  }
203 }
204 
206 {
207  UINT errorLength = getPacketV1ErrorLength (packet_ptr);
208  if (errorLength == valueFailure)
209  return valueFailure;
210  else {
211  UINT newLength = errorLength + addLength;
212  setPacketV1ErrorLength(packet_ptr, newLength);
213  return newLength;
214  }
215 }
216 
218 {
219  setWordMACRO(packet_ptr, ID_OFFSET_OF_DWORD, inId);
220  return TRUE;
221 }
222 
224 {
227  inEndianism);
228  return TRUE;
229 }
230 
232 {
235  return TRUE;
236 }
237 
239 {
242  return TRUE;
243 }
244 
246 {
249  return TRUE;
250 }
251 
253 {
256  return TRUE;
257 }
258 
260 {
263  return TRUE;
264 }
265 
267 {
270  return TRUE;
271 }
272 
273 
274 /*
275 ** Return a pointer to the data descriptor
276 */
278 {
279  return packet_ptr + DATADESCR_OFFSET_OF_DWORD;
280 }
281 
282 
283 #ifdef __cplusplus
284 }
285 /* end of extern "C" */
286 #endif
287 
288 #endif
289 /* end of ifndef _CPACKET_ */