Index: fact/FADctrl/FAD.cc
===================================================================
--- fact/FADctrl/FAD.cc	(revision 10114)
+++ fact/FADctrl/FAD.cc	(revision 10117)
@@ -37,5 +37,5 @@
    //{"rmode", &FAD::cmd_rmode, 0, "<first|stop>", "Readout start at first bin or stop position (DRS4)"},
    //{"dmode", &FAD::cmd_dmode, 0, "<single|continuous>", "Domino wave single shot or continuous"},
-   {"cancel", &FAD::cmd_cancel, false, 0, "", "Cancel current operation/run"},
+   {"stop", &FAD::cmd_stop, false, 0, "", "Stop current operation/run"},
    {"update", &FAD::cmd_update, false, 1, "<sec>", "Minimum delay between updates to DIM event service"},		  
    {"socketmode", &FAD::cmd_socketmode, true, 1, "<com|daq>", "Choose which Sockets are used for data transmission"},		  
@@ -167,5 +167,5 @@
 	  // Check if idle mode required
 	  if (CommandList[i].NeedIdle && Mode != idle) {
-		PrintMessage("Current mode is not idle ('cancel' will stop current operation)\n");
+		PrintMessage("Current mode is not idle ('stop' will stop current operation)\n");
 		return;
 	  }
@@ -285,7 +285,4 @@
   if (Match(Parameter[1],"enable")) PrintMessage("all active boards accept now incoming triggers\n");
   else if (Match(Parameter[1],"disable")) PrintMessage("no active board accepts any incoming trigger anymore.\n");
- // else PrintUsage();
-
-  
 } 
 
