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 | //////////////////////////////////////////////////////////////////////////////
|
---|
32 | #include "MReportCurrents.h"
|
---|
33 |
|
---|
34 | #include "MLogManip.h"
|
---|
35 |
|
---|
36 | #include "MParList.h"
|
---|
37 | #include "MCameraDC.h"
|
---|
38 |
|
---|
39 | ClassImp(MReportCurrents);
|
---|
40 |
|
---|
41 | using namespace std;
|
---|
42 |
|
---|
43 | // --------------------------------------------------------------------------
|
---|
44 | //
|
---|
45 | // Default construtor. Initialize identifier to "DC-REPORT" Reports
|
---|
46 | // are expected to have no 'subsystem' time.
|
---|
47 | //
|
---|
48 | MReportCurrents::MReportCurrents() : MReport("DC-REPORT", kFALSE)
|
---|
49 | {
|
---|
50 | fName = "MReportCurrents";
|
---|
51 | fTitle = "Class for DC-REPORT information";
|
---|
52 | }
|
---|
53 |
|
---|
54 | // --------------------------------------------------------------------------
|
---|
55 | //
|
---|
56 | // FindCreate the following objects:
|
---|
57 | // - MCameraDC
|
---|
58 | //
|
---|
59 | Bool_t MReportCurrents::SetupReading(MParList &plist)
|
---|
60 | {
|
---|
61 | fDC = (MCameraDC*)plist.FindCreateObj("MCameraDC");
|
---|
62 | if (!fDC)
|
---|
63 | return kFALSE;
|
---|
64 |
|
---|
65 | return MReport::SetupReading(plist);
|
---|
66 | }
|
---|
67 |
|
---|
68 | // --------------------------------------------------------------------------
|
---|
69 | //
|
---|
70 | // Interprete the body of the DC-REPORT string
|
---|
71 | //
|
---|
72 | Bool_t MReportCurrents::InterpreteBody(TString &str)
|
---|
73 | {
|
---|
74 | Int_t len;
|
---|
75 | Short_t err1, err2;
|
---|
76 | const Int_t n=sscanf(str.Data(), " %hd %hd %n", &err1, &err2, &len);
|
---|
77 | if (n!=2)
|
---|
78 | {
|
---|
79 | *fLog << err << "ERROR - Reading status information." << endl;
|
---|
80 | return kFALSE;
|
---|
81 | }
|
---|
82 |
|
---|
83 | fStatus1 = (Byte_t)err1;
|
---|
84 | fStatus2 = (Byte_t)err2;
|
---|
85 |
|
---|
86 | const char *pos = str.Data()+len;
|
---|
87 | const char *end = pos+577*4;
|
---|
88 |
|
---|
89 | Int_t i=0;
|
---|
90 | while (pos<end)
|
---|
91 | {
|
---|
92 | Int_t c;
|
---|
93 | const Char_t hex[5] = { pos[0], pos[1], pos[2], pos[3], 0 };
|
---|
94 | pos += 4;
|
---|
95 |
|
---|
96 | const Int_t n=sscanf(hex, "%4x", &c);
|
---|
97 | if (n!=1)
|
---|
98 | {
|
---|
99 | *fLog << err << "ERROR - Reading hexadecimal DC information." << endl;
|
---|
100 | return kFALSE;
|
---|
101 | }
|
---|
102 |
|
---|
103 | (*fDC)[i++] = 0.001*c;
|
---|
104 | }
|
---|
105 |
|
---|
106 | str.Remove(0, pos-str.Data()); // Remove DC currents
|
---|
107 | str=str.Strip(TString::kLeading);
|
---|
108 |
|
---|
109 | return str.IsNull();
|
---|
110 | }
|
---|