Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:20:45

0001 /* 
0002 ** frameRoutines.C
0003 ** 
0004 ** Author: $Author: purschke $  
0005 **   Date: $Date: 2000/07/21 01:51:13 $ 
0006 ** 
0007 ** $Log: frameRoutines.C,v $
0008 ** Revision 1.1.1.1  2000/07/21 01:51:13  purschke
0009 ** mlp -- adding the new automakified "basic" module to CVS.
0010 **
0011 **
0012 ** Revision 1.4  1999/10/07 19:53:35  steinber
0013 ** changed storeFrameHistory to not use padding.  breaks EvB code otherwise
0014 **
0015 ** Revision 1.3  1998/12/11 22:02:05  markacs
0016 ** (stephen markacs) adding log into cvs tags
0017 ** 
0018 */
0019 /*
0020 ** makeFrameHdr
0021 **
0022 **      Routine to make a new frame header in a buffer pointed 
0023 **      to by "newFramePtr". The header is created with "empty"
0024 **      data, history, and error blocks.
0025 */
0026 
0027 #include "phenixOnline.h"
0028 #include "frameRoutines.h"
0029 #include "framePublic.h"
0030 #include "Cframe.h"
0031 
0032 /*
0033 ** storeFrameData
0034 **
0035 **      Routine to store data in new frame. 
0036 **
0037 */
0038 VALUE_ret storeFrameData (PHDWORD* frame_ptr, UINT maxFrameLen, 
0039               PHDWORD* frameData, UINT dataDwords)
0040 {
0041   PHDWORD* output_ptr;
0042   UINT finalLength;
0043 
0044   /*
0045   **  Make sure we're pointing to a real frame and 
0046   **    that the header version is the current one
0047   **  (we don't write old frame headers)
0048   */
0049   if (currentFrameHdr(frame_ptr))
0050     return valueFailure;
0051 
0052   /*
0053   **    Only store data in empty frames
0054   */
0055   if (!emptyFrame (frame_ptr)) return valueFailure;
0056         
0057   /*
0058   **  Strip off any padding in the frame
0059   */
0060   removeFramePadding (frame_ptr);
0061 
0062   /*
0063   **  Find out where to write data
0064   */
0065   output_ptr = findFrameDataStart(frame_ptr); 
0066   if (output_ptr == ptrFailure)
0067     return valueFailure;
0068 
0069   /*
0070   **  Now extend the frame to hold the data
0071   */
0072   finalLength = extendFrameData (frame_ptr, maxFrameLen, dataDwords);
0073   if (finalLength == valueFailure)
0074     return valueFailure;
0075 
0076   /*
0077   **    Now transfer the data into the frame.
0078   */
0079   dwordCopy (output_ptr, frameData, dataDwords);
0080 
0081   return finalLength;
0082 }
0083 
0084 /*
0085 **  Store a history block in a frame that doesn't already have one
0086 */
0087 VALUE_ret storeFrameHistory (PHDWORD* frame_ptr, UINT maxFrameLen, 
0088                  PHDWORD* frameHistory, UINT historyDwords)
0089 {
0090   PHDWORD* history_ptr;
0091   UINT finalLength;
0092 
0093   /*
0094   **  Make sure we're pointing to a real frame and 
0095   **    that the header version is the current one
0096   **  (we don't write old frame headers)
0097   */
0098   if (!validFrameHdr (frame_ptr) || !currentFrameHdr (frame_ptr))
0099     return valueFailure;
0100 
0101   /*
0102   **  Only store history in empty history block
0103   */
0104   if (getFrameHistoryLength (frame_ptr) != 0) return valueFailure;
0105         
0106   /*
0107   **  Strip off any frame padding
0108   */
0109   removeFramePadding(frame_ptr);
0110 
0111   /*
0112   **  Get pointer to history block
0113   */
0114   history_ptr = findFrameHistoryStart (frame_ptr);
0115   if (history_ptr == ptrFailure)
0116     return valueFailure;
0117 
0118   /*
0119   **  Extend the frame to hold the history data
0120   */
0121   finalLength = extendFrameHistoryNopad (frame_ptr, maxFrameLen, historyDwords);
0122   if ( finalLength == valueFailure)
0123     return valueFailure;
0124 
0125   /*
0126   **  Now copy in history words
0127   */
0128   dwordCopy (history_ptr, frameHistory, historyDwords);
0129 
0130   return finalLength;
0131 }
0132 
0133 /*
0134 **  Extend the length of the data block in a frame
0135 */
0136 VALUE_ret extendFrameData (FRAME_ptr frame_ptr, UINT maxFrameLength, UINT dataDwords)
0137 {
0138   if (adjustFrameDataLength (frame_ptr, dataDwords) != valueFailure) {
0139     /*
0140     **  We only need to extend the length of the frame.
0141     */
0142     return adjustFrameLength (frame_ptr, maxFrameLength, dataDwords, TRUE);
0143   }
0144   else return valueFailure;
0145 }
0146 
0147 /*
0148 **  Extend the length of the data block in a frame
0149 */
0150 VALUE_ret extendFrameDataNopad (FRAME_ptr frame_ptr, UINT maxFrameLength, UINT dataDwords)
0151 {
0152   if (adjustFrameDataLength (frame_ptr, dataDwords) != valueFailure) {
0153     /*
0154     **  We only need to extend the length of the frame.
0155     */
0156     return adjustFrameLength (frame_ptr, maxFrameLength, dataDwords, FALSE);
0157   }
0158   else return valueFailure;
0159 }
0160 
0161 
0162 /*
0163 **  Extend the length of the history block in a frame
0164 */
0165 VALUE_ret extendFrameHistory (FRAME_ptr frame_ptr, UINT maxFrameLength, UINT historyDwords)
0166 {
0167   if (adjustFrameHistoryLength (frame_ptr, historyDwords) != valueFailure) {
0168     /*
0169     **  We only need to extend the length of the frame.
0170     */
0171     return adjustFrameLength (frame_ptr, maxFrameLength, historyDwords, TRUE);
0172   }
0173   else return valueFailure;
0174 }
0175 
0176 /*
0177 **  Extend the length of the history block in a frame
0178 */
0179 VALUE_ret extendFrameHistoryNopad (FRAME_ptr frame_ptr, UINT maxFrameLength, UINT historyDwords)
0180 {
0181   if (adjustFrameHistoryLength (frame_ptr, historyDwords) != valueFailure) {
0182     /*
0183     **  We only need to extend the length of the frame.
0184     */
0185     return adjustFrameLength (frame_ptr, maxFrameLength, historyDwords, FALSE);
0186   }
0187   else return valueFailure;
0188 }
0189 
0190 
0191 
0192 
0193 
0194 
0195 
0196 
0197 
0198