Changeset 14702 for trunk/FACT++
- Timestamp:
- 11/26/12 12:13:31 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/EventBuilderWrapper.h
r14685 r14702 110 110 111 111 string fPath; 112 uint64_t fNightAsInt; 112 113 uint32_t fRunNumber; 113 114 114 115 protected: 115 int64_t InitRunNumber() 116 { 116 bool InitRunNumber(const string &path="") 117 { 118 if (!path.empty()) 119 { 120 if (!DimWriteStatistics::DoesPathExist(path, fMsg)) 121 { 122 fMsg.Error("Data path "+path+" does not exist!"); 123 return false; 124 } 125 126 fPath = path; 127 fDimWriteStats.SetCurrentFolder(fPath); 128 129 fMsg.Info("Data path set to "+path+"."); 130 } 131 132 // Get current night 133 const uint64_t night = Time().NightAsInt(); 134 if (night==fNightAsInt) 135 return true; 136 137 // Check for run numbers 117 138 fRunNumber = 1000; 118 139 119 // Ensure that the night doesn't change during our check120 const int check = Time().NightAsInt();121 122 140 while (--fRunNumber>0) 123 141 { 124 const string name = DataProcessorImp::FormFileName(fPath, fRunNumber, "");142 const string name = DataProcessorImp::FormFileName(fPath, night, fRunNumber, ""); 125 143 126 144 if (access((name+"bin").c_str(), F_OK) == 0) … … 130 148 if (access((name+"drs.fits").c_str(), F_OK) == 0) 131 149 break; 132 133 } 134 135 if (check != Time().NightAsInt()) 136 return InitRunNumber(); 137 150 } 151 152 // This is now the first file which does not exist 138 153 fRunNumber++; 139 154 155 // Check if we have exceeded the maximum 140 156 if (fRunNumber==1000) 141 157 { 142 fMsg.Error("You have a file with run-number 1000 in "+fPath );143 return -1;158 fMsg.Error("You have a file with run-number 1000 in "+fPath+" ["+to_string(night)+"]"); 159 return false; 144 160 } 145 161 146 162 ostringstream str; 147 str << "Set next run-number to " << fRunNumber << " determined from '" << (fPath.empty()?".":fPath) << "'"; 163 if (fNightAsInt==0) 164 str << "First night..."; 165 else 166 str << "Night has changd from " << fNightAsInt << "... new"; 167 str << " run-number is " << night << "-" << setfill('0') << setw(3) << fRunNumber << " [" << (fPath.empty()?".":fPath) << "]"; 148 168 fMsg.Message(str); 149 169 150 //fMsg.Info(" ==> TODO: Crosscheck with database!"); 151 152 return check; 153 } 154 155 int64_t InitRunNumber(const string &path) 156 { 157 if (!DimWriteStatistics::DoesPathExist(path, fMsg)) 158 { 159 fMsg.Error("Data path "+path+" does not exist!"); 160 return -1; 161 } 162 163 //const fs::path fullPath = fs::system_complete(fs::path(path)); 164 165 fPath = path; 166 167 fDimWriteStats.SetCurrentFolder(fPath); 168 169 return InitRunNumber(); 170 fNightAsInt = night; 171 172 return true; 170 173 } 171 174 … … 255 258 "|numConn[int]:number of sockets successfully opened per board"), 256 259 fDimFileFormat ("FAD_CONTROL/FILE_FORMAT", "S:1", ""), 257 fDebugStream(false), fDebugRead(false), fDebugLog(false) 260 fDebugStream(false), fDebugRead(false), fDebugLog(false), fNightAsInt(0) 258 261 { 259 262 if (This) … … 298 301 ref.second, 299 302 }; 303 304 if (!InitRunNumber()) 305 return 0; 300 306 301 307 // FIMXE: Maybe reset an event counter so that the mcp can count events? … … 630 636 switch (fFileFormat) 631 637 { 632 case FAD::kNone: file = new DataDump(fPath, runid, fMsg); break;633 case FAD::kDebug: file = new DataDebug(fPath, runid, fMsg); break;634 case FAD::kCfitsio: file = new DataWriteFits(fPath, runid, fMsg); break;635 case FAD::kFits: file = new DataWriteFits2(fPath, runid, fMsg); break;636 case FAD::kRaw: file = new DataWriteRaw(fPath, runid, fMsg); break;637 case FAD::kCalib: file = new DataCalib(fPath, runid, fDimDrsCalibration, fDimDrsRuns, fMsg); break;638 case FAD::kNone: file = new DataDump(fPath, fNightAsInt, runid, fMsg); break; 639 case FAD::kDebug: file = new DataDebug(fPath, fNightAsInt, runid, fMsg); break; 640 case FAD::kCfitsio: file = new DataWriteFits(fPath, fNightAsInt, runid, fMsg); break; 641 case FAD::kFits: file = new DataWriteFits2(fPath, fNightAsInt, runid, fMsg); break; 642 case FAD::kRaw: file = new DataWriteRaw(fPath, fNightAsInt, runid, fMsg); break; 643 case FAD::kCalib: file = new DataCalib(fPath, fNightAsInt, runid, fDimDrsCalibration, fDimDrsRuns, fMsg); break; 638 644 } 639 645 … … 1050 1056 } 1051 1057 1052 void IncreaseRunNumber(uint32_t run) 1053 { 1054 if (run>fRunNumber) 1055 fRunNumber = run; 1058 bool IncreaseRunNumber(uint32_t run) 1059 { 1060 if (!InitRunNumber()) 1061 return false; 1062 1063 if (run<fRunNumber) 1064 { 1065 ostringstream msg; 1066 msg << 1067 "Run number " << run << " smaller than next available " 1068 "run number " << fRunNumber << " in " << fPath << " [" << fNightAsInt << "]"; 1069 fMsg.Error(msg); 1070 return false; 1071 } 1072 1073 fRunNumber = run; 1074 1075 return true; 1056 1076 } 1057 1077
Note:
See TracChangeset
for help on using the changeset viewer.