00001 /* 00002 * LtbFoot.cc 00003 * LtbReadoutFormat 00004 * 00005 * Created by Simon Patton on 7/21/10. 00006 * Copyright 2010 DayaBay Collaboration. All rights reserved. 00007 * 00008 */ 00009 00010 #include "LtbReadoutFormat/LtbFoot.h" 00011 00012 #include "DaqReadoutFormat/ByteBuffer.h" 00013 #include "LtbReadoutFormat/LtbHead.h" 00014 #include "LtbReadoutFormat/LtbTraits.h" 00015 00016 using DybDaq::ByteBuffer; 00017 using DybDaq::LtbBuffer; 00018 using DybDaq::LtbFoot; 00019 using DybDaq::LtbHead; 00020 using DybDaq::LtbTraits; 00021 00022 LtbFoot::LtbFoot(const LtbHead& head) : 00023 LtbBuffer(new char[head.ltbTraits().footSize() * kBytesInInt], 00024 head.ltbTraits()) { 00025 const LtbTraits& traits = ltbTraits(); 00026 traits.initializeFoot(buffer()); 00027 setDataLength((traits.headSize() + traits.footSize()) * kBytesInInt); 00028 } 00029 00030 LtbFoot::LtbFoot(const ByteBuffer& byteBuffer, 00031 const LtbTraits& traits) : 00032 LtbBuffer(byteBuffer, 00033 traits) { 00034 byteBuffer.position(byteBuffer.position() + kBytesInInt); 00035 } 00036 00037 LtbFoot::~LtbFoot() { 00038 } 00039 00040 unsigned int LtbFoot::formatComponent() const { 00041 return LtbTraits::kFoot; 00042 } 00043 00044 unsigned int LtbFoot::bufferSize() const { 00045 return ltbTraits().footSize(); 00046 } 00047 00048 unsigned int LtbFoot::dataLength() const { 00049 return readUnsignedInt(LtbTraits::kFootDataLength); 00050 } 00051 00052 void LtbFoot::setDataLength(const unsigned int dataLength) { 00053 writeField(dataLength, 00054 LtbTraits::kFootDataLength); 00055 }