1 |
/** @file |
/** @file |
2 |
* $Source: /home/cvsmanager/yoda/techmodel/McmdReader.cpp,v $ |
* $Source: /home/cvsmanager/yoda/techmodel/McmdReader.cpp,v $ |
3 |
* $Id: McmdReader.cpp,v 1.3 2004/08/24 16:01:57 kusanagi Exp $ |
* $Id: McmdReader.cpp,v 1.4 2004/08/26 08:21:31 kusanagi Exp $ |
4 |
* $Author: kusanagi $ |
* $Author: kusanagi $ |
5 |
* |
* |
6 |
* Implementation of the McmdReader class. |
* Implementation of the McmdReader class. |
8 |
|
|
9 |
#define BYTE unsigned char |
#define BYTE unsigned char |
10 |
#include <string> |
#include <string> |
11 |
#include <log4cpp/Category.hh> |
#include <log4cxx/logger.h> |
12 |
extern "C" { |
extern "C" { |
13 |
#include <sys/time.h> |
#include <sys/time.h> |
14 |
#include "CRC.h" |
#include "CRC.h" |
23 |
using namespace pamela; |
using namespace pamela; |
24 |
using namespace pamela::techmodel; |
using namespace pamela::techmodel; |
25 |
|
|
26 |
static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.McmdReader"); |
static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.McmdReader")); |
27 |
|
static std::stringstream oss; |
28 |
/** |
/** |
29 |
* Constructor. |
* Constructor. |
30 |
*/ |
*/ |
31 |
McmdReader::McmdReader(void): |
McmdReader::McmdReader(void): |
32 |
TechmodelAlgorithm(PacketType::Mcmd, "Mcmd") { |
TechmodelAlgorithm(PacketType::Mcmd, "Mcmd") { |
33 |
cat << log4cpp::Priority::DEBUG |
logger->debug(_T("Constructor")); |
|
<< "Constructor " |
|
|
<< "\n " << log4cpp::CategoryStream::ENDLINE; |
|
34 |
Mcmd = new McmdEvent(); |
Mcmd = new McmdEvent(); |
35 |
} |
} |
36 |
|
|
39 |
*/ |
*/ |
40 |
std::string McmdReader::GetVersionInfo(void) const { |
std::string McmdReader::GetVersionInfo(void) const { |
41 |
return |
return |
42 |
"$Header: /home/cvsmanager/yoda/techmodel/McmdReader.cpp,v 1.3 2004/08/24 16:01:57 kusanagi Exp $\n"; |
"$Header: /home/cvsmanager/yoda/techmodel/McmdReader.cpp,v 1.4 2004/08/26 08:21:31 kusanagi Exp $\n"; |
43 |
} |
} |
44 |
|
|
45 |
/** |
/** |
47 |
* event reader routines for all packet types. |
* event reader routines for all packet types. |
48 |
*/ |
*/ |
49 |
void McmdReader::Init(PamelaRun *run) { |
void McmdReader::Init(PamelaRun *run) { |
50 |
|
logger->debug(_T("Initialize")); |
51 |
SetInputStream(run); |
SetInputStream(run); |
52 |
run->WriteSubPacket(this, &Mcmd, Mcmd->Class()); |
run->WriteSubPacket(this, &Mcmd, Mcmd->Class()); |
53 |
} |
} |
170 |
//rec->setMcmdData((BYTE*)&subData); |
//rec->setMcmdData((BYTE*)&subData); |
171 |
delete [] subData; |
delete [] subData; |
172 |
} else { |
} else { |
173 |
cat << log4cpp::Priority::ERROR |
oss.flush(); |
174 |
<< "Wrong CRC on Subpacket int MCMD Packet starting at position " << start |
oss << "Wrong CRC on Subpacket internal to TMTC Packet starting at position" |
175 |
<< "\n " << log4cpp::CategoryStream::ENDLINE; |
<< start; |
176 |
|
logger->warn(oss.str().c_str()); |
177 |
} |
} |
178 |
} |
} |
179 |
//in the end compare the calculated partial CRC with the MCMD packet CRC |
//in the end compare the calculated partial CRC with the MCMD packet CRC |
181 |
readCRC = (((UINT16)(eventCRC[0]<<8))&0xFF00) + (((UINT16)eventCRC[1])&0x00FF); |
readCRC = (((UINT16)(eventCRC[0]<<8))&0xFF00) + (((UINT16)eventCRC[1])&0x00FF); |
182 |
|
|
183 |
if(!(partialCRC == readCRC)) { |
if(!(partialCRC == readCRC)) { |
184 |
cat << log4cpp::Priority::ERROR |
logger->warn(_T("The test of calculated CRC with one wrote on file FAILED!!")); |
|
<< "Wrong CRC for CalibS4 Packet" |
|
|
<< "\n " << log4cpp::CategoryStream::ENDLINE; |
|
185 |
} |
} |
186 |
} |
} |
187 |
|
|