Changeset 15343
- Timestamp:
- 04/15/13 13:06:27 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/EventBuilder.c
r15342 r15343 2325 2325 return -1; 2326 2326 2327 } /*-----------------------------------------------------------------*/ 2327 } 2328 2329 void checkAndCloseRun(int j, int irun, int cond, char *where) 2330 { 2331 if (!cond && 2332 runCtrl[j].closeTime >= g_actTime && 2333 runCtrl[j].lastTime >= g_actTime - 300 && 2334 runCtrl[j].maxEvt >= runCtrl[j].actEvt) 2335 return; 2336 2337 //close run for whatever reason 2338 if (runCtrl[j].runId == gi_myRun) 2339 gi_myRun = g_actTime; 2340 2341 int ii = 0; 2342 if (cond) 2343 ii = 1; 2344 if (runCtrl[j].closeTime < g_actTime) 2345 ii |= 2; // = 2; 2346 if (runCtrl[j].lastTime < g_actTime - 300) 2347 ii |= 4; // = 3; 2348 if (runCtrl[j].maxEvt <= runCtrl[j].actEvt) 2349 ii |= 8; // = 4; 2350 2351 if (runCtrl[j].procId == 0) 2352 { 2353 runFinish1(runCtrl[j].runId); 2354 runCtrl[j].procId = 92; 2355 } 2356 2357 runCtrl[j].closeTime = g_actTime - 1; 2358 2359 const int rc = runClose(runCtrl[j].fileHd, &runTail[j], sizeof(runTail[j])); 2360 if (rc<0) 2361 { 2362 factPrintf(kError, 503, "writeEvt-%s: Error closing run %d (runClose[1],rc=%d)", 2363 where, runCtrl[j].runId, rc); 2364 runCtrl[j].fileId = 92; 2365 } 2366 else 2367 { 2368 factPrintf(kInfo, 503, "writeEvt-%s: Closed run %d (ii=%d)", 2369 where, irun, ii); 2370 runCtrl[j].fileId = 93; 2371 } 2372 } 2373 2374 /*-----------------------------------------------------------------*/ 2328 2375 2329 2376 … … 2437 2484 // snprintf (str, MXSTR,"write event %d size %d",ievt,sizeof (mBuffer[id])); 2438 2485 // factOut (kInfo, 504, str); 2439 int i= runWrite (runCtrl[j].fileHd, mBuffer[id].fEvent,2486 const int rc = runWrite (runCtrl[j].fileHd, mBuffer[id].fEvent, 2440 2487 sizeof (mBuffer[id])); 2441 if ( i>= 0) {2488 if (rc >= 0) { 2442 2489 runCtrl[j].lastTime = g_actTime; 2443 2490 runCtrl[j].actEvt++; … … 2453 2500 } 2454 2501 2455 if (i < 0 2456 || runCtrl[j].lastTime < g_actTime - 300 2457 || runCtrl[j].closeTime < g_actTime 2458 || runCtrl[j].maxEvt < runCtrl[j].actEvt) { 2459 int ii = 0; 2460 if (i < 0) 2461 ii = 1; 2462 /*else*/ if (runCtrl[j].closeTime < g_actTime) 2463 ii |= 2; // = 2; 2464 /*else*/ if (runCtrl[j].lastTime < g_actTime - 300) 2465 ii |= 4; // = 3; 2466 /*else*/ if (runCtrl[j].maxEvt <= runCtrl[j].actEvt) 2467 ii |= 8; // = 4; 2468 2469 2470 2471 //close run for whatever reason 2472 if (runCtrl[j].runId == gi_myRun) 2473 gi_myRun = g_actTime; 2474 2475 if (runCtrl[j].procId == 0) { 2476 runFinish1 (runCtrl[j].runId); 2477 runCtrl[j].procId = 92; 2478 } 2479 2480 runCtrl[j].closeTime = g_actTime - 1; 2481 i = runClose (runCtrl[j].fileHd, &runTail[j], 2482 sizeof (runTail[j])); 2483 if (i < 0) { 2484 factPrintf(kError, 503, "writeEvt: Error closing run %d (runClose[1],i=%d)", runCtrl[j].runId, i); 2485 runCtrl[j].fileId = 92; 2486 } else { 2487 factPrintf(kInfo, 503, "writeEvt: Closed run %d (ii[1]=%d)", irun, ii); 2488 runCtrl[j].fileId = 93; 2489 } 2490 } 2502 checkAndCloseRun(j, irun, rc<0, "1"); 2491 2503 } 2492 2504 } … … 2535 2547 } 2536 2548 } 2537 for (j = 0; j < MAX_RUN; j++) { 2538 if (runCtrl[j].fileId == 0 2539 && (runCtrl[j].closeTime < g_actTime 2540 || runCtrl[j].lastTime < g_actTime - 300 2541 || runCtrl[j].maxEvt <= runCtrl[j].actEvt 2542 || (runCtrl[j].lastTime < lastStartedTime && runCtrl[j].runId != 0))) //ETIENNE added the condition at this line. dunno what to do with run 0: skipping it 2543 { 2544 if (runCtrl[j].runId == gi_myRun) 2545 gi_myRun = g_actTime; 2546 2547 int ii = 0; 2548 if (runCtrl[j].closeTime < g_actTime) 2549 ii |= 2; // = 2 2550 /*else*/ if (runCtrl[j].lastTime < g_actTime - 300) 2551 ii |= 4; // = 3 2552 /*else*/ if (runCtrl[j].maxEvt <= runCtrl[j].actEvt) 2553 ii |= 8; // = 4 2554 2555 if (runCtrl[j].procId == 0) { 2556 runFinish1 (runCtrl[j].runId); 2557 runCtrl[j].procId = 92; 2558 } 2559 2560 runCtrl[j].closeTime = g_actTime - 1; 2561 int i = runClose (runCtrl[j].fileHd, &runTail[j], 2562 sizeof (runTail[j])); 2563 if (i < 0) { 2564 factPrintf(kError, 506, "writeEvt: Error closing run %d (runClose[2],i=%d)", runCtrl[j].runId, i); 2565 runCtrl[j].fileId = 94; 2566 } else { 2567 factPrintf(kInfo, 507, "writeEvt: Closed run %d (ii[2]=%d)", runCtrl[j].runId, ii); 2568 runCtrl[j].fileId = 95; 2569 } 2570 } 2549 for (j = 0; j < MAX_RUN; j++) 2550 { 2551 if (runCtrl[j].fileId == 0) 2552 { 2553 //ETIENNE added the condition at this line. dunno what to do with run 0: skipping it 2554 const int cond = runCtrl[j].lastTime < lastStartedTime && runCtrl[j].runId != 0; 2555 checkAndCloseRun(j, runCtrl[j].runId, cond, "2"); 2556 } 2571 2557 } 2572 2558
Note:
See TracChangeset
for help on using the changeset viewer.