CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Private Attributes

evf::FUShmRawCell Class Reference

#include <FUShmRawCell.h>

List of all members.

Public Member Functions

unsigned int buResourceId () const
void clear ()
void dump () const
unsigned int eventSize () const
unsigned int evtNumber () const
unsigned char * fedAddr (unsigned int i) const
unsigned int fedSize (unsigned int i) const
unsigned int fuResourceId () const
 FUShmRawCell (unsigned int payloadSize)
unsigned int getEventType () const
unsigned int getLumiSection () const
unsigned int index () const
void initialize (unsigned int index)
bool markFed (unsigned int i, unsigned int size, unsigned char *addr)
bool markSuperFrag (unsigned int i, unsigned int size, unsigned char *addr)
unsigned int nFed () const
unsigned int nSuperFrag () const
unsigned char * payloadAddr () const
unsigned int payloadSize () const
unsigned int readFed (unsigned int i, unsigned char *buffer) const
void setBuResourceId (unsigned int id)
void setEventTypeData ()
void setEventTypeEol ()
void setEventTypeStopper ()
void setEvtNumber (unsigned int evt)
void setFuResourceId (unsigned int id)
void setLumiSection (unsigned int)
unsigned char * superFragAddr (unsigned int i) const
unsigned int superFragSize (unsigned int i) const
unsigned char * writeData (unsigned char *data, unsigned int dataSize)
 ~FUShmRawCell ()

Static Public Member Functions

static unsigned int size (unsigned int payloadSize)

Private Attributes

unsigned int buResourceId_
unsigned int eventType_
unsigned int evtNumber_
unsigned int fedOffset_
unsigned int fedSizeOffset_
unsigned int fuResourceId_
unsigned int index_
unsigned int lumiSection_
unsigned int nFed_
unsigned int nSuperFrag_
unsigned int payloadOffset_
unsigned int payloadPosition_
unsigned int payloadSize_
unsigned int superFragOffset_
unsigned int superFragSizeOffset_

Detailed Description

Definition at line 10 of file FUShmRawCell.h.


Constructor & Destructor Documentation

FUShmRawCell::FUShmRawCell ( unsigned int  payloadSize)

Definition at line 29 of file FUShmRawCell.cc.

References fedAddr(), fedOffset_, fedSizeOffset_, nFed_, nSuperFrag_, payloadAddr(), payloadOffset_, payloadSize_, superFragAddr(), superFragOffset_, and superFragSizeOffset_.

Referenced by size().

  : payloadSize_(payloadSize)
  , nFed_(NFED_MAX)
  , nSuperFrag_(NSUPERFRAG_MAX)
  , lumiSection_(0)
  , eventType_(evt::NOP)
{
  fedSizeOffset_=sizeof(FUShmRawCell);
  unsigned int* fedSizeAddr;
  fedSizeAddr=(unsigned int*)((unsigned long)this+fedSizeOffset_);
  new(fedSizeAddr) unsigned int[nFed_];
  
  fedOffset_=fedSizeOffset_+sizeof(unsigned int)*nFed_;
  unsigned int* fedAddr;
  fedAddr=(unsigned int*)((unsigned long)this+fedOffset_);
  new(fedAddr) unsigned int[nFed_];
  
  superFragSizeOffset_=fedOffset_+sizeof(unsigned int)*nFed_;
  unsigned int* superFragSizeAddr;
  superFragSizeAddr=(unsigned int*)((unsigned long)this+superFragSizeOffset_);
  new(superFragSizeAddr) unsigned int[nSuperFrag_];
  
  superFragOffset_=superFragSizeOffset_+sizeof(unsigned int)*nSuperFrag_;
  unsigned char* superFragAddr;
  superFragAddr=(unsigned char*)((unsigned long)this+superFragOffset_);
  new(superFragAddr) unsigned char[nSuperFrag_];
  
  payloadOffset_=superFragOffset_+sizeof(unsigned int)*nSuperFrag_;
  unsigned char* payloadAddr;
  payloadAddr=(unsigned char*)((unsigned long)this+payloadOffset_);
  new(payloadAddr) unsigned char[payloadSize_];
}
FUShmRawCell::~FUShmRawCell ( )

