Changeset 10117


Ignore:
Timestamp:
01/24/11 16:48:50 (12 years ago)
Author:
ogrimm
Message:
Amplitude calibration integrated into event loop
Location:
fact/FADctrl
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • fact/FADctrl/FAD.cc

    r10114 r10117  
    3737   //{"rmode", &FAD::cmd_rmode, 0, "<first|stop>", "Readout start at first bin or stop position (DRS4)"},
    3838   //{"dmode", &FAD::cmd_dmode, 0, "<single|continuous>", "Domino wave single shot or continuous"},
    39    {"cancel", &FAD::cmd_cancel, false, 0, "", "Cancel current operation/run"},
     39   {"stop", &FAD::cmd_stop, false, 0, "", "Stop current operation/run"},
    4040   {"update", &FAD::cmd_update, false, 1, "<sec>", "Minimum delay between updates to DIM event service"},                 
    4141   {"socketmode", &FAD::cmd_socketmode, true, 1, "<com|daq>", "Choose which Sockets are used for data transmission"},             
     
    167167          // Check if idle mode required
    168168          if (CommandList[i].NeedIdle && Mode != idle) {
    169                 PrintMessage("Current mode is not idle ('cancel' will stop current operation)\n");
     169                PrintMessage("Current mode is not idle ('stop' will stop current operation)\n");
    170170                return;
    171171          }
     
    285285  if (Match(Parameter[1],"enable")) PrintMessage("all active boards accept now incoming triggers\n");
    286286  else if (Match(Parameter[1],"disable")) PrintMessage("no active board accepts any incoming trigger anymore.\n");
    287  // else PrintUsage();
    288 
    289  
    290287}
    291288
     
    483480void FAD::cmd_acalib() {
    484481
    485   pthread_t Thread;
    486   int Code, Count;
     482  int Count;
    487483  FILE *File;
    488484  vector<string> Items;
     
    495491
    496492  // Read calibration data from file?
    497   if (Parameter.size() == 2 && !ConvertToInt(Parameter[1], &NumCalibEvents)) {
     493  //if (Parameter.size() == 2 && !ConvertToInt(Parameter[1], &NumCalibEvents)) {
     494  if (Parameter.size() == 2 && !ConvertToInt(Parameter[1], &NumEventsRequested)) {
    498495    // Open file
    499496        if ((File = fopen(Parameter[1].c_str(), "r")) == NULL) {
     
    546543
    547544  // Set number of events required for calibration
    548   if (Parameter.size()==1 || !ConvertToInt(Parameter[1], &NumCalibEvents) || NumCalibEvents<=0) {
    549         NumCalibEvents = DEFAULT_NUM_CALIB_EVENTS;
    550   }
    551 
    552   // Set mode before launching thread
     545  if (Parameter.size()==1 || !ConvertToInt(Parameter[1], &NumEventsRequested) || NumEventsRequested<=0) {
     546        NumEventsRequested = DEFAULT_NUM_CALIB_EVENTS;
     547  }
     548
     549  // Start ca;ibration by setting mode
    553550  Mode = acalib;
    554   Cancel = false;
    555  
    556   // Create detached thread
    557   if ((Code = pthread_create(&Thread, NULL, (void * (*)(void *)) FAD::LaunchAmplitudeCalibration,(void *) this)) != 0) {
    558     Message(ERROR, "pthread_create() failed in FAD::cmd_acalib() (%s)\n", strerror(Code));
    559         Mode = idle;
    560         return;
    561   }
    562 
    563   if ((Code = pthread_detach(Thread)) != 0) {
    564         Message(ERROR, "pthread_detach() failed in FAD::cmd_acalib() (%s)\n", strerror(Code));
    565   }
    566551}
    567552
     
    590575          if (Boards[i]->Active) PrintMessage(" %d", i);
    591576        }
     577
     578        // Current mode
     579        if (Mode == idle) PrintMessage("Current mode is IDLE\n");
     580        else if (Mode == acalib) PrintMessage("Current mode is ACALIB (3x%d events)\n", NumEventsRequested);
     581        else if (Mode == datarun) PrintMessage("Current mode is DATARUN (%d events requested, %d events taken)\n", NumEventsRequested, NumEvents);
     582
    592583        return;
    593584  }   
     
    711702// Cancel current operation
    712703//
    713 void FAD::cmd_cancel() {
     704void FAD::cmd_stop() {
    714705
    715706  static char Stop[] = "stop";
    716707
    717   if (Mode == idle) PrintMessage("Nothing to cancel\n");
    718   else {
     708  if (Mode == idle) {
     709        PrintMessage("Nothing to stop\n");
     710        return;
     711  }
     712 
     713  if (Mode == acalib) Mode = idle;
     714 
     715  if (Mode == datarun) { 
    719716        // Inform event thread to stop run in case datarun active
    720717        if (write(Pipe[1], Stop, strlen(Stop)+1) == -1) {
    721718          Message(ERROR, "write() to Pipe[1] failed in FAD::cmd_cancel() (%s)", strerror(errno));
    722719        }
    723     Cancel = true;
    724     PrintMessage("Requested cancelation of current operation\n");
    725   }
     720  }
     721 
     722  PrintMessage("Requested stopping of current operation\n");
    726723}
    727724
     
    741738
    742739//
    743 // Amplitude calibration (lauched as thread by cmd_acalib())
    744 //
    745 void FAD::AmplitudeCalibration() {
    746 
    747   vector<struct FADBoard::BoardStatus> Status;
    748   vector<unsigned short> ROICmd;
    749   unsigned short DACCmd[] = {htons(CMD_Write | (BADDR_DAC + 1)), 0, htons(CMD_Write | (BADDR_DAC + 2)), 0, htons(CMD_Write | (BADDR_DAC + 3)), 0};
    750 
    751   PrintMessage("Staring amplitude calibration of all active boards (%d events)\n"
    752                            "   Note: No input signals must be connected\n", NumCalibEvents);
    753  
    754   // Prepare command to set all ROIs to 1024
    755   for (unsigned int i=0; i<NChips*NChannels; i++) {
    756         ROICmd.push_back(htons(CMD_Write | (BADDR_ROI + i)));
    757         ROICmd.push_back(htons(NBins));
    758   }
    759 
    760   // ====== Part A: Baseline measurement =====
    761 
    762   // Initialise settings for baseline measurement
    763   for (unsigned int Brd=0; Brd<Boards.size(); Brd++) {
    764 
    765         // Invalidate current calibration
    766         Boards[Brd]->ACalibTime = -1;
    767 
    768         // Save initial board status
    769         Status.push_back(Boards[Brd]->GetStatus());
    770        
    771     // Set all ROI to 1024
    772         Boards[Brd]->Send(&ROICmd[0], ROICmd.size()*sizeof(unsigned short));
    773 
    774     // Set DAC values and start accumulation
    775     DACCmd[1] = htons(0);
    776     DACCmd[3] = htons(0);
    777     DACCmd[5] = htons(0);
    778         Boards[Brd]->Send(DACCmd, sizeof(DACCmd));
    779 
    780     Boards[Brd]->AccumulateSum(NumCalibEvents, true);   
    781   }
    782 
    783   // Wait until data for all boards taken
    784   bool Done = false;
    785   while (!Done && !Cancel) {
    786     usleep(300000);
    787         for (unsigned int Brd=0; Brd<Boards.size(); Brd++) {
    788           Done = true;
    789           if (Boards[Brd]->Active && Boards[Brd]->DoSum) Done = false;
    790         }
    791   }
    792 
    793   // Determine baseline
    794   for (unsigned int Brd=0; Brd<Boards.size(); Brd++) {
    795         for (unsigned int i=0; i<NChips; i++) for (unsigned int j=0; j<NChannels; j++) {
    796           for (unsigned int k=0; k<NBins; k++) {
    797                 Boards[Brd]->Baseline[i][j][k] = Boards[Brd]->Sum[i][j][k] / NumCalibEvents;
    798           }
    799         }
    800   }
    801   PrintMessage("Baseline measurement finished, next is gain measurement\n");
    802 
    803   // ====== Part B: Gain measurement =====
    804 
    805   // Set new DAC values and start accumulation
    806   for (unsigned int Brd=0; Brd<Boards.size(); Brd++) {
    807         DACCmd[1] = htons(50000);
    808         DACCmd[3] = htons(50000);
    809         DACCmd[5] = htons(50000);
    810         Boards[Brd]->Send(DACCmd, sizeof(DACCmd));
    811 
    812     Boards[Brd]->AccumulateSum(NumCalibEvents, true);   
    813   }
    814 
    815   // Wait until data for all boards taken
    816   Done = false;
    817   while (!Done && !Cancel) {
    818     usleep(300000);
    819         for (unsigned int Brd=0; Brd<Boards.size(); Brd++) {
    820           Done = true;
    821           if (Boards[Brd]->Active && Boards[Brd]->DoSum) Done = false;
    822         }
    823   }
    824  
    825   // Determine gain
    826   for (unsigned int Brd=0; Brd<Boards.size(); Brd++) {
    827         for (unsigned int i=0; i<NChips; i++) for (unsigned int j=0; j<NChannels; j++) {
    828           for (unsigned int k=0; k<NBins; k++) {
    829                 Boards[Brd]->Gain[i][j][k] = (Boards[Brd]->Sum[i][j][k] / NumCalibEvents)-Boards[Brd]->Baseline[i][j][k];
    830           }
    831         }
    832   }
    833   PrintMessage("Gain measurement finished, next is secondary calibration\n");
    834 
    835   // ====== Part C: Secondary calibration =====
    836 
    837   // Initialise settings for secondary calibration and start accumulation
    838   for (unsigned int Brd=0; Brd<Boards.size(); Brd++) {
    839     DACCmd[1] = htons(0);
    840     DACCmd[3] = htons(0);
    841     DACCmd[5] = htons(0);
    842         Boards[Brd]->Send(DACCmd, sizeof(DACCmd));
    843 
    844     Boards[Brd]->AccumulateSum(NumCalibEvents, false); 
    845   }
    846 
    847   // Wait until data for all boards taken
    848   Done = false;
    849   while (!Done && !Cancel) {
    850     usleep(300000);
    851         for (unsigned int Brd=0; Brd<Boards.size(); Brd++) {
    852           Done = true;
    853           if (Boards[Brd]->Active && Boards[Brd]->DoSum) Done = false;
    854         }
    855   }
    856 
    857   // Determine secondary calibration
    858   for (unsigned int Brd=0; Brd<Boards.size(); Brd++) {
    859         for (unsigned int i=0; i<NChips; i++) for (unsigned int j=0; j<NChannels; j++) {
    860           for (unsigned int k=0; k<NBins; k++) {
    861                 Boards[Brd]->SecondaryBaseline[i][j][k] = Boards[Brd]->Sum[i][j][k] / (double) NumCalibEvents;
    862           }
    863         }
    864   }
    865 
    866   // ===== Part D: Finish calibration =====
    867  
    868   // Write back original ROI and DAC settings
    869   for (unsigned int Brd=0; Brd<Boards.size(); Brd++) {
    870 
    871         // Determine gain
    872         for (unsigned int i=0; i<NChips; i++) for (unsigned int j=0; j<NChannels; j++) {
    873           for (unsigned int k=0; k<NBins; k++) {
    874                 Boards[Brd]->Gain[i][j][k] = (Boards[Brd]->Sum[i][j][k] / NumCalibEvents)-Boards[Brd]->Baseline[i][j][k];
    875           }
    876         }
    877 
    878         ROICmd.clear();
    879         for (unsigned int i=0; i<NChips*NChannels; i++) {
    880           ROICmd.push_back(htons(CMD_Write | (BADDR_ROI + i)));
    881           ROICmd.push_back(htons(Status[Brd].ROI[i/NChannels][i%NChannels]));
    882         }
    883         Boards[Brd]->Send(&ROICmd[0], ROICmd.size()*sizeof(unsigned short));
    884  
    885     DACCmd[1] = htons(Status[Brd].DAC[1]);
    886     DACCmd[3] = htons(Status[Brd].DAC[2]);
    887     DACCmd[5] = htons(Status[Brd].DAC[3]);
    888         Boards[Brd]->Send(DACCmd, sizeof(DACCmd));
    889        
    890         // Store calibration time and temperature
    891         Boards[Brd]->ACalibTime = Cancel ? -1 : time(NULL);
    892         Boards[Brd]->ACalibTemp = 0;
    893         for (unsigned int i=0; i<NTemp; i++) Boards[Brd]->ACalibTemp += Status[Brd].Temp[i] / NTemp;
    894   }
    895 
    896   Mode = idle;
    897  
    898   if (Cancel) {
    899     PrintMessage("Amplitude calibration cancelled\n");
    900         return;
    901   }
    902  
     740// Save amplitude calibration data to file
     741//
     742void FAD::SaveAmplitudeCalibration() {
     743
    903744  PrintMessage("Amplitude calibration of all active boards finished, original ROI and DAC set\n");
    904745 
     
    942783}
    943784
    944 // Launch read thread inside class
    945 void FAD::LaunchAmplitudeCalibration(class FAD *m) {
    946 
    947   m->AmplitudeCalibration();
    948 }
    949 
    950 
    951785//
    952786// Event thread (publishes/writes M0 format)
     
    958792  struct FADBoard::BoardStatus S;
    959793  vector<unsigned long> EventNumbers(Boards.size());
     794  vector<bool> AcalibDone(Boards.size());
    960795  double Temp;
    961796  string IDString;
     
    1012847        IDString = string(Buffer, Ret);
    1013848       
     849        // If amplitude calibration mode, check if board finished procedure
     850        if (Mode == acalib) {
     851          bool Done = true;
     852          for (unsigned int i=0; i<Boards.size(); i++) {
     853                if (IDString.find(string("ACALIBDONE")+Boards[i]->Name) != string::npos) AcalibDone[i] = true;
     854                if (!AcalibDone[i]) Done = false;
     855          }
     856          // Amplitude calibration finished?
     857          if (Done) {
     858            SaveAmplitudeCalibration();
     859                Mode = idle;
     860          }
     861        }
     862        else for (unsigned int i=0; i<Boards.size(); i++) AcalibDone[i] = false;
     863
    1014864        // Update run and event header with current time
    1015865        gettimeofday(&Time, NULL);
     
    1053903        for (unsigned int Brd=0; Brd<Boards.size(); Brd++) {
    1054904          // Identify board
    1055           if (IDString.find(Boards[Brd]->Name) == string::npos) continue;
     905          if (IDString.find(string("EVENT")+Boards[Brd]->Name) == string::npos) continue;
    1056906
    1057907          // Fill M0 BoardStructure             
     
    1140990        NumEvents++;
    1141991        FileSize += EventSize-Offset;
    1142        
    1143         printf("Wrote event %d\n", NumEvents-1);
    1144992  }
    1145993
  • fact/FADctrl/FAD.h

    r10114 r10117  
    2424const char CALIB_DIRECTORY[] = "~/";
    2525
    26 enum ModeType {idle, datarun, acalib};
    2726
    2827class FAD: public EvidenceServer {
    2928
     29  public:
     30    enum ModeType {idle, datarun, acalib};
     31        ModeType Mode;
     32
     33  private:
    3034        pthread_t MainThread;
    3135        DimCommand *Command;
     
    3337        char *ConsoleText;
    3438        std::vector<std::string> Parameter;
    35         ModeType Mode;
    36         volatile bool Cancel;
    3739    void PrintUsage();
    3840        void commandHandler();
    3941        bool Match(std::string, const char *);
    40         void AmplitudeCalibration();
    41         static void LaunchAmplitudeCalibration(class FAD *);
    4242        void EventThread();
    4343        static void LaunchEventThread(class FAD *);
     
    4747    int Datafile;
    4848    int NumEvents;                      // Number of event taken           
    49     int NumEventsRequested;     // Number of events requested
    50         int NumCalibEvents;
    5149       
    5250        std::vector<std::string> BoardList;
     
    7674        void cmd_roi();                 void cmd_address();
    7775        void cmd_phase();               void cmd_send();
    78         void cmd_cancel();              void cmd_update();
     76        void cmd_stop();                void cmd_update();
    7977        void cmd_take();
    8078
     
    8280    void DisableDomino();
    8381    void SoftTrigger();
    84     void SetDOMINOMode(int);
    85     void SetDOMINOReadMode(int);
    86     void SetDOMINOWaveMode(int);
    87     bool ReadCalibration();
     82    //void SetDOMINOMode(int);
     83    //void SetDOMINOReadMode(int);
     84    //void SetDOMINOWaveMode(int);
     85        void SaveAmplitudeCalibration();
    8886    void PrintMessage(const char*, ...);
    8987       
    9088        int Pipe[2];
     89    int NumEventsRequested;     // Number of events requested
    9190};
    9291
  • fact/FADctrl/FADBoard.cc

    r10114 r10117  
    173173}
    174174
    175 //
    176 // Initiate average
    177 //
    178 void FADBoard::AccumulateSum(unsigned int n, bool Rotate) {
    179 
    180   if (!Active) return;
     175
     176//
     177// Perform amplitude calibration in steps
     178//
     179void FADBoard::AmplitudeCalibration() {
     180
     181  enum StateType {wait, init, baseline, gain, secondary};
     182
     183  static struct BoardStatus InitialStatus;
     184  static vector<unsigned short> ROICmd;
     185  static unsigned short DACCmd[] = {htons(CMD_Write | (BADDR_DAC + 1)), 0, htons(CMD_Write | (BADDR_DAC + 2)), 0, htons(CMD_Write | (BADDR_DAC + 3)), 0};
     186  static StateType State = wait;
     187  static int Count = 0;
     188
     189  // Check if mode is amplitude calibration
     190  if (m->Mode != m->acalib) {
     191        State = init;
     192        return;
     193  }
     194
     195  switch (State) {
     196  // ====== Part A: Initialization =====
     197  case init:
     198        // Invalidate current calibration
     199        ACalibTime = -1;
     200
     201        // Save initial board status, set all ROIs to 1024 and set DAC values
     202        InitialStatus = GetStatus();
     203
     204        for (unsigned int i=0; i<NChips*NChannels; i++) {
     205          ROICmd.push_back(htons(CMD_Write | (BADDR_ROI + i)));
     206          ROICmd.push_back(htons(NBins));
     207        }
     208        Send(&ROICmd[0], ROICmd.size()*sizeof(unsigned short));
     209
     210    DACCmd[1] = htons(0);
     211    DACCmd[3] = htons(0);
     212    DACCmd[5] = htons(0);
     213        Send(DACCmd, sizeof(DACCmd));
     214
     215        // Clear sum vector and set state to accumulate
     216        memset(Sum, 0, sizeof(Sum));
     217        State = baseline;
     218        break;
     219
     220  // ====== Part B: Baseline calibration =====
     221  case baseline:
     222        for (unsigned int Chip=0; Chip<NChips; Chip++) {
     223          for (unsigned int Chan=0; Chan<NChannels; Chan++) {
     224                for (int i=0; i<Status.ROI[Chip][Chan]; i++) {
     225                  Sum[Chip][Chan][(i+Status.TriggerCell[Chip]) % NBins] += Data[Chip][Chan][i];
     226                }
     227          }
     228        }
     229    Count++;
     230       
     231        // Determine baseline if integration finished
     232        if (Count == m->NumEventsRequested) {
     233          for (unsigned int i=0; i<NChips; i++) {
     234                for (unsigned int j=0; j<NChannels; j++) {
     235                  for (unsigned int k=0; k<NBins; k++) {
     236                        Baseline[i][j][k] = Sum[i][j][k] / m->NumEventsRequested;
     237                  }
     238                }
     239          }
     240         
     241          // Set new DAC values and start accumulation
     242          DACCmd[1] = htons(50000);
     243          DACCmd[3] = htons(50000);
     244          DACCmd[5] = htons(50000);
     245          Send(DACCmd, sizeof(DACCmd));
     246
     247          // Clear sum vector and set state to accumulate
     248          memset(Sum, 0, sizeof(Sum));
     249          Count = 0;
     250          State = gain;
     251        }
     252        break;
     253
     254  // ====== Part C: Gain calibration =====
     255  case gain:
     256        for (unsigned int Chip=0; Chip<NChips; Chip++) {
     257          for (unsigned int Chan=0; Chan<NChannels; Chan++) {
     258                for (int i=0; i<Status.ROI[Chip][Chan]; i++) {
     259                  Sum[Chip][Chan][(i+Status.TriggerCell[Chip]) % NBins] += Data[Chip][Chan][i];
     260                }
     261          }
     262        }
     263    Count++;
     264       
     265        // Determine gain if integration finished
     266        if (Count == m->NumEventsRequested) {
     267          for (unsigned int i=0; i<NChips; i++) {
     268                for (unsigned int j=0; j<NChannels; j++) {
     269                  for (unsigned int k=0; k<NBins; k++) {
     270                        Gain[i][j][k] = (Sum[i][j][k] / m->NumEventsRequested) - Baseline[i][j][k];
     271                  }
     272                }
     273          }
     274         
     275          // Set new DAC values and start accumulation
     276          DACCmd[1] = htons(0);
     277          DACCmd[3] = htons(0);
     278          DACCmd[5] = htons(0);
     279          Send(DACCmd, sizeof(DACCmd));
     280
     281          // Clear sum vector and set state to accumulate
     282          memset(Sum, 0, sizeof(Sum));
     283          Count = 0;
     284          State = secondary;
     285        }
     286        break;
     287
     288  // ====== Part D: Secondary calibration =====
     289  case secondary:
     290        for (unsigned int Chip=0; Chip<NChips; Chip++) {
     291          for (unsigned int Chan=0; Chan<NChannels; Chan++) {
     292                for (int i=0; i<Status.ROI[Chip][Chan]; i++) {
     293                  Sum[Chip][Chan][i] = Data[Chip][Chan][i] - Baseline[Chip][Chan][(i-Status.TriggerCell[Chip]) % NBins];
     294                }
     295          }
     296        }
     297    Count++;
     298       
     299        // Determine secondary baseline if integration finished
     300        if (Count == m->NumEventsRequested) {
     301          for (unsigned int i=0; i<NChips; i++) {
     302                for (unsigned int j=0; j<NChannels; j++) {
     303                  for (unsigned int k=0; k<NBins; k++) {
     304                        SecondaryBaseline[i][j][k] = Sum[i][j][k] / (double) m->NumEventsRequested;
     305                  }
     306                }
     307          }
     308         
     309          // Write back original ROI and DAC settings
     310          ROICmd.clear();
     311          for (unsigned int i=0; i<NChips*NChannels; i++) {
     312                ROICmd.push_back(htons(CMD_Write | (BADDR_ROI + i)));
     313                ROICmd.push_back(htons(InitialStatus.ROI[i/NChannels][i%NChannels]));
     314          }
     315          Send(&ROICmd[0], ROICmd.size()*sizeof(unsigned short));
     316
     317      DACCmd[1] = htons(InitialStatus.DAC[1]);
     318      DACCmd[3] = htons(InitialStatus.DAC[2]);
     319      DACCmd[5] = htons(InitialStatus.DAC[3]);
     320          Send(DACCmd, sizeof(DACCmd));
     321
     322          // Store calibration time and temperature
     323          ACalibTime = time(NULL);
     324          ACalibTemp = 0;
     325          for (unsigned int i=0; i<NTemp; i++) ACalibTemp += Status.Temp[i] / NTemp;
     326         
     327          // Inform event thread that calibration is finished
     328          string Message = string("ACALIBDONE")+Name;
     329          if (write(m->Pipe[1], Message.data(), Message.size()) == -1) {
     330                m->Message(m->ERROR, "write() to Pipe[1] failed in class FADBoard::AmplitudeCalibration (%s)", strerror(errno));
     331          }
     332
     333          State = wait;
     334        }
     335        break;
     336
     337  // ====== Wait for Mode not being acalib =====
     338  case wait:
     339        if (m->Mode != m->acalib) State = init;
     340        break;
     341  }
     342
    181343 
    182   Lock();
    183   SumPhysPipeline = Rotate;
    184   memset(Sum, 0, sizeof(Sum));
    185   NumForSum = n;
    186   DoSum = true;
    187   Unlock();
    188 }
    189 
    190 
    191344//
    192345// Read data from board
     
    305458          }
    306459         
    307           // If requested for calibration, add rotated data for later averaging
    308           if (DoSum && NumForSum>0) {
    309                 for (unsigned int Chip=0; Chip<NChips; Chip++) for (unsigned int Chan=0; Chan<NChannels; Chan++) {
    310                   for (int i=0; i<Status.ROI[Chip][Chan]; i++) {
    311                         if (SumPhysPipeline) Sum[Chip][Chan][(i+Status.TriggerCell[Chip]) % NBins] += Data[Chip][Chan][i];
    312                         else Sum[Chip][Chan][i] = Data[Chip][Chan][i]-Baseline[Chip][Chan][(i-Status.TriggerCell[Chip]) % NBins];
    313                   }
    314                 }
    315                 NumForSum--;
    316                 if (NumForSum == 0) DoSum = false;
    317           }
    318 
     460          // Prepare predicate for condition variable
    319461          Continue = false;
    320462          Unlock();
    321463         
     464          // Amplitude calibration (will check if Mode is acalib)
     465          AmplitudeCalibration();
     466
    322467          // Update DIM services if necessary
    323468          if (memcmp(PrevStatus.Temp, Status.Temp, sizeof(Status.Temp)) != 0) {
     
    337482
    338483        // Inform event thread of new data
    339         if (write(m->Pipe[1], Name, strlen(Name)+1) == -1) {
     484        string Message = string("EVENT")+Name;
     485        if (write(m->Pipe[1], Message.data(), Message.size()) == -1) {
    340486          m->Message(m->ERROR, "write() to Pipe[1] failed in class FADBoard (%s)", strerror(errno));
    341487          m->ExitRequest = true;
  • fact/FADctrl/FADBoard.h

    r10114 r10117  
    5353
    5454        short Data[NChips][NChannels][NBins];
     55        long int Sum[NChips][NChannels][NBins];
    5556        short Baseline[NChips][NChannels][NBins];
    5657        double Gain[NChips][NChannels][NBins];
     
    5960        time_t ACalibTime;
    6061
    61         long int Sum[NChips][NChannels][NBins];
    62         unsigned int NumForSum;
    63         bool DoSum;
    64         bool SumPhysPipeline;
    6562
    6663        void Send(const void *, size_t);
    6764        void Send(unsigned short);
    6865        struct BoardStatus GetStatus();
    69         void AccumulateSum(unsigned int, bool);
     66        void AmplitudeCalibration();
    7067        void Lock();
    7168        void Unlock();
  • fact/FADctrl/History.txt

    r10114 r10117  
    7721/1/2011       DIM event thread now informed through pipe of new data
    8823/1/2011       Data can be written to disk in M0 format
     924/1/2011       Integrated amplitude calibration into FADBoard class
Note: See TracChangeset for help on using the changeset viewer.