source: trunk/Mars/mreport/MReportCC.cc@ 19702

Last change on this file since 19702 was 19007, checked in by tbretz, 7 years ago
Replaced some unicode characters by proper string representations.
File size: 7.2 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// Class Version 3:
40// ----------------
41// * Moved weather data to new base class
42//
43//
44//////////////////////////////////////////////////////////////////////////////
45#include "MReportCC.h"
46
47#include "fits.h"
48
49#include "MLogManip.h"
50
51#include "MParList.h"
52
53#include "MReportRec.h"
54
55#include "MCameraTH.h"
56#include "MCameraTD.h"
57#include "MCameraRecTemp.h"
58
59ClassImp(MReportWeather);
60ClassImp(MReportCC);
61
62using namespace std;
63
64// --------------------------------------------------------------------------
65//
66// Default construtor. Initialize identifier to "CC-REPORT" Report
67// is expected to have no 'subsystem' time.
68//
69MReportCC::MReportCC() : MReportWeather("CC-REPORT")
70{
71 fName = "MReportCC";
72 fTitle = "Class for CC-REPORT information";
73}
74
75// --------------------------------------------------------------------------
76//
77// FindCreate the following objects:
78// - MCameraTH
79//
80Bool_t MReportCC::SetupReading(MParList &plist)
81{
82 fRecRep = (MReportRec*)plist.FindCreateObj("MReportRec");
83 if (!fRecRep)
84 return kFALSE;
85
86
87 fTH = (MCameraTH*)plist.FindCreateObj("MCameraTH");
88 if (!fTH)
89 return kFALSE;
90
91 fTD = (MCameraTD*)plist.FindCreateObj("MCameraTD");
92 if (!fTD)
93 return kFALSE;
94
95 fRecTemp = (MCameraRecTemp*)plist.FindCreateObj("MCameraRecTemp");
96 if (!fRecTemp)
97 return kFALSE;
98
99
100 return MReport::SetupReading(plist);
101}
102
103// --------------------------------------------------------------------------
104//
105// Interprete the body of the CC-REPORT string
106//
107Bool_t MReportCC::InterpreteCC(TString &str, Int_t ver)
108{
109 const Int_t skip = ver<200407270 ? 30 : 31;
110
111 // Remove the 30/31 tokens of the subsystem status
112 // table 12.1 p59
113 for (int i=0; i<skip; i++)
114 str.Remove(0, str.First(' ')+1);
115
116 Int_t len;
117 const Int_t n=sscanf(str.Data(),
118 "%*f %*f %*f %*f %f %f %f %f %f %f %n",
119 &fTemperature, &fSolarRadiation, &fWindSpeed,
120 &fHumidity, &fUPSStatus, &fDifRubGPS, &len);
121 if (n!=6)
122 {
123 *fLog << warn << "WARNING - Wrong number of arguments (should be 6)." << endl;
124 return kFALSE;
125 }
126
127 str.Remove(0, len);
128
129 return kTRUE;
130}
131
132// --------------------------------------------------------------------------
133//
134// Interprete SCHEDULE section of the CC-REPORT string
135//
136Bool_t MReportCC::InterpreteSchedule(TString &str)
137{
138 if (!CheckTag(str, "SCHEDULE "))
139 return kFALSE;
140
141 str = str.Strip(TString::kBoth);
142
143 // [Sourcename] sourcecategory
144 const Ssiz_t pos1 = str.First(' ');
145 if (pos1<0)
146 {
147 *fLog << warn << "WARNING - Wrong number of arguments (should be 1 or 2)." << endl;
148 return kFALSE;
149 }
150
151 const TString str1 = str(0, pos1);
152
153 str.Remove(0, pos1);
154 str = str.Strip(TString::kBoth);
155
156 if (!str1.IsDigit())
157 {
158 const Ssiz_t pos2 = str.First(' ');
159 if (pos2<0)
160 {
161 *fLog << warn << "WARNING - Wrong number of arguments (should be 1 or 2)." << endl;
162 return kFALSE;
163 }
164
165 TString str2 = str(0, pos2);
166
167 str.Remove(0, pos2);
168
169 // Remove a leading minus. The negative numbers are error codes introduced
170 // by Arehucas. It's only meant for the GRB monitor to change the priority
171 // of its alerts.
172 if (str2[0]=='-')
173 str2.Remove(0, 1);
174
175 if (!str2.IsDigit())
176 {
177 *fLog << warn << "WARNING - Wrong type of second argument (obs. category): " << str2 << endl;
178 return kFALSE;
179 }
180 }
181
182 return kTRUE;
183}
184
185
186// --------------------------------------------------------------------------
187//
188// Interprete the part of the CC-Report with the MII Subsystem status'
189//
190Bool_t MReportCC::InterpreteStatusM2(TString &str)
191{
192 // Status of: DAQ, DominoCalibration, Drive, Starguider, CaCo,
193 // CaCo2 LID, CaCo sentinel, CaCo LV, CaCo2 HV, AMC, L2T,
194 // Domino, Readout, REC, DT, Readout cooling, calib
195 // %05.2f %05.2f Zd [deg], Az [deg]
196
197 // Remove the 18 tokens of the MAGIC II subsystem status
198 for (int i=0; i<19; i++)
199 str.Remove(0, str.First(' ')+1);
200
201 return kTRUE;
202}
203
204// --------------------------------------------------------------------------
205//
206// Interprete the body of the CC-REPORT string
207//
208Int_t MReportCC::InterpreteBody(TString &str, Int_t ver)
209{
210 if (ver<200404070)
211 {
212 *fLog << err << "ERROR - MReportCC::InterpreteBody not prepared for ";
213 *fLog << " report-files with version<200404070" << endl;
214 return kFALSE;
215 }
216
217 if (!InterpreteCC(str, ver))
218 return kCONTINUE;
219
220 if (ver>=200809030)
221 if (!InterpreteSchedule(str))
222 return kCONTINUE;
223
224 if (ver>=200902030)
225 if (!InterpreteStatusM2(str))
226 return kCONTINUE;
227
228 if (ver<200805190)
229 {
230 fRecRep->InterpreteRec(str, ver, *fTH, *fTD, *fRecTemp);
231 Copy(*fRecRep);
232 fRecRep->SetReadyToSave();
233 }
234
235 if (str.Strip(TString::kBoth)!=(TString)"OVER")
236 {
237 *fLog << warn << "WARNING - 'OVER' tag not found." << endl;
238 return kCONTINUE;
239 }
240
241 return kTRUE;
242}
243
244// --------------------------------------------------------------------------
245//
246// Print contents of report
247//
248void MReportWeather::Print(Option_t *opt) const
249{
250 *fLog << all << GetDescriptor() << ": Status=" << (int)GetState();
251 *fLog << " Hum=" << Form("%3.0f", fHumidity);
252 *fLog << "% Temp=" << Form("%+3.0f", fTemperature);
253 *fLog << "\u00b0C Wind=" << Form("%3.0f", fWindSpeed);
254 *fLog << "km/h SolarRad=" << Form("%4.0f", fSolarRadiation) << "W/m^2" << endl;
255}
256
257Bool_t MReportWeather::SetupReadingFits(fits &file)
258{
259 return
260 file.SetRefAddress("T", fTemperature) &&
261 file.SetRefAddress("H", fHumidity) &&
262 file.SetRefAddress("v", fWindSpeed);
263}
Note: See TracBrowser for help on using the repository browser.