1 | /* ======================================================================== *\
|
---|
2 | !
|
---|
3 | ! *
|
---|
4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
8 | ! *
|
---|
9 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
10 | ! * documentation for any purpose is hereby granted without fee,
|
---|
11 | ! * provided that the above copyright notice appear in all copies and
|
---|
12 | ! * that both that copyright notice and this permission notice appear
|
---|
13 | ! * in supporting documentation. It is provided "as is" without express
|
---|
14 | ! * or implied warranty.
|
---|
15 | ! *
|
---|
16 | !
|
---|
17 | !
|
---|
18 | ! Author(s): Thomas Bretz, 11/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2003
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | //////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MReportCurrents
|
---|
28 | //
|
---|
29 | // This is the class interpreting and storing the DC-REPORT information.
|
---|
30 | //
|
---|
31 | // --> Not yet finished...
|
---|
32 | //
|
---|
33 | //////////////////////////////////////////////////////////////////////////////
|
---|
34 | #include "MReportCurrents.h"
|
---|
35 |
|
---|
36 | #include "MLogManip.h"
|
---|
37 |
|
---|
38 | #include "MParList.h"
|
---|
39 | #include "MCameraDC.h"
|
---|
40 |
|
---|
41 | ClassImp(MReportCurrents);
|
---|
42 |
|
---|
43 | using namespace std;
|
---|
44 |
|
---|
45 | MReportCurrents::MReportCurrents() : MReport("DC-REPORT", kFALSE)
|
---|
46 | {
|
---|
47 | fName = "MReportCurrents";
|
---|
48 | fTitle = "Class for DC-REPORT information";
|
---|
49 | }
|
---|
50 |
|
---|
51 | Bool_t MReportCurrents::SetupReading(MParList &plist)
|
---|
52 | {
|
---|
53 | fDC = (MCameraDC*)plist.FindCreateObj("MCameraDC");
|
---|
54 | if (!fDC)
|
---|
55 | return kFALSE;
|
---|
56 |
|
---|
57 | return MReport::SetupReading(plist);
|
---|
58 | }
|
---|
59 |
|
---|
60 | Bool_t MReportCurrents::InterpreteBody(TString &str)
|
---|
61 | {
|
---|
62 | Int_t len;
|
---|
63 | Short_t err1, err2;
|
---|
64 | const Int_t n=sscanf(str.Data(), " %hd %hd %n", &err1, &err2, &len);
|
---|
65 | if (n!=2)
|
---|
66 | {
|
---|
67 | *fLog << err << "ERROR - Reading status information." << endl;
|
---|
68 | return kFALSE;
|
---|
69 | }
|
---|
70 |
|
---|
71 | fStatus1 = (Byte_t)err1;
|
---|
72 | fStatus2 = (Byte_t)err2;
|
---|
73 |
|
---|
74 | const char *pos = str.Data()+len;
|
---|
75 | const char *end = pos+577*4;
|
---|
76 |
|
---|
77 | Int_t i=0;
|
---|
78 | while (pos<end)
|
---|
79 | {
|
---|
80 | Int_t c;
|
---|
81 | const Char_t hex[5] = { pos[0], pos[1], pos[2], pos[3], 0 };
|
---|
82 | pos += 4;
|
---|
83 |
|
---|
84 | const Int_t n=sscanf(hex, "%4x", &c);
|
---|
85 | if (n!=1)
|
---|
86 | {
|
---|
87 | *fLog << err << "ERROR - Reading hexadecimal DC information." << endl;
|
---|
88 | return kFALSE;
|
---|
89 | }
|
---|
90 |
|
---|
91 | (*fDC)[i++] = 0.001*c;
|
---|
92 | }
|
---|
93 |
|
---|
94 | str.Remove(0, pos-str.Data()); // Remove DC currents
|
---|
95 | str=str.Strip(TString::kLeading);
|
---|
96 |
|
---|
97 | return str.IsNull();
|
---|
98 | }
|
---|