Definition at line 64 of file FUShmRawCell.cc.

Referenced by evf::RawMsgBuf::~RawMsgBuf().

{

}

Member Function Documentation

unsigned int evf::FUShmRawCell::buResourceId ( ) const [inline]

Definition at line 27 of file FUShmRawCell.h.

References buResourceId_.

Referenced by evf::FUResourceTable::discard(), and evf::FUResourceTable::discardWhileHalting().

{ return buResourceId_; }
void FUShmRawCell::clear ( void  )

Definition at line 149 of file FUShmRawCell.cc.

References buResourceId_, eventType_, fedSizeOffset_, fuResourceId_, i, lumiSection_, nFed(), evf::evt::NOP, nSuperFrag(), payloadPosition_, and superFragSizeOffset_.

Referenced by evf::FUResource::allocate(), evf::RawCache::releaseMsg(), evf::FUShmBuffer::releaseRawCell(), and evf::FUShmServer::writeNext().

{
  fuResourceId_=0xffffffff;
  buResourceId_=0xffffffff;
  lumiSection_ =0;
  eventType_   =evt::NOP;
  unsigned int* fedSizeAddr;
  fedSizeAddr=(unsigned int*)((unsigned long)this+fedSizeOffset_);
  for (unsigned int i=0;i<nFed();i++) *fedSizeAddr++=0;

  unsigned int* superFragSizeAddr;
  superFragSizeAddr=(unsigned int*)((unsigned long)this+superFragSizeOffset_);
  for (unsigned int i=0;i<nSuperFrag();i++) *superFragSizeAddr++=0;

  payloadPosition_=0;
}
void FUShmRawCell::dump ( void  ) const

Definition at line 168 of file FUShmRawCell.cc.

References gather_cfg::cout, fedAddr(), fedSize(), i, j, nFed(), and size().

{
  for (unsigned int i=0;i<nFed();i++) {
    cout<<"fed "<<i<<": "<<flush;
    unsigned char* addr=fedAddr(i);
    unsigned int   size=fedSize(i);
    cout.fill(0);
    cout<<setiosflags(ios::right);
    for (unsigned int j=0;j<size;j++)
      cout<<setw(2)<<hex<<(int)addr[j]<<dec<<" "<<flush;
    cout<<endl;
  }
}
unsigned int FUShmRawCell::eventSize ( ) const

Definition at line 142 of file FUShmRawCell.cc.

References payloadPosition_.

Referenced by evf::RawMsgBuf::usedSize(), and evf::FUShmBuffer::writeErrorEventData().

{
  return payloadPosition_;
}
unsigned int evf::FUShmRawCell::evtNumber ( ) const [inline]
unsigned char * FUShmRawCell::fedAddr ( unsigned int  i) const

Definition at line 96 of file FUShmRawCell.cc.

References gather_cfg::cout, fedOffset_, i, nFed(), payloadAddr(), and query::result.

Referenced by dump(), evf::IPCMethod::dumpEvent(), FUShmRawCell(), markFed(), readFed(), and evf::FUShmBuffer::writeErrorEventData().

{
  if (i>=nFed()) {cout<<"invalid fed index '"<<i<<"'."<<endl; return 0; }
  unsigned int* fedOffsetAddr;
  fedOffsetAddr=(unsigned int*)((unsigned long)this+fedOffset_);
  fedOffsetAddr+=i;
  unsigned int   fedOffset=*fedOffsetAddr;
  unsigned char* result=(unsigned char*)((unsigned long)payloadAddr()+fedOffset);
  return result;
}
unsigned int FUShmRawCell::fedSize ( unsigned int  i) const

Definition at line 84 of file FUShmRawCell.cc.

References gather_cfg::cout, fedSizeOffset_, i, nFed(), and query::result.

Referenced by dump(), evf::IPCMethod::dumpEvent(), FUShmReader::fillRawData(), readFed(), evf::FUShmClient::readNext(), and evf::FUShmBuffer::writeErrorEventData().

