1 |
/** @file |
/** @file |
2 |
* $Author: kusanagi $ |
* $Author: kusanagi $ |
3 |
* $Date: 2004/07/29 16:19:11 $ |
* $Date: 2004/08/19 15:24:46 $ |
4 |
* $Revision: 1.5 $ |
* $Revision: 1.6 $ |
5 |
* |
* |
6 |
* Implementation of the functions of a sample Algorithm class. |
* Implementation of the functions of a sample Algorithm class. |
7 |
* This file can be used as a templace to develop your own algorithm. |
* This file can be used as a templace to develop your own algorithm. |
24 |
using namespace pamela::techmodel; |
using namespace pamela::techmodel; |
25 |
|
|
26 |
static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.EventReader"); |
static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.EventReader"); |
27 |
static unsigned int prevPckCounter = 0; |
unsigned int EventReader::prevPckCounter = 0; |
28 |
static unsigned int prevPckOBT = 0; |
unsigned int EventReader::prevPckOBT = 0; |
29 |
/** |
/** |
30 |
* Constructor. |
* Constructor. |
31 |
*/ |
*/ |
75 |
*/ |
*/ |
76 |
std::string EventReader::GetVersionInfo(void) const { |
std::string EventReader::GetVersionInfo(void) const { |
77 |
return |
return |
78 |
"$Header: /home/cvsmanager/yoda/techmodel/EventReader.cpp,v 1.5 2004/07/29 16:19:11 kusanagi Exp $\n"; |
"$Header: /home/cvsmanager/yoda/techmodel/EventReader.cpp,v 1.6 2004/08/19 15:24:46 kusanagi Exp $\n"; |
79 |
} |
} |
80 |
|
|
81 |
/** |
/** |
138 |
//**TO BE DONE** <<WRONG CRC l --- LOST PACKET>>// |
//**TO BE DONE** <<WRONG CRC l --- LOST PACKET>>// |
139 |
//Have to be defined a "WrongCRC" packet::Type? |
//Have to be defined a "WrongCRC" packet::Type? |
140 |
//} |
//} |
141 |
} |
} |
142 |
} catch (...) { |
} catch (...) { |
143 |
//This have to be more detailed. More exceptions type are needed. |
//This have to be more detailed. More exceptions type are needed. |
144 |
cat << log4cpp::Priority::ERROR << "Couldn't read the event. Skipping to the next header." |
cat << log4cpp::Priority::ERROR << "Couldn't read the event. Skipping to the next header." |
162 |
char buff[16]; |
char buff[16]; |
163 |
InputFile->read(buff, sizeof(buff)); |
InputFile->read(buff, sizeof(buff)); |
164 |
|
|
|
prevPckCounter = 0; |
|
|
prevPckOBT = 0; |
|
165 |
|
|
166 |
unsigned char PacketId1 = buff[3]; |
unsigned char PacketId1 = buff[3]; |
167 |
unsigned char PacketId2 = buff[4]; |
unsigned char PacketId2 = buff[4]; |
173 |
if (Counter < prevPckCounter){ |
if (Counter < prevPckCounter){ |
174 |
cat << log4cpp::Priority::WARN |
cat << log4cpp::Priority::WARN |
175 |
<< " Packet counter is less than before of " << (prevPckCounter - Counter) |
<< " Packet counter is less than before of " << (prevPckCounter - Counter) |
176 |
<< "\n " << log4cpp::CategoryStream::ENDLINE; |
<< " " << log4cpp::CategoryStream::ENDLINE; |
177 |
} |
} |
178 |
|
|
179 |
if (OrbitalTime < prevPckOBT){ |
if (OrbitalTime < prevPckOBT){ |
180 |
cat << log4cpp::Priority::WARN |
cat << log4cpp::Priority::WARN |
181 |
<< " Orbital Time is less than before of " << (prevPckOBT - OrbitalTime) |
<< " Orbital Time is less than before of " << (prevPckOBT - OrbitalTime) |
182 |
<< "\n " << log4cpp::CategoryStream::ENDLINE; |
<< " " << log4cpp::CategoryStream::ENDLINE; |
183 |
} |
} |
184 |
|
|
185 |
|
|
186 |
if ((BYTE)CM_Compute_CRC16(0, (BYTE*)&buff, 15) == (BYTE)buff[15]){ |
if (((BYTE)CM_Compute_CRC16(0, (BYTE*)&buff, 15) == (BYTE)buff[15]) && (PacketId1 == PacketId2)){ |
187 |
|
prevPckCounter = Counter; |
188 |
|
prevPckOBT = OrbitalTime; |
189 |
long int initPos = InputFile->tellg(); |
long int initPos = InputFile->tellg(); |
190 |
long int finalPos; |
long int finalPos; |
191 |
Header->GetPscuHeader()->SetPacketId(PacketId1, PacketId2); |
Header->GetPscuHeader()->SetPacketId(PacketId1, PacketId2); |
201 |
FindStart(); |
FindStart(); |
202 |
finalPos = (long int)InputFile->tellg() - (1 + initPos + (long int)(Header->GetPscuHeader()->GetPacketLenght())); |
finalPos = (long int)InputFile->tellg() - (1 + initPos + (long int)(Header->GetPscuHeader()->GetPacketLenght())); |
203 |
if(finalPos == 0){ |
if(finalPos == 0){ |
204 |
cat << log4cpp::Priority::DEBUG << " Correct packet length \n" |
cat << log4cpp::Priority::DEBUG << " Correct packet length" |
205 |
<< "\n " << log4cpp::CategoryStream::ENDLINE; |
<< " " << log4cpp::CategoryStream::ENDLINE; |
206 |
} |
} |
207 |
if (finalPos > 0 && finalPos < 64) { |
if (finalPos > 0 && finalPos < 64) { |
208 |
cat << log4cpp::Priority::WARN |
cat << log4cpp::Priority::WARN |
209 |
<< " Correct packet length: Padded of " << finalPos << " bytes \n" |
<< " Correct packet length: Padded of " << finalPos << " bytes" |
210 |
<< "\n " << log4cpp::CategoryStream::ENDLINE; |
<< " " << log4cpp::CategoryStream::ENDLINE; |
211 |
} |
} |
212 |
if (finalPos > 64){ |
if (finalPos > 64){ |
213 |
cat << log4cpp::Priority::ERROR << " Wrong packet length? (because of wrong padding?) \n" |
cat << log4cpp::Priority::ERROR << " Wrong packet length? (because of wrong padding?) " |
214 |
<< "\n " << log4cpp::CategoryStream::ENDLINE; |
<< " " << log4cpp::CategoryStream::ENDLINE; |
215 |
} |
} |
216 |
InputFile->seekg(initPos, std::ios::beg); |
InputFile->seekg(initPos, std::ios::beg); |
217 |
response = true; |
response = true; |
218 |
} else { |
} else { |
219 |
cat << log4cpp::Priority::ERROR << " WRONG CRC FOR HEADER " |
cat << log4cpp::Priority::ERROR << " WRONG CRC FOR HEADER " |
220 |
<< "\n " << log4cpp::CategoryStream::ENDLINE; |
<< " " << log4cpp::CategoryStream::ENDLINE; |
221 |
response = false; |
response = false; |
222 |
} |
} |
|
|
|
223 |
char tmpId1[4]; |
char tmpId1[4]; |
224 |
char tmpId2[4]; |
char tmpId2[4]; |
225 |
char tmpLength[12]; |
char tmpLength[12]; |