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

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