source: trunk/MagicSoft/Mars/mreport/MReportCC.cc@ 8955

Last change on this file since 8955 was 8955, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 4.9 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, 12/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2008
21!
22!
23\* ======================================================================== */
24
25//////////////////////////////////////////////////////////////////////////////
26//
27// MReportCC
28//
29// This is the class interpreting and storing the CC-REPORT information.
30//
31// From here maily weather station data is decoded such as
32// temperature, humidity, wind-speed and solar radiation
33//
34// Class Version 2:
35// ----------------
36// + Float_t fUPSStatus; // arbitrary units (still not properly defined)
37// + Float_t fDifRubGPS; // [us] Difference between the Rubidium clock time and the time provided by the GPS receiver
38//
39//
40//////////////////////////////////////////////////////////////////////////////
41#include "MReportCC.h"
42
43#include "MLogManip.h"
44
45#include "MParList.h"
46
47#include "MReportRec.h"
48
49#include "MCameraTH.h"
50#include "MCameraTD.h"
51#include "MCameraRecTemp.h"
52
53ClassImp(MReportCC);
54
55using namespace std;
56
57// --------------------------------------------------------------------------
58//
59// Default construtor. Initialize identifier to "CC-REPORT" Report
60// is expected to have no 'subsystem' time.
61//
62MReportCC::MReportCC() : MReport("CC-REPORT", kFALSE)
63{
64 fName = "MReportCC";
65 fTitle = "Class for CC-REPORT information";
66}
67
68// --------------------------------------------------------------------------
69//
70// FindCreate the following objects:
71// - MCameraTH
72//
73Bool_t MReportCC::SetupReading(MParList &plist)
74{
75 fRecRep = (MReportRec*)plist.FindCreateObj("MReportRec");
76 if (!fRecRep)
77 return kFALSE;
78
79 fRecTime = (MTime*)plist.FindCreateObj("MTime", "MTimeRec");
80 if (!fRecTime)
81 return kFALSE;
82
83
84 fTH = (MCameraTH*)plist.FindCreateObj("MCameraTH");
85 if (!fTH)
86 return kFALSE;
87
88 fTD = (MCameraTD*)plist.FindCreateObj("MCameraTD");
89 if (!fTD)
90 return kFALSE;
91
92 fRecTemp = (MCameraRecTemp*)plist.FindCreateObj("MCameraRecTemp");
93 if (!fRecTemp)
94 return kFALSE;
95
96
97 return MReport::SetupReading(plist);
98}
99
100// --------------------------------------------------------------------------
101//
102// Interprete the body of the CC-REPORT string
103//
104Bool_t MReportCC::InterpreteCC(TString &str, Int_t ver)
105{
106 const Int_t skip = ver<200407270 ? 30 : 31;
107
108 // Remove the 30/31 tokens of the subsystem status
109 // table 12.1 p59
110 for (int i=0; i<skip; i++)
111 str.Remove(0, str.First(' ')+1);
112
113 Int_t len;
114 const Int_t n=sscanf(str.Data(),
115 "%*f %*f %*f %*f %f %f %f %f %f %f %n",
116 &fTemperature, &fSolarRadiation, &fWindSpeed,
117 &fHumidity, &fUPSStatus, &fDifRubGPS, &len);
118 if (n!=6)
119 {
120 cout << n << endl;
121 *fLog << warn << "WARNING - Wrong number of arguments (should be 6)." << endl;
122 return kFALSE;
123 }
124
125 str.Remove(0, len);
126
127 return kTRUE;
128}
129
130// --------------------------------------------------------------------------
131//
132// Interprete the body of the CC-REPORT string
133//
134Int_t MReportCC::InterpreteBody(TString &str, Int_t ver)
135{
136 if (ver<200404070)
137 {
138 *fLog << err << "ERROR - MReportCC::InterpreteBody not prepared for ";
139 *fLog << " report-files with version<200404070" << endl;
140 return kFALSE;
141 }
142
143 if (!InterpreteCC(str, ver))
144 return kCONTINUE;
145
146 if (ver<200805190)
147 {
148 fRecRep->InterpreteRec(str, ver, *fTH, *fTD, *fRecTemp);
149 fRecRep->Copy(*this);
150 fRecRep->SetReadyToSave();
151 }
152
153 if (str.Strip(TString::kBoth)!=(TString)"OVER")
154 {
155 *fLog << warn << "WARNING - 'OVER' tag not found." << endl;
156 return kCONTINUE;
157 }
158
159 return kTRUE;
160}
161
162// --------------------------------------------------------------------------
163//
164// Print contents of report
165//
166void MReportCC::Print(Option_t *opt) const
167{
168 *fLog << all << GetDescriptor() << ": Status=" << (int)GetState();
169 *fLog << " Hum=" << Form("%3.0f", fHumidity);
170 *fLog << "% Temp=" << Form("%+3.0f", fTemperature);
171 *fLog << "°C Wind=" << Form("%3.0f", fWindSpeed);
172 *fLog << "km/h SolarRad=" << Form("%4.0f", fSolarRadiation) << "W/m^2" << endl;
173}
Note: See TracBrowser for help on using the repository browser.