Changeset 12485 for trunk


Ignore:
Timestamp:
11/10/11 04:33:09 (13 years ago)
Author:
lyard
Message:
Extreme memory swapping
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/EventBuilder.c

    r12474 r12485  
    11091109                        maxread, MSG_DONTWAIT);
    11101110//                      rd[i].bufLen, MSG_DONTWAIT);
    1111 
    11121111               if (jrd > 0) {
    11131112                  debugStream (i, &rd[i].rBuf->B[rd[i].bufPos], jrd);
     
    12261225*/
    12271226                 //we have a complete buffer, copy to WORK area
     1227
     1228
     1229                  //End of the header. to channels now
     1230                  int eCount = 0;
     1231                  int eStart = 36;
     1232                  int ePatchesCount = 0;
     1233                  int currentRoi;
     1234                  for (;ePatchesCount<4*9;ePatchesCount++)
     1235                  {
     1236                      rd[i].rBuf->S[eStart+eCount] = ntohs(rd[i].rBuf->S[eStart+eCount]);//id
     1237                      eCount++;
     1238                      rd[i].rBuf->S[eStart+eCount] = ntohs(rd[i].rBuf->S[eStart+eCount]);//start_cell
     1239                      eCount++;
     1240                      rd[i].rBuf->S[eStart+eCount] = ntohs(rd[i].rBuf->S[eStart+eCount]);//roi
     1241                      currentRoi = rd[i].rBuf->S[eStart+eCount];
     1242                      eCount++;
     1243                      rd[i].rBuf->S[eStart+eCount] = ntohs(rd[i].rBuf->S[eStart+eCount]);//filling
     1244                      eCount++;
     1245                      eCount+=currentRoi;//skip the pixel data
     1246                  }
     1247        //                        snprintf(str, MXSTR, "Swapped %d bytes", eCount*2);
     1248        //                        factOut(kError, 000, str);
     1249
     1250                  //channels done. footer now
     1251   //               rd[i].rBuf->S[eStart+eCount] = ntohs(rd[i].rBuf->S[eStart+eCount]);//package_crc
     1252   //               eCount++;
     1253   //               rd[i].rBuf->S[eStart+eCount] = ntohs(rd[i].rBuf->S[eStart+eCount]);//end_package_flag
     1254   //               snprintf(str, MXSTR, "Bytes read %d bytes swapped %d", jrd, eCount*2);
     1255   //               factOut(kInfo, 000, str);
     1256                  //ETIENNE end of bytes swapping already
     1257
     1258
    12281259                  int jr, kr;
    12291260                  int  checkRoi;
    12301261                  int roiHopper = head_len/2 + 2; //points to the very first roi
    1231                   roi[0] = ntohs (rd[i].rBuf->S[roiHopper]);
     1262                  roi[0] = rd[i].rBuf->S[roiHopper];
    12321263                  roiHopper += roi[0]+4;//skip to the second roi (i.e. next board, same patch-pixel)
    12331264                  for (kr = 1; kr < 4; kr++)
    12341265                  {
    1235                       checkRoi = ntohs(rd[i].rBuf->S[roiHopper]);
     1266                      checkRoi = rd[i].rBuf->S[roiHopper];
    12361267                      if (checkRoi != roi[0])
    12371268                      {
     
    12441275                  //roiHopper now points to the first pixel of board 2. Do the 8 remaining pixels
    12451276                  for (jr = 1; jr < 9; jr++) {
    1246                      roi[jr] = ntohs(rd[i].rBuf->S[roiHopper]);
     1277                     roi[jr] = rd[i].rBuf->S[roiHopper];
    12471278                     checkRoi = roi[jr];
    12481279                     for (kr = 1; kr < 4; kr++)
    12491280                     {
    12501281                         roiHopper += checkRoi+4;
    1251                          checkRoi = ntohs(rd[i].rBuf->S[roiHopper]);
     1282                         checkRoi = rd[i].rBuf->S[roiHopper];
    12521283                         if (checkRoi != roi[jr])
    12531284                         {
     
    13071338                  int qncpy = 0;
    13081339                  boardId = b;
    1309                   int fadBoard = ntohs (rd[i].rBuf->S[12]);
     1340                  int fadBoard = rd[i].rBuf->S[12];
    13101341                  int fadCrate = fadBoard / 256;
    13111342                  if (boardId != (fadCrate * 10 + fadBoard % 256)) {
     
    13341365                  for (px = 0; px < 9; px++) {  //different sort in FAD board.....
    13351366                     for (drs = 0; drs < 4; drs++) {
    1336                         pixH = ntohs (rd[i].rBuf->S[src++]);    // ID
    1337                         pixC = ntohs (rd[i].rBuf->S[src++]);    // start-cell
    1338                         pixR = ntohs (rd[i].rBuf->S[src++]);    // roi
     1367                        pixH = rd[i].rBuf->S[src++];    // ID
     1368                        pixC = rd[i].rBuf->S[src++];    // start-cell
     1369                        pixR = rd[i].rBuf->S[src++];    // roi
    13391370//here we should check if pixH is correct ....
    13401371
     
    14491480                     }
    14501481                     goodhed++;
    1451                      rd[i].fadLen = ntohs (rd[i].rBuf->S[1]) * 2;
    1452                      rd[i].fadVers = ntohs (rd[i].rBuf->S[2]);
    1453                      rd[i].ftmTyp = ntohs (rd[i].rBuf->S[5]);
    1454                      rd[i].ftmID = ntohl (rd[i].rBuf->I[3]);    //(FTMevt)
    1455                      rd[i].evtID = ntohl (rd[i].rBuf->I[4]);    //(FADevt)
    1456                      rd[i].runID = ntohl (rd[i].rBuf->I[11]);
     1482                     //ETIENNE swap the header bytes already
     1483                     int eStart = 0;
     1484                     rd[i].rBuf->S[eStart+0] = ntohs(rd[i].rBuf->S[eStart+0]);//start_package_flag
     1485                     rd[i].rBuf->S[eStart+1] = ntohs(rd[i].rBuf->S[eStart+1]);//package_length
     1486                     rd[i].rBuf->S[eStart+2] = ntohs(rd[i].rBuf->S[eStart+2]);//version_no
     1487                     rd[i].rBuf->S[eStart+3] = ntohs(rd[i].rBuf->S[eStart+3]);//PLLLCK
     1488                     rd[i].rBuf->S[eStart+4] = ntohs(rd[i].rBuf->S[eStart+4]);//trigger_crc
     1489                     rd[i].rBuf->S[eStart+5] = ntohs(rd[i].rBuf->S[eStart+5]);//trigger_type
     1490                     rd[i].rBuf->I[eStart+3] = ntohl(rd[i].rBuf->I[eStart+3]);//trigger_id
     1491                     rd[i].rBuf->I[eStart+4] = ntohl(rd[i].rBuf->I[eStart+4]);//fad_evt_counter
     1492                     rd[i].rBuf->I[eStart+5] = ntohl(rd[i].rBuf->I[eStart+5]);//REFCLK_frequency
     1493                    rd[i].rBuf->S[eStart+12] = ntohs(rd[i].rBuf->S[eStart+12]);//board_id
     1494                     rd[i].rBuf->S[eStart+14] = ntohs(rd[i].rBuf->S[eStart+14]);//number_of_triggers_to_generate
     1495                     rd[i].rBuf->S[eStart+15] = ntohs(rd[i].rBuf->S[eStart+15]);//trigger_generator_prescaler
     1496                   //  int eInter = ntohl(rd[i].rBuf->I[eStart+8]);//DNA
     1497                    // rd[i].rBuf->I[eStart+8] = ntohl(rd[i].rBuf->I[eStart+9]);
     1498                     //rd[i].rBuf->I[eStart+9] = eInter;
     1499                     rd[i].rBuf->I[eStart+10] = ntohl(rd[i].rBuf->I[eStart+10]);//time
     1500                     rd[i].rBuf->I[eStart+11] = ntohl(rd[i].rBuf->I[eStart+11]);//runnumber;
     1501                     int eCount = 24;
     1502                     for (;eCount<24+NTemp;eCount++)
     1503                         rd[i].rBuf->S[eStart+eCount] = ntohs(rd[i].rBuf->S[eStart+eCount]);//drs_temperature
     1504                     for (; eCount < 24+NTemp+NDAC; eCount++)
     1505                         rd[i].rBuf->S[eStart+eCount] = ntohs(rd[i].rBuf->S[eStart+eCount]);//dac
     1506
     1507
     1508 //                    rd[i].fadLen = rd[i].rBuf->S[1] * 2;
     1509//                                       snprintf(str, MXSTR, "Size of the fad buffer: %d", rd[i].fadLen);
     1510//                                       factOut(kError, 000, str);
     1511                                         
     1512                     rd[i].fadVers = rd[i].rBuf->S[2];
     1513                     rd[i].ftmTyp = rd[i].rBuf->S[5];
     1514                     rd[i].ftmID = rd[i].rBuf->I[3];    //(FTMevt)
     1515                     rd[i].evtID = rd[i].rBuf->I[4];    //(FADevt)
     1516                     rd[i].runID = rd[i].rBuf->I[11];
    14571517                     rd[i].bufTyp = 1;  //ready to read full record
    14581518                     rd[i].bufLen = rd[i].fadLen - rd[i].bufPos;
    14591519
    1460                      int fadboard = ntohs (rd[i].rBuf->S[12]);
     1520                     int fadboard = rd[i].rBuf->S[12];
    14611521                     int fadcrate = fadboard / 256;
    14621522                     fadboard = (fadcrate * 10 + fadboard % 256);
     
    14781538                        rd[i].bufLen = 100000;  //?
    14791539                     }
    1480                      int fadBoard = ntohs (rd[i].rBuf->S[12]);
     1540                     int fadBoard = rd[i].rBuf->S[12];
    14811541                     debugHead (i, fadBoard, rd[i].rBuf);
    14821542                     debugRead (i, jrd, rd[i].evtID, rd[i].ftmID, rd[i].runID, -1, tsec, tusec);        // i=socket; jrd=#bytes; ievt=eventid;-1=start event
     
    20212081                     } else {
    20222082                        mBuffer[id].fEvent->BoardTime[ib] =
    2023                            ntohl (mBuffer[id].FADhead[ib].time);
     2083                           mBuffer[id].FADhead[ib].time;
    20242084                     }
    20252085                  }
Note: See TracChangeset for help on using the changeset viewer.