Ignore:
Timestamp:
01/21/11 15:46:15 (14 years ago)
Author:
ogrimm
Message:
Event thread informed through pipe of new incoming data
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fact/FADctrl/FADBoard.cc

    r10101 r10113  
    8989  int Ret;
    9090
    91   // Cancel thread and wait for it to quit
     91  // Cancel thread (if it did not quit already) and wait for it to quit
    9292  if (pthread_equal(Thread, pthread_self()) == 0) {
    93         if ((Ret = pthread_cancel(Thread)) != 0) m->Message(m->ERROR, "pthread_cancel() failed in ~FADBoard() (%s)", strerror(Ret));
     93        if ((Ret = pthread_cancel(Thread)) != 0 && Ret != ESRCH) m->Message(m->ERROR, "pthread_cancel() failed in ~FADBoard() (%s)", strerror(Ret));
    9494        if ((Ret = pthread_join(Thread, NULL)) != 0) m->Message(m->ERROR, "pthread_join() failed in ~FADBoard (%s)", strerror(Ret));
    9595  }
     
    164164// Initiate average
    165165//
    166 void FADBoard::AccumulateSum(unsigned int n) {
     166void FADBoard::AccumulateSum(unsigned int n, bool Rotate) {
    167167
    168168  if (!Active) return;
    169169 
    170170  Lock();
     171  SumPhysPipeline = Rotate;
    171172  memset(Sum, 0, sizeof(Sum));
    172173  NumForSum = n;
     
    253254          // Extract ID and type information
    254255          Status.BoardID = ntohl(Header->board_id);
     256          Status.FirmwareRevision = ntohl(Header->version_no);
    255257          Status.TriggerID = ntohl(Header->local_trigger_id);
    256258          Status.TriggerType = ntohs(Header->local_trigger_type);
     
    287289                for (unsigned int Chip=0; Chip<NChips; Chip++) for (unsigned int Chan=0; Chan<NChannels; Chan++) {
    288290                  for (int i=0; i<Status.ROI[Chip][Chan]; i++) {
    289                         Sum[Chip][Chan][(i+Status.TriggerCell[Chip]) % NBins] += Data[Chip][Chan][i];
     291                        if (SumPhysPipeline) Sum[Chip][Chan][(i+Status.TriggerCell[Chip]) % NBins] += Data[Chip][Chan][i];
     292                        else Sum[Chip][Chan][i] = Data[Chip][Chan][i]-Baseline[Chip][Chan][(i-Status.TriggerCell[Chip]) % NBins];
    290293                  }
    291294                }
     
    312315        else printf("End package flag incorrect, removing corrupt event\n");
    313316
     317        // Inform event thread of new data
     318        if (write(m->Pipe[1], Name, strlen(Name)+1) == -1) {
     319          m->Message(m->ERROR, "write() to Pipe[1] failed in class FADBoard (%s)", strerror(errno));
     320          m->ExitRequest = true;
     321        }
     322
    314323        // Remove event data from internal buffer
    315324        memmove(Buffer, Buffer+Length, Pos-Length);
Note: See TracChangeset for help on using the changeset viewer.