Changeset 18339 for trunk/FACT++
- Timestamp:
- 09/30/15 16:47:02 (9 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/HeadersTNGWeather.h
r18338 r18339 19 19 20 20 float fTemperature; 21 float fTempTrend; 21 22 float fDewPoint; 22 23 float fHumidity; 23 24 float fAirPressure; 24 float fTrend;25 25 float fWindSpeed; 26 26 float fWindDirection; 27 27 float fDustTotal; 28 double fSeeingMjd; 28 float fSolarimeter; 29 30 } __attribute__((__packed__)); 31 32 struct DimSeeing 33 { 34 DimSeeing() { memset(this, 0, sizeof(DimSeeing)); } 35 29 36 float fSeeing; 30 37 float fSeeingMed; 31 38 float fSeeingStdev; 32 float fSolarimeter;33 39 34 40 } __attribute__((__packed__)); -
trunk/FACT++/src/tngweather.cc
r18338 r18339 43 43 } 44 44 45 virtual void UpdateSeeing(const Time &, const DimSeeing &) 46 { 47 } 48 45 49 virtual void UpdateDust(const Time &, const float &) 46 50 { … … 56 60 Time fLastReport; 57 61 Time fLastReception; 62 63 Time fLastSeeing; 58 64 59 65 void HandleRead(const boost::system::error_code& err, size_t bytes_received) … … 168 174 169 175 DimWeather w; 170 w.fSeeingMjd = Time(mjd.text().toStdString()).Mjd();171 w.fSeeing = see .text().toFloat();172 w.fSeeingMed = med .text().toFloat();173 w.fSeeingStdev = sdev .text().toFloat();174 176 w.fDustTotal = dust .text().toFloat(); 175 w.fT rend= trend.text().toFloat();177 w.fTempTrend = trend.text().toFloat(); 176 178 w.fAirPressure = pres .text().toFloat(); 177 179 w.fDewPoint = dew .text().toFloat(); … … 182 184 w.fSolarimeter = solar.text().toFloat(); 183 185 184 const string obj = date.text().toStdString(); 185 186 Time time(obj); 187 if (!time.IsValid()) 186 DimSeeing s; 187 s.fSeeing = see .text().toFloat(); 188 s.fSeeingMed = med .text().toFloat(); 189 s.fSeeingStdev = sdev .text().toFloat(); 190 191 const string dateObj = date.text().toStdString(); 192 const string dateSee = mjd .text().toStdString(); 193 194 Time timeObj(dateObj); 195 Time timeSee(dateSee); 196 if (!timeObj.IsValid()) 188 197 { 189 198 struct tm tm; 190 199 191 200 vector<char> buf(255); 192 if (strptime(obj.c_str(), "%c", &tm)) 193 time = Time(tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, 194 tm.tm_hour, tm.tm_min, tm.tm_sec); 195 } 196 197 if (!time.IsValid()) 198 throw runtime_error("time invalid"); 199 200 if (time!=fLastReport && fIsVerbose) 201 if (strptime(dateObj.c_str(), "%c", &tm)) 202 timeObj = Time(tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, 203 tm.tm_hour, tm.tm_min, tm.tm_sec); 204 } 205 206 if (!timeSee.IsValid()) 207 { 208 struct tm tm; 209 210 vector<char> buf(255); 211 if (strptime(dateSee.c_str(), "%c", &tm)) 212 timeSee = Time(tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, 213 tm.tm_hour, tm.tm_min, tm.tm_sec); 214 215 Warn("Seeing time invalid ["+dateObj+"]"); 216 } 217 218 if (!timeObj.IsValid()) 219 throw runtime_error("object time invalid"); 220 221 if (timeObj!=fLastReport && fIsVerbose) 201 222 { 202 223 Out() << endl; 203 Out() << "Date: " << time << endl; 204 Out() << "Seeing: " << w.fSeeing << " [" << Time(w.fSeeingMjd) << "]" << endl; 205 Out() << "Seeing: " << w.fSeeingMed << " +- " << w.fSeeingStdev << endl; 206 Out() << "DustTotal: " << w.fDustTotal << endl; 207 Out() << "AirPressure: " << w.fAirPressure << endl; 208 Out() << "Trend: " << w.fTrend << endl; 209 Out() << "DewPoint: " << w.fDewPoint << endl; 210 Out() << "WindDirection: " << w.fWindDirection << endl; 211 Out() << "WindSpeed: " << w.fWindSpeed << endl; 212 Out() << "Humidity: " << w.fHumidity << endl; 213 Out() << "Temperature: " << w.fTemperature << endl; 214 Out() << "Solarimeter: " << w.fSolarimeter << endl; 224 Out() << "Date: " << timeObj << endl; 225 Out() << "DustTotal: " << w.fDustTotal << " ugr/m^2" << endl; 226 Out() << "AirPressure: " << w.fAirPressure << " mbar" << endl; 227 Out() << "DewPoint: " << w.fDewPoint << " deg C" << endl; 228 Out() << "WindDirection: " << w.fWindDirection << " deg" << endl; 229 Out() << "WindSpeed: " << w.fWindSpeed << " m/s" << endl; 230 Out() << "Humidity: " << w.fHumidity << "%" << endl; 231 Out() << "Temperature: " << w.fTemperature << " deg C" << endl; 232 Out() << "TempTrend 24h: " << w.fTempTrend << " deg C" << endl; 233 Out() << "Solarimeter: " << w.fSolarimeter << " W/m^2" << endl; 215 234 Out() << endl; 216 } 217 218 fLastReport = time; 219 220 UpdateWeather(time, w); 235 Out() << "Seeing: " << s.fSeeing << " arcsec [" << timeSee << "]" << endl; 236 Out() << "Seeing: " << s.fSeeingMed << " +- " << s.fSeeingStdev << endl; 237 Out() << endl; 238 } 239 240 fLastReport = timeObj; 241 242 UpdateWeather(timeObj, w); 243 244 if (timeSee.IsValid() && fLastSeeing!=timeSee) 245 { 246 UpdateSeeing(timeSee, s); 247 fLastSeeing = timeSee; 248 } 221 249 222 250 if (fDust==w.fDustTotal) 223 251 return; 224 252 225 UpdateDust(time , w.fDustTotal);253 UpdateDust(timeObj, w.fDustTotal); 226 254 fDust = w.fDustTotal; 227 255 228 256 ostringstream out; 229 out << setprecision(3) << "Dust: " << fDust << "ug/m^3 [" << time << "]";257 out << setprecision(3) << "Dust: " << fDust << "ug/m^3 [" << timeObj << "]"; 230 258 Message(out); 231 259 } … … 246 274 "User-Agent: FACT tngweather\r\n" 247 275 "Accept: */*\r\n" 248 "Host: "+ Address()+"\r\n"276 "Host: "+URL()+"\r\n" 249 277 "Connection: close\r\n"//Keep-Alive\r\n" 250 278 "Content-Type: application/rss+xml\r\n" … … 315 343 ConnectionWeather(ba::io_service& ioservice, MessageImp &imp) : Connection(ioservice, imp()), 316 344 fIsVerbose(true), fDust(-1), 317 fLastReport(Time::none), fLastReception(Time::none), 345 fLastReport(Time::none), fLastReception(Time::none), fLastSeeing(Time::none), 318 346 fKeepAlive(ioservice) 319 347 { … … 360 388 DimDescribedService fDimWeather; 361 389 DimDescribedService fDimAtmosphere; 390 DimDescribedService fDimSeeing; 362 391 363 392 virtual void UpdateWeather(const Time &t, const DimWeather &data) … … 371 400 fDimAtmosphere.setData(&dust, sizeof(float)); 372 401 fDimAtmosphere.Update(t); 402 } 403 404 virtual void UpdateSeeing(const Time &t, const DimSeeing &see) 405 { 406 fDimSeeing.setData(&see, sizeof(DimSeeing)); 407 fDimSeeing.Update(t); 373 408 } 374 409 … … 376 411 ConnectionDimWeather(ba::io_service& ioservice, MessageImp &imp) : 377 412 ConnectionWeather(ioservice, imp), 378 fDimWeather("TNG_WEATHER/DATA", "F:1;F:1;F:1;F:1;F:1;F:1;F:1;F:1; D:1;F:1;F:1;F:1;F:1",413 fDimWeather("TNG_WEATHER/DATA", "F:1;F:1;F:1;F:1;F:1;F:1;F:1;F:1;F:1", 379 414 "|T[deg C]:Temperature" 415 "|DeltaT[deg C]:Temperature trend 24h" 380 416 "|T_dew[deg C]:Dew point" 381 417 "|H[%]:Humidity" 382 418 "|P[mbar]:Air pressure" 383 "|Trend"384 419 "|v[km/h]:Wind speed" 385 420 "|d[deg]:Wind direction (N-E)" 386 421 "|Dust[ug/m^3]:Dust (total)" 387 "|SeeingDate[mjd]:Seeing MJD"388 "|Seeing[arcsec]:Seeing"389 "|Seeing[arcsec]:Seeing Median"390 "|SeeingStdev[arcsec]:Seeing Stdev"391 422 "|Solarimeter[W/m^2]:Solarimeter"), 392 423 fDimAtmosphere("TNG_WEATHER/DUST", "F:1", 393 "|Dust[ug/m^3]:Dust (total)") 424 "|Dust[ug/m^3]:Dust (total)"), 425 fDimSeeing("TNG_WEATHER/SEEING", "F:1;F:1;F:1", 426 "|Seeing[arcsec]:Seeing" 427 "|Seeing[arcsec]:Seeing Median" 428 "|SeeingStdev[arcsec]:Seeing Stdev") 394 429 { 395 430 }
Note:
See TracChangeset
for help on using the changeset viewer.