{
  if (i>=nFed()) {cout<<"invalid fed index '"<<i<<"'."<<endl; return 0; }
  unsigned int* fedSizeAddr;
  fedSizeAddr=(unsigned int*)((unsigned long)this+fedSizeOffset_);
  fedSizeAddr+=i;
  unsigned int result=*fedSizeAddr;
  return result;
}
unsigned int evf::FUShmRawCell::fuResourceId ( ) const [inline]
unsigned int evf::FUShmRawCell::getEventType ( ) const [inline]

Definition at line 69 of file FUShmRawCell.h.

References eventType_.

Referenced by FUShmReader::fillRawData().

{return eventType_;}
unsigned int evf::FUShmRawCell::getLumiSection ( ) const [inline]

Definition at line 70 of file FUShmRawCell.h.

References lumiSection_.

Referenced by FUShmReader::fillRawData().

{return lumiSection_;}
unsigned int evf::FUShmRawCell::index ( ) const [inline]
void FUShmRawCell::initialize ( unsigned int  index)
bool FUShmRawCell::markFed ( unsigned int  i,
unsigned int  size,
unsigned char *  addr 
)

Definition at line 217 of file FUShmRawCell.cc.

References gather_cfg::cout, fedAddr(), fedOffset_, fedSizeOffset_, i, nFed(), evf::evtn::offset(), payloadAddr(), payloadSize(), and size().

Referenced by evf::ResourceChecker::findFEDs(), evf::FUResource::process(), and evf::FUShmServer::writeNext().

{
  if (i>=nFed())
    {cout<<"invalid fed index '"<<i<<"'."<<endl; return false; }
  if (addr<payloadAddr())
    { cout<<"invalid fed addr '0x"<<hex<<(unsigned long)addr<<dec<<"'."<<endl; return false; }

  unsigned long offset=(unsigned long)addr-(unsigned long)payloadAddr();

  if (offset>=payloadSize())
    { cout<<"invalid fed addr '0x"<<hex<<(unsigned long)addr<<dec<<"'."<<endl; return false; }

  unsigned int* fedSizeAddr;
  fedSizeAddr=(unsigned int*)((unsigned long)this+fedSizeOffset_);
  fedSizeAddr+=i;
  *fedSizeAddr=size;

  unsigned int* fedAddr;
  fedAddr=(unsigned int*)((unsigned long)this+fedOffset_);
  fedAddr+=i;
  *fedAddr=offset;

  return true;
}
bool FUShmRawCell::markSuperFrag ( unsigned int  i,
unsigned int  size,
unsigned char *  addr 
)

Definition at line 246 of file FUShmRawCell.cc.

References gather_cfg::cout, i, nSuperFrag(), evf::evtn::offset(), payloadAddr(), payloadSize(), size(), superFragAddr(), superFragOffset_, and superFragSizeOffset_.

Referenced by evf::FUResource::fillSuperFragPayload(), and evf::FUResource::process().

{
  if (i>=nSuperFrag())
    {cout<<"invalid sf index '"<<i<<"'."<<endl; return false; }
  if (addr<payloadAddr())
    {cout<<"invalid sf addr '0x"<<hex<<(unsigned long)addr<<dec<<"'."<<endl;return false;}

  unsigned int offset=(unsigned long)addr-(unsigned long)payloadAddr();

  if (offset>=payloadSize())
    {cout<<"invalid sf addr '0x"<<hex<<(unsigned long)addr<<dec<<"'."<<endl;return false;}

  unsigned int* superFragSizeAddr;
  superFragSizeAddr=(unsigned int*)((unsigned long)this+superFragSizeOffset_);
  superFragSizeAddr+=i;
  *superFragSizeAddr=size;

  unsigned int* superFragAddr;
  superFragAddr=(unsigned int*)((unsigned long)this+superFragOffset_);
  superFragAddr+=i;
  *superFragAddr=offset;

  return true;
}
unsigned int evf::FUShmRawCell::nFed ( ) const [inline]
unsigned int evf::FUShmRawCell::nSuperFrag ( ) const [inline]

Definition at line 37 of file FUShmRawCell.h.

References nSuperFrag_.

Referenced by evf::FUResource::allocate(), clear(), markSuperFrag(), superFragAddr(), and superFragSize().

{ return nSuperFrag_; }
unsigned char * FUShmRawCell::payloadAddr ( ) const

Definition at line 134 of file FUShmRawCell.cc.

References payloadOffset_, and query::result.

Referenced by fedAddr(), FUShmRawCell(), markFed(), markSuperFrag(), superFragAddr(), and evf::FUShmBuffer::writeErrorEventData().

{
  unsigned char* result=(unsigned char*)((unsigned long)this+payloadOffset_);
  return result;
}
unsigned int evf::FUShmRawCell::payloadSize ( ) const [inline]

Definition at line 30 of file FUShmRawCell.h.

References payloadSize_.

Referenced by evf::FUResource::allocate(), markFed(), markSuperFrag(), and size().

{ return payloadSize_; }
unsigned int FUShmRawCell::readFed ( unsigned int  i,
unsigned char *  buffer 
) const

Definition at line 184 of file FUShmRawCell.cc.

References fedAddr(), fedSize(), and size().

Referenced by FUShmReader::fillRawData(), and evf::FUShmClient::readNext().

{
  unsigned int   size=fedSize(i);
  unsigned char* addr=fedAddr(i);
  memcpy(buffer,addr,size);
  return size;
}
void evf::FUShmRawCell::setBuResourceId ( unsigned int  id) [inline]

Definition at line 44 of file FUShmRawCell.h.

References buResourceId_.

{ buResourceId_=id; }
void evf::FUShmRawCell::setEventTypeData ( ) [inline]

Definition at line 57 of file FUShmRawCell.h.

References cscdqm::DATA, eventType_, and evf::evt::NOP.

Referenced by evf::FUResource::allocate().

void evf::FUShmRawCell::setEventTypeEol ( ) [inline]

Definition at line 61 of file FUShmRawCell.h.

References evf::evt::EOL, eventType_, and evf::evt::NOP.

Referenced by evf::FUShmBuffer::writeRawLumiSectionEvent().

void evf::FUShmRawCell::setEventTypeStopper ( ) [inline]
void evf::FUShmRawCell::setEvtNumber ( unsigned int  evt) [inline]

Definition at line 45 of file FUShmRawCell.h.

References evtNumber_.

Referenced by evf::ResourceChecker::findFEDs().

{ evtNumber_   =evt; }
void evf::FUShmRawCell::setFuResourceId ( unsigned int  id) [inline]

Definition at line 43 of file FUShmRawCell.h.

References fuResourceId_.

Referenced by evf::FUResource::allocate().

{ fuResourceId_=id; }
void FUShmRawCell::setLumiSection ( unsigned int  ls)
unsigned int FUShmRawCell::size ( unsigned int  payloadSize) [static]

Definition at line 275 of file FUShmRawCell.cc.

References FUShmRawCell(), NFED_MAX, NSUPERFRAG_MAX, and payloadSize().

Referenced by dump(), markFed(), markSuperFrag(), and readFed().

{
  return 
    sizeof(FUShmRawCell)+
    sizeof(unsigned int)*2*(NFED_MAX+NSUPERFRAG_MAX)+
    sizeof(unsigned char)*payloadSize;
}
unsigned char * FUShmRawCell::superFragAddr ( unsigned int  i) const

Definition at line 121 of file FUShmRawCell.cc.

References gather_cfg::cout, i, nSuperFrag(), payloadAddr(), query::result, and superFragOffset_.

Referenced by evf::ResourceChecker::findFEDs(), FUShmRawCell(), and markSuperFrag().

{
  if (i>=nSuperFrag()) {cout<<"invalid fed index '"<<i<<"'."<<endl; return 0; }
  unsigned int* superFragOffsetAddr;
  superFragOffsetAddr=(unsigned int*)((unsigned long)this+superFragOffset_);
  superFragOffsetAddr+=i;
  unsigned int   superFragOffset=*superFragOffsetAddr;
  unsigned char* result=(unsigned char*)((unsigned long)payloadAddr()+superFragOffset);
  return result;
}
unsigned int FUShmRawCell::superFragSize ( unsigned int  i) const

Definition at line 109 of file FUShmRawCell.cc.

