Analysis Software
Documentation for
sPHENIX
simulation software
Home page
Related Pages
Modules
Namespaces
Classes
Files
Examples
External Links
File List
File Members
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
42
VALUE_ret
makePacketV1Hdr
(
PACKET_ptr
,
UINT
);
43
44
PTR_ret
findPacketV1DataStart
(
PACKET_ptr
);
45
PTR_ret
findPacketV1DataEnd
(
PACKET_ptr
);
46
PTR_ret
findPacketV1DebugStart
(
PACKET_ptr
);
47
PTR_ret
findPacketV1ErrorStart
(
PACKET_ptr
);
48
49
INLINE_P
PTR_ret
findPacketV1DataDescr
(
PACKET_ptr
);
50
51
INLINE_P
VALUE_ret
getPacketV1DataLength
(
PACKET_ptr
);
52
INLINE_P
VALUE_ret
getPacketV1DebugLength
(
PACKET_ptr
);
53
INLINE_P
VALUE_ret
getPacketV1ErrorLength
(
PACKET_ptr
);
54
INLINE_P
VALUE_ret
getPacketV1Padding
(
PACKET_ptr
);
55
INLINE_P
VALUE_ret
getPacketV1NumErrors
(
PACKET_ptr
);
56
INLINE_P
VALUE_ret
getPacketV1Id
(
PACKET_ptr
);
57
INLINE_P
VALUE_ret
getPacketV1Structure
(
PACKET_ptr
);
58
INLINE_P
VALUE_ret
getPacketV1Endianism
(
PACKET_ptr
);
59
INLINE_P
VALUE_ret
getPacketV1Status
(
PACKET_ptr
);
60
INLINE_P
VALUE_ret
getPacketV1DataDescrLength
(
PACKET_ptr
);
61
62
INLINE_P
VALUE_ret
orPacketV1Status
(
PACKET_ptr
,
UINT
);
63
INLINE_P
VALUE_ret
adjustPacketV1DataLength
(
PACKET_ptr
,
int
);
64
INLINE_P
VALUE_ret
adjustPacketV1DebugLength
(
PACKET_ptr
,
int
);
65
INLINE_P
VALUE_ret
adjustPacketV1ErrorLength
(
PACKET_ptr
,
int
);
66
67
LOGIC_ret
validPacketV1Hdr
(
PACKET_ptr
);
68
69
INLINE_P
LOGIC_ret
emptyPacketV1
(
PACKET_ptr
);
70
INLINE_P
LOGIC_ret
setPacketV1Id
(
PACKET_ptr
,
UINT
);
71
INLINE_P
LOGIC_ret
setPacketV1Endianism
(
PACKET_ptr
,
UINT
);
72
INLINE_P
LOGIC_ret
setPacketV1Structure
(
PACKET_ptr
,
UINT
);
73
INLINE_P
LOGIC_ret
setPacketV1Padding
(
PACKET_ptr
,
UINT
);
74
INLINE_P
LOGIC_ret
setPacketV1Status
(
PACKET_ptr
,
UINT
);
75
INLINE_P
LOGIC_ret
setPacketV1ErrorLength
(
PACKET_ptr
,
UINT
);
76
INLINE_P
LOGIC_ret
setPacketV1DebugLength
(
PACKET_ptr
,
UINT
);
77
INLINE_P
LOGIC_ret
setPacketV1NumErrors
(
PACKET_ptr
,
UINT
);
78
INLINE_P
LOGIC_ret
setPacketV1DataDescrLength
(
PACKET_ptr
,
UINT
);
79
80
/*
81
** Check to see if this is an empty packet.
82
*/
83
INLINE_D
LOGIC_ret
emptyPacketV1
(
PACKET_ptr
packet_ptr)
84
{
85
return
getPacketHdrLength
(packet_ptr) ==
getPacketLength
(packet_ptr);
86
}
87
88
INLINE_D
VALUE_ret
getPacketV1DataLength
(
PACKET_ptr
packet_ptr)
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
113
INLINE_D
VALUE_ret
getPacketV1DebugLength
(
PACKET_ptr
packet_ptr)
114
{
115
return
getBitsMACRO
(packet_ptr,
DEBUG_LENGTH_OFFSET_OF_DWORD
,
116
DEBUG_LENGTH_OFFSET_IN_DWORD
,
DEBUG_LENGTH_MASK
);
117
}
118
119
INLINE_D
VALUE_ret
getPacketV1ErrorLength
(
PACKET_ptr
packet_ptr)
120
{
121
return
getBitsMACRO
(packet_ptr,
PACKET_ERROR_LENGTH_OFFSET_OF_DWORD
,
122
PACKET_ERROR_LENGTH_OFFSET_IN_DWORD
,
123
PACKET_ERROR_LENGTH_MASK
);
124
}
125
126
INLINE_D
VALUE_ret
getPacketV1Padding
(
PACKET_ptr
packet_ptr)
127
{
128
return
getBitsMACRO
(packet_ptr,
PACKET_PADDING_OFFSET_OF_DWORD
,
129
PACKET_PADDING_OFFSET_IN_DWORD
,
PACKET_PADDING_MASK
);
130
}
131
132
INLINE_D
VALUE_ret
getPacketV1NumErrors
(
PACKET_ptr
packet_ptr)
133
{
134
UINT
errorBlockLength =
getPacketV1ErrorLength
(packet_ptr);
135
return
calcNumErrorsV1
(errorBlockLength);
136
}
137
138
INLINE_D
VALUE_ret
getPacketV1Id
(
PACKET_ptr
packet_ptr)
139
{
140
return
getWordMACRO
(packet_ptr,
ID_OFFSET_OF_DWORD
);
141
}
142
143
INLINE_D
VALUE_ret
getPacketV1Structure
(
PACKET_ptr
packet_ptr)
144
{
145
return
getBitsMACRO
(packet_ptr,
STRUCTURE_OFFSET_OF_DWORD
,
146
STRUCTURE_OFFSET_IN_DWORD
,
STRUCTURE_MASK
);
147
}
148
149
INLINE_D
VALUE_ret
getPacketV1Status
(
PACKET_ptr
packet_ptr)
150
{
151
return
getBitsMACRO
(packet_ptr,
PACKET_STATUS_OFFSET_OF_DWORD
,
152
PACKET_STATUS_OFFSET_IN_DWORD
,
PACKET_STATUS_MASK
);
153
}
154
155
INLINE_D
VALUE_ret
getPacketV1DataDescrLength
(
PACKET_ptr
packet_ptr)
156
{
157
return
getBitsMACRO
(packet_ptr,
DESCR_LENGTH_OFFSET_OF_DWORD
,
158
DESCR_LENGTH_OFFSET_IN_DWORD
,
DESCR_LENGTH_MASK
);
159
}
160
161
INLINE_D
VALUE_ret
getPacketV1Endianism
(
PACKET_ptr
packet_ptr)
162
{
163
return
getBitsMACRO
(packet_ptr,
ENDIANISM_OFFSET_OF_DWORD
,
164
ENDIANISM_OFFSET_IN_DWORD
,
ENDIANISM_MASK
);
165
}
166
167
INLINE_D
VALUE_ret
orPacketV1Status
(
PACKET_ptr
packet_ptr,
UINT
inBits)
168
{
169
UINT
status
;
170
if
((inBits & ((1<<
PACKET_STATUS_NUM_BITS
)-1)) == inBits) {
171
status =
getBitsMACRO
(packet_ptr,
PACKET_STATUS_OFFSET_OF_DWORD
,
172
PACKET_STATUS_OFFSET_IN_DWORD
,
PACKET_STATUS_MASK
);
173
status|=inBits;
174
setBitsMACRO
(packet_ptr,
PACKET_STATUS_OFFSET_OF_DWORD
,
175
PACKET_STATUS_OFFSET_IN_DWORD
,
176
PACKET_STATUS_MASK
, status);
177
return
status
;
178
}
179
else
{
180
setUserError
(
FORMAT_ERR_INVALID_DATA
, inBits);
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
*/
188
INLINE_D
VALUE_ret
adjustPacketV1DataLength
(
PACKET_ptr
packet_ptr,
int
addDwords)
189
{
190
return
getPacketV1DataLength
(packet_ptr);
191
}
192
193
INLINE_D
VALUE_ret
adjustPacketV1DebugLength
(
PACKET_ptr
packet_ptr,
int
addLength)
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
205
INLINE_D
VALUE_ret
adjustPacketV1ErrorLength
(
PACKET_ptr
packet_ptr,
int
addLength)
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
217
INLINE_D
LOGIC_ret
setPacketV1Id
(
PACKET_ptr
packet_ptr,
UINT
inId)
218
{
219
setWordMACRO
(packet_ptr,
ID_OFFSET_OF_DWORD
, inId);
220
return
TRUE
;
221
}
222
223
INLINE_D
LOGIC_ret
setPacketV1Endianism
(
PACKET_ptr
packet_ptr,
UINT
inEndianism)
224
{
225
setBitsMACRO
(packet_ptr,
ENDIANISM_OFFSET_OF_DWORD
,
226
ENDIANISM_OFFSET_IN_DWORD
,
ENDIANISM_MASK
,
227
inEndianism);
228
return
TRUE
;
229
}
230
231
INLINE_D
LOGIC_ret
setPacketV1Structure
(
PACKET_ptr
packet_ptr,
UINT
inStruct)
232
{
233
setBitsMACRO
(packet_ptr,
STRUCTURE_OFFSET_OF_DWORD
,
234
STRUCTURE_OFFSET_IN_DWORD
,
STRUCTURE_MASK
, inStruct);
235
return
TRUE
;
236
}
237
238
INLINE_D
LOGIC_ret
setPacketV1Padding
(
PACKET_ptr
packet_ptr,
UINT
inPadding)
239
{
240
setBitsMACRO
(packet_ptr,
PACKET_PADDING_OFFSET_OF_DWORD
,
241
PACKET_PADDING_OFFSET_IN_DWORD
,
PACKET_PADDING_MASK
, inPadding);
242
return
TRUE
;
243
}
244
245
INLINE_D
LOGIC_ret
setPacketV1Status
(
PACKET_ptr
packet_ptr,
UINT
inStatus)
246
{
247
setBitsMACRO
(packet_ptr,
PACKET_STATUS_OFFSET_OF_DWORD
,
248
PACKET_STATUS_OFFSET_IN_DWORD
,
PACKET_STATUS_MASK
, inStatus);
249
return
TRUE
;
250
}
251
252
INLINE_D
LOGIC_ret
setPacketV1ErrorLength
(
PACKET_ptr
packet_ptr,
UINT
inLength)
253
{
254
setBitsMACRO
(packet_ptr,
PACKET_ERROR_LENGTH_OFFSET_OF_DWORD
,
255
PACKET_ERROR_LENGTH_OFFSET_IN_DWORD
,
PACKET_ERROR_LENGTH_MASK
, inLength);
256
return
TRUE
;
257
}
258
259
INLINE_D
LOGIC_ret
setPacketV1DebugLength
(
PACKET_ptr
packet_ptr,
UINT
inLength)
260
{
261
setBitsMACRO
(packet_ptr,
DEBUG_LENGTH_OFFSET_OF_DWORD
,
262
DEBUG_LENGTH_OFFSET_IN_DWORD
,
DEBUG_LENGTH_MASK
, inLength);
263
return
TRUE
;
264
}
265
266
INLINE_D
LOGIC_ret
setPacketV1DataDescrLength
(
PACKET_ptr
packet_ptr,
UINT
inLength)
267
{
268
setBitsMACRO
(packet_ptr,
DESCR_LENGTH_OFFSET_OF_DWORD
,
269
DESCR_LENGTH_OFFSET_IN_DWORD
,
DESCR_LENGTH_MASK
, inLength);
270
return
TRUE
;
271
}
272
273
274
/*
275
** Return a pointer to the data descriptor
276
*/
277
INLINE_D
PTR_ret
findPacketV1DataDescr
(
PACKET_ptr
packet_ptr)
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_ */
online_distribution
blob
master
newbasic
CpacketV1.h
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:27
using
1.8.2 with
sPHENIX GitHub integration