FACT++  1.0
void ConnectionDimFSC::UpdateTemp ( float  time,
const vector< float > &  temp 
)
inlineprivatevirtual

Reimplemented from ConnectionFSC.

Definition at line 604 of file fscctrl.cc.

References i, Interpolator2D::Interpolate(), and Interpolator2D::SetOutputGrid().

605  {
606  Update(fDimTemp, temp, time);
607 
608  vector<double> T;
609  vector<Interpolator2D::vec> xy;
610 
611  T.reserve(31);
612  xy.reserve(31);
613 
614  double avg = 0;
615  double rms = 0;
616 
617  // Create a list of all valid sensors
618  for (int i=0; i<31; i++)
619  if (temp[i]!=0)
620  {
621  T.emplace_back(temp[i]);
622  xy.emplace_back(fPositionsSensors[i]);
623 
624  avg += temp[i];
625  rms += temp[i]*temp[i];
626  }
627 
628  if (T.size()==0)
629  {
630  Warn("No valid sensor temperatures.");
631  return;
632  }
633 
634  avg /= T.size();
635  rms /= T.size();
636  rms -= avg*avg;
637  rms = rms<0 ? 0 : sqrt(rms);
638 
639  // Clean broken reports
640  const double cut_val = 0.015;
641  const bool reject = rms>4 || (fabs(fLastRms[0]-fLastRms[1])<=cut_val && fabs(rms-fLastRms[0])>cut_val);
642 
643  fLastRms[1] = fLastRms[0];
644  fLastRms[0] = rms;
645 
646  if (reject)
647  {
648  Warn("Suspicious temperature values rejecte for BIAS_TEMP.");
649  return;
650  }
651 
652  // Create interpolator for the corresponding sensor positions
653  Interpolator2D inter(xy);
654 
655  // Calculate weights for the output positions
656  if (!inter.SetOutputGrid(fPositionsBias))
657  {
658  Warn("Temperature values rejecte for BIAS_TEMP (calculation of weights failed).");
659  return;
660  }
661 
662  // Interpolate the data
663  T = inter.Interpolate(T);
664 
665  avg = 0;
666  rms = 0;
667  for (int i=0; i<320; i++)
668  {
669  avg += T[i];
670  rms += T[i]*T[i];
671  }
672 
673  avg /= 320;
674  rms /= 320;
675  rms -= avg*avg;
676  rms = rms<0 ? 0 : sqrt(rms);
677 
678  vector<float> out;
679  out.reserve(322);
680  out.assign(T.cbegin(), T.cend());
681  out.emplace_back(avg);
682  out.emplace_back(rms);
683 
684  // Update the Dim service with the interpolated positions
685  Update(fDimTemp2, out, time);
686  }
int i
Definition: db_dim_client.c:21
DimDescribedService fDimTemp
Definition: fscctrl.cc:592
vector< Interpolator2D::vec > fPositionsBias
Definition: fscctrl.cc:42
Extra- and interpolate in 2D.
vector< double > fLastRms
Definition: fscctrl.cc:590
Warning because the service this data corrsponds to might have been last updated longer ago than Local time
Definition: smartfact.txt:92
vector< Interpolator2D::vec > fPositionsSensors
Definition: fscctrl.cc:41
void Update(DimDescribedService &svc, vector< float > data, float time) const
Definition: fscctrl.cc:598
DimDescribedService fDimTemp2
Definition: fscctrl.cc:593

+ Here is the call graph for this function: