Changeset 15184
- Timestamp:
- 03/29/13 20:41:49 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/ftmctrl.cc
r15132 r15184 1207 1207 uint64_t fTimeStampOn; 1208 1208 uint32_t fTriggerCounter; 1209 uint64_t fPrevState; 1209 1210 1210 1211 void UpdateFirstHeader() … … 1253 1254 fDimDynamicData.Update(data); 1254 1255 1255 float rate = -1; 1256 uint64_t tdiff = 0; 1257 uint64_t odiff = 0; 1258 if (fHeader.fTimeStamp>=fTimeStamp && fHeader.fTriggerCounter>=fTriggerCounter) 1259 { 1260 tdiff = fHeader.fTimeStamp -fTimeStamp; 1261 odiff = fDynamicData.fOnTimeCounter -fTimeStampOn; 1262 1263 const uint32_t cdiff = fHeader.fTriggerCounter-fTriggerCounter; 1264 rate = tdiff==0 ? 0 : 1000000*float(cdiff)/tdiff; 1265 } 1256 uint64_t odiff = fDynamicData.fOnTimeCounter; 1257 uint32_t cdiff = fHeader.fTriggerCounter; 1258 1259 // When the state changes (trigger on or trigger off) 1260 // The counters will be resetted, thus in the next report 1261 // the correct counters are the counters itself, or the correct 1262 // offset is 0. For the first call, fPrevState is 0 (which is not 1263 // a valid state, so it will be considered as 'changed') and 1264 // fTimeStamp, fTimeStampOn and fTriggerCounter are also 0. 1265 // The checks on the on-time counter and the trigger counter 1266 // are just for the very unlikely case that we miss the state 1267 // change because we get no updated reports in between. 1268 const uint8_t state = fHeader.fState & FTM::States::kFtmStates; 1269 1270 if (state == fPrevState && fHeader.fTriggerCounter>=fTriggerCounter && 1271 fDynamicData.fOnTimeCounter>=fTimeStampOn) 1272 { 1273 odiff -= fTimeStampOn; 1274 cdiff -= fTriggerCounter; 1275 } 1276 1277 // The observation time calculated in the first report is most likely 1278 // too large because the previous report is taken as reference, 1279 // but this is the best what could be done. 1280 const uint64_t tdiff = fHeader.fTimeStamp - fTimeStamp; 1281 const float rate = fHeader.fTimeStamp>fTimeStamp ? 0 : 1000000*float(cdiff)/tdiff; 1266 1282 1267 1283 fTimeStamp = fHeader.fTimeStamp; 1268 1284 fTimeStampOn = fDynamicData.fOnTimeCounter; 1269 1285 fTriggerCounter = fHeader.fTriggerCounter; 1286 fPrevState = state; 1270 1287 1271 1288 const FTM::DimTriggerRates rates(fHeader, fDynamicData, fStaticData, … … 1317 1334 "|BoardRate[Hz]:Trigger rate of individual FTUs" 1318 1335 "|PatchRate[Hz]:Trigger rate of individual patches" 1319 "|ElapsedTime[s ec]:Time elapsed since previous report"1320 "|OnTime[s ec]:OnTime elapsed since previous report"),1336 "|ElapsedTime[s]:Time elapsed since previous report" 1337 "|OnTime[s]:OnTime elapsed since previous report"), 1321 1338 fDimError ("FTM_CONTROL/ERROR", "X:1;S:1;S:28", ""), 1322 1339 fDimFtuList ("FTM_CONTROL/FTU_LIST", "X:1;X:1;S:1;C:4;X:40;C:40;C:40", … … 1369 1386 "|NumErrors[int]:Num. of error messages" 1370 1387 "|NumRegister[int]:Num. of answers from a single register accesess"), 1371 fTimeStamp(UINT64_MAX), 1372 fTriggerCounter(UINT32_MAX) 1388 fTimeStamp(0), fTimeStampOn(0), fTriggerCounter(0), fPrevState(0) 1373 1389 { 1374 1390 } … … 1988 2004 fCounterStat = fFTM.GetCounter(FTM::kStaticData); 1989 2005 2006 // T::Info(" ==> TODO: Update run in database!"); 1990 2007 T::Message("Sending new configuration was successfull."); 1991 2008
Note:
See TracChangeset
for help on using the changeset viewer.