1 |
/** @file |
/** @file |
2 |
* $Source: /home/cvsmanager/yoda/techmodel/physics/S4Reader.cpp,v $ |
* $Source: /home/cvsmanager/yoda/techmodel/physics/S4Reader.cpp,v $ |
3 |
* $Id: S4Reader.cpp,v 2.5 2005/02/11 16:40:19 kusanagi Exp $ |
* $Id: S4Reader.cpp,v 4.0 2005/03/06 04:33:02 kusanagi Exp $ |
4 |
* $Author: kusanagi $ |
* $Author: kusanagi $ |
5 |
* |
* |
6 |
* Implementation of the S4Reader class. |
* Implementation of the S4Reader class. |
29 |
*/ |
*/ |
30 |
std::string S4Reader::GetVersionInfo(void) const { |
std::string S4Reader::GetVersionInfo(void) const { |
31 |
return |
return |
32 |
"$Header: /home/cvsmanager/yoda/techmodel/physics/S4Reader.cpp,v 2.5 2005/02/11 16:40:19 kusanagi Exp $"; |
"$Header: /home/cvsmanager/yoda/techmodel/physics/S4Reader.cpp,v 4.0 2005/03/06 04:33:02 kusanagi Exp $"; |
33 |
} |
} |
34 |
|
|
35 |
/** |
/** |
60 |
int offset; |
int offset; |
61 |
int index = haveData(data, length); |
int index = haveData(data, length); |
62 |
|
|
63 |
if (index > -1){ |
if (index > 0){ |
64 |
int offset = length - index; |
int offset = length - index; |
65 |
s4->S4_REG_STATUS = (((UINT8)subData[offset])&0xF0); |
s4->S4_REG_STATUS = (((UINT8)subData[offset])&0xF0); |
66 |
s4->S4_DATA = ((((UINT16)subData[offset]<<8)&0x0FFF) + (((UINT16)subData[offset+1])&0x00FF)); |
s4->S4_DATA = ((((UINT16)subData[offset]<<8)&0x0FFF) + (((UINT16)subData[offset+1])&0x00FF)); |
85 |
* Check if S4Data are present. |
* Check if S4Data are present. |
86 |
* @param const char data[] - Physics data |
* @param const char data[] - Physics data |
87 |
* @param long int lenght - Lenght of data[] |
* @param long int lenght - Lenght of data[] |
88 |
* @return int - -1 if S4 has not been found, otherwise it represent the |
* @return int represent the index from the end of data[] |
89 |
* index from the end of data[] from which S4 data starts |
* from which S4 data starts |
90 |
*/ |
*/ |
91 |
int S4Reader::haveData(const char data[], long int length){ |
int S4Reader::haveData(const char data[], long int length){ |
|
int ret = -1; |
|
92 |
/* I start 20 bytes from the end because we have three cases: |
/* I start 20 bytes from the end because we have three cases: |
93 |
* |
* |
94 |
* 1) S4 (4bytes) + NeutronDetector (12bytes) //END PACKET |
* 1) S4 (4bytes) + NeutronDetector (12bytes) //END PACKET |
101 |
* sholud be the same of the Tracker |
* sholud be the same of the Tracker |
102 |
* |
* |
103 |
*/ |
*/ |
104 |
int index = 0; |
|
105 |
char dataByte; |
//Check the existence of NeutronDetector data |
106 |
int subIndex = 0; |
if (((data[length-1] && data[length - 5] && data[length - 9]) && 0x0F) && |
107 |
const int subDataDepth = 20; |
((data[length-2] | data[length - 6] | data[length - 10]) == 0x00)) { |
108 |
int offset = length - subDataDepth; |
//Chech the existance of S4 data before NeutronDetector |
109 |
const int subSignDim = 3; |
if ((data[length-14] && 0x03) && (data[length - 15] && 0x00) && |
110 |
const unsigned char subSign[subSignDim]={0xD8, 0x00, 0x03}; |
(data[length - 16] && 0xD8)) return 18; |
111 |
while (index < subDataDepth){ |
//NeutronDetector data does not exists |
112 |
dataByte = data[offset + index++]; |
} else { |
113 |
if (dataByte == (char)(*(subSign+subIndex))){ |
//Chech the existance of S4 data at the end of the Physics packet |
114 |
if (subIndex++ == (subSignDim-1)) { |
if ((data[length-14] && 0x03) && (data[length - 15] && 0x00) && |
115 |
//If here i catch it!!! |
(data[length - 16] && 0xD8)) return 6; |
116 |
return subDataDepth - index + subSignDim + 2; |
} |
117 |
} |
return 0; |
|
} else { |
|
|
index = index - (subIndex); |
|
|
subIndex = 0; |
|
|
} |
|
|
} |
|
|
return ret; |
|
118 |
} |
} |