source: trunk/MagicSoft/Mars/mreport/MReportCurrents.cc@ 6525

Last change on this file since 6525 was 4575, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 3.1 KB
Line 
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
39ClassImp(MReportCurrents);
40
41using namespace std;
42
43// --------------------------------------------------------------------------
44//
45// Default construtor. Initialize identifier to "DC-REPORT" Reports
46// are expected to have no 'subsystem' time.
47//
48MReportCurrents::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//
59Bool_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//
72Int_t MReportCurrents::InterpreteBody(TString &str, Int_t ver)
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 << warn << "WARNING - Reading status information." << endl;
80 return kCONTINUE;
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 << warn << "WARNING - Reading hexadecimal DC information." << endl;
100 return kCONTINUE;
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() ? kTRUE : kCONTINUE;
110}
Note: See TracBrowser for help on using the repository browser.