Changeset 12535
- Timestamp:
- 11/16/11 10:24:51 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/datalogger.cc
r12480 r12535 386 386 bool fShouldAutoStart; 387 387 bool fAutoStarted; 388 389 //Current day variable. Used to close nightly files when night changes 390 int fCurrentDay; 388 391 public: 389 392 int Write(const Time &time, const std::string &txt, int qos=kMessage); … … 751 754 //initialize member data 752 755 fFilePath = "."; 756 757 //calculate time "centered" around noon instead of midnight 758 const Time timeNow; 759 const Time nowMinusTwelve = timeNow-boost::posix_time::hours(12); 760 fCurrentDay = nowMinusTwelve.M()*31 + nowMinusTwelve.D();//assume 31 days per month. we do not really care, only want unique number per day of the year 753 761 754 762 //Give a name to this machine's specific states … … 1179 1187 // of only one. 1180 1188 // 1181 if (Time().h() == 12 && !fDailyFileDayChangedAlready) 1182 { 1189 // Last but not least, the datalogger MUST receive at least one service update during 1190 // noon otherwise this is skipped (which is not good). Thus I would suggest that the datalogger 1191 // should always subscribe to at least its statistics services. 1192 // 1193 //calculate time "centered" around noon instead of midnight 1194 const Time timeNow; 1195 const Time nowMinusTwelve = timeNow-boost::posix_time::hours(12); 1196 int newDayNumber = nowMinusTwelve.M()*31 + nowMinusTwelve.D();//assume 31 days per month. we do not really care, only want unique number per day of the year 1197 1198 // if (Time().h() == 12 && !fDailyFileDayChangedAlready) 1199 if (newDayNumber != fCurrentDay) 1200 { 1201 fCurrentDay = newDayNumber; 1202 //crawl through the subcriptions and close any open nightly file 1203 SubscriptionsListType::iterator x; 1204 map<string, SubscriptionType>::iterator y; 1205 for (x=fServiceSubscriptions.begin(); x != fServiceSubscriptions.end(); x++) 1206 {//find current service is subscriptions 1207 for (y=x->second.begin(); y!=x->second.end();y++) 1208 if (y->second.nightlyFile.IsOpen()) 1209 { 1210 y->second.nightlyFile.Close(); 1211 } 1212 } 1213 1183 1214 if (fDebugIsOn) 1184 Debug(" Its Noon! Closing and reopening nightly textfiles");1215 Debug("Day have changed! Closing and reopening nightly files"); 1185 1216 1186 1217 fNightlyLogFile << endl; … … 1208 1239 } 1209 1240 1210 fDailyFileDayChangedAlready = true;1211 } 1212 if (Time().h() != 12 && fDailyFileDayChangedAlready)1213 fDailyFileDayChangedAlready = false;1241 // fDailyFileDayChangedAlready = true; 1242 } 1243 // if (Time().h() != 12 && fDailyFileDayChangedAlready) 1244 // fDailyFileDayChangedAlready = false; 1214 1245 1215 1246 //create the converter for that service … … 1325 1356 //check if the last received event was before noon and if current one is after noon. 1326 1357 //if so, close the file so that it gets reopened. 1327 if (sub.nightlyFile.IsOpen())1328 if ((sub.lastReceivedEvent != Time::None) && (sub.lastReceivedEvent.h() < 12) && (cTime.h() >= 12))1329 {1330 sub.nightlyFile.Close();1331 }1358 // if (sub.nightlyFile.IsOpen()) 1359 // if ((sub.lastReceivedEvent != Time::None) && (sub.lastReceivedEvent.h() < 12) && (cTime.h() >= 12)) 1360 // { 1361 // sub.nightlyFile.Close(); 1362 // } 1332 1363 sub.lastReceivedEvent = cTime;//ici 1333 1364 if (!sub.nightlyFile.IsOpen() || !sub.runFile.IsOpen() || sub.runNumber != sub.runFile.fRunNumber)
Note:
See TracChangeset
for help on using the changeset viewer.