00001 #include "otsdaq-core/DataDecoders/PSI46DigData.h"
00002
00003 #include <iostream>
00004
00005 using namespace ots;
00006
00007
00008
00009 PSI46DigData::PSI46DigData(void)
00010 {
00011 }
00012
00013
00014 PSI46DigData::~PSI46DigData(void)
00015 {
00016 }
00017
00018
00019 bool PSI46DigData::isPSI46Dig(uint32_t data)
00020 {
00021 int type = data & 0x0f;
00022 if (type == 1)
00023 return true;
00024 return false;
00025 }
00026
00027
00028 PSI46DigData& PSI46DigData::decode(uint32_t data)
00029 {
00030 stibId_ = (data >> 30) & 0x03;
00031 channelNumber_ = (data >> 27) & 0x07;
00032 chipId_ = (data >> 24) & 0x07;
00033 set_ = (data >> 12) & 0x1f;
00034 stripNumber_ = (data >> 17) & 0x0f;
00035 bco_ = (data >> 4) & 0xff;
00036 adc_ = (data >> 1) & 0x7;
00037
00038
00039
00040 return *this;
00041 }
00042
00043
00044 unsigned int PSI46DigData::getStibId(void)
00045 {
00046 return (unsigned int)stibId_;
00047 }
00048
00049
00050 unsigned int PSI46DigData::getChannelNumber(void)
00051 {
00052 return (unsigned int)channelNumber_;
00053 }
00054
00055
00056 unsigned int PSI46DigData::getChipId(void)
00057 {
00058 return (unsigned int)chipId_;
00059 }
00060
00061
00062 unsigned int PSI46DigData::getStripNumber(void)
00063 {
00064 return (unsigned int)stripNumber_;
00065 }
00066
00067
00068 unsigned int PSI46DigData::getBco(void)
00069 {
00070 return (unsigned int)bco_;
00071 }
00072
00073
00074 unsigned int PSI46DigData::getAdc(void)
00075 {
00076 return (unsigned int)adc_;
00077 }
00078
00079
00080 unsigned int PSI46DigData::getSensorStrip()
00081 {
00082 static unsigned char set_number[] = { 255, 255, 255, 255, 255, 255, 255, 255,
00083 255, 255, 0, 1, 4, 5, 3, 2,
00084 255, 255, 12, 13, 8, 9, 11, 10,
00085 255, 255, 15, 14, 7, 6, 255, 255 };
00086 static unsigned char strip_number[] = { 255, 255, 255, 255,
00087 255, 0, 2, 1,
00088 255, 6, 4, 5,
00089 255, 7, 3, 255 };
00090
00091 return 128*((int)chipId_-1)+set_number[(int)set_]*8+strip_number[(int)stripNumber_];
00092 }
00093