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

In This Package:

Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Private Member Functions | Friends
DybDaq::LtbTime Class Reference

#include <LtbTime.h>

Inheritance diagram for DybDaq::LtbTime:
Inheritance graph
[legend]
Collaboration diagram for DybDaq::LtbTime:
Collaboration graph
[legend]

List of all members.

Public Types

typedef std::pair< const char
*, unsigned int > 
OutputBuffer
typedef std::vector< OutputBufferOutputBufferList
typedef std::vector
< ByteInspector * > 
Bytes
typedef std::vector
< BitsInspector * > 
Bits

Public Member Functions

 LtbTime (const LtbTraits::LtbDateTime &dateTime, const unsigned int halfNanoseconds, const unsigned int accumulation, const LtbTraits &traits)
 Create an instance of this class.
 LtbTime (const ByteBuffer &byteBuffer, const LtbTraits &traits)
 Create an instance of this class.
virtual ~LtbTime ()
 Destroy this instance of the class.
unsigned int year () const
 Returns the year of the LTB trigger.
unsigned int month () const
 Returns the month of the LTB trigger.
unsigned int day () const
 Returns the day of the LTB trigger.
unsigned int hour () const
 Returns the hour of the LTB trigger.
unsigned int minutes () const
 Returns the minutes of the LTB trigger.
unsigned int seconds () const
 Returns the seconds of the LTB trigger.
unsigned int ticks () const
 Returns the 12.5 ns ticks of the LTB trigger.
time_t unixTime () const
 Returns the time as millisecond since 1970-01-01T00:00:00Z.
unsigned int halfNanoseconds () const
 Returns the 1/2 nanoseconds within the seconds of this object.
int accumulation () const
 Returns the accumulated deviation of 1/2 nanosecond from the PPS.
virtual unsigned int bufferSize () const
 Returns the size, in 4-bytes, of this object's contents in the buffer.
void setDateTime (const LtbTraits::LtbDateTime &dateTime)
 Sets the date and time (to the second) of this object.
void setDateTime (const time_t &dateTime)
 Sets the date and time (to the second) of this object.
void setHalfNanoseconds (const unsigned int halfNanoseconds)
 Sets the 1/2 nanoseconds within the seconds of this object.
void setAccumulation (const int accumulation)
 Sets the accumulated deviation of 1/2 nanosecond from the PPS.
const LtbTraitsltbTraits () const
 Returns the LtbTraits instance used to parse this object's buffer.
bool hasDaqTraits () const
virtual const DaqTraitsdaqTraits () const
virtual unsigned int gather (OutputBufferList &outputBuffers) const
virtual unsigned int inspect (DaqBuffer::Bytes &inspectors) const

Static Public Attributes

static const unsigned int kBytesInInt
static const unsigned int kUndefinedFormatComponent

Protected Member Functions

 LtbTime (const time_t &dateTime, const unsigned int halfNanoseconds, const unsigned int accumulation, const LtbTraits &traits)
 Create an instance of this class.
virtual unsigned int formatComponent () const
 Returns the component with the format of this buffer.
const char * buffer () const
char * buffer ()
bool hasByteBuffer () const
const ByteBufferbyteBuffer () const
unsigned int fillInspectors (DaqBuffer::Bytes &inspectors, unsigned int component, unsigned int cursor) const
virtual bool readBool (const unsigned int field) const
virtual int readInt (const unsigned int field) const
virtual unsigned char readUnsignedChar (const unsigned int field) const
virtual unsigned int readUnsignedInt (const unsigned int field) const
virtual void writeField (const bool value, const unsigned int field)
virtual void writeField (const int value, const unsigned int field)
virtual void writeField (const unsigned int value, const unsigned int field)

Private Member Functions

 LtbTime (LtbTime &rhs)
 Suppress default.
LtbTimeoperator= (LtbTime &rhs)
 Suppress default.

Friends

class LtbFrame
class LtbTraits

Detailed Description

Definition at line 24 of file LtbTime.h.


Constructor & Destructor Documentation

LtbTime::LtbTime ( const LtbTraits::LtbDateTime dateTime,
const unsigned int  halfNanoseconds,
const unsigned int  accumulation,
const LtbTraits traits 
)

Create an instance of this class.

Definition at line 37 of file LtbTime.cc.

LtbTime::LtbTime ( const ByteBuffer byteBuffer,
const LtbTraits traits 
)

Create an instance of this class.

Definition at line 49 of file LtbTime.cc.

                                          :
LtbBuffer(byteBuffer,
          traits) {
}
LtbTime::~LtbTime ( ) [virtual]

Destroy this instance of the class.

Definition at line 55 of file LtbTime.cc.

                  {
}
LtbTime::LtbTime ( const time_t &  dateTime,
const unsigned int  halfNanoseconds,
const unsigned int  accumulation,
const LtbTraits traits 
) [protected]

Create an instance of this class.

Definition at line 25 of file LtbTime.cc.

DybDaq::LtbTime::LtbTime ( LtbTime rhs) [private]

Suppress default.


Member Function Documentation

unsigned int LtbTime::year ( ) const

Returns the year of the LTB trigger.

Definition at line 62 of file LtbTime.cc.

                                 {
    if (4 > ltbTraits().majorVersion()) {
        unsigned int result = readUnsignedInt(LtbTraits::kYear);
        if (0 == result) {
            return kYearZero;
        }
        return result;
    }
    const time_t time = unixTime();
    struct tm* tmStruct = gmtime(&time);
    return tmStruct->tm_year + kTmBaseYear;
}
unsigned int LtbTime::month ( ) const

Returns the month of the LTB trigger.

Definition at line 75 of file LtbTime.cc.

                                  {
    if (4 > ltbTraits().majorVersion()) {
        return readUnsignedInt(LtbTraits::kMonth);
    }
    const time_t time = unixTime();
    struct tm* tmStruct = gmtime(&time);
    return tmStruct->tm_mon + 1;
}
unsigned int LtbTime::day ( ) const

Returns the day of the LTB trigger.

Definition at line 84 of file LtbTime.cc.

                                {
    if (4 > ltbTraits().majorVersion()) {
        return readUnsignedInt(LtbTraits::kDay);
    }
    const time_t time = unixTime();
    struct tm* tmStruct = gmtime(&time);
    return tmStruct->tm_mday;
}
unsigned int LtbTime::hour ( ) const

Returns the hour of the LTB trigger.

Definition at line 93 of file LtbTime.cc.

                                 {
    if (4 > ltbTraits().majorVersion()) {
        return readUnsignedInt(LtbTraits::kHour);
    }
    const time_t time = unixTime();
    struct tm* tmStruct = gmtime(&time);
    return tmStruct->tm_hour;
}
unsigned int LtbTime::minutes ( ) const

Returns the minutes of the LTB trigger.

Definition at line 102 of file LtbTime.cc.

                                    {
    if (4 > ltbTraits().majorVersion()) {
        return readUnsignedInt(LtbTraits::kMinutes);
    }
    const time_t time = unixTime();
    struct tm* tmStruct = gmtime(&time);
    return tmStruct->tm_min;
}
unsigned int LtbTime::seconds ( ) const

Returns the seconds of the LTB trigger.

Definition at line 111 of file LtbTime.cc.

                                    {
    if (4 > ltbTraits().majorVersion()) {
        return readUnsignedInt(LtbTraits::kSeconds);
    }
    const time_t time = unixTime();
    struct tm* tmStruct = gmtime(&time);
    return tmStruct->tm_sec;
}
unsigned int LtbTime::ticks ( ) const

Returns the 12.5 ns ticks of the LTB trigger.

Definition at line 120 of file LtbTime.cc.

                                  {
    if (4 > ltbTraits().majorVersion()) {
        return readUnsignedInt(LtbTraits::kTicks);
    }
    return (halfNanoseconds() / 25U);
}
time_t LtbTime::unixTime ( ) const

Returns the time as millisecond since 1970-01-01T00:00:00Z.

Definition at line 127 of file LtbTime.cc.

                               {
    if (4 > ltbTraits().majorVersion()) {
        struct tm gmtAsLocal;
        gmtAsLocal.tm_sec = seconds();
        gmtAsLocal.tm_min = minutes();
        gmtAsLocal.tm_hour = hour();
        gmtAsLocal.tm_mday = day();
        gmtAsLocal.tm_mon = month() - 1;
        gmtAsLocal.tm_year = year() - kTmBaseYear;
        const time_t local = mktime(&gmtAsLocal);
        struct tm lcl = *localtime(&local);
        struct tm gmt = *gmtime(&local);
        gmt.tm_isdst = gmtAsLocal.tm_isdst;
        const time_t a = mktime(&lcl);
        const time_t b = mktime(&gmt);
        return local + (a - b);
    }
    const unsigned int highUnixTime = readUnsignedInt(LtbTraits::kHighUnixTime);
    const unsigned int lowUnixTime = readUnsignedInt(LtbTraits::kLowUnixTime);
    const TIME_T_BUILTIN_TYPE unixTime = (highUnixTime << 16U) | lowUnixTime;
    return *((const time_t*)(&unixTime));
}
unsigned int LtbTime::halfNanoseconds ( ) const

Returns the 1/2 nanoseconds within the seconds of this object.

Definition at line 150 of file LtbTime.cc.

                                            {
    if (4 > ltbTraits().majorVersion()) {
        return ticks() * 25U;
    }
    const unsigned int highNonaseconds = readUnsignedInt(LtbTraits::kHighNanoseconds);
    const unsigned int lowNanoseconds = readUnsignedInt(LtbTraits::kLowNanoseconds);
    return (highNonaseconds << 4U) | lowNanoseconds;
}
int LtbTime::accumulation ( ) const

Returns the accumulated deviation of 1/2 nanosecond from the PPS.

