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 | 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 | TString str2 = str(0, pos2);
|
---|
152 |
|
---|
153 | str.Remove(0, pos2);
|
---|
154 |
|
---|
155 | // Remove a leading minus. The negative numbers are error codes introduced
|
---|
156 | // by Arehucas. It's only meant for the GRB monitor to change the priority
|
---|
157 | // of its alerts.
|
---|
158 | if (str2[0]=='-')
|
---|
159 | str2.Remove(0, 1);
|
---|
160 |
|
---|
161 | if (!str2.IsDigit())
|
---|
162 | {
|
---|
163 | *fLog << warn << "WARNING - Wrong type of second argument (obs. category): " << str2 << endl;
|
---|
164 | return kFALSE;
|
---|
165 | }
|
---|
166 | }
|
---|
167 | }
|
---|
168 |
|
---|
169 | return kTRUE;
|
---|
170 | }
|
---|
171 |
|
---|
172 | // --------------------------------------------------------------------------
|
---|
173 | //
|
---|
174 | // Interprete the body of the CC-REPORT string
|
---|
175 | //
|
---|
176 | Int_t MReportCC::InterpreteBody(TString &str, Int_t ver)
|
---|
177 | {
|
---|
178 | if (ver<200404070)
|
---|
179 | {
|
---|
180 | *fLog << err << "ERROR - MReportCC::InterpreteBody not prepared for ";
|
---|
181 | *fLog << " report-files with version<200404070" << endl;
|
---|
182 | return kFALSE;
|
---|
183 | }
|
---|
184 |
|
---|
185 | if (!InterpreteCC(str, ver))
|
---|
186 | return kCONTINUE;
|
---|
187 |
|
---|
188 | if (ver<200805190)
|
---|
189 | {
|
---|
190 | fRecRep->InterpreteRec(str, ver, *fTH, *fTD, *fRecTemp);
|
---|
191 | Copy(*fRecRep);
|
---|
192 | fRecRep->SetReadyToSave();
|
---|
193 | }
|
---|
194 |
|
---|
195 | if (str.Strip(TString::kBoth)!=(TString)"OVER")
|
---|
196 | {
|
---|
197 | *fLog << warn << "WARNING - 'OVER' tag not found." << endl;
|
---|
198 | return kCONTINUE;
|
---|
199 | }
|
---|
200 |
|
---|
201 | return kTRUE;
|
---|
202 | }
|
---|
203 |
|
---|
204 | // --------------------------------------------------------------------------
|
---|
205 | //
|
---|
206 | // Print contents of report
|
---|
207 | //
|
---|
208 | void MReportCC::Print(Option_t *opt) const
|
---|
209 | {
|
---|
210 | *fLog << all << GetDescriptor() << ": Status=" << (int)GetState();
|
---|
211 | *fLog << " Hum=" << Form("%3.0f", fHumidity);
|
---|
212 | *fLog << "% Temp=" << Form("%+3.0f", fTemperature);
|
---|
213 | *fLog << "°C Wind=" << Form("%3.0f", fWindSpeed);
|
---|
214 | *fLog << "km/h SolarRad=" << Form("%4.0f", fSolarRadiation) << "W/m^2" << endl;
|
---|
215 | }
|
---|