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-2003
|
---|
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 "MCameraTH.h"
|
---|
48 | #include "MCameraTD.h"
|
---|
49 | #include "MCameraRecTemp.h"
|
---|
50 |
|
---|
51 | ClassImp(MReportCC);
|
---|
52 |
|
---|
53 | using namespace std;
|
---|
54 |
|
---|
55 | // --------------------------------------------------------------------------
|
---|
56 | //
|
---|
57 | // Default construtor. Initialize identifier to "CC-REPORT" Report
|
---|
58 | // is expected to have no 'subsystem' time.
|
---|
59 | //
|
---|
60 | MReportCC::MReportCC() : MReport("CC-REPORT", kFALSE)
|
---|
61 | {
|
---|
62 | fName = "MReportCC";
|
---|
63 | fTitle = "Class for CC-REPORT information";
|
---|
64 | }
|
---|
65 |
|
---|
66 | // --------------------------------------------------------------------------
|
---|
67 | //
|
---|
68 | // FindCreate the following objects:
|
---|
69 | // - MCameraTH
|
---|
70 | //
|
---|
71 | Bool_t MReportCC::SetupReading(MParList &plist)
|
---|
72 | {
|
---|
73 | fTH = (MCameraTH*)plist.FindCreateObj("MCameraTH");
|
---|
74 | if (!fTH)
|
---|
75 | return kFALSE;
|
---|
76 |
|
---|
77 | fTD = (MCameraTD*)plist.FindCreateObj("MCameraTD");
|
---|
78 | if (!fTD)
|
---|
79 | return kFALSE;
|
---|
80 |
|
---|
81 | fRecTemp = (MCameraRecTemp*)plist.FindCreateObj("MCameraRecTemp");
|
---|
82 | if (!fRecTemp)
|
---|
83 | return kFALSE;
|
---|
84 |
|
---|
85 | return MReport::SetupReading(plist);
|
---|
86 | }
|
---|
87 |
|
---|
88 | // --------------------------------------------------------------------------
|
---|
89 | //
|
---|
90 | // Check whether the given TString begins with the given tag. Remove
|
---|
91 | // the tag from the string.
|
---|
92 | //
|
---|
93 | Bool_t MReportCC::CheckTag(TString &str, const char *tag) const
|
---|
94 | {
|
---|
95 | if (!str.BeginsWith(tag))
|
---|
96 | {
|
---|
97 | *fLog << warn << "WARNING - '" << tag << "' tag not found." << endl;
|
---|
98 | return kFALSE;
|
---|
99 | }
|
---|
100 | str.Remove(0, strlen(tag)); // Remove Tag
|
---|
101 | return kTRUE;
|
---|
102 | }
|
---|
103 |
|
---|
104 |
|
---|
105 | // --------------------------------------------------------------------------
|
---|
106 | //
|
---|
107 | // Interprete the body of the CC-REPORT string
|
---|
108 | //
|
---|
109 | Bool_t MReportCC::InterpreteCC(TString &str, Int_t ver)
|
---|
110 | {
|
---|
111 | const Int_t skip = ver<200407270 ? 30 : 31;
|
---|
112 |
|
---|
113 | // Remove the 30/31 tokens of the subsystem status
|
---|
114 | // table 12.1 p59
|
---|
115 | for (int i=0; i<skip; i++)
|
---|
116 | str.Remove(0, str.First(' ')+1);
|
---|
117 |
|
---|
118 | Int_t len;
|
---|
119 | const Int_t n=sscanf(str.Data(),
|
---|
120 | "%*f %*f %*f %*f %f %f %f %f %f %f %n",
|
---|
121 | &fTemperature, &fSolarRadiation, &fWindSpeed,
|
---|
122 | &fHumidity, &fUPSStatus, &fDifRubGPS, &len);
|
---|
123 | if (n!=6)
|
---|
124 | {
|
---|
125 | *fLog << warn << "WARNING - Wrong number of arguments." << endl;
|
---|
126 | return kFALSE;
|
---|
127 | }
|
---|
128 |
|
---|
129 | str.Remove(0, len);
|
---|
130 |
|
---|
131 | return kTRUE;
|
---|
132 | }
|
---|
133 |
|
---|
134 | // --------------------------------------------------------------------------
|
---|
135 | //
|
---|
136 | // Interprete the TH (discriminator thresholds) part of the report
|
---|
137 | //
|
---|
138 | Bool_t MReportCC::InterpreteTH(TString &str)
|
---|
139 | {
|
---|
140 | if (!CheckTag(str, "TH "))
|
---|
141 | return kFALSE;
|
---|
142 |
|
---|
143 | const char *pos = str.Data();
|
---|
144 | const char *end = str.Data()+577*2;
|
---|
145 |
|
---|
146 | Int_t i=0;
|
---|
147 | while (pos<end)
|
---|
148 | {
|
---|
149 | const Char_t hex[2] = { pos[0], pos[1] };
|
---|
150 | pos += 2;
|
---|
151 |
|
---|
152 | const Int_t n=sscanf(hex, "%2hhx", &fTH->fTH[i++]);
|
---|
153 | if (n==1)
|
---|
154 | continue;
|
---|
155 |
|
---|
156 | *fLog << warn << "WARNING - Reading hexadecimal TH information." << endl;
|
---|
157 | return kFALSE;
|
---|
158 | }
|
---|
159 |
|
---|
160 | str.Remove(0, end-str.Data()); // Remove TH
|
---|
161 | str=str.Strip(TString::kLeading);
|
---|
162 | return kTRUE;
|
---|
163 | }
|
---|
164 |
|
---|
165 | // --------------------------------------------------------------------------
|
---|
166 | //
|
---|
167 | // Interprete the TD (discriminator delays) part of the report
|
---|
168 | //
|
---|
169 | Bool_t MReportCC::InterpreteTD(TString &str, Int_t ver)
|
---|
170 | {
|
---|
171 | if (!CheckTag(str, "TD "))
|
---|
172 | return kFALSE;
|
---|
173 |
|
---|
174 | const Int_t numpix = ver<200510250 ? 500 : 577;
|
---|
175 |
|
---|
176 | const char *pos = str.Data();
|
---|
177 | const char *end = str.Data()+numpix*2;
|
---|
178 |
|
---|
179 | Int_t i=0;
|
---|
180 | while (pos<end)
|
---|
181 | {
|
---|
182 | const Char_t hex[3] = { pos[0], pos[1], 0 };
|
---|
183 | pos += 2;
|
---|
184 |
|
---|
185 | const Int_t n=sscanf(hex, "%2hhx", &fTD->fTD[i++]);
|
---|
186 | if (n==1)
|
---|
187 | continue;
|
---|
188 |
|
---|
189 | *fLog << warn << "WARNING - Reading hexadecimal TD information." << endl;
|
---|
190 | return kFALSE;
|
---|
191 | }
|
---|
192 |
|
---|
193 | str.Remove(0, end-str.Data()); // Remove TD
|
---|
194 | str=str.Strip(TString::kLeading);
|
---|
195 | return kTRUE;
|
---|
196 | }
|
---|
197 |
|
---|
198 |
|
---|
199 | // --------------------------------------------------------------------------
|
---|
200 | //
|
---|
201 | // Interprete the receiver board temperature part of the report
|
---|
202 | //
|
---|
203 | Bool_t MReportCC::InterpreteRecTemp(TString &str)
|
---|
204 | {
|
---|
205 | if (!CheckTag(str, "RECTEMP "))
|
---|
206 | return kFALSE;
|
---|
207 |
|
---|
208 | Int_t len;
|
---|
209 | for (Int_t i=0; i<76; i++)
|
---|
210 | {
|
---|
211 | const Int_t n=sscanf(str.Data(), "%f %n", &fRecTemp->fRecTemp[i], &len);
|
---|
212 | str.Remove(0, len);
|
---|
213 |
|
---|
214 | if (n==1)
|
---|
215 | continue;
|
---|
216 |
|
---|
217 | *fLog << warn << "WARNING - Reading Receiver Board Temperature information." << endl;
|
---|
218 | return kFALSE;
|
---|
219 | }
|
---|
220 |
|
---|
221 | return kTRUE;
|
---|
222 | }
|
---|
223 |
|
---|
224 | // --------------------------------------------------------------------------
|
---|
225 | //
|
---|
226 | // Interprete the body of the CC-REPORT string
|
---|
227 | //
|
---|
228 | Int_t MReportCC::InterpreteBody(TString &str, Int_t ver)
|
---|
229 | {
|
---|
230 | if (ver<200404070)
|
---|
231 | {
|
---|
232 | *fLog << err << "ERROR - MReportCC::InterpreteBody not prepared for ";
|
---|
233 | *fLog << " report-files with version<200404070" << endl;
|
---|
234 | return kFALSE;
|
---|
235 | }
|
---|
236 |
|
---|
237 | if (!InterpreteCC(str, ver))
|
---|
238 | return kCONTINUE;
|
---|
239 |
|
---|
240 | if (!InterpreteTH(str))
|
---|
241 | return kCONTINUE;
|
---|
242 |
|
---|
243 | if (!InterpreteTD(str, ver))
|
---|
244 | return kCONTINUE;
|
---|
245 |
|
---|
246 | if (ver>=200510250)
|
---|
247 | if (!InterpreteRecTemp(str))
|
---|
248 | return kCONTINUE;
|
---|
249 |
|
---|
250 | if (str.Strip(TString::kBoth)!=(TString)"OVER")
|
---|
251 | {
|
---|
252 | *fLog << warn << "WARNING - 'OVER' tag not found." << endl;
|
---|
253 | return kCONTINUE;
|
---|
254 | }
|
---|
255 |
|
---|
256 | return kTRUE;
|
---|
257 | }
|
---|
258 |
|
---|
259 | // --------------------------------------------------------------------------
|
---|
260 | //
|
---|
261 | // Print contents of report
|
---|
262 | //
|
---|
263 | void MReportCC::Print(Option_t *opt) const
|
---|
264 | {
|
---|
265 | *fLog << all << GetDescriptor() << ": Status=" << (int)GetState();
|
---|
266 | *fLog << " Hum=" << Form("%3.0f", fHumidity);
|
---|
267 | *fLog << "% Temp=" << Form("%+3.0f", fTemperature);
|
---|
268 | *fLog << "°C Wind=" << Form("%3.0f", fWindSpeed);
|
---|
269 | *fLog << "km/h SolarRad=" << Form("%4.0f", fSolarRadiation) << "W/m^2" << endl;
|
---|
270 | }
|
---|