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

Last change on this file since 9030 was 8963, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 4.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 cout << n << endl;
117 *fLog << warn << "WARNING - Wrong number of arguments (should be 6)." << endl;
118 return kFALSE;
119 }
120
121 str.Remove(0, len);
122
123 return kTRUE;
124}
125
126// --------------------------------------------------------------------------
127//
128// Interprete the body of the CC-REPORT string
129//
130Int_t MReportCC::InterpreteBody(TString &str, Int_t ver)
131{
132 if (ver<200404070)
133 {
134 *fLog << err << "ERROR - MReportCC::InterpreteBody not prepared for ";
135 *fLog << " report-files with version<200404070" << endl;
136 return kFALSE;
137 }
138
139 if (!InterpreteCC(str, ver))
140 return kCONTINUE;
141
142 if (ver<200805190)
143 {
144 fRecRep->InterpreteRec(str, ver, *fTH, *fTD, *fRecTemp);
145 Copy(*fRecRep);
146 fRecRep->SetReadyToSave();
147 }
148
149 if (str.Strip(TString::kBoth)!=(TString)"OVER")
150 {
151 *fLog << warn << "WARNING - 'OVER' tag not found." << endl;
152 return kCONTINUE;
153 }
154
155 return kTRUE;
156}
157
158// --------------------------------------------------------------------------
159//
160// Print contents of report
161//
162void MReportCC::Print(Option_t *opt) const
163{
164 *fLog << all << GetDescriptor() << ": Status=" << (int)GetState();
165 *fLog << " Hum=" << Form("%3.0f", fHumidity);
166 *fLog << "% Temp=" << Form("%+3.0f", fTemperature);
167 *fLog << "°C Wind=" << Form("%3.0f", fWindSpeed);
168 *fLog << "km/h SolarRad=" << Form("%4.0f", fSolarRadiation) << "W/m^2" << endl;
169}
Note: See TracBrowser for help on using the repository browser.