LCOV - code coverage report
Current view: top level - HLT/BASE - AliHLTDirectHOMERManager.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 52 0.0 %
Date: 2016-06-14 17:26:59 Functions: 0 7 0.0 %

          Line data    Source code
       1             : //-*- Mode: C++ -*-
       2             : #include "AliHLTDirectHOMERManager.h"
       3             : #include <AliHLTHOMERReader.h>
       4             : #include "AliHLTHOMERBlockDesc.h"
       5             : #include "AliHLTOUT.h"
       6             : #include <TString.h>
       7             : #include <TObjString.h>
       8             : #include <TObjArray.h>
       9             : #include <iostream>
      10             :   
      11           0 : AliHLTDirectHOMERManager::AliHLTDirectHOMERManager(int argc, char** argv) : fconnectionList(), fBlockList(0) {
      12           0 :   for (int i = 1; i<argc; ++i){
      13           0 :     TString addr = argv[i];
      14           0 :     TObjArray* tokens = addr.Tokenize(":");
      15           0 :     if(tokens->GetEntriesFast() == 2){
      16           0 :       TObjString* hostname = dynamic_cast<TObjString*>(tokens->At(0));
      17           0 :       TObjString* port = dynamic_cast<TObjString*>(tokens->At(1));
      18           0 :       std::cout << "Adding host \'" << hostname->String().Data() << "\', port \'" << port->String().Data() << "\'" << std::endl;
      19           0 :       fconnectionList.push_back( connectionID(hostname->String(), (unsigned short) port->String().Atoi()) );
      20           0 :     }
      21           0 :     delete tokens;
      22           0 :   }
      23           0 : }
      24             : 
      25           0 : AliHLTDirectHOMERManager::~AliHLTDirectHOMERManager() {
      26           0 :   if (fBlockList) delete fBlockList;
      27           0 :   fBlockList = NULL;
      28           0 : }
      29             : 
      30             : 
      31             : TList* AliHLTDirectHOMERManager::GetNextBlocks() {
      32           0 :   if (fBlockList) delete fBlockList;
      33           0 :   fBlockList = new TList();
      34           0 :   fBlockList->SetOwner(kTRUE);
      35           0 :   std::list<connectionID>::iterator iter;
      36             :   int result=0;
      37             :   unsigned long timeout = 100000000;
      38           0 :   for ( iter = fconnectionList.begin(); iter != fconnectionList.end(); ++iter ){
      39           0 :     AliHLTHOMERReader h(iter->first, iter->second);
      40           0 :     result = h.ReadNextEvent( timeout );
      41           0 :     if (result) {
      42           0 :       std::cout << "Error getting blocks from " << iter->first << ":" << iter->second << ": "
      43           0 :                 << strerror(result) << " (" << result << ")." << std::endl;
      44           0 :       continue;
      45             :     }
      46           0 :     for(unsigned long idx = 0; idx < h.GetBlockCnt(); ++idx){
      47           0 :       AliHLTHOMERBlockDesc * block = new AliHLTHOMERBlockDesc();
      48             :       
      49           0 :       block->SetBlock(const_cast<void*>( h.GetBlockData(idx)), h.GetBlockDataLength(idx), 
      50           0 :                       MakeOrigin(h.GetBlockDataOrigin(idx)),
      51           0 :                       MakeDataType(h.GetBlockDataType(idx)), 
      52           0 :                       (ULong_t) h.GetBlockDataSpec(idx) 
      53             :                       );
      54           0 :       fBlockList->Add(block);
      55             :     }
      56           0 :   }
      57             : 
      58           0 :   return fBlockList;
      59           0 : }
      60             : 
      61             : 
      62             : TString AliHLTDirectHOMERManager::MakeOrigin(homer_uint32 origin) {
      63           0 :   TString ret;
      64           0 :   union{
      65             :     AliHLTUInt32_t data;
      66             :     Char_t array[4];
      67             :   } reverseOrigin;
      68             : 
      69           0 :   reverseOrigin.data = AliHLTOUT::ByteSwap32(origin);
      70           0 :   for(int i=0; i<4; ++i)
      71           0 :     ret.Append(reverseOrigin.array[i]);
      72             : 
      73           0 :   ret.Remove( TString::kTrailing, ' ' );
      74             :   return ret;
      75           0 : }
      76             : 
      77             : TString AliHLTDirectHOMERManager::MakeDataType(homer_uint64 type) {
      78           0 :   TString ret;
      79           0 :   union{
      80             :     AliHLTUInt64_t data;
      81             :     Char_t array[8];
      82             :   } reverseType;
      83             : 
      84           0 :   reverseType.data = AliHLTOUT::ByteSwap64(type);
      85           0 :   for(int i=0; i<8; ++i)
      86           0 :     ret.Append(reverseType.array[i]);
      87             : 
      88           0 :   ret.Remove( TString::kTrailing, ' ' );
      89             :   return ret;
      90           0 : }

Generated by: LCOV version 1.11