forked from sPHENIX-Collaboration/online_distribution
/
frameRoutines.C
198 lines (166 loc) · 4.55 KB
/
frameRoutines.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/*
** frameRoutines.C
**
** Author: $Author: purschke $
** Date: $Date: 2000/07/21 01:51:13 $
**
** $Log: frameRoutines.C,v $
** Revision 1.1.1.1 2000/07/21 01:51:13 purschke
** mlp -- adding the new automakified "basic" module to CVS.
**
**
** Revision 1.4 1999/10/07 19:53:35 steinber
** changed storeFrameHistory to not use padding. breaks EvB code otherwise
**
** Revision 1.3 1998/12/11 22:02:05 markacs
** (stephen markacs) adding log into cvs tags
**
*/
/*
** makeFrameHdr
**
** Routine to make a new frame header in a buffer pointed
** to by "newFramePtr". The header is created with "empty"
** data, history, and error blocks.
*/
#include "phenixOnline.h"
#include "frameRoutines.h"
#include "framePublic.h"
#include "Cframe.h"
/*
** storeFrameData
**
** Routine to store data in new frame.
**
*/
VALUE_ret storeFrameData (PHDWORD* frame_ptr, UINT maxFrameLen,
PHDWORD* frameData, UINT dataDwords)
{
PHDWORD* output_ptr;
UINT finalLength;
/*
** Make sure we're pointing to a real frame and
** that the header version is the current one
** (we don't write old frame headers)
*/
if (currentFrameHdr(frame_ptr))
return valueFailure;
/*
** Only store data in empty frames
*/
if (!emptyFrame (frame_ptr)) return valueFailure;
/*
** Strip off any padding in the frame
*/
removeFramePadding (frame_ptr);
/*
** Find out where to write data
*/
output_ptr = findFrameDataStart(frame_ptr);
if (output_ptr == ptrFailure)
return valueFailure;
/*
** Now extend the frame to hold the data
*/
finalLength = extendFrameData (frame_ptr, maxFrameLen, dataDwords);
if (finalLength == valueFailure)
return valueFailure;
/*
** Now transfer the data into the frame.
*/
dwordCopy (output_ptr, frameData, dataDwords);
return finalLength;
}
/*
** Store a history block in a frame that doesn't already have one
*/
VALUE_ret storeFrameHistory (PHDWORD* frame_ptr, UINT maxFrameLen,
PHDWORD* frameHistory, UINT historyDwords)
{
PHDWORD* history_ptr;
UINT finalLength;
/*
** Make sure we're pointing to a real frame and
** that the header version is the current one
** (we don't write old frame headers)
*/
if (!validFrameHdr (frame_ptr) || !currentFrameHdr (frame_ptr))
return valueFailure;
/*
** Only store history in empty history block
*/
if (getFrameHistoryLength (frame_ptr) != 0) return valueFailure;
/*
** Strip off any frame padding
*/
removeFramePadding(frame_ptr);
/*
** Get pointer to history block
*/
history_ptr = findFrameHistoryStart (frame_ptr);
if (history_ptr == ptrFailure)
return valueFailure;
/*
** Extend the frame to hold the history data
*/
finalLength = extendFrameHistoryNopad (frame_ptr, maxFrameLen, historyDwords);
if ( finalLength == valueFailure)
return valueFailure;
/*
** Now copy in history words
*/
dwordCopy (history_ptr, frameHistory, historyDwords);
return finalLength;
}
/*
** Extend the length of the data block in a frame
*/
VALUE_ret extendFrameData (FRAME_ptr frame_ptr, UINT maxFrameLength, UINT dataDwords)
{
if (adjustFrameDataLength (frame_ptr, dataDwords) != valueFailure) {
/*
** We only need to extend the length of the frame.
*/
return adjustFrameLength (frame_ptr, maxFrameLength, dataDwords, TRUE);
}
else return valueFailure;
}
/*
** Extend the length of the data block in a frame
*/
VALUE_ret extendFrameDataNopad (FRAME_ptr frame_ptr, UINT maxFrameLength, UINT dataDwords)
{
if (adjustFrameDataLength (frame_ptr, dataDwords) != valueFailure) {
/*
** We only need to extend the length of the frame.
*/
return adjustFrameLength (frame_ptr, maxFrameLength, dataDwords, FALSE);
}
else return valueFailure;
}
/*
** Extend the length of the history block in a frame
*/
VALUE_ret extendFrameHistory (FRAME_ptr frame_ptr, UINT maxFrameLength, UINT historyDwords)
{
if (adjustFrameHistoryLength (frame_ptr, historyDwords) != valueFailure) {
/*
** We only need to extend the length of the frame.
*/
return adjustFrameLength (frame_ptr, maxFrameLength, historyDwords, TRUE);
}
else return valueFailure;
}
/*
** Extend the length of the history block in a frame
*/
VALUE_ret extendFrameHistoryNopad (FRAME_ptr frame_ptr, UINT maxFrameLength, UINT historyDwords)
{
if (adjustFrameHistoryLength (frame_ptr, historyDwords) != valueFailure) {
/*
** We only need to extend the length of the frame.
*/
return adjustFrameLength (frame_ptr, maxFrameLength, historyDwords, FALSE);
}
else return valueFailure;
}