FACT++  1.0
int StateMachineSmartFACT::HandleFscTemperature ( const EventImp d)
inlineprivate

Definition at line 1799 of file smartfact.cc.

References StateMachineSmartFACT::Statistics::avg, EventImp::GetJavaDate(), HTML::kWhite, StateMachineSmartFACT::Statistics::max, StateMachineSmartFACT::Statistics::min, EventImp::Ptr(), and t.

Referenced by StateMachineSmartFACT().

1800  {
1801  if (!CheckDataSize(d, "FscControl:Temperature", 240))
1802  return GetCurrentState();
1803 
1804  const float *ptr = d.Ptr<float>(4);
1805 
1806  double avg = 0;
1807  double rms = 0;
1808  double min = 99;
1809  double max = -99;
1810 
1811  int num = 0;
1812  for (const float *t=ptr; t<ptr+31; t++)
1813  {
1814  if (*t==0)
1815  continue;
1816 
1817  if (*t>max)
1818  max = *t;
1819 
1820  if (*t<min)
1821  min = *t;
1822 
1823  avg += *t;
1824  rms += *t * *t;
1825 
1826  num++;
1827  }
1828 
1829  avg /= num;
1830  rms /= num;
1831  rms += avg*avg;
1832  rms = rms<0 ? 0 : sqrt(rms);
1833 
1834  // Clean broken reports
1835  static double pre_rms1 = 1.5;
1836  static double pre_rms2 = 0;
1837 
1838  const double cut = pre_rms1 + 0.1;
1839 
1840  const bool reject = rms>cut && pre_rms2<cut;
1841 
1842  pre_rms2 = pre_rms1;
1843  pre_rms1 = rms;
1844 
1845  if (reject)
1846  return GetCurrentState();
1847 
1848 
1849  if (!fMagicWeatherHist[kTemp].empty())
1850  {
1851  fFscControlTemperatureHist.push_back(avg-fMagicWeatherHist[kTemp].back());
1852  if (fFscControlTemperatureHist.size()>300)
1853  fFscControlTemperatureHist.pop_front();
1854  }
1855 
1856  const Statistics stat(fFscControlTemperatureHist);
1857 
1858  ostringstream out;
1859  out << setprecision(3);
1860  out << d.GetJavaDate() << '\n';
1861  out << HTML::kWhite << '\t' << fFscControlHumidityAvg << '\n';
1862  out << HTML::kWhite << '\t' << stat.min << '\n';
1863  out << HTML::kWhite << '\t' << stat.avg << '\n';
1864  out << HTML::kWhite << '\t' << stat.max << '\n';
1865 
1866  ofstream(fPath+"/fsc.data") << out.str();
1867 
1868  WriteHist(d, "hist-fsccontrol-temperature",
1870 
1871  out.str("");
1872  out << setprecision(3);
1873  out << d.GetJavaDate() << '\n';
1874  out << HTML::kWhite << '\t' << max << '\n';
1875  out << HTML::kWhite << '\t' << avg << '\n';
1876  out << HTML::kWhite << '\t' << min << '\n';
1877 
1878  ofstream(fPath+"/camtemp.data") << out.str();
1879 
1880  return GetCurrentState();
1881  }
int GetCurrentState() const
return the current state of the machine
deque< float > fFscControlTemperatureHist
Definition: smartfact.cc:553
bool CheckDataSize(const EventImp &d, const char *name, size_t size, bool min=false)
Definition: smartfact.cc:669
void WriteHist(const EventImp &d, const string &fname, const T &t, double scale, double offset=0)
Definition: smartfact.cc:752
static const string kWhite
Definition: smartfact.cc:74
uint64_t GetJavaDate() const
Definition: EventImp.cc:303
deque< float > fMagicWeatherHist[kWeatherEnd]
Definition: smartfact.cc:540
TT t
Definition: test_client.c:26
const T * Ptr(size_t offset=0) const
Definition: EventImp.h:74

+ Here is the call graph for this function:

+ Here is the caller graph for this function: