00001 #ifndef NXYTER_DATADEBUG_H 00002 #define NXYTER_DATADEBUG_H 00003 00004 #include <stdint.h> 00005 #include <iostream> 00006 00007 namespace nxyter { 00008 00009 class DataDebug 00010 { 00011 protected: 00012 uint32_t fAdc; 00013 uint32_t fNx; 00014 uint32_t fLtsLow; 00015 uint32_t fLtsHigh; 00016 00017 public: 00019 explicit DataDebug(uint32_t adc=0, uint32_t nx=0, 00020 uint32_t ltslow=0, uint32_t ltshigh=0) : 00021 fAdc(adc), fNx(nx), fLtsLow(ltslow), fLtsHigh(ltshigh) 00022 {} 00023 00025 uint32_t getRawAdc() const 00026 { return fAdc; } 00028 uint32_t getRawNx() const 00029 { return fNx; } 00031 uint32_t getRawLtsLow() const 00032 { return fLtsLow; } 00034 uint32_t getRawLtsHigh() const 00035 { return fLtsHigh; } 00036 00038 uint64_t getRawLts() const 00039 { return (uint64_t(fLtsHigh)<<32) + uint64_t(fLtsLow); } 00040 00042 uint32_t getRawMessageType() const 00043 { return (fAdc>>13) & 0x7; } 00044 00046 uint32_t getNxAdcValue() const 00047 { return fAdc & 0xfff; } 00048 00050 uint32_t getNxNumber() const 00051 { return (fNx>>3) & 0x3; } 00052 00054 uint32_t getRawNxChNum() const 00055 { return (fNx>>8) & 0x7f; } 00056 00058 uint32_t getNxChNum() const 00059 { return ungray(getRawNxChNum(), 7); } 00060 00062 uint32_t getRawNxTs() const 00063 { return ((fNx & 0x7f000000)>>17) + ((fNx & 0x007f0000)>>16); } 00064 00066 uint32_t getNxTs() const 00067 { return ungray(getRawNxTs()^(0x3fff), 14); } 00068 00070 uint32_t getNxParity() const 00071 { return fNx & 0x1; } 00072 00073 uint32_t getNxParityCheck() const; 00074 00075 void print(std::ostream& os) const; 00076 00077 static uint32_t ungray(uint32_t val, int n); 00078 }; 00079 00080 } 00081 00082 #endif