@@ -483,6 +480,5 @@
 void FAD::cmd_acalib() {
 
-  pthread_t Thread;
-  int Code, Count;
+  int Count;
   FILE *File;
   vector<string> Items;
@@ -495,5 +491,6 @@
 
   // Read calibration data from file?
-  if (Parameter.size() == 2 && !ConvertToInt(Parameter[1], &NumCalibEvents)) {
+  //if (Parameter.size() == 2 && !ConvertToInt(Parameter[1], &NumCalibEvents)) {
+  if (Parameter.size() == 2 && !ConvertToInt(Parameter[1], &NumEventsRequested)) {
     // Open file
 	if ((File = fopen(Parameter[1].c_str(), "r")) == NULL) {
@@ -546,22 +543,10 @@
 
   // Set number of events required for calibration
-  if (Parameter.size()==1 || !ConvertToInt(Parameter[1], &NumCalibEvents) || NumCalibEvents<=0) {
-	NumCalibEvents = DEFAULT_NUM_CALIB_EVENTS;
-  }
-
-  // Set mode before launching thread
+  if (Parameter.size()==1 || !ConvertToInt(Parameter[1], &NumEventsRequested) || NumEventsRequested<=0) {
+	NumEventsRequested = DEFAULT_NUM_CALIB_EVENTS;
+  }
+
+  // Start ca;ibration by setting mode
   Mode = acalib;
-  Cancel = false;
-  
-  // Create detached thread
-  if ((Code = pthread_create(&Thread, NULL, (void * (*)(void *)) FAD::LaunchAmplitudeCalibration,(void *) this)) != 0) {
-    Message(ERROR, "pthread_create() failed in FAD::cmd_acalib() (%s)\n", strerror(Code));
-	Mode = idle;
-	return;
-  }
-
-  if ((Code = pthread_detach(Thread)) != 0) {
-	Message(ERROR, "pthread_detach() failed in FAD::cmd_acalib() (%s)\n", strerror(Code));
-  }
 }
 
@@ -590,4 +575,10 @@
 	  if (Boards[i]->Active) PrintMessage(" %d", i);
 	}
+
+	// Current mode
+	if (Mode == idle) PrintMessage("Current mode is IDLE\n");
+	else if (Mode == acalib) PrintMessage("Current mode is ACALIB (3x%d events)\n", NumEventsRequested);
+	else if (Mode == datarun) PrintMessage("Current mode is DATARUN (%d events requested, %d events taken)\n", NumEventsRequested, NumEvents);
+
 	return;
   }    
@@ -711,17 +702,23 @@
 // Cancel current operation
 //
-void FAD::cmd_cancel() {
+void FAD::cmd_stop() {
 
   static char Stop[] = "stop";
 
-  if (Mode == idle) PrintMessage("Nothing to cancel\n");
-  else {
+  if (Mode == idle) {
+	PrintMessage("Nothing to stop\n");
+	return;
+  }
+  
+  if (Mode == acalib) Mode = idle;
+  
+  if (Mode == datarun) {  
 	// Inform event thread to stop run in case datarun active
 	if (write(Pipe[1], Stop, strlen(Stop)+1) == -1) {
 	  Message(ERROR, "write() to Pipe[1] failed in FAD::cmd_cancel() (%s)", strerror(errno));
 	}
-    Cancel = true;
-    PrintMessage("Requested cancelation of current operation\n");
-  }
+  }
+  
+  PrintMessage("Requested stopping of current operation\n");
 }
 
@@ -741,164 +738,8 @@
 
 //
-// Amplitude calibration (lauched as thread by cmd_acalib())
-//
-void FAD::AmplitudeCalibration() {
-
-  vector<struct FADBoard::BoardStatus> Status;
-  vector<unsigned short> ROICmd;
-  unsigned short DACCmd[] = {htons(CMD_Write | (BADDR_DAC + 1)), 0, htons(CMD_Write | (BADDR_DAC + 2)), 0, htons(CMD_Write | (BADDR_DAC + 3)), 0};
-
-  PrintMessage("Staring amplitude calibration of all active boards (%d events)\n"
-			   "   Note: No input signals must be connected\n", NumCalibEvents);
-  
-  // Prepare command to set all ROIs to 1024
-  for (unsigned int i=0; i<NChips*NChannels; i++) {
-	ROICmd.push_back(htons(CMD_Write | (BADDR_ROI + i)));
-	ROICmd.push_back(htons(NBins));
-  }
-
-  // ====== Part A: Baseline measurement =====
-
-  // Initialise settings for baseline measurement
-  for (unsigned int Brd=0; Brd<Boards.size(); Brd++) {
-
-	// Invalidate current calibration
-	Boards[Brd]->ACalibTime = -1;
-
-	// Save initial board status
-	Status.push_back(Boards[Brd]->GetStatus());
-	
-    // Set all ROI to 1024
-	Boards[Brd]->Send(&ROICmd[0], ROICmd.size()*sizeof(unsigned short));
-
-    // Set DAC values and start accumulation
-    DACCmd[1] = htons(0);
-    DACCmd[3] = htons(0);
-    DACCmd[5] = htons(0);
-	Boards[Brd]->Send(DACCmd, sizeof(DACCmd));
-
-    Boards[Brd]->AccumulateSum(NumCalibEvents, true);	
-  }
-
-  // Wait until data for all boards taken
-  bool Done = false;
-  while (!Done && !Cancel) {
-    usleep(300000);
-	for (unsigned int Brd=0; Brd<Boards.size(); Brd++) {
-	  Done = true;
-	  if (Boards[Brd]->Active && Boards[Brd]->DoSum) Done = false;
-	}
-  }
-
-  // Determine baseline
-  for (unsigned int Brd=0; Brd<Boards.size(); Brd++) {
-	for (unsigned int i=0; i<NChips; i++) for (unsigned int j=0; j<NChannels; j++) {
-	  for (unsigned int k=0; k<NBins; k++) {
-	  	Boards[Brd]->Baseline[i][j][k] = Boards[Brd]->Sum[i][j][k] / NumCalibEvents;
-	  }
-	}
-  }
-  PrintMessage("Baseline measurement finished, next is gain measurement\n");
-
-  // ====== Part B: Gain measurement =====
-
-  // Set new DAC values and start accumulation
-  for (unsigned int Brd=0; Brd<Boards.size(); Brd++) {
-	DACCmd[1] = htons(50000);
-	DACCmd[3] = htons(50000);
-	DACCmd[5] = htons(50000);
-	Boards[Brd]->Send(DACCmd, sizeof(DACCmd));
-
-    Boards[Brd]->AccumulateSum(NumCalibEvents, true);	
-  }
-
-  // Wait until data for all boards taken
-  Done = false;
-  while (!Done && !Cancel) {
-    usleep(300000);
-	for (unsigned int Brd=0; Brd<Boards.size(); Brd++) {
-	  Done = true;
-	  if (Boards[Brd]->Active && Boards[Brd]->DoSum) Done = false;
-	}
-  }
-  
-  // Determine gain
-  for (unsigned int Brd=0; Brd<Boards.size(); Brd++) {
-	for (unsigned int i=0; i<NChips; i++) for (unsigned int j=0; j<NChannels; j++) {
-	  for (unsigned int k=0; k<NBins; k++) {
-		Boards[Brd]->Gain[i][j][k] = (Boards[Brd]->Sum[i][j][k] / NumCalibEvents)-Boards[Brd]->Baseline[i][j][k];
-	  }
-	}
-  }
-  PrintMessage("Gain measurement finished, next is secondary calibration\n");
-
-  // ====== Part C: Secondary calibration =====
-
-  // Initialise settings for secondary calibration and start accumulation
-  for (unsigned int Brd=0; Brd<Boards.size(); Brd++) {
-    DACCmd[1] = htons(0);
-    DACCmd[3] = htons(0);
-    DACCmd[5] = htons(0);
-	Boards[Brd]->Send(DACCmd, sizeof(DACCmd));
-
-    Boards[Brd]->AccumulateSum(NumCalibEvents, false);	
-  }
-
-  // Wait until data for all boards taken
-  Done = false;
-  while (!Done && !Cancel) {
-    usleep(300000);
-	for (unsigned int Brd=0; Brd<Boards.size(); Brd++) {
-	  Done = true;
-	  if (Boards[Brd]->Active && Boards[Brd]->DoSum) Done = false;
-	}
-  }
-
-  // Determine secondary calibration
-  for (unsigned int Brd=0; Brd<Boards.size(); Brd++) {
-	for (unsigned int i=0; i<NChips; i++) for (unsigned int j=0; j<NChannels; j++) {
-	  for (unsigned int k=0; k<NBins; k++) {
-		Boards[Brd]->SecondaryBaseline[i][j][k] = Boards[Brd]->Sum[i][j][k] / (double) NumCalibEvents;
-	  }
-	}
-  }
-
-  // ===== Part D: Finish calibration =====
- 
-  // Write back original ROI and DAC settings
-  for (unsigned int Brd=0; Brd<Boards.size(); Brd++) {
-
-	// Determine gain
-	for (unsigned int i=0; i<NChips; i++) for (unsigned int j=0; j<NChannels; j++) {
-	  for (unsigned int k=0; k<NBins; k++) {
-		Boards[Brd]->Gain[i][j][k] = (Boards[Brd]->Sum[i][j][k] / NumCalibEvents)-Boards[Brd]->Baseline[i][j][k];
-	  }
-	}
-
-	ROICmd.clear();
-	for (unsigned int i=0; i<NChips*NChannels; i++) {
-	  ROICmd.push_back(htons(CMD_Write | (BADDR_ROI + i)));
-	  ROICmd.push_back(htons(Status[Brd].ROI[i/NChannels][i%NChannels]));
-	}
-	Boards[Brd]->Send(&ROICmd[0], ROICmd.size()*sizeof(unsigned short));
-  
-    DACCmd[1] = htons(Status[Brd].DAC[1]);
-    DACCmd[3] = htons(Status[Brd].DAC[2]);
-    DACCmd[5] = htons(Status[Brd].DAC[3]);
-  	Boards[Brd]->Send(DACCmd, sizeof(DACCmd));
-	
-	// Store calibration time and temperature
-	Boards[Brd]->ACalibTime = Cancel ? -1 : time(NULL);
-	Boards[Brd]->ACalibTemp = 0;
-	for (unsigned int i=0; i<NTemp; i++) Boards[Brd]->ACalibTemp += Status[Brd].Temp[i] / NTemp;
-  }
-
-  Mode = idle;
-  
-  if (Cancel) {
-    PrintMessage("Amplitude calibration cancelled\n");
-	return;
-  }
- 
+// Save amplitude calibration data to file
+//
+void FAD::SaveAmplitudeCalibration() {
+
   PrintMessage("Amplitude calibration of all active boards finished, original ROI and DAC set\n");
   
@@ -942,11 +783,4 @@
 }
 
-// Launch read thread inside class
-void FAD::LaunchAmplitudeCalibration(class FAD *m) {
-
-  m->AmplitudeCalibration();
-}
-
-
 //
 // Event thread (publishes/writes M0 format)
@@ -958,4 +792,5 @@
   struct FADBoard::BoardStatus S;
   vector<unsigned long> EventNumbers(Boards.size());
+  vector<bool> AcalibDone(Boards.size());
   double Temp;
   string IDString;
@@ -1012,4 +847,19 @@
 	IDString = string(Buffer, Ret);
 	
+	// If amplitude calibration mode, check if board finished procedure
+	if (Mode == acalib) {
+	  bool Done = true;
+	  for (unsigned int i=0; i<Boards.size(); i++) {
+		if (IDString.find(string("ACALIBDONE")+Boards[i]->Name) != string::npos) AcalibDone[i] = true;
+		if (!AcalibDone[i]) Done = false;
+	  }
+	  // Amplitude calibration finished?
+	  if (Done) {
+	    SaveAmplitudeCalibration();
+		Mode = idle;
+	  }
+	}
+	else for (unsigned int i=0; i<Boards.size(); i++) AcalibDone[i] = false;
+
 	// Update run and event header with current time
 	gettimeofday(&Time, NULL);
@@ -1053,5 +903,5 @@
 	for (unsigned int Brd=0; Brd<Boards.size(); Brd++) {
 	  // Identify board
-	  if (IDString.find(Boards[Brd]->Name) == string::npos) continue;
+	  if (IDString.find(string("EVENT")+Boards[Brd]->Name) == string::npos) continue;
 
 	  // Fill M0 BoardStructure		
@@ -1140,6 +990,4 @@
 	NumEvents++;
 	FileSize += EventSize-Offset;
-	
-	printf("Wrote event %d\n", NumEvents-1);
   }
 
Index: fact/FADctrl/FAD.h
===================================================================
--- fact/FADctrl/FAD.h	(revision 10114)
+++ fact/FADctrl/FAD.h	(revision 10117)
@@ -24,8 +24,12 @@
 const char CALIB_DIRECTORY[] = "~/";
 
-enum ModeType {idle, datarun, acalib};
 
 class FAD: public EvidenceServer {
 
+  public:
+    enum ModeType {idle, datarun, acalib};
+	ModeType Mode;
+
+  private:
 	pthread_t MainThread;
 	DimCommand *Command;
@@ -33,11 +37,7 @@
 	char *ConsoleText;
 	std::vector<std::string> Parameter;
-	ModeType Mode;
-	volatile bool Cancel;
     void PrintUsage();
 	void commandHandler();
 	bool Match(std::string, const char *);
-	void AmplitudeCalibration();
-	static void LaunchAmplitudeCalibration(class FAD *);
 	void EventThread();
 	static void LaunchEventThread(class FAD *);
@@ -47,6 +47,4 @@
     int Datafile;
     int NumEvents;			// Number of event taken            
-    int NumEventsRequested;	// Number of events requested
-	int NumCalibEvents;
 	
 	std::vector<std::string> BoardList;
@@ -76,5 +74,5 @@
 	void cmd_roi();			void cmd_address();
 	void cmd_phase();		void cmd_send();
-	void cmd_cancel();		void cmd_update();
+	void cmd_stop();		void cmd_update();
 	void cmd_take();
 
@@ -82,11 +80,12 @@
     void DisableDomino();
     void SoftTrigger();
-    void SetDOMINOMode(int);
-    void SetDOMINOReadMode(int);
-    void SetDOMINOWaveMode(int);
-    bool ReadCalibration();
+    //void SetDOMINOMode(int);
+    //void SetDOMINOReadMode(int);
+    //void SetDOMINOWaveMode(int);
+	void SaveAmplitudeCalibration();
     void PrintMessage(const char*, ...);
 	
 	int Pipe[2];
+    int NumEventsRequested;	// Number of events requested
 };
 
Index: fact/FADctrl/FADBoard.cc
===================================================================
--- fact/FADctrl/FADBoard.cc	(revision 10114)
+++ fact/FADctrl/FADBoard.cc	(revision 10117)
@@ -173,20 +173,173 @@
 }
 
-//
-// Initiate average
-//
-void FADBoard::AccumulateSum(unsigned int n, bool Rotate) {
-
-  if (!Active) return;
+
+//
+// Perform amplitude calibration in steps
+//
+void FADBoard::AmplitudeCalibration() {
+
+  enum StateType {wait, init, baseline, gain, secondary};
+
+  static struct BoardStatus InitialStatus;
+  static vector<unsigned short> ROICmd;
+  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};
+  static StateType State = wait;
+  static int Count = 0;
+
+  // Check if mode is amplitude calibration
+  if (m->Mode != m->acalib) {
+	State = init;
+	return;
+  }
+
+  switch (State) {
+  // ====== Part A: Initialization =====
+  case init:
+	// Invalidate current calibration
+	ACalibTime = -1;
+
+	// Save initial board status, set all ROIs to 1024 and set DAC values
+	InitialStatus = GetStatus();
+
+	for (unsigned int i=0; i<NChips*NChannels; i++) {
+	  ROICmd.push_back(htons(CMD_Write | (BADDR_ROI + i)));
+	  ROICmd.push_back(htons(NBins));
+	}
+	Send(&ROICmd[0], ROICmd.size()*sizeof(unsigned short));
+
+    DACCmd[1] = htons(0);
+    DACCmd[3] = htons(0);
+    DACCmd[5] = htons(0);
+	Send(DACCmd, sizeof(DACCmd));
+
+	// Clear sum vector and set state to accumulate
+	memset(Sum, 0, sizeof(Sum));
+	State = baseline;
+	break;
+
+  // ====== Part B: Baseline calibration =====
+  case baseline:
+	for (unsigned int Chip=0; Chip<NChips; Chip++) {
+	  for (unsigned int Chan=0; Chan<NChannels; Chan++) {
+		for (int i=0; i<Status.ROI[Chip][Chan]; i++) {
+		  Sum[Chip][Chan][(i+Status.TriggerCell[Chip]) % NBins] += Data[Chip][Chan][i];
+		}
+	  }
+	}
+    Count++;
+	
+	// Determine baseline if integration finished
+	if (Count == m->NumEventsRequested) {
+	  for (unsigned int i=0; i<NChips; i++) {
+		for (unsigned int j=0; j<NChannels; j++) {
+		  for (unsigned int k=0; k<NBins; k++) {
+			Baseline[i][j][k] = Sum[i][j][k] / m->NumEventsRequested;
+		  }
+		}
+	  }
+	  
+	  // Set new DAC values and start accumulation
+	  DACCmd[1] = htons(50000);
+	  DACCmd[3] = htons(50000);
+	  DACCmd[5] = htons(50000);
+	  Send(DACCmd, sizeof(DACCmd));
+
+	  // Clear sum vector and set state to accumulate
+	  memset(Sum, 0, sizeof(Sum));
+	  Count = 0;
+	  State = gain;
+	}
+	break;
+
+  // ====== Part C: Gain calibration =====
+  case gain:
+	for (unsigned int Chip=0; Chip<NChips; Chip++) {
+	  for (unsigned int Chan=0; Chan<NChannels; Chan++) {
+		for (int i=0; i<Status.ROI[Chip][Chan]; i++) {
+		  Sum[Chip][Chan][(i+Status.TriggerCell[Chip]) % NBins] += Data[Chip][Chan][i];
+		}
+	  }
+	}
+    Count++;
+	
+	// Determine gain if integration finished
+	if (Count == m->NumEventsRequested) {
+	  for (unsigned int i=0; i<NChips; i++) {
+		for (unsigned int j=0; j<NChannels; j++) {
+		  for (unsigned int k=0; k<NBins; k++) {
+			Gain[i][j][k] = (Sum[i][j][k] / m->NumEventsRequested) - Baseline[i][j][k];
+		  }
+		}
+	  }
+	  
+	  // Set new DAC values and start accumulation
+	  DACCmd[1] = htons(0);
+	  DACCmd[3] = htons(0);
+	  DACCmd[5] = htons(0);
+	  Send(DACCmd, sizeof(DACCmd));
+
+	  // Clear sum vector and set state to accumulate
+	  memset(Sum, 0, sizeof(Sum));
+	  Count = 0;
+	  State = secondary;
+	}
+	break;
+
+  // ====== Part D: Secondary calibration =====
+  case secondary:
+	for (unsigned int Chip=0; Chip<NChips; Chip++) {
+	  for (unsigned int Chan=0; Chan<NChannels; Chan++) {
+		for (int i=0; i<Status.ROI[Chip][Chan]; i++) {
+		  Sum[Chip][Chan][i] = Data[Chip][Chan][i] - Baseline[Chip][Chan][(i-Status.TriggerCell[Chip]) % NBins];
+		}
+	  }
+	}
+    Count++;
+	
+	// Determine secondary baseline if integration finished
+	if (Count == m->NumEventsRequested) {
+	  for (unsigned int i=0; i<NChips; i++) {
+		for (unsigned int j=0; j<NChannels; j++) {
+		  for (unsigned int k=0; k<NBins; k++) {
+			SecondaryBaseline[i][j][k] = Sum[i][j][k] / (double) m->NumEventsRequested;
+		  }
+		}
+	  }
+	  
+	  // Write back original ROI and DAC settings
+	  ROICmd.clear();
+	  for (unsigned int i=0; i<NChips*NChannels; i++) {
+		ROICmd.push_back(htons(CMD_Write | (BADDR_ROI + i)));
+		ROICmd.push_back(htons(InitialStatus.ROI[i/NChannels][i%NChannels]));
+	  }
+	  Send(&ROICmd[0], ROICmd.size()*sizeof(unsigned short));
+
+      DACCmd[1] = htons(InitialStatus.DAC[1]);
+      DACCmd[3] = htons(InitialStatus.DAC[2]);
+      DACCmd[5] = htons(InitialStatus.DAC[3]);
+  	  Send(DACCmd, sizeof(DACCmd));
+
+	  // Store calibration time and temperature
+	  ACalibTime = time(NULL);
+	  ACalibTemp = 0;
+	  for (unsigned int i=0; i<NTemp; i++) ACalibTemp += Status.Temp[i] / NTemp;
+	  
+	  // Inform event thread that calibration is finished
+	  string Message = string("ACALIBDONE")+Name;
+	  if (write(m->Pipe[1], Message.data(), Message.size()) == -1) {
+		m->Message(m->ERROR, "write() to Pipe[1] failed in class FADBoard::AmplitudeCalibration (%s)", strerror(errno));
+	  }
+
+	  State = wait;
+	}
+	break;
+
+  // ====== Wait for Mode not being acalib =====
+  case wait:
+	if (m->Mode != m->acalib) State = init;
+	break;
+  }
+}  
   
-  Lock();
-  SumPhysPipeline = Rotate;
-  memset(Sum, 0, sizeof(Sum));
-  NumForSum = n;
-  DoSum = true; 
-  Unlock();
-}
-
-
 //
 // Read data from board
@@ -305,19 +458,11 @@
 	  }
 	  
