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

Last change on this file since 7005 was 6962, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 16.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-2003
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// Check whether the given TString begins with the given tag. Remove
118// the tag from the string.
119//
120Bool_t MReportCamera::CheckTag(TString &str, const char *tag) const
121{
122 if (!str.BeginsWith(tag))
123 {
124 *fLog << warn << "WARNING - '" << tag << "' tag not found." << endl;
125 return kFALSE;
126 }
127 str.Remove(0, strlen(tag)); // Remove DC currents
128 return kTRUE;
129}
130
131// --------------------------------------------------------------------------
132//
133// Interprete the DC* part of the report
134//
135Bool_t MReportCamera::InterpreteDC(TString &str)
136{
137 if (!CheckTag(str, "DC "))
138 return kFALSE;
139
140 str.Remove(0, 577*4); // Remove DC currents
141 str=str.Strip(TString::kLeading);
142 return kTRUE;
143}
144
145// --------------------------------------------------------------------------
146//
147// Interprete the HV* part of the report
148//
149Bool_t MReportCamera::InterpreteHV(TString &str)
150{
151 if (!CheckTag(str, "HV "))
152 return kFALSE;
153
154 const char *pos = str.Data();
155 const char *end = str.Data()+577*3;
156
157 Int_t i=0;
158 while (pos<end)
159 {
160 const Char_t hex[4] = { pos[0], pos[1], pos[2], 0 };
161 pos += 3;
162
163 const Int_t n=sscanf(hex, "%3hx", &fHV->fHV[i++]);
164 if (n==1)
165 continue;
166
167 *fLog << warn << "WARNING - Reading hexadecimal HV information." << endl;
168 return kFALSE;
169 }
170
171 str.Remove(0, end-str.Data()); // Remove DC currents
172 str=str.Strip(TString::kLeading);
173 return kTRUE;
174}
175
176// --------------------------------------------------------------------------
177//
178// Interprete the COOL* part of the report
179//
180Bool_t MReportCamera::InterpreteCOOL(TString &str)
181{
182 if (!CheckTag(str, "COOL "))
183 return kFALSE;
184
185 Int_t len;
186
187 Int_t wall, opt, center, water;
188 Short_t hwall, hcenter, hip, lop, pump, ref, valv, res, fans;
189 const Int_t n=sscanf(str.Data(), "%d %d %d %d %hu %hu %hu %hu %hu %hu %hu %hu %hu %n",
190 &wall, &opt, &center, &water, &hwall, &hcenter,
191 &hip, &lop, &pump, &ref, &valv, &res, &fans, &len);
192 if (n!=13)
193 {
194 *fLog << warn << "WARNING - Reading information of 'COOL' section." << endl;
195 return kFALSE;
196 }
197
198 fCooling->fTempWall = 0.1*wall;
199 fCooling->fTempOptLink = 0.1*opt;
200 fCooling->fTempCenter = 0.1*center;
201 fCooling->fTempWater = 0.1*water;
202 fCooling->fHumWall = (Byte_t)hwall;
203 fCooling->fHumCenter = (Byte_t)hcenter;
204 fCooling->fStatusPressureHi = (Bool_t)hip;
205 fCooling->fStatusPressureLo = (Bool_t)lop;
206 fCooling->fStatusPump = (Bool_t)pump;
207 fCooling->fStatusRefrigrerator = (Bool_t)ref;
208 fCooling->fStatusValve = (Bool_t)valv;
209 fCooling->fStatusResistor = (Bool_t)res;
210 fCooling->fStatusFans = (Bool_t)fans;
211
212 str.Remove(0, len);
213 str=str.Strip(TString::kLeading);
214 return kTRUE;
215}
216
217// --------------------------------------------------------------------------
218//
219// Interprete the LID* part of the report
220//
221Bool_t MReportCamera::InterpreteLID(TString &str)
222{
223 if (!CheckTag(str, "LID "))
224 return kFALSE;
225
226 Int_t len;
227 Short_t limao, limac, limbo, limbc;
228 Short_t slimao, slimac, slimbo, slimbc;
229 Short_t slida, slidb, mlida, mlidb;
230 const Int_t n=sscanf(str.Data(), "%hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %hu %n",
231 &limao, &limac, &limbo, &limbc,
232 &slimao, &slimac, &slimbo, &slimbc,
233 &slida, &slidb, &mlida, &mlidb,
234 &len);
235 if (n!=12)
236 {
237 *fLog << warn << "WARNING - Reading information of 'LID' section." << endl;
238 return kFALSE;
239 }
240
241 fLids->fLidA.fLimitOpen = (Bool_t)limao;
242 fLids->fLidA.fLimitClose = (Bool_t)limac;
243 fLids->fLidA.fSafetyLimitOpen = (Bool_t)slimao;
244 fLids->fLidA.fSafetyLimitClose= (Bool_t)slimac;
245 fLids->fLidA.fStatusLid = (Byte_t)slida;
246 fLids->fLidA.fStatusMotor = (Byte_t)mlida;
247
248 fLids->fLidB.fLimitOpen = (Bool_t)limbo;
249 fLids->fLidB.fLimitClose = (Bool_t)limbc;
250 fLids->fLidB.fSafetyLimitOpen = (Bool_t)slimbo;
251 fLids->fLidB.fSafetyLimitClose= (Bool_t)slimbc;
252 fLids->fLidB.fStatusLid = (Byte_t)slidb;
253 fLids->fLidB.fStatusMotor = (Byte_t)mlidb;
254
255 str.Remove(0, len);
256 str=str.Strip(TString::kLeading);
257 return kTRUE;
258}
259
260// --------------------------------------------------------------------------
261//
262// Interprete the HVPS* part of the report
263//
264Bool_t MReportCamera::InterpreteHVPS(TString &str)
265{
266 if (!CheckTag(str, "HVPS "))
267 return kFALSE;
268
269 Int_t len;
270 Short_t c1, c2;
271 const Int_t n=sscanf(str.Data(), "%hd %hd %hd %hd %n",
272 &fHV->fVoltageA, &fHV->fVoltageB, &c1, &c2, &len);
273 if (n!=4)
274 {
275 *fLog << warn << "WARNING - Reading information of 'HVPS' section." << endl;
276 return kFALSE;
277 }
278
279 fHV->fCurrentA = (Byte_t)c1;
280 fHV->fCurrentB = (Byte_t)c2;
281
282 str.Remove(0, len);
283 str=str.Strip(TString::kLeading);
284 return kTRUE;
285}
286
287// --------------------------------------------------------------------------
288//
289// Interprete the LV* part of the report
290//
291Bool_t MReportCamera::InterpreteLV(TString &str)
292{
293 if (!CheckTag(str, "LV "))
294 return kFALSE;
295
296 Int_t len;
297 Short_t vap5, vap12, van12, vbp5, vbp12, vbn12;
298 Short_t valp12, vblp12, cap5, cap12, can12, cbp5, cbp12;
299 Short_t cbn12, calp12, cblp12, lvps, temp, hum;
300 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",
301 &vap5, &vap12, &van12, &vbp5, &vbp12, &vbn12,
302 &valp12, &vblp12, &cap5, &cap12, &can12, &cbp5, &cbp12,
303 &cbn12, &calp12, &cblp12, &lvps, &temp, &hum, &len);
304 if (n!=19)
305 {
306 *fLog << warn << "WARNING - Reading information of 'LV' section." << endl;
307 return kFALSE;
308 }
309
310 fLV->fRequestPowerSupply = (Bool_t)lvps;
311 fLV->fTemp = 0.1*temp;
312 fLV->fHumidity = (Byte_t)hum;
313
314 fLV->fPowerSupplyA.fVoltagePos5V = 0.01*vap5;
315 fLV->fPowerSupplyA.fVoltagePos12V = 0.01*vap12;
316 fLV->fPowerSupplyA.fVoltageNeg12V = 0.01*van12;
317 fLV->fPowerSupplyA.fVoltageOptLinkPos12V = 0.01*valp12;
318 fLV->fPowerSupplyA.fCurrentPos5V = 0.001*cap5;
319 fLV->fPowerSupplyA.fCurrentPos12V = 0.001*cap12;
320 fLV->fPowerSupplyA.fCurrentNeg12V = 0.001*can12;
321 fLV->fPowerSupplyA.fCurrentOptLinkPos12V = 0.001*calp12;
322
323 fLV->fPowerSupplyB.fVoltagePos5V = 0.01*vbp5;
324 fLV->fPowerSupplyB.fVoltagePos12V = 0.01*vbp12;
325 fLV->fPowerSupplyB.fVoltageNeg12V = 0.01*vbn12;
326 fLV->fPowerSupplyB.fVoltageOptLinkPos12V = 0.01*vblp12;
327 fLV->fPowerSupplyB.fCurrentPos5V = 0.001*cbp5;
328 fLV->fPowerSupplyB.fCurrentPos12V = 0.001*cbp12;
329 fLV->fPowerSupplyB.fCurrentNeg12V = 0.001*cbn12;
330 fLV->fPowerSupplyB.fCurrentOptLinkPos12V = 0.001*cblp12;
331
332 str.Remove(0, len);
333 str=str.Strip(TString::kLeading);
334 return kTRUE;
335}
336
337// --------------------------------------------------------------------------
338//
339// Interprete the AUX* part of the report
340//
341Bool_t MReportCamera::InterpreteAUX(TString &str)
342{
343 if (!CheckTag(str, "AUX "))
344 return kFALSE;
345
346 Int_t len;
347 Short_t led, fan;
348 const Int_t n=sscanf(str.Data(), "%hd %hd %n", &led, &fan, &len);
349 if (n!=2)
350 {
351 *fLog << warn << "WARNING - Reading information of 'AUX' section." << endl;
352 return kFALSE;
353 }
354
355 fAUX->fRequestCaosLEDs=(Bool_t)led;
356 fAUX->fRequestFansFADC=(Bool_t)fan;
357
358 str.Remove(0, len);
359 str=str.Strip(TString::kLeading);
360 return kTRUE;
361}
362
363// --------------------------------------------------------------------------
364//
365// Interprete the CAL* part of the report
366//
367Bool_t MReportCamera::InterpreteCAL(TString &str)
368{
369 if (!CheckTag(str, "CAL "))
370 return kFALSE;
371
372 Int_t len;
373 Short_t hv, lv, cont, pin;
374
375 const Int_t n=sscanf(str.Data(), "%hd %hd %hd %hd %n", &hv, &lv, &cont, &pin, &len);
376 if (n!=4)
377 {
378 *fLog << warn << "WARNING - Reading information of 'CAL' section." << endl;
379 return kFALSE;
380 }
381
382 fCalibration->fRequestHiVoltage = (Bool_t)hv;
383 fCalibration->fRequestLoVoltage = (Bool_t)lv;
384 fCalibration->fRequestContLight = (Bool_t)cont;
385 fCalibration->fRequestPinDiode = (Bool_t)pin;
386
387 str.Remove(0, len);
388 str=str.Strip(TString::kBoth);
389 return kTRUE;
390}
391
392// --------------------------------------------------------------------------
393//
394// Interprete the HOT* part of the report
395//
396Bool_t MReportCamera::InterpreteHOT(TString &str)
397{
398
399 if (!CheckTag(str, "HOT "))
400 return kFALSE;
401
402 Int_t len;
403 Int_t hot;
404
405 const Int_t n=sscanf(str.Data(), "%d %n", &hot, &len);
406 if (n!=1)
407 {
408 *fLog << warn << "WARNING - Reading information of 'HOT' section." << endl;
409 return kFALSE;
410 }
411
412 str.Remove(0, len);
413 str=str.Strip(TString::kBoth);
414 return kTRUE;
415
416}
417
418
419// --------------------------------------------------------------------------
420//
421// Interprete the Active Load REPORT part
422//
423Bool_t MReportCamera::InterpreteActiveLoad(TString &str)
424{
425 if (!CheckTag(str, "ACTLOAD "))
426 return kFALSE;
427
428 Int_t len;
429 Short_t v360a, i360a, v360b, i360b, v175a, i175a, v175b, i175b;
430 Int_t n=sscanf(str.Data(), " %hd %hd %hd %hd %hd %hd %hd %hd %n",
431 &v360a, &i360a, &v360b, &i360b, &v175a, &i175a, &v175b, &i175b, &len);
432 if (n!=8)
433 {
434 *fLog << warn << "WARNING - Reading information of 'ACTLOAD' section." << endl;
435 return kFALSE;
436 }
437
438 fActiveLoad->fVoltage360A = (float)v360a*0.1;
439 fActiveLoad->fIntens360A = (float)i360a*0.01;
440 fActiveLoad->fVoltage360B = (float)v360b*0.1;
441 fActiveLoad->fIntens360B = (float)i360b*0.01;
442 fActiveLoad->fVoltage175A = (float)v175a*0.1;
443 fActiveLoad->fIntens175A = (float)i175a*0.01;
444 fActiveLoad->fVoltage175B = (float)v175b*0.1;
445 fActiveLoad->fIntens175B = (float)i175b*0.01;
446
447 str.Remove(0, len);
448 str=str.Strip(TString::kBoth);
449
450 return kTRUE;
451}
452
453// --------------------------------------------------------------------------
454//
455// Interprete the Central Pixel part
456//
457Bool_t MReportCamera::InterpreteCentralPix(TString &str)
458{
459 if (!CheckTag(str, "CPIX "))
460 return kFALSE;
461
462 Int_t len;
463 Short_t status;
464 Int_t n=sscanf(str.Data(), " %hd %n",
465 &status, &len);
466 if (n!=1)
467 {
468 *fLog << warn << "WARNING - Reading information of 'CPIX' section." << endl;
469 return kFALSE;
470 }
471
472 fCentralPix->fStatus = (Bool_t)status;
473
474 str.Remove(0, len);
475 str=str.Strip(TString::kBoth);
476
477 return kTRUE;
478}
479// --------------------------------------------------------------------------
480//
481// Interprete the CAMERA-REPORT part
482//
483Bool_t MReportCamera::InterpreteCamera(TString &str, Int_t ver)
484{
485 //
486 // I have tried to do it with pure pointer arithmentics, but most of the time is spent
487 // to do the sscanf. So we gain less than 5% not using TString like it is done here.
488 Int_t len1=0;
489 Short_t cal, stat, hvps, lid, lv, cool, hv, dc, led, fan, can, io, clv;
490 Int_t n;
491
492 n=sscanf(str.Data(), " %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %hd %n",
493 &cal, &stat, &hvps, &lid, &lv, &cool, &hv,
494 &dc, &led, &fan, &can, &io, &clv, &len1);
495 if (n!=13)
496 {
497 *fLog << warn << "WARNING - Cannot interprete status' of subsystems." << endl;
498 return kFALSE;
499 }
500
501 fHV->fStatus = (Byte_t)hvps;
502 fLids->fStatus = (Byte_t)lid;
503 fLV->fStatus = (Byte_t)lv;
504 fCooling->fStatus = (Byte_t)cool;
505 fHV->fStatusRamping = (Byte_t)hv;
506 fAUX->fStatusCaosLEDs = (Bool_t)led;
507 fAUX->fStatusFansFADC = (Bool_t)fan;
508 fCalibration->fStatus = (Bool_t)cal;
509 fCalibration->fStatusCANbus = (Bool_t)can;
510 fCalibration->fStatusIO = (Bool_t)io;
511 fCalibration->fStatusLoVoltage = (Bool_t)clv;
512 fStatus = (Byte_t)stat;
513 fStatusDC = (Byte_t)dc;
514 fActiveLoad->fStatus = 0xff;
515
516 Int_t len2=0;
517 if (ver > gkActiveLoadControlVersNum)
518 {
519 Short_t actl;
520 n=sscanf(str.Data()+len1, " %hd %n", &actl, &len2);
521 if (n!=1)
522 {
523 *fLog << warn << "WARNING - Cannot interprete status of active load." << endl;
524 return kFALSE;
525 }
526 fActiveLoad->fStatus = (Byte_t)actl;
527 }
528 str.Remove(0, len1+len2);
529 str=str.Strip(TString::kLeading);
530
531 return kTRUE;
532}
533
534// --------------------------------------------------------------------------
535//
536// Interprete the body of the CAMERA-REPORT string
537//
538Int_t MReportCamera::InterpreteBody(TString &str, Int_t ver)
539{
540 if (!InterpreteCamera(str, ver))
541 return kCONTINUE;
542
543 if (!InterpreteDC(str))
544 return kCONTINUE;
545
546 if (!InterpreteHV(str))
547 return kCONTINUE;
548
549 if (!InterpreteCOOL(str))
550 return kCONTINUE;
551
552 if (!InterpreteLID(str))
553 return kCONTINUE;
554
555 if (!InterpreteHVPS(str))
556 return kCONTINUE;
557
558 if (!InterpreteLV(str))
559 return kCONTINUE;
560
561 if (!InterpreteAUX(str))
562 return kCONTINUE;
563
564 if (!InterpreteCAL(str))
565 return kCONTINUE;
566
567 if (!InterpreteHOT(str))
568 return kCONTINUE;
569
570 if (ver > gkActiveLoadControlVersNum)
571 {
572 if (!InterpreteActiveLoad(str))
573 return kCONTINUE;
574 if (!InterpreteCentralPix(str))
575 return kCONTINUE;
576 }
577
578 if (str!="OVER")
579 {
580 *fLog << warn << "WARNING - 'OVER' tag not found." << endl;
581 return kCONTINUE;
582 }
583
584 return kTRUE;
585}
Note: See TracBrowser for help on using the repository browser.