References gather_cfg::cout, i, nSuperFrag(), query::result, and superFragSizeOffset_.

Referenced by evf::ResourceChecker::findFEDs().

{
  if (i>=nSuperFrag()) {cout<<"invalid sf index '"<<i<<"'."<<endl; return 0; }
  unsigned int* superFragSizeAddr;
  superFragSizeAddr=(unsigned int*)((unsigned long)this+superFragSizeOffset_);
  superFragSizeAddr+=i;
  unsigned int result=*superFragSizeAddr;
  return result;
}
unsigned char * FUShmRawCell::writeData ( unsigned char *  data,
unsigned int  dataSize 
)

Definition at line 195 of file FUShmRawCell.cc.

References gather_cfg::cout, payloadOffset_, payloadPosition_, payloadSize_, and query::result.

Referenced by evf::FUResource::fillSuperFragPayload(), evf::FUResource::process(), and evf::FUShmServer::writeNext().

{
  if (payloadPosition_+dataSize>payloadSize_) {
    cout<<"FUShmRawCell::writeData: data to be written does not fit!"<<endl;
    return 0;
  }
  
  // result = addr of data to be written *in* the cell
  unsigned char* result=
    (unsigned char*)((unsigned long)this+payloadOffset_+payloadPosition_);
  memcpy(result,data,dataSize);
  payloadPosition_+=dataSize;
  return result;
}

Member Data Documentation

unsigned int evf::FUShmRawCell::buResourceId_ [private]

Definition at line 83 of file FUShmRawCell.h.

Referenced by buResourceId(), clear(), and setBuResourceId().

unsigned int evf::FUShmRawCell::eventType_ [private]
unsigned int evf::FUShmRawCell::evtNumber_ [private]

Definition at line 84 of file FUShmRawCell.h.

Referenced by evtNumber(), and setEvtNumber().

unsigned int evf::FUShmRawCell::fedOffset_ [private]

Definition at line 91 of file FUShmRawCell.h.

Referenced by fedAddr(), FUShmRawCell(), and markFed().

unsigned int evf::FUShmRawCell::fedSizeOffset_ [private]

Definition at line 90 of file FUShmRawCell.h.

Referenced by clear(), fedSize(), FUShmRawCell(), and markFed().

unsigned int evf::FUShmRawCell::fuResourceId_ [private]

Definition at line 82 of file FUShmRawCell.h.

Referenced by clear(), fuResourceId(), and setFuResourceId().

unsigned int evf::FUShmRawCell::index_ [private]

Definition at line 81 of file FUShmRawCell.h.

Referenced by index(), and initialize().

unsigned int evf::FUShmRawCell::lumiSection_ [private]

Definition at line 88 of file FUShmRawCell.h.

Referenced by clear(), getLumiSection(), initialize(), and setLumiSection().

unsigned int evf::FUShmRawCell::nFed_ [private]

Definition at line 86 of file FUShmRawCell.h.

Referenced by FUShmRawCell(), and nFed().

unsigned int evf::FUShmRawCell::nSuperFrag_ [private]

Definition at line 87 of file FUShmRawCell.h.

Referenced by FUShmRawCell(), and nSuperFrag().

unsigned int evf::FUShmRawCell::payloadOffset_ [private]

Definition at line 94 of file FUShmRawCell.h.

Referenced by FUShmRawCell(), payloadAddr(), and writeData().

unsigned int evf::FUShmRawCell::payloadPosition_ [private]

Definition at line 95 of file FUShmRawCell.h.

Referenced by clear(), eventSize(), and writeData().

unsigned int evf::FUShmRawCell::payloadSize_ [private]

Definition at line 85 of file FUShmRawCell.h.

Referenced by FUShmRawCell(), payloadSize(), and writeData().

unsigned int evf::FUShmRawCell::superFragOffset_ [private]

Definition at line 93 of file FUShmRawCell.h.

Referenced by FUShmRawCell(), markSuperFrag(), and superFragAddr().

Definition at line 92 of file FUShmRawCell.h.

Referenced by clear(), FUShmRawCell(), markSuperFrag(), and superFragSize().