source: trunk/MagicSoft/Mars/mreport/MReportCamera.cc@ 2591

Last change on this file since 2591 was 2591, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 11.7 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// MReportCamera
28//
29// This is the class interpreting and storing the CAMERA-REPORT information.
30//
31// Most of the information is redirected to the classes MCamera* and stored
32// there.
33//
34//////////////////////////////////////////////////////////////////////////////
35#include "MReportCamera.h"
36
37#include "MLogManip.h"
38
39#include "MAstro.h"
40#include "MParList.h"
41
42#include "MCameraCalibration.h"
43#include "MCameraCooling.h"
44#include "MCameraHV.h"
45#include "MCameraLV.h"
46#include "MCameraAUX.h"
47#include "MCameraLids.h"
48
49ClassImp(MReportCamera);
50
51using namespace std;
52
53MReportCamera::MReportCamera() : MReport("CAMERA-REPORT")
54{
55 fName = "MReportCamera";
56}
57
58Bool_t MReportCamera::SetupReading(MParList &plist)
59{
60 fCooling = (MCameraCooling*)plist.FindCreateObj("MCameraCooling");
61 if (!fCooling)
62 return kFALSE;
63
64 fLids = (MCameraLids*)plist.FindCreateObj("MCameraLids");
65 if (!fLids)
66 return kFALSE;
67
68 fAUX = (MCameraAUX*)plist.FindCreateObj("MCameraAUX");
69 if (!fAUX)
70 return kFALSE;
71
72 fHV = (MCameraHV*)plist.FindCreateObj("MCameraHV");
73 if (!fHV)
74 return kFALSE;
75
76 fLV = (MCameraLV*)plist.FindCreateObj("MCameraLV");
77 if (!fLV)
78 return kFALSE;
79
80 fCalibration = (MCameraCalibration*)plist.FindCreateObj("MCameraCalibration");
81 if (!fCalibration)
82 return kFALSE;
83
84 return MReport::SetupReading(plist);
85}
86
87Bool_t MReportCamera::CheckTag(TString &str, const char *tag) const
88{
89 if (!str.BeginsWith(tag))
90 {
91 *fLog << err << "ERROR - '" << tag << "' tag not found." << endl;
92 return kFALSE;
93 }
94 str.Remove(0, strlen(tag)); // Remove DC currents
95 return kTRUE;
96}
97
98Bool_t MReportCamera::InterpreteDC(TString &str)
99{
100 if (!CheckTag(str, "DC "))
101 return kFALSE;
102
103 str.Remove(0, 577*4); // Remove DC currents
104 str=str.Strip(TString::kLeading);
105 return kTRUE;
106}
107
108Bool_t MReportCamera::InterpreteHV(TString &str)
109{
110 if (!CheckTag(str, "HV "))
111 return kFALSE;
112
113 const char *pos = str.Data();
114 const char *end = str.Data()+577*3;
115
116 Int_t i=0;
117 while (pos<end)
118 {
119 const Char_t hex[4] = { pos[0], pos[1], pos[2], 0 };
120 pos += 3;
121
122 const Int_t n=sscanf(hex, "%3hx", &fHV->fHV[i++]);
123 if (n==1)
124 continue;
125
126 *fLog << err << "ERROR - Reading hexadecimal HV information." << endl;
127 return kFALSE;
128 }
129
130 str.Remove(0, end-str.Data()); // Remove DC currents
131 str=str.Strip(TString::kLeading);
132 return kTRUE;
133}
134
135Bool_t MReportCamera::InterpreteCOOL(TString &str)
136{
137 if (!CheckTag(str, "COOL "))
138 return kFALSE;
139
140 Int_t len;
141
142 Int_t wall, opt, center, water;
143 Short_t hwall, hcenter, hip, lop, pump, ref, valv, res, fans;
144 const Int_t n=sscanf(str.Data(), "%d %d %d %d %hu %hu %hu %hu %hu %hu %hu %hu %hu %n",
145 &wall, &opt, &center, &water, &hwall, &hcenter,
146 &hip, &lop, &pump, &ref, &valv, &res, &fans, &len);
147 if (n!=13)
148 {
149 *fLog << err << "ERROR - Reading information of 'COOL' section." << endl;
150 return kFALSE;
151 }
152
153 fCooling->fTempWall = 0.1*wall;
154 fCooling->fTempOptLink = 0.1*opt;
155 fCooling->fTempCenter = 0.1*center;
156 fCooling->fTempWater = 0.1*water;
157 fCooling->fHumWall = (Byte_t)hwall;
158 fCooling->fHumCenter = (Byte_t)hcenter;
159 fCooling->fStatusPressureHi = (Bool_t)hip;
160 fCooling->fStatusPressureLo = (Bool_t)lop;
161 fCooling->fStatusPump = (Bool_t)pump;
162 fCooling->fStatusRefrigrerator = (Bool_t)ref;
163 fCooling->fStatusValve = (Bool_t)valv;
164 fCooling->fStatusResistor = (Bool_t)res;
165 fCooling->fStatusFans = (Bool_t)fans;
166
167 str.Remove(0, len);
168 str=str.Strip(TString::kLeading);
169 return kTRUE;
170}
171
172Bool_t MReportCamera::InterpreteLID(TString &str)
173{
174 if (!CheckTag(str, "LID "))
175 return kFALSE;
176
177 Int_t len;
178 Short_t limao, limac, limbo, limbc;
179 Short_t slimao, slimac, slimbo, slimbc;
180 Short_t slida, slidb, mlida, mlidb;
181 const Int_t n=sscanf(str.Data(), "%hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %n",
182 &limao, &limac, &limbo, &limbc,
183 &slimao, &slimac, &slimbo, &slimbc,
184 &slida, &slidb, &mlida, &mlidb,
185 &len);
186 if (n!=12)
187 {
188 *fLog << err << "ERROR - Reading information of 'LID' section." << endl;
189 return kFALSE;
190 }
191
192 fLids->fLidA.fLimitOpen = (Bool_t)limao;
193 fLids->fLidA.fLimitClose = (Bool_t)limac;
194 fLids->fLidA.fSafetyLimitOpen = (Bool_t)slimao;
195 fLids->fLidA.fSafetyLimitClose= (Bool_t)slimac;
196 fLids->fLidA.fStatusLid = (Byte_t)slida;
197 fLids->fLidA.fStatusMotor = (Byte_t)mlida;
198
199 fLids->fLidB.fLimitOpen = (Bool_t)limbo;
200 fLids->fLidB.fLimitClose = (Bool_t)limbc;
201 fLids->fLidB.fSafetyLimitOpen = (Bool_t)slimbo;
202 fLids->fLidB.fSafetyLimitClose= (Bool_t)slimbc;
203 fLids->fLidB.fStatusLid = (Byte_t)slidb;
204 fLids->fLidB.fStatusMotor = (Byte_t)mlidb;
205
206 str.Remove(0, len);
207 str=str.Strip(TString::kLeading);
208 return kTRUE;
209}
210
211Bool_t MReportCamera::InterpreteHVPS(TString &str)
212{
213 if (!CheckTag(str, "HVPS "))
214 return kFALSE;
215
216 Int_t len;
217 Short_t c1, c2;
218 const Int_t n=sscanf(str.Data(), "%hd %hd %hd %hd %n",
219 &fHV->fVoltageA, &fHV->fVoltageB, &c1, &c2, &len);
220 if (n!=4)
221 {
222 *fLog << err << "ERROR - Reading information of 'HVPS' section." << endl;
223 return kFALSE;
224 }
225
226 fHV->fCurrentA = (Byte_t)c1;
227 fHV->fCurrentB = (Byte_t)c2;
228
229 str.Remove(0, len);
230 str=str.Strip(TString::kLeading);
231 return kTRUE;
232}
233
234Bool_t MReportCamera::InterpreteLV(TString &str)
235{
236 if (!CheckTag(str, "LV "))
237 return kFALSE;
238
239 Int_t len;
240 Short_t vap5, vap12, van12, vbp5, vbp12, vbn12;
241 Short_t valp12, vblp12, cap5, cap12, can12, cbp5, cbp12;
242 Short_t cbn12, calp12, cblp12, lvps, temp, hum;
243 const Int_t n=sscanf(str.Data(), "%hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %n",
244 &vap5, &vap12, &van12, &vbp5, &vbp12, &vbn12,
245 &valp12, &vblp12, &cap5, &cap12, &can12, &cbp5, &cbp12,
246 &cbn12, &calp12, &cblp12, &lvps, &temp, &hum, &len);
247 if (n!=19)
248 {
249 *fLog << err << "ERROR - Reading information of 'LV' section." << endl;
250 return kFALSE;
251 }
252
253 fLV->fRequestPowerSupply = (Bool_t)lvps;
254 fLV->fTemp = 0.1*temp;
255 fLV->fHumidity = (Byte_t)hum;
256
257 fLV->fPowerSupplyA.fVoltagePos5V = 0.01*vap5;
258 fLV->fPowerSupplyA.fVoltagePos12V = 0.01*vap12;
259 fLV->fPowerSupplyA.fVoltageNeg12V = 0.01*van12;
260 fLV->fPowerSupplyA.fVoltageOptLinkPos12V = 0.01*valp12;
261 fLV->fPowerSupplyA.fCurrentPos5V = 0.001*cap5;
262 fLV->fPowerSupplyA.fCurrentPos12V = 0.001*cap12;
263 fLV->fPowerSupplyA.fCurrentNeg12V = 0.001*can12;
264 fLV->fPowerSupplyA.fCurrentOptLinkPos12V = 0.001*calp12;
265
266 fLV->fPowerSupplyB.fVoltagePos5V = 0.01*vbp5;
267 fLV->fPowerSupplyB.fVoltagePos12V = 0.01*vbp12;
268 fLV->fPowerSupplyB.fVoltageNeg12V = 0.01*vbn12;
269 fLV->fPowerSupplyB.fVoltageOptLinkPos12V = 0.01*vblp12;
270 fLV->fPowerSupplyB.fCurrentPos5V = 0.001*cbp5;
271 fLV->fPowerSupplyB.fCurrentPos12V = 0.001*cbp12;
272 fLV->fPowerSupplyB.fCurrentNeg12V = 0.001*cbn12;
273 fLV->fPowerSupplyB.fCurrentOptLinkPos12V = 0.001*cblp12;
274
275 str.Remove(0, len);
276 str=str.Strip(TString::kLeading);
277 return kTRUE;
278}
279
280Bool_t MReportCamera::InterpreteAUX(TString &str)
281{
282 if (!CheckTag(str, "AUX "))
283 return kFALSE;
284
285 Int_t len;
286 Short_t led, fan;
287 const Int_t n=sscanf(str.Data(), "%hd %hd %n", &led, &fan, &len);
288 if (n!=2)
289 {
290 *fLog << err << "ERROR - Reading information of 'AUX' section." << endl;
291 return kFALSE;
292 }
293
294 fAUX->fRequestCaosLEDs=(Bool_t)led;
295 fAUX->fRequestFansFADC=(Bool_t)fan;
296
297 str.Remove(0, len);
298 str=str.Strip(TString::kLeading);
299 return kTRUE;
300}
301
302Bool_t MReportCamera::InterpreteCAL(TString &str)
303{
304 if (!CheckTag(str, "CAL "))
305 return kFALSE;
306
307 Int_t len;
308 Short_t hv, lv, cont, pin;
309
310 const Int_t n=sscanf(str.Data(), "%hd %hd %hd %hd %n", &hv, &lv, &cont, &pin, &len);
311 if (n!=4)
312 {
313 *fLog << err << "ERROR - Reading information of 'CAL' section." << endl;
314 return kFALSE;
315 }
316
317 fCalibration->fRequestHiVoltage = (Bool_t)hv;
318 fCalibration->fRequestLoVoltage = (Bool_t)lv;
319 fCalibration->fRequestContLight = (Bool_t)cont;
320 fCalibration->fRequestPinDiode = (Bool_t)pin;
321
322 str.Remove(0, len);
323 str=str.Strip(TString::kBoth);
324 return kTRUE;
325}
326
327Bool_t MReportCamera::InterpreteCamera(TString &str)
328{
329 //
330 // I have tried to do it with pure pointer arithmentics, but most of the time is spent
331 // to do the sscanf. So we gain less than 5% not using TString like it is done here.
332 Int_t len;
333 Short_t cal, stat, hvps, lid, lv, cool, hv, dc, led, fan, can, io, clv;
334 Int_t n=sscanf(str.Data(), " %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %n",
335 &cal, &stat, &hvps, &lid, &lv, &cool, &hv,
336 &dc, &led, &fan, &can, &io, &clv, &len);
337 if (n!=13)
338 {
339 *fLog << err << "ERROR - Cannot interprete status' of subsystems." << endl;
340 return kFALSE;
341 }
342 str.Remove(0, len);
343 str=str.Strip(TString::kLeading);
344
345 fHV->fStatus = (Byte_t)hvps;
346 fLids->fStatus = (Byte_t)lid;
347 fLV->fStatus = (Byte_t)lv;
348 fCooling->fStatus = (Byte_t)cool;
349 fHV->fStatusRamping = (Byte_t)hv;
350 fAUX->fStatusCaosLEDs = (Bool_t)led;
351 fAUX->fStatusFansFADC = (Bool_t)fan;
352 fCalibration->fStatus = (Bool_t)cal;
353 fCalibration->fStatusCANbus = (Bool_t)can;
354 fCalibration->fStatusIO = (Bool_t)io;
355 fCalibration->fStatusLoVoltage = (Bool_t)clv;
356 fStatus = (Byte_t)stat;
357 fStatusDC = (Byte_t)dc;
358
359 return kTRUE;
360}
361
362Bool_t MReportCamera::InterpreteBody(TString &str)
363{
364 if (!InterpreteCamera(str))
365 return kFALSE;
366
367 if (!InterpreteDC(str))
368 return kFALSE;
369
370 if (!InterpreteHV(str))
371 return kFALSE;
372
373 if (!InterpreteCOOL(str))
374 return kFALSE;
375
376 if (!InterpreteLID(str))
377 return kFALSE;
378
379 if (!InterpreteHVPS(str))
380 return kFALSE;
381
382 if (!InterpreteLV(str))
383 return kFALSE;
384
385 if (!InterpreteAUX(str))
386 return kFALSE;
387
388 if (!InterpreteCAL(str))
389 return kFALSE;
390
391 if (str!="OVER")
392 {
393 *fLog << err << "ERROR - 'OVER' tag not found." << endl;
394 return kFALSE;
395 }
396
397 return kTRUE;
398}
Note: See TracBrowser for help on using the repository browser.