Definition at line 159 of file LtbTime.cc.

                                {
    if (4 > ltbTraits().majorVersion()) {
        return 0;
    }
    const unsigned int highAccumulation = readUnsignedInt(LtbTraits::kHighAccumulation);
    const unsigned int lowAccumulation = readUnsignedInt(LtbTraits::kLowAccumulation);
    return (highAccumulation << 4U) + lowAccumulation;
}
unsigned int LtbTime::bufferSize ( ) const [virtual]

Returns the size, in 4-bytes, of this object's contents in the buffer.

Implements DybDaq::DaqBuffer.

Definition at line 168 of file LtbTime.cc.

                                       {
    return ltbTraits().timeSize();
}
void LtbTime::setDateTime ( const LtbTraits::LtbDateTime dateTime)

Sets the date and time (to the second) of this object.

Definition at line 172 of file LtbTime.cc.

                                                              {
    if (4 > ltbTraits().majorVersion()) {
        writeField(dateTime.year(),
                   LtbTraits::kYear);
        writeField(dateTime.month(),
                   LtbTraits::kMonth);
        writeField(dateTime.day(),
                   LtbTraits::kDay);
        writeField(dateTime.hour(),
                   LtbTraits::kHour);
        writeField(dateTime.minutes(),
                   LtbTraits::kMinutes);
        writeField(dateTime.seconds(),
                   LtbTraits::kSeconds);
        return;
    }
    const time_t timeToCopy = dateTime.unixTime();
    const TIME_T_BUILTIN_TYPE time = *((TIME_T_BUILTIN_TYPE*)(&timeToCopy));
    writeField((((unsigned int)time) >> 16U) & 0x0000ffffU,
               LtbTraits::kHighUnixTime);
    writeField(((unsigned int)time) & 0x0000ffffU,
               LtbTraits::kLowUnixTime);
    
}
void LtbTime::setDateTime ( const time_t &  dateTime)

Sets the date and time (to the second) of this object.

Definition at line 197 of file LtbTime.cc.

                                                {
    if (4 > ltbTraits().majorVersion()) {
        const tm* time = gmtime(&dateTime);
        writeField(time->tm_year + kTmBaseYear,
                   LtbTraits::kYear);
        writeField(time->tm_mon + 1,
                   LtbTraits::kMonth);
        writeField(time->tm_mday,
                   LtbTraits::kDay);
        writeField(time->tm_hour,
                   LtbTraits::kHour);
        writeField(time->tm_min,
                   LtbTraits::kMinutes);
        writeField(time->tm_sec,
                   LtbTraits::kSeconds);
        return;
    }
    const TIME_T_BUILTIN_TYPE time = *((TIME_T_BUILTIN_TYPE*)(&dateTime));
    writeField((((unsigned int)time) >> 16U) & 0x0000ffffU,
               LtbTraits::kHighUnixTime);
    writeField(((unsigned int)time) & 0x0000ffffU,
               LtbTraits::kLowUnixTime);
    
}
void LtbTime::setHalfNanoseconds ( const unsigned int  halfNanoseconds)

Sets the 1/2 nanoseconds within the seconds of this object.

Definition at line 222 of file LtbTime.cc.

                                                                   {
    if (4 > ltbTraits().majorVersion()) {
        writeField(halfNanoseconds / 25U,
                   LtbTraits::kTicks);
        return;
    }
    writeField((halfNanoseconds >> 4U) & 0x0fffffffU,
               LtbTraits::kHighNanoseconds);
    writeField(halfNanoseconds & 0x0000000fU,
               LtbTraits::kLowNanoseconds);
}
void LtbTime::setAccumulation ( const int  accumulation)

Sets the accumulated deviation of 1/2 nanosecond from the PPS.

Definition at line 234 of file LtbTime.cc.

                                                    {
    if (4 > ltbTraits().majorVersion()) {
        return;
    }
    writeField((accumulation >> 4U) & 0x0fffffffU,
               LtbTraits::kHighAccumulation);
    writeField(accumulation & 0x0000000fU,
               LtbTraits::kLowAccumulation);
}
unsigned int LtbTime::formatComponent ( ) const [protected, virtual]

Returns the component with the format of this buffer.

Reimplemented from DybDaq::DaqBuffer.

Definition at line 58 of file LtbTime.cc.

                                            {
    return LtbTraits::kUnixTime;
}
LtbTime& DybDaq::LtbTime::operator= ( LtbTime rhs) [private]

Suppress default.

const LtbTraits & LtbBuffer::ltbTraits ( ) const [inherited]

Returns the LtbTraits instance used to parse this object's buffer.

Definition at line 36 of file LtbBuffer.cc.

                                            {
        return dynamic_cast<const LtbTraits&>(daqTraits());
}

Friends And Related Function Documentation

friend class LtbFrame [friend]

Definition at line 28 of file LtbTime.h.

friend class LtbTraits [friend]

Definition at line 29 of file LtbTime.h.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:53:06 for LtbReadoutFormat by doxygen 1.7.4