]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTOUTHomerBuffer.cxx
Updates
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTOUTHomerBuffer.cxx
index ebeb347c67a70c0b5dd00be32f366803154e029f..a2d1fc75ebf0cf7271fdc4c452cb3eef870b0c22 100644 (file)
@@ -39,10 +39,10 @@ ClassImp(AliHLTOUTHomerBuffer)
 AliHLTOUTHomerBuffer::AliHLTOUTHomerBuffer(const AliHLTUInt8_t* pBuffer, int size)
   :
   AliHLTOUT(),
+  fpManager(new AliHLTHOMERLibManager),
   fpBuffer(pBuffer),
   fSize(size),
-  fpReader(NULL),
-  fpManager(new AliHLTHOMERLibManager)
+  fpReader(NULL)
 {
   // see header file for class documentation
   // or
@@ -71,7 +71,7 @@ int AliHLTOUTHomerBuffer::GenerateIndex()
   int iResult=0;
   if (!fpReader) {
     if (fpManager) {
-      fpReader=fpManager->OpenReader(fpBuffer, fSize);
+      fpReader=fpManager->OpenReaderBuffer(fpBuffer, fSize);
     }
   }
   if (fpReader) {
@@ -99,15 +99,15 @@ int AliHLTOUTHomerBuffer::GetDataBuffer(AliHLTUInt32_t index, const AliHLTUInt8_
   return iResult;
 }
 
-AliHLTOUT::AliHLTOUTByteOrder_t AliHLTOUTHomerBuffer::CheckBlockByteOrder(AliHLTUInt32_t index)
+AliHLTOUT::AliHLTOUTByteOrder AliHLTOUTHomerBuffer::CheckBlockByteOrder(AliHLTUInt32_t index)
 {
   if (fpReader) {
-    return static_cast<AliHLTOUTByteOrder_t>(fpReader->GetBlockByteOrder(index));
+    return static_cast<AliHLTOUTByteOrder>(fpReader->GetBlockByteOrder(index));
   }
   return kInvalidByteOrder;
 }
 
-int AliHLTOUTHomerBuffer::CheckBlockAlignment(AliHLTUInt32_t index, AliHLTOUT::AliHLTOUTDataType_t type)
+int AliHLTOUTHomerBuffer::CheckBlockAlignment(AliHLTUInt32_t index, AliHLTOUT::AliHLTOUTDataType type)
 {
   if (fpReader) {
     return fpReader->GetBlockTypeAlignment(index, static_cast<homer_uint8>(type));
@@ -115,24 +115,24 @@ int AliHLTOUTHomerBuffer::CheckBlockAlignment(AliHLTUInt32_t index, AliHLTOUT::A
   return -ENODATA;
 }
 
-int AliHLTOUTHomerBuffer::ScanReader(AliHLTHOMERReader* pReader, AliHLTUInt32_t offset)
+int AliHLTOUTHomerBuffer::ScanReader(AliHLTMonitoringReader* pReader, AliHLTUInt32_t offset)
 {
   // see header file for class documentation
   int iResult=0;
-  if (pReader) {
+  if (pReader && (iResult=pReader->ReadNextEvent())==0) {
     AliHLTUInt32_t nofBlocks=pReader->GetBlockCnt();
     AliHLTUInt32_t tmp1=0x1;
     AliHLTUInt32_t tmp2=offset;
 
     // first check if the offset allows to add all data blocks without exceeding the
     // range
-    while (nofBlocks<tmp1 && tmp2>0) {
+    while (nofBlocks>tmp1 && tmp2>0) {
       if (tmp2&0x1) {
        HLTError("index range %#x exceeded for %d data blocks", nofBlocks, offset);
        iResult=-ERANGE;
       }
-      tmp2>>1;
-      tmp1<<1;
+      tmp2>>=1;
+      tmp1<<=1;
     }
 
     // loop over data blocks
@@ -142,13 +142,21 @@ int AliHLTOUTHomerBuffer::ScanReader(AliHLTHOMERReader* pReader, AliHLTUInt32_t
       homer_uint32 origin=pReader->GetBlockDataOrigin( i );
       homer_uint32 spec=pReader->GetBlockDataSpec( i );
       AliHLTComponentDataType dt;
-      memcpy(&dt.fID, &id, kAliHLTComponentDataTypefIDsize);
-      memcpy(&dt.fOrigin, &origin, kAliHLTComponentDataTypefOriginSize);
-      AliHLTOUTBlockDescriptor desc(dt, spec, offset|i);
+      AliHLTComponent::SetDataType(dt, ByteSwap64(id), ByteSwap32(origin));
+      AliHLTOUTBlockDescriptor desc(dt, spec, offset|i, this);
+      HLTDebug("adding block %d: %s %#x", i, AliHLTComponent::DataType2Text(dt).c_str(), spec);
       iResult=AddBlockDescriptor(desc);
     }
   } else {
-    iResult=-ENODEV;
+    if (iResult==EBADMSG) {
+      HLTWarning("Format error in data block");
+      iResult*=-1;
+    } else if (iResult==126/*ENOKEY*/) {
+      HLTWarning("Format error in data block: can not find HOMER block descriptor id");
+      iResult*=-1;
+    } else {
+      iResult=-ENODEV;
+    }
   }
   return iResult;
 }