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

Last change on this file since 2563 was 2557, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 2.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, 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//////////////////////////////////////////////////////////////////////////////
30#include "MReport.h"
31
32#include "MLogManip.h"
33
34#include "MTime.h"
35#include "MParList.h"
36
37ClassImp(MReport);
38
39using namespace std;
40
41Bool_t MReport::InterpreteHeader(TString &str)
42{
43 int len, state;
44 int hor, min, sec, ms;
45
46 int n = sscanf(str.Data(),
47 fHasReportTime ?
48 " %d %*d %*d %*d %d %d %d %d "
49 "%*d %*d %*d %*d %*d %*d %*d %*d %n" :
50 " %d %*d %*d %*d %d %d %d %d ",
51 &state, &hor, &min, &sec, &ms, &len);
52 if (n!=5)
53 {
54 *fLog << err << "ERROR - Cannot interprete Body of " << fIdentifier << endl;
55 return kFALSE;
56 }
57
58 fState=state;
59 if (fTime)
60 fTime->SetTime(hor, min, sec, ms*1000000);
61
62 str.Remove(0, len);
63 return kTRUE;
64}
65
66Bool_t MReport::InterpreteBody(TString &str)
67{
68 *fLog << warn << "No interpreter existing for: " << fIdentifier << endl;
69 return kTRUE;
70}
71
72Bool_t MReport::Interprete(TString &str)
73{
74 if (!InterpreteHeader(str))
75 return kFALSE;
76
77 if (!InterpreteBody(str))
78 return kFALSE;
79
80 SetReadyToSave();
81 if (fTime)
82 fTime->SetReadyToSave();
83
84 return kTRUE;
85}
86
87Bool_t MReport::SetupReading(MParList &plist)
88{
89 fTime = NULL;
90
91 TString id(ClassName());
92 if (!id.BeginsWith("MReport"))
93 {
94 *fLog << warn << " WARNING - Class name '" << id << "' ";
95 *fLog << " doesn't begin with 'MReport'... no MTime assigned." << endl;
96 return kFALSE;
97 }
98
99 id.Remove(0, 7);
100 if (id.IsNull())
101 {
102 *fLog << warn << " WARNING - No postfix existing... no MTime assigned." << endl;
103 return kFALSE;
104 }
105
106 id.Prepend("MTime");
107
108 fTime = (MTime*)plist.FindCreateObj("MTime", id);
109 if (!fTime)
110 return kFALSE;
111
112 return kTRUE;
113}
Note: See TracBrowser for help on using the repository browser.