-	  // If requested for calibration, add rotated data for later averaging
-	  if (DoSum && NumForSum>0) {
-		for (unsigned int Chip=0; Chip<NChips; Chip++) for (unsigned int Chan=0; Chan<NChannels; Chan++) {
-		  for (int i=0; i<Status.ROI[Chip][Chan]; i++) {
-			if (SumPhysPipeline) Sum[Chip][Chan][(i+Status.TriggerCell[Chip]) % NBins] += Data[Chip][Chan][i];
-			else Sum[Chip][Chan][i] = Data[Chip][Chan][i]-Baseline[Chip][Chan][(i-Status.TriggerCell[Chip]) % NBins];
-		  }
-		}
-		NumForSum--;
-		if (NumForSum == 0) DoSum = false;
-	  }
-
+	  // Prepare predicate for condition variable
 	  Continue = false;
 	  Unlock();
 	  
+  	  // Amplitude calibration (will check if Mode is acalib)
+	  AmplitudeCalibration();
+
 	  // Update DIM services if necessary
 	  if (memcmp(PrevStatus.Temp, Status.Temp, sizeof(Status.Temp)) != 0) {
@@ -337,5 +482,6 @@
 
 	// Inform event thread of new data
-	if (write(m->Pipe[1], Name, strlen(Name)+1) == -1) {
+	string Message = string("EVENT")+Name;
+	if (write(m->Pipe[1], Message.data(), Message.size()) == -1) {
 	  m->Message(m->ERROR, "write() to Pipe[1] failed in class FADBoard (%s)", strerror(errno));
 	  m->ExitRequest = true;
Index: fact/FADctrl/FADBoard.h
===================================================================
--- fact/FADctrl/FADBoard.h	(revision 10114)
+++ fact/FADctrl/FADBoard.h	(revision 10117)
@@ -53,4 +53,5 @@
 
 	short Data[NChips][NChannels][NBins];
+	long int Sum[NChips][NChannels][NBins];
 	short Baseline[NChips][NChannels][NBins];
 	double Gain[NChips][NChannels][NBins];
@@ -59,13 +60,9 @@
 	time_t ACalibTime;
 
-	long int Sum[NChips][NChannels][NBins];
-	unsigned int NumForSum;
-	bool DoSum;
-	bool SumPhysPipeline;
 
 	void Send(const void *, size_t);
 	void Send(unsigned short);
 	struct BoardStatus GetStatus();
-	void AccumulateSum(unsigned int, bool);
+	void AmplitudeCalibration();
 	void Lock();
 	void Unlock();
Index: fact/FADctrl/History.txt
===================================================================
--- fact/FADctrl/History.txt	(revision 10114)
+++ fact/FADctrl/History.txt	(revision 10117)
@@ -7,2 +7,3 @@
 21/1/2011	DIM event thread now informed through pipe of new data
 23/1/2011	Data can be written to disk in M0 format
+24/1/2011	Integrated amplitude calibration into FADBoard class
