Changeset 15153
- Timestamp:
- 03/26/13 17:01:18 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/datalogger.cc
r15107 r15153 85 85 86 86 #include "DimState.h" 87 88 #include <libnova/solar.h> 89 #include <libnova/rise_set.h> 87 90 88 91 //Dim structures … … 239 242 //overloading of DIM's infoHandler function 240 243 int infoCallback(const EventImp& evt, unsigned int infoIndex); 244 245 Time GetSunRise(const Time &time=Time()); 241 246 242 247 /*************************************************** … … 386 391 387 392 //Current day variable. Used to close nightly files when night changes 388 intfCurrentDay;393 Time fCurrentDay; 389 394 Time lastFlush; 390 395 … … 849 854 850 855 //calculate time suitable for naming files. 851 const Time ftime = time-boost::posix_time::hours(12); 856 //fCurrentDay is 30 minutes after upcoming sunrise. So just use 12 hours before then 857 const Time ftime = fCurrentDay-boost::posix_time::hours(12); 852 858 853 859 //output it … … 858 864 CreateDirectory(str.str()); 859 865 860 str << '/' << CompileFileName(service, extension, time);866 str << '/' << CompileFileName(service, extension, fCurrentDay); 861 867 862 868 return str.str(); … … 916 922 //calculate time "centered" around noon instead of midnight 917 923 const Time timeNow; 918 const Time nowMinusTwelve = timeNow-boost::posix_time::hours(12); 919 fCurrentDay = (int)(nowMinusTwelve.Mjd());//nowMinusTwelve.M()*31 + nowMinusTwelve.D();//assume 31 days per month. we do not really care, only want unique number per day of the year 924 // const Time nowMinusTwelve = timeNow-boost::posix_time::hours(12); 925 //the "current day" is actually the next closing time of nightly files 926 //the next closing time is 30 minutes after upcoming sunrise. 927 //If we are within 30 minutes after sunrise, closing time is soon 928 fCurrentDay = GetSunRise(Time()-boost::posix_time::minutes(30)) + boost::posix_time::minutes(30);//(int)(nowMinusTwelve.Mjd());//nowMinusTwelve.M()*31 + nowMinusTwelve.D();//assume 31 days per month. we do not really care, only want unique number per day of the year 920 929 lastFlush = Time(); 921 930 … … 1255 1264 AddNewRunNumber(evt.GetXtra(), evt.GetTime()); 1256 1265 } 1266 // -------------------------------------------------------------------------- 1267 // 1268 //! Get SunRise. Copied from drivectrl.cc 1269 //! Used to know when to close and reopen files 1270 //! 1271 Time DataLogger::GetSunRise(const Time &time) 1272 { 1273 const double lon = -(17.+53./60+26.525/3600); 1274 const double lat = 28.+45./60+42.462/3600; 1275 1276 ln_lnlat_posn observer; 1277 observer.lng = lon; 1278 observer.lat = lat; 1279 1280 // This caluclates the sun-rise of the next day after 12:00 noon 1281 ln_rst_time sun_day; 1282 if (ln_get_solar_rst(time.JD(), &observer, &sun_day)==1) 1283 { 1284 Fatal("GetSunRise reported the sun to be circumpolar!"); 1285 return Time(Time::none); 1286 } 1287 1288 if (Time(sun_day.rise)>=time) 1289 return Time(sun_day.rise); 1290 1291 if (ln_get_solar_rst(time.JD()+0.5, &observer, &sun_day)==1) 1292 { 1293 Fatal("GetSunRise reported the sun to be circumpolar!"); 1294 return Time(Time::none); 1295 } 1296 1297 return Time(sun_day.rise); 1298 } 1257 1299 1258 1300 // -------------------------------------------------------------------------- … … 1285 1327 // if number of days has changed, then files should be closed and reopenned. 1286 1328 const Time timeNow; 1287 const Time nowMinusTwelve = timeNow-boost::posix_time::hours(12);1288 int newDayNumber = (int)(nowMinusTwelve.Mjd());//nowMinusTwelve.M()*31 + nowMinusTwelve.D();//assume 31 days per month. we do not really care, only want unique number per day of the year 1329 // const Time nowMinusTwelve = timeNow-boost::posix_time::hours(12); 1330 // int newDayNumber = (int)(nowMinusTwelve.Mjd()); 1289 1331 1290 1332 //also check if we should flush the nightly files … … 1305 1347 Debug("Just flushed nightly fits files to the disk"); 1306 1348 } 1307 1308 if (newDayNumber != fCurrentDay) 1309 { 1310 fCurrentDay = newDayNumber; 1349 //check if we should close and reopen the nightly files 1350 if (timeNow > fCurrentDay)//GetSunRise(fCurrentDay)+boost::posix_time::minutes(30)) //if we went past 30 minutes after sunrise 1351 { 1352 //set the next closing time. If we are here, we have passed 30 minutes after sunrise. 1353 fCurrentDay = GetSunRise(timeNow-boost::posix_time::minutes(30))+boost::posix_time::minutes(30); 1311 1354 //crawl through the subcriptions and close any open nightly file 1312 1355 SubscriptionsListType::iterator x; … … 1374 1417 if (isItaReport) 1375 1418 { 1419 //DISABLED REPORT WRITING BY THOMAS REQUEST 1376 1420 //write text header 1377 string serviceName = (sub.service == "MESSAGE") ? "" : "_"+sub.service;1421 /* string serviceName = (sub.service == "MESSAGE") ? "" : "_"+sub.service; 1378 1422 header << sub.server << serviceName << " " << fQuality << " "; 1379 1423 header << evt.GetTime() << " "; … … 1414 1458 return; 1415 1459 } 1460 */ 1416 1461 #ifdef HAVE_FITS 1417 1462 //check if the last received event was before noon and if current one is after noon.
Note:
See TracChangeset
for help on using the changeset viewer.