1 |
/** @file |
2 |
* $Source: /home/cvsmanager/yoda/techmodel/physics/AnticounterReader.cpp,v $ |
3 |
* $Id: AnticounterReader.cpp,v 1.2 2004/08/24 08:00:12 kusanagi Exp $ |
4 |
* $Author: kusanagi $ |
5 |
* |
6 |
* Implementation of the AnticounterReader class. |
7 |
*/ |
8 |
|
9 |
#include <string> |
10 |
#include <log4cxx/logger.h> |
11 |
#include "AnticounterReader.h" |
12 |
|
13 |
extern "C" { |
14 |
#include "../forroutines/anticounter/ACphysics.h" |
15 |
extern int ACphysics(int length,unsigned short* datapointer,struct datastruct* physicspointer); |
16 |
//Struct per il passaggio di dati da e verso la chiamata fortran |
17 |
} |
18 |
|
19 |
using namespace pamela; |
20 |
using namespace pamela::anticounter; |
21 |
|
22 |
static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.anticounter.AnticounterReader")); |
23 |
|
24 |
/** |
25 |
* Constructor. |
26 |
*/ |
27 |
AnticounterReader::AnticounterReader(void): |
28 |
TechmodelAlgorithm(PacketType::Physics, "TechmodelAnticounterReader") { |
29 |
logger->debug(_T("Constructor")); |
30 |
anticounter = new AnticounterEvent(); |
31 |
} |
32 |
|
33 |
/** |
34 |
* Get a string with the version info of the algorithm. |
35 |
*/ |
36 |
std::string AnticounterReader::GetVersionInfo(void) const { |
37 |
return |
38 |
"$Header: /home/cvsmanager/yoda/techmodel/physics/AnticounterReader.cpp,v 1.2 2004/08/24 08:00:12 kusanagi Exp $"; |
39 |
} |
40 |
|
41 |
/** |
42 |
* Initialize the algorithm with a special run. This will initialize the |
43 |
* event reader routines for all packet types. |
44 |
*/ |
45 |
void AnticounterReader::Init(PamelaRun *run) { |
46 |
logger->debug(_T("Initialize")); |
47 |
SetInputStream(run); |
48 |
run->WriteSubPacket(this, &anticounter, anticounter->Class()); |
49 |
} |
50 |
|
51 |
/** |
52 |
* Unpack the anticounter event from an input file. |
53 |
*/ |
54 |
void AnticounterReader::RunEvent(int EventNumber) { |
55 |
|
56 |
} |
57 |
|
58 |
/** |
59 |
* Unpack the Anticounter data event from the physical packet. |
60 |
*/ |
61 |
void AnticounterReader::RunEvent(int EventNumber, const char subData[], long int length) { |
62 |
char *data = new char[length]; |
63 |
memcpy(data, subData, length); |
64 |
int ERROR; |
65 |
datastruct output; |
66 |
|
67 |
//Call to the routine that unpack anitocounter events |
68 |
ERROR = ACphysics(length, (unsigned short*) data, &output); |
69 |
|
70 |
//TO BE activated as soon i will know what codes means "error" |
71 |
/*if (ERROR != 0) { |
72 |
char *errmsg; |
73 |
switch (ERROR){ |
74 |
case 1: errmsg = "---------------------"; |
75 |
} |
76 |
} else {*/ |
77 |
memcpy(anticounter->header, output.header, sizeof(anticounter->header)); |
78 |
anticounter->status = output.status; |
79 |
anticounter->hitmap = output.hitmap; |
80 |
memcpy(anticounter->regist, output.regist, sizeof(anticounter->regist)); |
81 |
memcpy(anticounter->shift, output.shift, sizeof(anticounter->shift)); |
82 |
memcpy(anticounter->counters, output.counters, sizeof(anticounter->counters)); |
83 |
memcpy(anticounter->coinc, output.coinc, sizeof(anticounter->coinc)); |
84 |
anticounter->trigg = output.trigg; |
85 |
memcpy(anticounter->clock, output.clock, sizeof(anticounter->clock)); |
86 |
memcpy(anticounter->temp, output.temp, sizeof(anticounter->temp)); |
87 |
memcpy(anticounter->DAC, output.DAC, sizeof(anticounter->DAC)); |
88 |
anticounter->CRC = output.CRC; |
89 |
//} |
90 |
delete[] data; |
91 |
} |