source: trunk/MagicSoft/Mars/mreport/MReport.cc@ 2592

Last change on this file since 2592 was 2591, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 4.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, 11/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2003
21!
22!
23\* ======================================================================== */
24
25//////////////////////////////////////////////////////////////////////////////
26//
27// MReport
28//
29// This is a base class for all reports comming from subsystems stored in
30// a report file.
31//
32// Be carefull: The class name of all classes derived from this class
33// should start with 'MReport', see SetupReading
34//
35//////////////////////////////////////////////////////////////////////////////
36#include "MReport.h"
37
38#include "MLogManip.h"
39
40#include "MTime.h"
41#include "MParList.h"
42
43ClassImp(MReport);
44
45using namespace std;
46
47// --------------------------------------------------------------------------
48//
49// Interpretes the beginning of a line which starts like:
50// status hour minute second millisec skip skip skip skip skip
51// The identifier is assumed to be removed.
52//
53// While skip are numbers which won't enter the analysis
54//
55Bool_t MReport::InterpreteHeader(TString &str)
56{
57 int len, state;
58 int hor, min, sec, ms;
59
60 int n = sscanf(str.Data(),
61 fHasReportTime ?
62 " %d %*d %*d %*d %d %d %d %d "
63 "%*d %*d %*d %*d %*d %*d %*d %*d %n" :
64 " %d %*d %*d %*d %d %d %d %d ",
65 &state, &hor, &min, &sec, &ms, &len);
66 if (n!=5)
67 {
68 *fLog << err << "ERROR - Cannot interprete Body of " << fIdentifier << endl;
69 return kFALSE;
70 }
71
72 fState=state;
73 if (fTime)
74 fTime->SetTime(hor, min, sec, ms*1000000);
75
76 str.Remove(0, len);
77 return kTRUE;
78}
79
80// --------------------------------------------------------------------------
81//
82// Report Body must be overwritten. It will get the line idetified to belong
83// to fIdentifier without the leading status and time infomration as an
84// argument.
85//
86Bool_t MReport::InterpreteBody(TString &str)
87{
88 *fLog << warn << "No interpreter existing for: " << fIdentifier << endl;
89 return kTRUE;
90}
91
92// --------------------------------------------------------------------------
93//
94// Interprets Header and Body of a report file line. Calls SetReadyToSave()
95// in case the interpretation was successfull. And fTime->SetReadyToSave()
96// when a corresponding time container exists.
97//
98Bool_t MReport::Interprete(TString &str)
99{
100 if (!InterpreteHeader(str))
101 return kFALSE;
102
103 if (!InterpreteBody(str))
104 return kFALSE;
105
106 SetReadyToSave();
107 if (fTime)
108 fTime->SetReadyToSave();
109
110 return kTRUE;
111}
112
113// --------------------------------------------------------------------------
114//
115// Check for the existance of a corresponding MTime in the given parameter
116// list. If it is not found a new one will be created. The name of the
117// MTime object is created by taking the ClassName() of the derived MReport
118// class and stripping the leading MReport
119//
120Bool_t MReport::SetupReading(MParList &plist)
121{
122 fTime = NULL;
123
124 TString id(ClassName());
125 if (!id.BeginsWith("MReport"))
126 {
127 *fLog << warn << " WARNING - Class name '" << id << "' ";
128 *fLog << " doesn't begin with 'MReport'... no MTime assigned." << endl;
129 return kFALSE;
130 }
131
132 id.Remove(0, 7);
133 if (id.IsNull())
134 {
135 *fLog << warn << " WARNING - No postfix existing... no MTime assigned." << endl;
136 return kFALSE;
137 }
138
139 id.Prepend("MTime");
140
141 fTime = (MTime*)plist.FindCreateObj("MTime", id);
142 if (!fTime)
143 return kFALSE;
144
145 return kTRUE;
146}
Note: See TracBrowser for help on using the repository browser.