FACT++  1.0
int StateMachineFeedback::CheckLimits ( const float *  I)
inlineprivate

Definition at line 350 of file feedback.cc.

References Error(), Feedback::State::kCritical, Feedback::State::kInProgress, Feedback::State::kOnStandby, Feedback::State::kWarning, and Dim::SendCommandNB().

351  {
352  const float fAbsoluteMedianCurrentLimit = 85;
353  const float fRelativePixelCurrentLimit3 = 20;
354  const float fRelativePixelCurrentLimit0 = 45;
355 
356  const float fAbsolutePixelCurrentLimit3 = fAbsoluteMedianCurrentLimit + fRelativePixelCurrentLimit3;
357  const float fAbsolutePixelCurrentLimit0 = fAbsoluteMedianCurrentLimit + fRelativePixelCurrentLimit0;
358 
359  const float fRelativeCurrentLimitWarning = 10;//10;
360  const float fRelativeCurrentLimitCritical = 15;//20;
361  const float fRelativeCurrentLimitShutdown = 25;
362 
363  fTimeoutCritical = 3000; // 5s
364 
365  // Copy the calibrated currents
366  vector<float> v(I, I+320);
367 
368  // Exclude the crazy patches (that's currently the best which could be done)
369  v[66] = 0;
370  v[191] = 0;
371  v[193] = 0;
372 
373  sort(v.begin(), v.end());
374 
375  const float &imax0 = v[319];
376  const float &imax3 = v[316];
377  const float &imed = v[161];
378 
379  const bool shutdown =
380  imed >fAbsoluteMedianCurrentLimit+fRelativeCurrentLimitShutdown ||
381  imax3>fAbsolutePixelCurrentLimit3+fRelativeCurrentLimitShutdown ||
382  imax0>fAbsolutePixelCurrentLimit0+fRelativeCurrentLimitShutdown;
383 
384  const bool critical =
385  imed >fAbsoluteMedianCurrentLimit+fRelativeCurrentLimitCritical ||
386  imax3>fAbsolutePixelCurrentLimit3+fRelativeCurrentLimitCritical ||
387  imax0>fAbsolutePixelCurrentLimit0+fRelativeCurrentLimitCritical;
388 
389  const bool warning =
390  imed >fAbsoluteMedianCurrentLimit+fRelativeCurrentLimitWarning ||
391  imax3>fAbsolutePixelCurrentLimit3+fRelativeCurrentLimitWarning ||
392  imax0>fAbsolutePixelCurrentLimit0+fRelativeCurrentLimitWarning;
393 
395 
396  if (standby)
397  {
398  // On Standby
399  if (fVoltageReduction==0 &&
400  imed <fAbsoluteMedianCurrentLimit &&
401  imax3<fAbsolutePixelCurrentLimit3 &&
402  imax0<fAbsolutePixelCurrentLimit0)
403  {
404  // Currents are back at nominal value and currents are again
405  // below the current limit, switching back to standard operation.
407  }
408  }
409 
410  // Shutdown level
411  if (!standby && shutdown)
412  {
413  // Currents exceed the shutdown limit, operation is switched
414  // immediately to voltage reduced operation
415 
416  // Just in case (FIXME: Is that really the right location?)
417  Dim::SendCommandNB("FAD_CONTROL/CLOSE_ALL_OPEN_FILES");
418 
419  Error("Current limit for shutdown exceeded.... switching to standby mode.");
420 
421  standby = true;
422  }
423 
424  // Critical level
425  if (!standby && critical)
426  {
427  // This is a state transition from InProgress or Warning to Critical.
428  // Keep the transition time.
430  {
431  Info("Critical current limit exceeded.... waiting for "+to_string(fTimeoutCritical)+" ms.");
432  fTimeCritical = Time();
433  }
434 
435  // Critical is only allowed for fTimeoutCritical milliseconds.
436  // After this time, the operation is changed to reduced voltage.
437  if (Time()<fTimeCritical+boost::posix_time::milliseconds(fTimeoutCritical))
439 
440  // Just in case (FIXME: Is that really the right location?)
441  Dim::SendCommandNB("FAD_CONTROL/CLOSE_ALL_OPEN_FILES");
442 
443  // Currents in critical state
444  Warn("Critical current limit exceeded timeout.... switching to standby mode.");
445 
446  standby = true;
447  }
448 
449  // Warning level (is just informational)
450  if (!standby && warning)
452 
453  // keep voltage
455  }
int GetCurrentState() const
return the current state of the machine
Adds some functionality to boost::posix_time::ptime for our needs.
Definition: Time.h:30
uint16_t fTimeoutCritical
Definition: feedback.cc:84
int Error(const std::string &str)
Definition: MessageImp.h:49
void SendCommandNB(const std::string &command)
Definition: Dim.h:30
int Warn(const std::string &str)
Definition: MessageImp.h:48
double fVoltageReduction
Definition: feedback.cc:68
int Info(const std::string &str)
Definition: MessageImp.h:47

+ Here is the call graph for this function: