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

Last change on this file since 9206 was 9059, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 17.9 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! Author(s): Daniel Mazin, 04/2005 <mailto:mazin@mppmu.mpg.de>
20!
21! Copyright: MAGIC Software Development, 2000-2008
22!
23!
24\* ======================================================================== */
25
26//////////////////////////////////////////////////////////////////////////////
27//
28// MReportCamera
29//
30// This is the class interpreting and storing the CAMERA-REPORT information.
31//
32// Most of the information is redirected to the classes MCamera* and stored
33// there.
34//
35// Version 2:
36// ----------
37// - fStstusDC
38//
39//////////////////////////////////////////////////////////////////////////////
40#include "MReportCamera.h"
41
42#include "MLogManip.h"
43
44#include "MAstro.h"
45#include "MParList.h"
46
47#include "MCameraCalibration.h"
48#include "MCameraCooling.h"
49#include "MCameraDC.h"
50#include "MCameraHV.h"
51#include "MCameraLV.h"
52#include "MCameraAUX.h"
53#include "MCameraActiveLoad.h"
54#include "MCameraCentralPix.h"
55#include "MCameraLids.h"
56
57ClassImp(MReportCamera);
58
59using namespace std;
60
61// --------------------------------------------------------------------------
62//
63// Default construtor. Initialize identifier to "CAMERA-REPORT"
64//
65MReportCamera::MReportCamera() : MReport("CAMERA-REPORT")
66{
67 fName = "MReportCamera";
68 fTitle = "Class for CAMERA-REPORT information";
69}
70
71// --------------------------------------------------------------------------
72//
73// FindCreate the following objects:
74// - MCameraCooling
75// - MCameraLids
76// - MCameraAUX
77// - MCameraHV
78// - MCameraLV
79// - MCameraCalibration
80//
81Bool_t MReportCamera::SetupReading(MParList &plist)
82{
83 fCooling = (MCameraCooling*)plist.FindCreateObj("MCameraCooling");
84 if (!fCooling)
85 return kFALSE;
86
87 fLids = (MCameraLids*)plist.FindCreateObj("MCameraLids");
88 if (!fLids)
89 return kFALSE;
90
91 fAUX = (MCameraAUX*)plist.FindCreateObj("MCameraAUX");
92 if (!fAUX)
93 return kFALSE;
94
95 fHV = (MCameraHV*)plist.FindCreateObj("MCameraHV");
96 if (!fHV)
97 return kFALSE;
98
99 fDC = (MCameraDC*)plist.FindCreateObj("MCameraDC");
100 if (!fDC)
101 return kFALSE;
102
103 fLV = (MCameraLV*)plist.FindCreateObj("MCameraLV");
104 if (!fLV)
105 return kFALSE;
106
107 fCalibration = (MCameraCalibration*)plist.FindCreateObj("MCameraCalibration");
108 if (!fCalibration)
109 return kFALSE;
110
111 fActiveLoad = (MCameraActiveLoad*)plist.FindCreateObj("MCameraActiveLoad");
112 if (!fActiveLoad)
113 return kFALSE;
114
115 fCentralPix = (MCameraCentralPix*)plist.FindCreateObj("MCameraCentralPix");
116 if (!fCentralPix)
117 return kFALSE;
118
119 return MReport::SetupReading(plist);
120}
121
122// --------------------------------------------------------------------------
123//
124// Interprete the DC* part of the report
125//
126Bool_t MReportCamera::InterpreteDC(TString &str)
127{
128 if (!CheckTag(str, "DC "))
129 return kFALSE;
130
131 return fDC->Interprete(str);
132}
133
134// --------------------------------------------------------------------------
135//
136// Interprete the HV* part of the report
137//
138Bool_t MReportCamera::InterpreteHV(TString &str)
139{
140 if (!CheckTag(str, "HV "))
141 return kFALSE;
142
143 const char *pos = str.Data();
144 const char *end = str.Data()+577*3;
145
146 Int_t i=0;
147 while (pos<end)
148 {
149 const Char_t hex[4] = { pos[0], pos[1], pos[2], 0 };
150 pos += 3;
151
152 const Int_t n=sscanf(hex, "%3hx", &fHV->fHV[i++]);
153 if (n==1)
154 continue;
155
156 *fLog << warn << "WARNING - Reading hexadecimal HV information." << endl;
157 return kFALSE;
158 }
159
160 str.Remove(0, end-str.Data()); // Remove DC currents
161 str=str.Strip(TString::kLeading);
162 return kTRUE;
163}
164
165// --------------------------------------------------------------------------
166//
167// Interprete the COOL* part of the report
168//
169Bool_t MReportCamera::InterpreteCOOL(TString &str)
170{
171 if (!CheckTag(str, "COOL "))
172 return kFALSE;
173
174 Int_t len;
175
176 Int_t wall, opt, center, water;
177 Short_t hwall, hcenter, hip, lop, pump, ref, valv, res, fans;
178 const Int_t n=sscanf(str.Data(), "%d %d %d %d %hu %hu %hu %hu %hu %hu %hu %hu %hu %n",
179 &wall, &opt, &center, &water, &hwall, &hcenter,
180 &hip, &lop, &pump, &ref, &valv, &res, &fans, &len);
181 if (n!=13)
182 {
183 *fLog << warn << "WARNING - Reading information of 'COOL' section." << endl;
184 return kFALSE;
185 }
186
187 fCooling->fTempWall = 0.1*wall;
188 fCooling->fTempOptLink = 0.1*opt;
189 fCooling->fTempCenter = 0.1*center;
190 fCooling->fTempWater = 0.1*water;
191 fCooling->fHumWall = (Byte_t)hwall;
192 fCooling->fHumCenter = (Byte_t)hcenter;
193 fCooling->fStatusPressureHi = (Bool_t)hip;
194 fCooling->fStatusPressureLo = (Bool_t)lop;
195 fCooling->fStatusPump = (Bool_t)pump;
196 fCooling->fStatusRefrigrerator = (Bool_t)ref;
197 fCooling->fStatusValve = (Bool_t)valv;
198 fCooling->fStatusResistor = (Bool_t)res;
199 fCooling->fStatusFans = (Bool_t)fans;
200
201 str.Remove(0, len);
202 str=str.Strip(TString::kLeading);
203 return kTRUE;
204}
205
206// --------------------------------------------------------------------------
207//
208// Interprete the LID* part of the report
209//
210Bool_t MReportCamera::InterpreteLID(TString &str)
211{
212 if (!CheckTag(str, "LID "))
213 return kFALSE;
214
215 Int_t len;
216 Short_t limao, limac, limbo, limbc;
217 Short_t slimao, slimac, slimbo, slimbc;
218 Short_t slida, slidb, mlida, mlidb;
219 const Int_t n=sscanf(str.Data(), "%hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %n",
220 &limao, &limac, &limbo, &limbc,
221 &slimao, &slimac, &slimbo, &slimbc,
222 &slida, &slidb, &mlida, &mlidb,
223 &len);
224 if (n!=12)
225 {
226 *fLog << warn << "WARNING - Reading information of 'LID' section." << endl;
227 return kFALSE;
228 }
229
230 fLids->fLidA.fLimitOpen = (Bool_t)limao;
231 fLids->fLidA.fLimitClose = (Bool_t)limac;
232 fLids->fLidA.fSafetyLimitOpen = (Bool_t)slimao;
233 fLids->fLidA.fSafetyLimitClose= (Bool_t)slimac;
234 fLids->fLidA.fStatusLid = (Byte_t)slida;
235 fLids->fLidA.fStatusMotor = (Byte_t)mlida;
236
237 fLids->fLidB.fLimitOpen = (Bool_t)limbo;
238 fLids->fLidB.fLimitClose = (Bool_t)limbc;
239 fLids->fLidB.fSafetyLimitOpen = (Bool_t)slimbo;
240 fLids->fLidB.fSafetyLimitClose= (Bool_t)slimbc;
241 fLids->fLidB.fStatusLid = (Byte_t)slidb;
242 fLids->fLidB.fStatusMotor = (Byte_t)mlidb;
243
244 str.Remove(0, len);
245 str=str.Strip(TString::kLeading);
246 return kTRUE;
247}
248
249// --------------------------------------------------------------------------
250//
251// Interprete the HVPS* part of the report
252//
253Bool_t MReportCamera::InterpreteHVPS(TString &str)
254{
255 if (!CheckTag(str, "HVPS "))
256 return kFALSE;
257
258 Int_t len;
259 Short_t c1, c2;
260 const Int_t n=sscanf(str.Data(), "%hd %hd %hd %hd %n",
261 &fHV->fVoltageA, &fHV->fVoltageB, &c1, &c2, &len);
262 if (n!=4)
263 {
264 *fLog << warn << "WARNING - Reading information of 'HVPS' section." << endl;
265 return kFALSE;
266 }
267
268 fHV->fCurrentA = (Byte_t)c1;
269 fHV->fCurrentB = (Byte_t)c2;
270
271 str.Remove(0, len);
272 str=str.Strip(TString::kLeading);
273 return kTRUE;
274}
275
276// --------------------------------------------------------------------------
277//
278// Interprete the LV* part of the report
279//
280Bool_t MReportCamera::InterpreteLV(TString &str)
281{
282 if (!CheckTag(str, "LV "))
283 return kFALSE;
284
285 Int_t len;
286 Short_t vap5, vap12, van12, vbp5, vbp12, vbn12;
287 Short_t valp12, vblp12, cap5, cap12, can12, cbp5, cbp12;
288 Short_t cbn12, calp12, cblp12, lvps, temp, hum;
289 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",
290 &vap5, &vap12, &van12, &vbp5, &vbp12, &vbn12,
291 &valp12, &vblp12, &cap5, &cap12, &can12, &cbp5, &cbp12,
292 &cbn12, &calp12, &cblp12, &lvps, &temp, &hum, &len);
293 if (n!=19)
294 {
295 *fLog << warn << "WARNING - Reading information of 'LV' section." << endl;
296 return kFALSE;
297 }
298
299 fLV->fRequestPowerSupply = (Bool_t)lvps;
300 fLV->fTemp = 0.1*temp;
301 fLV->fHumidity = (Byte_t)hum;
302
303 fLV->fPowerSupplyA.fVoltagePos5V = 0.01*vap5;
304 fLV->fPowerSupplyA.fVoltagePos12V = 0.01*vap12;
305 fLV->fPowerSupplyA.fVoltageNeg12V = 0.01*van12;
306 fLV->fPowerSupplyA.fVoltageOptLinkPos12V = 0.01*valp12;
307 fLV->fPowerSupplyA.fCurrentPos5V = 0.001*cap5;
308 fLV->fPowerSupplyA.fCurrentPos12V = 0.001*cap12;
309 fLV->fPowerSupplyA.fCurrentNeg12V = 0.001*can12;
310 fLV->fPowerSupplyA.fCurrentOptLinkPos12V = 0.001*calp12;
311
312 fLV->fPowerSupplyB.fVoltagePos5V = 0.01*vbp5;
313 fLV->fPowerSupplyB.fVoltagePos12V = 0.01*vbp12;
314 fLV->fPowerSupplyB.fVoltageNeg12V = 0.01*vbn12;
315 fLV->fPowerSupplyB.fVoltageOptLinkPos12V = 0.01*vblp12;
316 fLV->fPowerSupplyB.fCurrentPos5V = 0.001*cbp5;
317 fLV->fPowerSupplyB.fCurrentPos12V = 0.001*cbp12;
318 fLV->fPowerSupplyB.fCurrentNeg12V = 0.001*cbn12;
319 fLV->fPowerSupplyB.fCurrentOptLinkPos12V = 0.001*cblp12;
320
321 str.Remove(0, len);
322 str=str.Strip(TString::kLeading);
323 return kTRUE;
324}
325
326// --------------------------------------------------------------------------
327//
328// Interprete the AUX* part of the report
329//
330Bool_t MReportCamera::InterpreteAUX(TString &str)
331{
332 if (!CheckTag(str, "AUX "))
333 return kFALSE;
334
335 Int_t len;
336 Short_t led, fan;
337 const Int_t n=sscanf(str.Data(), "%hd %hd %n", &led, &fan, &len);
338 if (n!=2)
339 {
340 *fLog << warn << "WARNING - Reading information of 'AUX' section." << endl;
341 return kFALSE;
342 }
343
344 fAUX->fRequestCaosLEDs=(Bool_t)led;
345 fAUX->fRequestFansFADC=(Bool_t)fan;
346
347 str.Remove(0, len);
348 str=str.Strip(TString::kLeading);
349 return kTRUE;
350}
351
352// --------------------------------------------------------------------------
353//
354// Interprete the CAL* part of the report
355//
356Bool_t MReportCamera::InterpreteCAL(TString &str)
357{
358 if (!CheckTag(str, "CAL "))
359 return kFALSE;
360
361 Int_t len;
362 Short_t hv, lv, cont, pin;
363
364 const Int_t n=sscanf(str.Data(), "%hd %hd %hd %hd %n", &hv, &lv, &cont, &pin, &len);
365 if (n!=4)
366 {
367 *fLog << warn << "WARNING - Reading information of 'CAL' section." << endl;
368 return kFALSE;
369 }
370
371 fCalibration->fRequestHiVoltage = (Bool_t)hv;
372 fCalibration->fRequestLoVoltage = (Bool_t)lv;
373 fCalibration->fRequestContLight = (Bool_t)cont;
374 fCalibration->fRequestPinDiode = (Bool_t)pin;
375
376 str.Remove(0, len);
377 str=str.Strip(TString::kBoth);
378 return kTRUE;
379}
380
381// --------------------------------------------------------------------------
382//
383// Interprete the HOT* part of the report
384//
385Bool_t MReportCamera::InterpreteHOT(TString &str)
386{
387 if (!CheckTag(str, "HOT "))
388 return kFALSE;
389
390 Int_t len;
391 Int_t hot;
392
393 const Int_t n=sscanf(str.Data(), "%d %n", &hot, &len);
394 if (n!=1)
395 {
396 *fLog << warn << "WARNING - Reading information of 'HOT' section." << endl;
397 return kFALSE;
398 }
399
400 str.Remove(0, len);
401 str=str.Strip(TString::kBoth);
402 return kTRUE;
403
404}
405
406
407// --------------------------------------------------------------------------
408//
409// Interprete the Active Load REPORT part
410//
411Bool_t MReportCamera::InterpreteActiveLoad(TString &str)
412{
413 if (!CheckTag(str, "ACTLOAD "))
414 return kFALSE;
415
416 Int_t len;
417 Short_t v360a, i360a, v360b, i360b, v175a, i175a, v175b, i175b;
418 Int_t n=sscanf(str.Data(), " %hd %hd %hd %hd %hd %hd %hd %hd %n",
419 &v360a, &i360a, &v360b, &i360b, &v175a, &i175a, &v175b, &i175b, &len);
420 if (n!=8)
421 {
422 *fLog << warn << "WARNING - Reading information of 'ACTLOAD' section." << endl;
423 return kFALSE;
424 }
425
426 fActiveLoad->fVoltage360A = (float)v360a*0.1;
427 fActiveLoad->fIntens360A = (float)i360a*0.01;
428 fActiveLoad->fVoltage360B = (float)v360b*0.1;
429 fActiveLoad->fIntens360B = (float)i360b*0.01;
430 fActiveLoad->fVoltage175A = (float)v175a*0.1;
431 fActiveLoad->fIntens175A = (float)i175a*0.01;
432 fActiveLoad->fVoltage175B = (float)v175b*0.1;
433 fActiveLoad->fIntens175B = (float)i175b*0.01;
434
435 str.Remove(0, len);
436 str=str.Strip(TString::kBoth);
437
438 return kTRUE;
439}
440
441// --------------------------------------------------------------------------
442//
443// Interprete the Central Pixel part
444//
445Bool_t MReportCamera::InterpreteCentralPix(TString &str)
446{
447 if (!CheckTag(str, "CPIX "))
448 return kFALSE;
449
450 Int_t len;
451 Short_t status;
452 Int_t n=sscanf(str.Data(), " %hd %n",
453 &status, &len);
454 if (n!=1)
455 {
456 *fLog << warn << "WARNING - Reading information of 'CPIX' section." << endl;
457 return kFALSE;
458 }
459
460 fCentralPix->fStatus = (Bool_t)status;
461
462 str.Remove(0, len);
463 str=str.Strip(TString::kBoth);
464
465 return kTRUE;
466}
467
468// --------------------------------------------------------------------------
469//
470// Interprete the CHTEMP part
471//
472Bool_t MReportCamera::InterpreteCHTEMP(TString &str)
473{
474 if (!CheckTag(str, "CHTEMP "))
475 return kFALSE;
476
477 Int_t len, temp1, temp2, temp3;
478 Int_t n=sscanf(str.Data(), " %d %d %d %n", &temp1, &temp2, &temp3, &len);
479 if (n!=3)
480 {
481 *fLog << warn << "WARNING - Reading information of 'CHTEMP' section." << endl;
482 return kFALSE;
483 }
484
485 fAUX->fTempCountingHouse1 = temp1*0.01;
486 fAUX->fTempCountingHouse2 = temp2*0.01;
487 fAUX->fTempCountingHouse3 = temp3*0.01;
488
489 str.Remove(0, len);
490 str=str.Strip(TString::kBoth);
491
492 return kTRUE;
493}
494
495// --------------------------------------------------------------------------
496//
497// Interprete the HVFIL part
498//
499Bool_t MReportCamera::InterpreteHVFIL(TString &str)
500{
501 if (!CheckTag(str, "HVFIL "))
502 return kFALSE;
503
504 str=str.Strip(TString::kBoth);
505
506 const Ssiz_t pos = str.First(' ');
507 /*
508 if (pos<0)
509 {
510 *fLog << warn << "WARNING - Reading information of 'HVFIL' section." << endl;
511 return kFALSE;
512 }
513 */
514
515 fHV->fFileName = pos<0 ? (TString)"" : str(0, pos);
516 if (pos<0)
517 return kTRUE;
518
519 str.Remove(0, pos);
520 str=str.Strip(TString::kBoth);
521
522 return kTRUE;
523}
524
525// --------------------------------------------------------------------------
526//
527// Interprete the CAMERA-REPORT part
528//
529Bool_t MReportCamera::InterpreteCamera(TString &str, Int_t ver)
530{
531 //
532 // I have tried to do it with pure pointer arithmentics, but most of the time is spent
533 // to do the sscanf. So we gain less than 5% not using TString like it is done here.
534 Int_t len1=0;
535 Short_t cal, stat, hvps, lid, lv, cool, hv, dc, led, fan, can, io, clv;
536 Int_t n;
537
538 n=sscanf(str.Data(), " %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %n",
539 &cal, &stat, &hvps, &lid, &lv, &cool, &hv,
540 &dc, &led, &fan, &can, &io, &clv, &len1);
541 if (n!=13)
542 {
543 *fLog << warn << "WARNING - Cannot interprete status' of subsystems." << endl;
544 return kFALSE;
545 }
546
547 fHV->fStatus = (Byte_t)hvps;
548 fLids->fStatus = (Byte_t)lid;
549 fLV->fStatus = (Byte_t)lv;
550 fCooling->fStatus = (Byte_t)cool;
551 fHV->fStatusRamping = (Byte_t)hv;
552 fAUX->fStatusCaosLEDs = (Bool_t)led;
553 fAUX->fStatusFansFADC = (Bool_t)fan;
554 fCalibration->fStatus = (Bool_t)cal;
555 fCalibration->fStatusCANbus = (Bool_t)can;
556 fCalibration->fStatusIO = (Bool_t)io;
557 fCalibration->fStatusLoVoltage = (Bool_t)clv;
558 fStatus = (Byte_t)stat;
559 fDC->fStatus = (Byte_t)dc;
560 fActiveLoad->fStatus = 0xff;
561
562 Int_t len2=0;
563 if (ver > 200504130)
564 {
565 Short_t actl;
566 n=sscanf(str.Data()+len1, " %hd %n", &actl, &len2);
567 if (n!=1)
568 {
569 *fLog << warn << "WARNING - Cannot interprete status of active load." << endl;
570 return kFALSE;
571 }
572 fActiveLoad->fStatus = (Byte_t)actl;
573 }
574 str.Remove(0, len1+len2);
575 str=str.Strip(TString::kLeading);
576
577 return kTRUE;
578}
579
580// --------------------------------------------------------------------------
581//
582// Interprete the body of the CAMERA-REPORT string
583//
584Int_t MReportCamera::InterpreteBody(TString &str, Int_t ver)
585{
586 if (!InterpreteCamera(str, ver))
587 return kCONTINUE;
588
589 if (!InterpreteDC(str))
590 return kCONTINUE;
591
592 if (!InterpreteHV(str))
593 return kCONTINUE;
594
595 if (!InterpreteCOOL(str))
596 return kCONTINUE;
597
598 if (!InterpreteLID(str))
599 return kCONTINUE;
600
601 if (!InterpreteHVPS(str))
602 return kCONTINUE;
603
604 if (!InterpreteLV(str))
605 return kCONTINUE;
606
607 if (!InterpreteAUX(str))
608 return kCONTINUE;
609
610 if (!InterpreteCAL(str))
611 return kCONTINUE;
612
613 if (ver >= 200407070)
614 {
615 if (!InterpreteHOT(str))
616 return kCONTINUE;
617 }
618
619 if (ver > 200504130)
620 {
621 if (!InterpreteActiveLoad(str))
622 return kCONTINUE;
623 if (!InterpreteCentralPix(str))
624 return kCONTINUE;
625 }
626
627 if (ver >= 200507190)
628 {
629 if (!InterpreteCHTEMP(str))
630 return kCONTINUE;
631 if (!InterpreteHVFIL(str))
632 return kCONTINUE;
633 }
634
635 if (str!="OVER")
636 {
637 *fLog << warn << "WARNING - 'OVER' tag not found." << endl;
638 return kCONTINUE;
639 }
640
641 return kTRUE;
642}
Note: See TracBrowser for help on using the repository browser.