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

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