]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RAW/AliRawEquipmentHeader.cxx
Restored compilation on Windows/Cygwin
[u/mrichter/AliRoot.git] / RAW / AliRawEquipmentHeader.cxx
index 2cea94f8d3c2e75757c3432a43015fbaf42c5022..65f98c78ab1645cae90be90615c381b90e9b8c6b 100644 (file)
@@ -1,6 +1,3 @@
-// @(#)alimdc:$Name$:$Id$
-// Author: Fons Rademakers  26/11/99
-
 /**************************************************************************
  * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
  *                                                                        *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
+// @(#) $Id$
+// Author: Fons Rademakers  26/11/99
+
 //////////////////////////////////////////////////////////////////////////
 //                                                                      //
 // AliRawEquipmentHeader                                                //
 //                                                                      //
 //////////////////////////////////////////////////////////////////////////
 
+#include <Bytes.h>
+
 #include "AliRawEquipmentHeader.h"
+#include "AliDAQ.h"
 
+#include <Riostream.h>
 
 ClassImp(AliRawEquipmentHeader)
 
+//______________________________________________________________________________
+AliRawEquipmentHeader::AliRawEquipmentHeader():
+  fSize(0),
+  fEquipmentType(0),
+  fEquipmentID(0xffffffff),
+  fBasicElementSizeType(0)
+{
+  // Default constructor
+  for(Int_t i = 0; i < kAttributeWords; i++)
+    fTypeAttribute[i] = 0;
+}
+
+//______________________________________________________________________________
+UInt_t AliRawEquipmentHeader::SwapWord(UInt_t x) const
+{
+   // Swap the endianess of the integer value 'x'
+
+   return (((x & 0x000000ffU) << 24) | ((x & 0x0000ff00U) <<  8) |
+           ((x & 0x00ff0000U) >>  8) | ((x & 0xff000000U) >> 24));
+}
 
 //______________________________________________________________________________
 void AliRawEquipmentHeader::Swap()
@@ -35,10 +59,36 @@ void AliRawEquipmentHeader::Swap()
    // has already been swapped. This method is only called when the
    // header is read from the DATE event builder (GDC).
 
-   fSize                 = net2host(fSize);
-   fEquipmentType        = net2host(fEquipmentType);
-   fEquipmentID          = net2host(fEquipmentID);
-   fBasicElementSizeType = net2host(fBasicElementSizeType);
+   fSize                 = SwapWord(fSize);
+   fEquipmentType        = SwapWord(fEquipmentType);
+   fEquipmentID          = SwapWord(fEquipmentID);
+   fBasicElementSizeType = SwapWord(fBasicElementSizeType);
    for (int i = 0; i < kAttributeWords; i++)
-      fTypeAttribute[i] = net2host(fTypeAttribute[i]);
+      fTypeAttribute[i] = SwapWord(fTypeAttribute[i]);
+}
+
+//______________________________________________________________________________
+void AliRawEquipmentHeader::Reset()
+{
+  // Reset the contents of the equipment
+  // header data
+  fSize = fEquipmentType = fBasicElementSizeType = 0;
+  fEquipmentID = 0xffffffff;
+
+  for(Int_t i = 0; i < kAttributeWords; i++)
+    fTypeAttribute[i] = 0;
+}
+
+//_____________________________________________________________________________
+void AliRawEquipmentHeader::Print( const Option_t* opt ) const
+{
+  // Dumps the equipment header
+  // fields
+
+  cout << opt << "  Equipment size: " << fSize << endl;
+  cout << opt << "  Equipment type: " << fEquipmentType << endl;
+  Int_t ddlIndex;
+  cout << opt << "  Equipment ID: " << fEquipmentID << " ( " << AliDAQ::DetectorNameFromDdlID(fEquipmentID,ddlIndex) << " )" << endl;
+  cout << opt << "  Type attribute: " << fTypeAttribute[0] << "-" << fTypeAttribute[1] << "-" << fTypeAttribute[2] << endl;
+  cout << opt << "  Basic element size type: " << fBasicElementSizeType << endl;
 }