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 |
|
---|
53 | ClassImp(MReportCC);
|
---|
54 |
|
---|
55 | using namespace std;
|
---|
56 |
|
---|
57 | // --------------------------------------------------------------------------
|
---|
58 | //
|
---|
59 | // Default construtor. Initialize identifier to "CC-REPORT" Report
|
---|
60 | // is expected to have no 'subsystem' time.
|
---|
61 | //
|
---|
62 | MReportCC::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 | //
|
---|
73 | Bool_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 | //
|
---|
100 | Bool_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 | return kTRUE;
|
---|
123 | }
|
---|
124 |
|
---|
125 | // --------------------------------------------------------------------------
|
---|
126 | //
|
---|
127 | // Interprete SCHEDULE section of the CC-REPORT string
|
---|
128 | //
|
---|
129 | Bool_t MReportCC::InterpreteSchedule(TString &str)
|
---|
130 | {
|
---|
131 | if (!CheckTag(str, "SCHEDULE "))
|
---|
132 | return kFALSE;
|
---|
133 |
|
---|
134 | str = str.Strip(TString::kBoth);
|
---|
135 |
|
---|
136 | // [Sourcename] sourcecategory
|
---|
137 | const Ssiz_t pos1 = str.First(' ');
|
---|
138 | if (pos1<0)
|
---|
139 | {
|
---|
140 | *fLog << warn << "WARNING - Wrong number of arguments (should be 1 or 2)." << endl;
|
---|
141 | return kFALSE;
|
---|
142 | }
|
---|
143 |
|
---|
144 | const TString str1 = str(0, pos1);
|
---|
145 |
|
---|
146 | str.Remove(0, pos1);
|
---|
147 | str = str.Strip(TString::kBoth);
|
---|
148 |
|
---|
149 | if (!str1.IsDigit())
|
---|
150 | {
|
---|
151 | const Ssiz_t pos2 = str.First(' ');
|
---|
152 | if (pos2<0)
|
---|
153 | {
|
---|
154 | *fLog << warn << "WARNING - Wrong number of arguments (should be 1 or 2)." << endl;
|
---|
155 | return kFALSE;
|
---|
156 | }
|
---|
157 |
|
---|
158 | TString str2 = str(0, pos2);
|
---|
159 |
|
---|
160 | str.Remove(0, pos2);
|
---|
161 |
|
---|
162 | // Remove a leading minus. The negative numbers are error codes introduced
|
---|
163 | // by Arehucas. It's only meant for the GRB monitor to change the priority
|
---|
164 | // of its alerts.
|
---|
165 | if (str2[0]=='-')
|
---|
166 | str2.Remove(0, 1);
|
---|
167 |
|
---|
168 | if (!str2.IsDigit())
|
---|
169 | {
|
---|
170 | *fLog << warn << "WARNING - Wrong type of second argument (obs. category): " << str2 << endl;
|
---|
171 | return kFALSE;
|
---|
172 | }
|
---|
173 | }
|
---|
174 |
|
---|
175 | return kTRUE;
|
---|
176 | }
|
---|
177 |
|
---|
178 |
|
---|
179 | // --------------------------------------------------------------------------
|
---|
180 | //
|
---|
181 | // Interprete the part of the CC-Report with the MII Subsystem status'
|
---|
182 | //
|
---|
183 | Bool_t MReportCC::InterpreteStatusM2(TString &str)
|
---|
184 | {
|
---|
185 | // Status of: DAQ, DominoCalibration, Drive, Starguider, CaCo,
|
---|
186 | // CaCo2 LID, CaCo sentinel, CaCo LV, CaCo2 HV, AMC, L2T,
|
---|
187 | // Domino, Readout, REC, DT, Readout cooling, calib
|
---|
188 | // %05.2f %05.2f Zd [deg], Az [deg]
|
---|
189 |
|
---|
190 | // Remove the 18 tokens of the MAGIC II subsystem status
|
---|
191 | for (int i=0; i<19; i++)
|
---|
192 | str.Remove(0, str.First(' ')+1);
|
---|
193 |
|
---|
194 | return kTRUE;
|
---|
195 | }
|
---|
196 |
|
---|
197 | // --------------------------------------------------------------------------
|
---|
198 | //
|
---|
199 | // Interprete the body of the CC-REPORT string
|
---|
200 | //
|
---|
201 | Int_t MReportCC::InterpreteBody(TString &str, Int_t ver)
|
---|
202 | {
|
---|
203 | if (ver<200404070)
|
---|
204 | {
|
---|
205 | *fLog << err << "ERROR - MReportCC::InterpreteBody not prepared for ";
|
---|
206 | *fLog << " report-files with version<200404070" << endl;
|
---|
207 | return kFALSE;
|
---|
208 | }
|
---|
209 |
|
---|
210 | if (!InterpreteCC(str, ver))
|
---|
211 | return kCONTINUE;
|
---|
212 |
|
---|
213 | if (ver>=200809030)
|
---|
214 | if (!InterpreteSchedule(str))
|
---|
215 | return kCONTINUE;
|
---|
216 |
|
---|
217 | if (ver>=200902030)
|
---|
218 | if (!InterpreteStatusM2(str))
|
---|
219 | return kCONTINUE;
|
---|
220 |
|
---|
221 | if (ver<200805190)
|
---|
222 | {
|
---|
223 | fRecRep->InterpreteRec(str, ver, *fTH, *fTD, *fRecTemp);
|
---|
224 | Copy(*fRecRep);
|
---|
225 | fRecRep->SetReadyToSave();
|
---|
226 | }
|
---|
227 |
|
---|
228 | if (str.Strip(TString::kBoth)!=(TString)"OVER")
|
---|
229 | {
|
---|
230 | *fLog << warn << "WARNING - 'OVER' tag not found." << endl;
|
---|
231 | return kCONTINUE;
|
---|
232 | }
|
---|
233 |
|
---|
234 | return kTRUE;
|
---|
235 | }
|
---|
236 |
|
---|
237 | // --------------------------------------------------------------------------
|
---|
238 | //
|
---|
239 | // Print contents of report
|
---|
240 | //
|
---|
241 | void MReportCC::Print(Option_t *opt) const
|
---|
242 | {
|
---|
243 | *fLog << all << GetDescriptor() << ": Status=" << (int)GetState();
|
---|
244 | *fLog << " Hum=" << Form("%3.0f", fHumidity);
|
---|
245 | *fLog << "% Temp=" << Form("%+3.0f", fTemperature);
|
---|
246 | *fLog << "°C Wind=" << Form("%3.0f", fWindSpeed);
|
---|
247 | *fLog << "km/h SolarRad=" << Form("%4.0f", fSolarRadiation) << "W/m^2" << endl;
|
---|
248 | }
|
---|