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