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

Definition at line 990 of file smartfact.cc.

References Sun::color, Moon::color, Sun::description, Moon::description, Time::GetAsStr(), EventImp::GetJavaDate(), i, Sun::isday, Time::IsValid(), HTML::kWhite, EventImp::Ptr(), size, Moon::time, and Sun::time.

Referenced by StateMachineSmartFACT().

991  {
992  if (!CheckDataSize(d, "MagicWeather:Data", 7*4+2))
993  return GetCurrentState();
994 
995  // Store a history of the last 300 entries
996  for (int i=kWeatherBegin; i<kWeatherEnd; i++)
997  {
998  fMagicWeatherHist[i].push_back(d.Ptr<float>(2)[i]);
999  if (fMagicWeatherHist[i].size()>300)
1000  fMagicWeatherHist[i].pop_front();
1001  }
1002 
1003  ostringstream out;
1004  out << d.GetJavaDate() << '\n';
1005  if (fSun.time.IsValid() && fMoon.time.IsValid())
1006  {
1007  out << fSun.color << '\t' << fSun.description << '\n';
1008  out << setprecision(2);
1009  out << (fSun.isday?HTML::kWhite:fMoon.color) << '\t' << fMoon.description << '\n';
1010  }
1011  else
1012  out << "\n\n";
1013  out << setprecision(3);
1014  for (int i=0; i<6; i++)
1015  out << HTML::kWhite << '\t' << fMagicWeatherHist[i].back() << '\n';
1016  out << HTML::kWhite << '\t' << GetDir(fMagicWeatherHist[kDir].back()) << '\n';
1017  out << HTML::kWhite << '\t';
1018  if (!fTngWeatherDustHist.empty())
1019  out << fTngWeatherDustHist.back() << '\t' << fTngWeatherDustTime.GetAsStr("%H:%M") << '\n';
1020  else
1021  out << "\t\n";
1022 
1023  ofstream(fPath+"/weather.data") << out.str();
1024 
1025  WriteWeather(d, "temp", kTemp, -5, 35);
1026  WriteWeather(d, "dew", kDew, -5, 35);
1027  WriteWeather(d, "hum", kHum, 0, 100);
1028  WriteWeather(d, "wind", kWind, 0, 100);
1029  WriteWeather(d, "gusts", kGusts, 0, 100);
1030  WriteWeather(d, "press", kPress, 700, 1000);
1031 
1032  return GetCurrentState();
1033  }
string description
Definition: smartfact.cc:326
void WriteWeather(const EventImp &d, const string &name, int i, float min, float max)
Definition: smartfact.cc:972
string description
Definition: smartfact.cc:102
int GetCurrentState() const
return the current state of the machine
deque< float > fTngWeatherDustHist
Definition: smartfact.cc:542
bool CheckDataSize(const EventImp &d, const char *name, size_t size, bool min=false)
Definition: smartfact.cc:669
int i
Definition: db_dim_client.c:21
Time time
Definition: moon.cc:16
static const string kWhite
Definition: smartfact.cc:74
bool IsValid() const
Definition: Time.h:90
bool isday
Definition: smartfact.cc:105
uint64_t GetJavaDate() const
Definition: EventImp.cc:303
deque< float > fMagicWeatherHist[kWeatherEnd]
Definition: smartfact.cc:540
int size
Definition: db_dim_server.c:17
string GetDir(const double angle)
Definition: smartfact.cc:653
string color
Definition: smartfact.cc:327
Time time
Definition: smartfact.cc:88
std::string GetAsStr(const char *fmt="%Y-%m-%d %H:%M:%S") const
Definition: Time.cc:240
string color
Definition: smartfact.cc:103
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: