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 |
|
---|
37 | ClassImp(MReport);
|
---|
38 |
|
---|
39 | using namespace std;
|
---|
40 |
|
---|
41 | Bool_t MReport::InterpreteHeader(TString &str)
|
---|
42 | {
|
---|
43 | int len, state;
|
---|
44 | int hor, min, sec, ms;
|
---|
45 |
|
---|
46 | int n = sscanf(str.Data(),
|
---|
47 | " %d %*d %*d %*d %d %d %d %d "
|
---|
48 | "%*d %*d %*d %*d %*d %*d %*d %*d"
|
---|
49 | "%n",
|
---|
50 | &state, &hor, &min, &sec, &ms, &len);
|
---|
51 | if (n!=5)
|
---|
52 | {
|
---|
53 | *fLog << err << "ERROR - Cannot interprete Body of " << fIdentifier << endl;
|
---|
54 | return kFALSE;
|
---|
55 | }
|
---|
56 |
|
---|
57 | fState=state;
|
---|
58 | if (fTime)
|
---|
59 | fTime->SetTime(hor, min, sec, ms*1000000);
|
---|
60 |
|
---|
61 | str.Remove(0, len);
|
---|
62 | return kTRUE;
|
---|
63 | }
|
---|
64 |
|
---|
65 | Bool_t MReport::InterpreteBody(TString &str)
|
---|
66 | {
|
---|
67 | *fLog << warn << "No interpreter existing for: " << fIdentifier << endl;
|
---|
68 | return kTRUE;
|
---|
69 | }
|
---|
70 |
|
---|
71 | Bool_t MReport::Interprete(TString &str)
|
---|
72 | {
|
---|
73 | if (!InterpreteHeader(str))
|
---|
74 | return kFALSE;
|
---|
75 |
|
---|
76 | if (!InterpreteBody(str))
|
---|
77 | return kFALSE;
|
---|
78 |
|
---|
79 | SetReadyToSave();
|
---|
80 | if (fTime)
|
---|
81 | fTime->SetReadyToSave();
|
---|
82 |
|
---|
83 | return kTRUE;
|
---|
84 | }
|
---|
85 |
|
---|
86 | Bool_t MReport::SetupReading(MParList &plist)
|
---|
87 | {
|
---|
88 | fTime = NULL;
|
---|
89 |
|
---|
90 | TString id(ClassName());
|
---|
91 | if (!id.BeginsWith("MReport"))
|
---|
92 | {
|
---|
93 | *fLog << warn << " WARNING - Class name '" << id << "' ";
|
---|
94 | *fLog << " doesn't begin with 'MReport'... no MTime assigned." << endl;
|
---|
95 | return kFALSE;
|
---|
96 | }
|
---|
97 |
|
---|
98 | id.Remove(0, 7);
|
---|
99 | if (id.IsNull())
|
---|
100 | {
|
---|
101 | *fLog << warn << " WARNING - No postfix existing... no MTime assigned." << endl;
|
---|
102 | return kFALSE;
|
---|
103 | }
|
---|
104 |
|
---|
105 | id.Prepend("MTime");
|
---|
106 |
|
---|
107 | fTime = (MTime*)plist.FindCreateObj("MTime", id);
|
---|
108 | if (!fTime)
|
---|
109 | return kFALSE;
|
---|
110 |
|
---|
111 | return kTRUE;
|
---|
112 | }
|
---|