FACT++  1.0
bool ConnectionFSC::ProcessMessage ( )
inlineprivate

Definition at line 130 of file fscctrl.cc.

References FSC::BinaryOutput_t::ad7719_values, FSC::BinaryOutput_t::adc_values, i, FSC::kNumResistanceChannels, FSC::kNumVoltageChannels, time, FSC::BinaryOutput_t::time_ms, and FSC::BinaryOutput_t::time_sec.

131  {
132  if (fIsVerbose)
133  Out() << "Received one_message of FSC::BinaryOutput_t ... will now process it" << endl;
134 
135  if (!CheckChecksum())
136  return false;
137 
138  // That looks a bit odd because it copies the values twice for no reason.
139  // This is historical and keeps the following code consistent with the
140  // previous code which was reading ascii data from the fsc
141  vector<float> volt(kNumVoltageChannels);
142  vector<float> resist(kNumResistanceChannels);
143 
144  const float time = fMsg.time_sec + fMsg.time_ms/1000.;
145 
146  // We want to convert the pure ADC values from the FSC board to mV and kOhm respectively
147  // So we do:
148  for (unsigned int i=0; i<volt.size(); i++)
149  volt[i] = fMsg.adc_values[i]*0.1;
150 
151  for (unsigned int i=0; i<resist.size(); i++)
152  resist[i] = fMsg.ad7719_values[i] * (6.25 * 1024) / (1 << 25);
153 
154  int mapv[] =
155  {
156  0, 16, 24, 8,
157  1, 17, 25, 9,
158  2, 18, 26, 10,
159  //
160  3, 19, 27, 11,
161  4, 20, 28, 12,
162  5, 21, 29, 13,
163  //
164  32, 36, 33, 34, 37, 38,
165  //
166  -1
167  };
168 
169  int mapc[] =
170  {
171  40, 56, 64, 48,
172  41, 57, 65, 49,
173  42, 58, 66, 50,
174  //
175  43, 59, 67, 51,
176  44, 60, 68, 52,
177  45, 61, 69, 53,
178  //
179  72, 76, 73, 74, 77, 78,
180  //
181  -1
182  };
183 
184 
185  int maprh[] =
186  {
187  80, 81, 82, 83, -1
188  };
189 
190  int offrh[] =
191  {
192  821, 822, 816, 822,
193  };
194 
195  int mapt[] =
196  {
197  // sensor compartment temperatures
198  0, 1, 2, 3, 4, 5, 6, 56, 57, 58, 59, 60,
199  61, 62, 32, 33, 34, 35, 36, 63, 37, 38, 39, 24,
200  25, 26, 27, 28, 29, 30, 31,
201  // crate temperatures (0-3, back/front)
202  12, 13, 52, 53, 44, 46, 20, 21,
203  //crate power supply temperatures (0-3)
204  8, 9, 48, 49, 40, 41, 16, 17,
205  // aux power supplies (FTM-side top/bot, FSC-side top/bot)
206  45, 50, 19, 42,
207  // backpanel (FTM-side top/bot, FSC-side top/bot)
208  11, 51, 18, 43,
209  // switch boxes (top front/back, bottom front/back)
210  15, 14, 47, 10,
211  //
212  -1
213  };
214 
215  vector<float> voltages;
216  vector<float> currents;
217  vector<float> humidities;
218  vector<float> temperatures;
219 
220  for (int *pv=mapv; *pv>=0; pv++)
221  voltages.push_back(volt[*pv]*0.001);
222 
223  for (int *pc=mapc; *pc>=0; pc++)
224  currents.push_back(volt[*pc]*0.005);
225 
226  for (int idx=0; idx<4; idx++)
227  {
228  voltages[idx +8] *= -1;
229  voltages[idx+20] *= -1;
230  currents[idx +8] *= -1;
231  currents[idx+20] *= -1;
232  }
233  voltages[12] *= 2;
234  voltages[13] *= 2;
235  voltages[14] *= 2;
236  voltages[15] *= 2;
237 
238  voltages[24] *= 2;
239  voltages[25] *= 2;
240 
241  voltages[27] *= -1;
242  voltages[29] *= -1;
243 
244  currents[27] *= -1;
245  currents[29] *= -1;
246 
247  int idx=0;
248  for (int *ph=maprh; *ph>=0; ph++, idx++)
249  humidities.push_back((volt[*ph]-offrh[idx])*0.0313);
250 
251  //1019=4.8
252  //1005=1.3
253  //970=-7.6
254  //1300=76
255  for (int *pt=mapt; *pt>=0; pt++)
256  //temperatures.push_back(resist[*pt]>800&&resist[*pt]<2000 ? GetTempPT1000(resist[*pt]) : 0);
257  temperatures.push_back(resist[*pt]>970&&resist[*pt]<1300 ? GetTempPT1000(resist[*pt]) : 0);
258  //temperatures.push_back(resist[*pt]>1019&&resist[*pt]<1300 ? GetTempPT1000(resist[*pt]) : 0);
259 
260  // 0 = 3-(3+0)%4
261  // 3 = 3-(3+1)%4
262  // 2 = 3-(3+2)%4
263  // 1 = 3-(3+3)%4
264 
265  /*
266  index unit offset scale crate for board:
267  0 mV 0 1 0 FAD 3.3V
268  24 mV 0 1 1 FAD 3.3V
269  16 mV 0 1 2 FAD 3.3V
270  8 mV 0 1 3 FAD 3.3V
271 
272  1 mV 0 1 0 FAD 3.3V
273  25 mV 0 1 1 FAD 3.3V
274  17 mV 0 1 2 FAD 3.3V
275  9 mV 0 1 3 FAD 3.3V
276 
277  2 mV 0 -1 0 FAD -2.0V
278  26 mV 0 -1 1 FAD -2.0V
279  18 mV 0 -1 2 FAD -2.0V
280  10 mV 0 -1 3 FAD -2.0V
281 
282  --
283 
284  3 mV 0 1 0 FPA 5.0V
285  27 mV 0 1 1 FPA 5.0V
286  19 mV 0 1 2 FPA 5.0V
287  11 mV 0 1 3 FPA 5.0V
288 
289  4 mV 0 1 0 FPA 3.3V
290  28 mV 0 1 1 FPA 3.3V
291  20 mV 0 1 2 FPA 3.3V
292  12 mV 0 1 3 FPA 3.3V
293 
294  5 mV 0 -1 0 FPA -3.3V
295  29 mV 0 -1 1 FPA -3.3V
296  21 mV 0 -1 2 FPA -3.3V
297  13 mV 0 -1 3 FPA -3.3V
298 
299  --
300 
301  32 mV 0 1 bottom ETH 5V
302  36 mV 0 1 top ETH 5V
303 
304  33 mV 0 1 bottom FTM 3.3V
305  34 mV 0 -1 bottom FTM -3.3V
306 
307  37 mV 0 1 top FFC 3.3V
308  38 mV 0 -1 top FLP -3.3V
309 
310  -----
311 
312  40 mA 0 5 0 FAD
313  64 mA 0 5 1 FAD
314  56 mA 0 5 2 FAD
315  48 mA 0 5 3 FAD
316 
317  41 mA 0 5 0 FAD
318  65 mA 0 5 1 FAD
319  57 mA 0 5 2 FAD
320  49 mA 0 5 3 FAD
321 
322  42 mA 0 -5 0 FAD
323  66 mA 0 -5 1 FAD
324  58 mA 0 -5 2 FAD
325  50 mA 0 -5 3 FAD
326 
327  --
328 
329  43 mA 0 5 0 FPA
330  67 mA 0 5 1 FPA
331  59 mA 0 5 2 FPA
332  51 mA 0 5 3 FPA
333 
334  44 mA 0 5 0 FPA
335  68 mA 0 5 1 FPA
336  60 mA 0 5 2 FPA
337  52 mA 0 5 3 FPA
338 
339  45 mA 0 -5 0 FPA
340  69 mA 0 -5 1 FPA
341  61 mA 0 -5 2 FPA
342  53 mA 0 -5 3 FPA
343 
344  ---
345 
346  72 mA 0 5 bottom ETH
347  76 mA 0 5 top ETH
348 
349  73 mA 0 5 bottom FTM
350  74 mA 0 -5 bottom FTM
351 
352  77 mA 0 5 top FFC
353  78 mA 0 -5 top FLP
354 
355  ----
356 
357  80 % RH -821 0.0313 FSP000
358  81 % RH -822 0.0313 FSP221
359  82 % RH -816 0.0313 Sector0
360  83 % RH -822 0.0313 Sector2
361  */
362 
363  // TEMPERATURES
364  // 31 x Sensor plate
365  // 8 x Crate
366  // 12 x PS
367  // 4 x Backpanel
368  // 4 x Switchbox
369 
370 
371 
372  /*
373  0 ohms FSP 000
374  1 ohms FSP 010
375  2 ohms FSP 023
376  3 ohms FSP 043
377  4 ohms FSP 072
378  5 ohms FSP 080
379  6 ohms FSP 092
380  56 ohms FSP 103
381  57 ohms FSP 111
382  58 ohms FSP 121
383  59 ohms FSP 152
384  60 ohms FSP 163
385  61 ohms FSP 171
386  62 ohms FSP 192
387  32 ohms FSP 200
388  33 ohms FSP 210
389  34 ohms FSP 223
390  35 ohms FSP 233
391  36 ohms FSP 243
392  63 ohms FSP 252
393  37 ohms FSP 280
394  38 ohms FSP 283
395  39 ohms FSP 293
396  24 ohms FSP 311
397  25 ohms FSP 321
398  26 ohms FSP 343
399  27 ohms FSP 352
400  28 ohms FSP 363
401  29 ohms FSP 371
402  30 ohms FSP 381
403  31 ohms FSP 392
404  8 ohms Crate0 ?
405  9 ohms Crate0 ?
406  48 ohms Crate1 ?
407  49 ohms Crate1 ?
408  40 ohms Crate2 ?
409  41 ohms Crate2 ?
410  16 ohms Crate3 ?
411  17 ohms Crate3 ?
412  10 ohms PS Crate 0
413  11 ohms PS Crate 0
414  50 ohms PS Crate 1
415  51 ohms PS Crate 1
416  42 ohms PS Crate 2
417  43 ohms PS Crate 2
418  18 ohms PS Crate 3
419  19 ohms PS Crate 3
420  12 ohms PS Aux0
421  52 ohms PS Aux0
422  20 ohms PS Aux1
423  44 ohms PS Aux1
424  13 ohms Backpanel ?
425  21 ohms Backpanel ?
426  45 ohms Backpanel ?
427  53 ohms Backpanel ?
428  14 ohms Switchbox0 ?
429  15 ohms Switchbox0 ?
430  46 ohms Switchbox1 ?
431  47 ohms Switchbox1 ?
432  7 ohms nc nc
433  22 ohms nc nc
434  23 ohms nc nc
435  54 ohms nc nc
436  55 ohms nc nc
437  */
438 
439  if (fIsVerbose)
440  {
441  for (size_t i=0; i<resist.size(); i++)
442  //if (resist[i]>800 && resist[i]<2000)
443  if (resist[i]>970 && resist[i]<1300)
444  //if (resist[i]>1019 && resist[i]<1300)
445  Out() << setw(2) << i << " - " << setw(4) << (int)resist[i] << ": " << setprecision(1) << fixed << GetTempPT1000(resist[i]) << endl;
446  else
447  Out() << setw(2) << i << " - " << setw(4) << (int)resist[i] << ": " << "----" << endl;
448  }
449 
450  UpdateTemp(time, temperatures);
451  UpdateVolt(time, voltages);
452  UpdateCur( time, currents);
453  UpdateHum( time, humidities);
454 
457 
458  return true;
459  }
uint32_t ad7719_values[kNumResistanceChannels]
Definition: HeadersFSC.h:30
bool CheckChecksum()
Definition: fscctrl.cc:82
size_t fNumConsecutiveMessages
Definition: fscctrl.cc:36
virtual void UpdateTemp(float, const vector< float > &)
Definition: fscctrl.cc:44
int i
Definition: db_dim_client.c:21
bool fIsVerbose
Definition: fscctrl.cc:32
FSC::BinaryOutput_t fMsg
Definition: fscctrl.cc:30
virtual void UpdateCur(float, const vector< float > &)
Definition: fscctrl.cc:56
virtual void UpdateHum(float, const vector< float > &)
Definition: fscctrl.cc:48
double GetTempPT1000(double R) const
Definition: fscctrl.cc:64
size_t fNumConsecutiveErrors
Definition: fscctrl.cc:35
Warning because the service this data corrsponds to might have been last updated longer ago than Local time
Definition: smartfact.txt:92
uint16_t adc_values[kNumVoltageChannels]
Definition: HeadersFSC.h:38
virtual void UpdateVolt(float, const vector< float > &)
Definition: fscctrl.cc:52