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

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