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

Last change on this file since 9256 was 9141, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 5.8 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
80 fTH = (MCameraTH*)plist.FindCreateObj("MCameraTH");
81 if (!fTH)
82 return kFALSE;
83
84 fTD = (MCameraTD*)plist.FindCreateObj("MCameraTD");
85 if (!fTD)
86 return kFALSE;
87
88 fRecTemp = (MCameraRecTemp*)plist.FindCreateObj("MCameraRecTemp");
89 if (!fRecTemp)
90 return kFALSE;
91
92
93 return MReport::SetupReading(plist);
94}
95
96// --------------------------------------------------------------------------
97//
98// Interprete the body of the CC-REPORT string
99//
100Bool_t MReportCC::InterpreteCC(TString &str, Int_t ver)
101{
102 const Int_t skip = ver<200407270 ? 30 : 31;
103
104 // Remove the 30/31 tokens of the subsystem status
105 // table 12.1 p59
106 for (int i=0; i<skip; i++)
107 str.Remove(0, str.First(' ')+1);
108
109 Int_t len;
110 const Int_t n=sscanf(str.Data(),
111 "%*f %*f %*f %*f %f %f %f %f %f %f %n",
112 &fTemperature, &fSolarRadiation, &fWindSpeed,
113 &fHumidity, &fUPSStatus, &fDifRubGPS, &len);
114 if (n!=6)
115 {
116 *fLog << warn << "WARNING - Wrong number of arguments (should be 6)." << endl;
117 return kFALSE;
118 }
119
120 str.Remove(0, len);
121
122 if (ver>=200809030)
123 {
124 if (!CheckTag(str, "SCHEDULE "))
125 return kFALSE;
126
127 str = str.Strip(TString::kBoth);
128
129 // [Sourcename] sourcecategory
130 const Ssiz_t pos1 = str.First(' ');
131 if (pos1<0)
132 {
133 *fLog << warn << "WARNING - Wrong number of arguments (should be 1 or 2)." << endl;
134 return kFALSE;
135 }
136
137 const TString str1 = str(0, pos1);
138
139 str.Remove(0, pos1);
140 str = str.Strip(TString::kBoth);
141
142 if (!str1.IsDigit())
143 {
144 const Ssiz_t pos2 = str.First(' ');
145 if (pos2<0)
146 {
147 *fLog << warn << "WARNING - Wrong number of arguments (should be 1 or 2)." << endl;
148 return kFALSE;
149 }
150
151 const TString str2 = str(0, pos2);
152
153 str.Remove(0, pos2);
154
155 if (!str2.IsDigit())
156 {
157 *fLog << warn << "WARNING - Wrong type of second argument." << endl;
158 return kFALSE;
159 }
160 }
161 }
162
163 return kTRUE;
164}
165
166// --------------------------------------------------------------------------
167//
168// Interprete the body of the CC-REPORT string
169//
170Int_t MReportCC::InterpreteBody(TString &str, Int_t ver)
171{
172 if (ver<200404070)
173 {
174 *fLog << err << "ERROR - MReportCC::InterpreteBody not prepared for ";
175 *fLog << " report-files with version<200404070" << endl;
176 return kFALSE;
177 }
178
179 if (!InterpreteCC(str, ver))
180 return kCONTINUE;
181
182 if (ver<200805190)
183 {
184 fRecRep->InterpreteRec(str, ver, *fTH, *fTD, *fRecTemp);
185 Copy(*fRecRep);
186 fRecRep->SetReadyToSave();
187 }
188
189 if (str.Strip(TString::kBoth)!=(TString)"OVER")
190 {
191 *fLog << warn << "WARNING - 'OVER' tag not found." << endl;
192 return kCONTINUE;
193 }
194
195 return kTRUE;
196}
197
198// --------------------------------------------------------------------------
199//
200// Print contents of report
201//
202void MReportCC::Print(Option_t *opt) const
203{
204 *fLog << all << GetDescriptor() << ": Status=" << (int)GetState();
205 *fLog << " Hum=" << Form("%3.0f", fHumidity);
206 *fLog << "% Temp=" << Form("%+3.0f", fTemperature);
207 *fLog << "°C Wind=" << Form("%3.0f", fWindSpeed);
208 *fLog << "km/h SolarRad=" << Form("%4.0f", fSolarRadiation) << "W/m^2" << endl;
209}
Note: See TracBrowser for help on using the repository browser.