/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

CbltHead.cc
Go to the documentation of this file.
00001 /*
00002  *  CbltHead.cc
00003  *  CbltReadoutFormat
00004  *
00005  *  Created by Simon Patton on 7/21/10.
00006  *  Copyright 2010 DayaBay Collaboration. All rights reserved.
00007  *
00008  */
00009 #include "CbltReadoutFormat/CbltHead.h"
00010 
00011 #include "CbltReadoutFormat/CbltTraits.h"
00012 #include "DaqReadoutFormat/ByteBuffer.h"
00013 
00014 using DybDaq::ByteBuffer;
00015 using DybDaq::CbltBuffer;
00016 using DybDaq::CbltHead;
00017 using DybDaq::CbltTraits;
00018 using DybDaq::DaqTraits;
00019 
00020 CbltHead::CbltHead(const unsigned int moduleAddress,
00021                    const unsigned int moduleType,
00022                    const CbltTraits& traits) :
00023 CbltBuffer(new char[traits.headSize() * kBytesInInt],
00024 traits) {
00025     m_traits = &traits;
00026     traits.initializeHead(buffer());
00027     setModuleAddress(moduleAddress);
00028     setModuleType(moduleType);
00029 }
00030 
00031 CbltHead::CbltHead(const ByteBuffer& byteBuffer) :
00032 CbltBuffer(byteBuffer,
00033           *((CbltTraits*)0)) {
00034     const char* buffer = byteBuffer.cursor();
00035     m_traits = CbltTraits::readTraits(buffer);
00036         byteBuffer.position(byteBuffer.position() + kBytesInInt);
00037 }
00038 
00039 CbltHead::~CbltHead() {
00040 }
00041 
00042 const DaqTraits& CbltHead::daqTraits() const  {
00043     return *m_traits;
00044 }
00045 
00046 unsigned int CbltHead::formatComponent() const {
00047     return CbltTraits::kHead;
00048 }
00049 
00050 unsigned int CbltHead::majorVersion() const {
00051     if (0 == m_traits->majorVersion()) {
00052         return m_traits->majorVersion();
00053     }
00054     return readUnsignedInt(CbltTraits::kMajorVersion);
00055 }
00056 
00057 unsigned int CbltHead::minorVersion() const {
00058     if (0 == m_traits->majorVersion()) {
00059         return m_traits->minorVersion();
00060     }
00061     return readUnsignedInt(CbltTraits::kMinorVersion);
00062 }
00063 
00064 unsigned int CbltHead::moduleAddress() const {
00065         return readUnsignedInt(CbltTraits::kHeadModuleAddress);
00066 }
00067 
00068 unsigned int CbltHead::moduleType() const {
00069         return readUnsignedInt(CbltTraits::kHeadModuleType);
00070 }
00071 
00072 unsigned int CbltHead::bufferSize() const {
00073     return cbltTraits().headSize();
00074 }
00075 
00076 void CbltHead::setModuleAddress(const unsigned int moduleAddress) {
00077     writeField(moduleAddress,
00078                CbltTraits::kHeadModuleAddress);
00079 }
00080 
00081 void CbltHead::setModuleType(const unsigned int moduleType) {
00082     writeField(moduleType,
00083                CbltTraits::kHeadModuleType);
00084 }
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:53:11 for CbltReadoutFormat by doxygen 1.7.4