Index: /drsdaq/DAQReadout.cc
===================================================================
--- /drsdaq/DAQReadout.cc	(revision 181)
+++ /drsdaq/DAQReadout.cc	(revision 182)
@@ -10,7 +10,4 @@
 
 #include "DAQReadout.h"
-#include "SlowData.h"
-
-#define TMPNAME "/tmp/__tmp__drsdaq__"  // ..for log file truncation
 
 static const char* daq_state_str[] = {"active", "stopped"};
@@ -63,5 +60,5 @@
 //
  
-DAQReadout::DAQReadout(const char *Configfile) {
+DAQReadout::DAQReadout() :EvidenceServer(SERVER_NAME) {
    
   time(&StartTime);  // Start time of DAQ
@@ -78,30 +75,15 @@
   LastBoard	     = -1;
   CmdFromSocket      = false;
-  ConfigOK  	     = true;
-  
-  // Read configuration file (if any item missing, program will be terminated in main() routine)
-  FILE *File;
-  if ((File = fopen(Configfile,"r")) == NULL) {
-    printf("Error: Could not open drsdaq configuration file '%s'\n", Configfile);
-    ConfigOK = false;
-    return;
-  }
-  else {
-    printf("Reading drsdaq configuration file %s\n", Configfile);
-    ConfigOK &= ReadCard("LogFile",             fLogFile,           's', File);
-    ConfigOK &= ReadCard("SlowDataPath",        fSlowDataPath,      's', File);
-    ConfigOK &= ReadCard("MaxLogLines",        &fMaxLogLines,       'U', File);
-    ConfigOK &= ReadCard("RawDataPath",         fRawDataPath,       's', File);
-    ConfigOK &= ReadCard("CalibDataPath",       fCalibDataPath,     's', File);
-    ConfigOK &= ReadCard("FirstSample",        &fFirstSample,       'I', File);
-    ConfigOK &= ReadCard("Samples",            &fSamples,           'U', File);
-    ConfigOK &= ReadCard("MinDiskSpaceMB",     &fMinDiskSpaceMB,    'U', File);
-    ConfigOK &= ReadCard("MaxFileSizeMB",      &fMaxFileSizeMB,     'I', File);
-    ConfigOK &= ReadCard("CCPort",             &fCCPort,            'I', File);
-    ConfigOK &= ReadCard("HVFeedbackConfig",    fHVFeedbackConfig,  's', File);
-    ConfigOK &= ReadCard("DefaultFrequency",   &fDefaultFrequency , 'd', File);
-    fclose(File);
-    if (!ConfigOK) return;
-  }
+  
+  // Get configuration data
+  fRawDataPath = GetConfig("RawDataPath");
+  fCalibDataPath = GetConfig("CalibDataPath");
+  fFirstSample = atoi(GetConfig("FirstSample"));
+  fSamples = atoi(GetConfig("Samples"));
+  fMinDiskSpaceMB = atoi(GetConfig("MinDiskSpaceMB"));
+  fMaxFileSizeMB = atoi(GetConfig("MaxFileSizeMB"));
+  fCCPort = atoi(GetConfig("CCPort"));
+  fDefaultFrequency = atof(GetConfig("DefaultFrequency"));
+
   if (fFirstSample < 0 || fFirstSample > kNumberOfBins || fSamples > kNumberOfBins) {
     PrintMessage("Warning: Sample range in configuration beyond limits, setting to full range\n");
@@ -109,10 +91,6 @@
     fSamples = kNumberOfBins;
   }
-  
-  // Open log file and log configuration
-  if ((Logfile = fopen(fLogFile, "a")) == NULL) printf("Warning: Could not open log file '%s'\n", fLogFile);
-  PrintMessage(MsgToLog,"********** Logging started **********\n");
-  PrintConfig(MsgToLog);
-
+  snprintf(CalibInfoFilename,sizeof(CalibInfoFilename), "%s/CalibInfo", fCalibDataPath);
+  
   // Allocate headers and initialise to zero
   RHeader = new RunHeader;
@@ -120,15 +98,15 @@
   EHeader = new EventHeader;
   memset(EHeader, 0, sizeof(EventHeader));
-  
+
   // Scan for DRS boards
-  DRSFreq = new float [GetNumberOfBoards()];
-  ACalib = new bool [GetNumberOfBoards()];
-  ACalibTemp = new double [GetNumberOfBoards()];
-  TCalib = new bool [GetNumberOfBoards()];
-
-  if (GetNumberOfBoards() == 0) PrintMessage("No DRS boards found - check VME crate and configuration file!\n");
-
-  for (int i=0; i<GetNumberOfBoards(); i++) {
-    NumBoards++;
+  NumBoards = GetNumberOfBoards();
+  DRSFreq = new float [NumBoards];
+  ACalib = new bool [NumBoards];
+  ACalibTemp = new double [NumBoards];
+  TCalib = new bool [NumBoards];
+
+  if (NumBoards == 0) PrintMessage("No DRS boards found - check VME crate and configuration file!\n");
+
+  for (int i=0; i<NumBoards; i++) {
     LastBoard++;
     GetBoard(i)->Init();
@@ -138,6 +116,6 @@
     TCalib[i] = false;      
   }
-  BStruct  = new BoardStructure [NumBoards == 0 ? 1:GetNumberOfBoards()];
-  memset(BStruct, 0, sizeof(BoardStructure)*(NumBoards == 0 ? 1:GetNumberOfBoards()));
+  BStruct  = new BoardStructure [NumBoards == 0 ? 1:NumBoards];
+  memset(BStruct, 0, sizeof(BoardStructure)*(NumBoards == 0 ? 1:NumBoards));
 
   WaveForm = new short [NumBoards == 0 ? 1:NumBoards][kNumberOfChipsMax][kNumberOfChannelsMax][kNumberOfBins];
@@ -145,12 +123,5 @@
   
   // Create instance of HV feedback (must be called after CMC board detection)
-  HVFB	  = new HVFeedback(this, fHVFeedbackConfig);
-  
-  // Create instance of slow data class for DAQ
-  SlowDataClass = new SlowData("DAQ", fSlowDataPath);
-  if(SlowDataClass->ErrorCode != 0) {
-   PrintMessage("Warning: Could not open DAQ slowdata file (%s)\n", strerror(SlowDataClass->ErrorCode));
-  }
-  SlowDataClass->NewEntry("Runinfo-Info", "Run information written after completion or termination of run (Status can be OK or Error): Runnumber Status Runtype Events Files Description ");
+  HVFB	  = new HVFeedback(this);  
 }
 
@@ -160,5 +131,5 @@
 
 DAQReadout::~DAQReadout() {
-  delete SlowDataClass;
+
   delete RHeader;     delete EHeader;
   delete HVFB;	      delete[] ACalibTemp;
@@ -166,9 +137,4 @@
   delete[] DRSFreq;   delete[] BStruct;
   delete[] WaveForm;  delete[] TriggerCell;
-  
-  if(Logfile) {
-    if(!fclose(Logfile)) printf("Closing logfile\n");
-    else perror("Error closing logfile");
-  }
 }
 
@@ -514,6 +480,6 @@
     }
 
-    PrintMessage("Creating amplitude calibration of board %d (serial #%04d)\n", i, GetBoard(i)->GetBoardSerialNumber());
-    
+    PrintMessage("Creating amplitude calibration of board %d (serial #%04d)\n  Note: No input signals should be connected\n", i, GetBoard(i)->GetBoardSerialNumber());
+		
     GetBoard(i)->EnableTcal(0);
     GetBoard(i)->SelectClockSource(0);
@@ -545,6 +511,20 @@
     ACalib[i] = true;
     ACalibTemp[i] = GetBoard(i)->GetTemperature();
+	
   } // Loop over boards
   PrintMessage("Amplitude calibration finished\n");
+  
+  // Write short calibration information
+  time_t Time = time(NULL);
+  FILE *InfoFile = fopen(CalibInfoFilename, "w");
+  if (InfoFile != NULL) {
+	fprintf(InfoFile, "# Calibration information as of %s\n", ctime(&Time));
+	for (int i=0; i<GetNumberOfBoards(); i++) {
+	  fprintf(InfoFile, "%d %d %.1f %d %.2f\n", GetBoard(i)->GetBoardSerialNumber(), ACalib[i], ACalibTemp[i], TCalib[i], DRSFreq[i]);
+	}
+	fclose(InfoFile);
+  }
+  else PrintMessage("Could not write calibration information to file '%s'\n", CalibInfoFilename);
+
 }
 
@@ -554,4 +534,8 @@
   if (!IsDRSFreqSet()) {
     PrintMessage("Set sampling frequency for all boards first\n");
+    return;
+  }
+  if (!ReadCalibration()) {
+    PrintMessage("Amplitude calibration has to be done first\n");
     return;
   }
@@ -562,9 +546,5 @@
       continue;
     }
-    if (!ACalib[i]) {
-      PrintMessage("Amplitude calibration of board %d has to be done first, skipping this board\n", i);
-      continue;
-    }
-    PrintMessage("Creating time calibration of board %d (serial #%04d)\n", i, GetBoard(i)->GetBoardSerialNumber());
+    PrintMessage("Creating time calibration of board %d (serial #%04d)\n  Note: No input signals should be connected\n", i, GetBoard(i)->GetBoardSerialNumber());
     
     GetBoard(i)->SetFrequency(DRSFreq[i], true);
@@ -586,6 +566,7 @@
       GetBoard(i)->GetTime(Chip, Time[Chip], true, false);
 	}
-    
-    if (asprintf(&Filename, "TCalib_%d_%.2fGHz.txt", GetBoard(i)->GetBoardSerialNumber(), DRSFreq[i]) == -1) {
+
+	// Write calibration data to file
+    if (asprintf(&Filename, "%s/TCalib_%d_%.2fGHz.txt", fCalibDataPath, GetBoard(i)->GetBoardSerialNumber(), DRSFreq[i]) == -1) {
       PrintMessage("Error: asprintf() failed, cannot generate filename (%s)\n", strerror(errno));
       return; 
@@ -827,8 +808,9 @@
     GetBoard(i)->TransferWaves(GetBoard(i)->GetNumberOfChannels()*GetBoard(i)->GetNumberOfChips()); 
 
-    for (int j=0; j<GetBoard(i)->GetNumberOfChannels(); j++) {
-      for (int k=0; k<GetBoard(i)->GetNumberOfChips(); k++) {
-        GetBoard(i)->GetWave(k, j, WaveForm[i][k][j], true, GetBoard(i)->GetTriggerCell(k));
-        TriggerCell[i][k] = GetBoard(i)->GetTriggerCell(k);
+    for (int k=0; k<GetBoard(i)->GetNumberOfChips(); k++) {
+	  TriggerCell[i][k] = GetBoard(i)->GetTriggerCell(k);
+
+	  for (int j=0; j<GetBoard(i)->GetNumberOfChannels(); j++) {
+        GetBoard(i)->GetWave(k, j, WaveForm[i][k][j], true, TriggerCell[i][k]);
       }
     }
@@ -836,12 +818,34 @@
 }
 
-// Read calibration file
+// Read calibration data
 bool DAQReadout::ReadCalibration() {
 
+  static char Buffer[MAX_COM_SIZE];
+  int Serial, Calib;
+  float Temp, Freq;
+
   for (int i=FirstBoard; i<=LastBoard; i++) {
-    if (!TCalib[i]) PrintMessage("Warning: No time calibration for board %d\n", i);
-    
     if (GetBoard(i)->GetDRSType() == 4) {
-      if (ACalib[i] == false) return false;
+      if (ACalib[i] == false) {
+	    // Check calibration info file if EEPROM data on DRS board still valild
+		FILE *CalibInfo = fopen(CalibInfoFilename, "r");
+		if (CalibInfo == NULL) return false;
+		fgets(Buffer, sizeof(Buffer), CalibInfo); // skip first two lines
+		fgets(Buffer, sizeof(Buffer), CalibInfo);
+
+		while (fgets(Buffer, sizeof(Buffer), CalibInfo) != NULL) {
+		  if (sscanf(Buffer, "%d %d %f %*d %f", &Serial, &Calib, &Temp, &Freq) != 4) {
+			fclose(CalibInfo);
+			return false;
+		  }
+
+		  if (Serial==GetBoard(i)->GetBoardSerialNumber() && int(Freq*100)==int(DRSFreq[i]*100) && Calib==1) {
+			ACalib[i] = true;
+			ACalibTemp[i] = Temp;
+			break;
+		  }
+		}
+		fclose(CalibInfo);
+	  }
     }
     else {
@@ -855,4 +859,5 @@
       }
     }
+	if (fabs(ACalibTemp[i]-GetBoard(i)->GetTemperature())>2) PrintMessage("Warning: Large difference to calibration temperature for board %d\n", i);
   } // Loop over boards
   return true;
@@ -1127,11 +1132,10 @@
 // Print configuration to target
 void DAQReadout::PrintConfig(int Target) {
-  PrintMessage(Target, "LogFile: %s\tMaxLogLines: %u\tRawDataPath: %s\n"
+  PrintMessage(Target, "RawDataPath: %s\n"
       	       "DefaultFrequency: %.2f\tFirstSample: %d\tSamples: %u\n"
      	       "MinDiskSpaceMB: %u\tMaxFileSizeMB: %d\tCCPort: %d\n"
-	       "CalibDataPath: %s\n"
-	       "SlowDataPath: %s\tHVFeedbackConfig: %s\n",
-    fLogFile,fMaxLogLines,fRawDataPath,fDefaultFrequency,fFirstSample,fSamples,fMinDiskSpaceMB,
-    fMaxFileSizeMB,fCCPort,fCalibDataPath,fSlowDataPath,fHVFeedbackConfig);
+			   "CalibDataPath: %s\n",
+    fRawDataPath,fDefaultFrequency,fFirstSample,fSamples,fMinDiskSpaceMB,
+    fMaxFileSizeMB,fCCPort,fCalibDataPath);
 }
 
@@ -1160,6 +1164,6 @@
   va_list ArgumentPointer;
   va_start(ArgumentPointer, Format);
-  if(CmdFromSocket) DoPrintMessage(Format, ArgumentPointer, MsgToSocket|MsgToLog);
-  else DoPrintMessage(Format, ArgumentPointer, MsgToConsole|MsgToLog);
+  if(CmdFromSocket) DoPrintMessage(Format, ArgumentPointer, MsgToSocket);
+  else DoPrintMessage(Format, ArgumentPointer, MsgToConsole);
   va_end(ArgumentPointer);
 }
@@ -1179,14 +1183,16 @@
     if(strlen(Textbuffer)>0 && Textbuffer[strlen(Textbuffer)-1]=='\n') {
       printf("\r%s%s", Textbuffer, Prompt);   // New prompt
-      fflush(stdout);
     }
     else printf("%s", Textbuffer);
-  }
-  // Print to log file
-  if((Target & MsgToLog) && Logfile!=NULL) {
-    time_t Time;
-    strftime(Textbuffer+strlen(Textbuffer)+1,MAX_COM_SIZE-strlen(Textbuffer)-1, "%d/%m/%y %X", localtime(&(Time=time(NULL))));
-    fprintf(Logfile, "%s: %s", Textbuffer+strlen(Textbuffer)+1, Textbuffer);
-    fflush(Logfile);
+	fflush(stdout);
+  }
+  // Send to log
+  if(Target & MsgToLog) {
+    char *Buf;
+    if (asprintf(&Buf, "%s %s", SERVER_NAME, Textbuffer) != -1) { 
+      DimClient::sendCommandNB("DColl/Log", Buf);
+      free(Buf);
+    }
+    else DimClient::sendCommandNB("DColl/Log", SERVER_NAME" asprintf() failed"); 
   }
   // Print to socket
@@ -1233,49 +1239,4 @@
 }
 
-// ReadCard function (original version by F. Goebel)
-// Data is read into an array if MaxNum is larger than 1
-bool ReadCard(const char *card_flag, void *store, char Type, FILE *File, unsigned int MaxNum) {
-  
-  char *card_name, *card_val, Buffer[MAX_COM_SIZE];
-  unsigned int Count=0;
-  
-  rewind(File);
-
-  while (fgets(Buffer, sizeof(Buffer), File) != NULL) {    // Read line by line
-    card_name = strtok(Buffer," \t\n");
-    
-     // Ignore empty lines, comments, and skip if card name does not match
-    if (card_name==NULL || card_name[0]=='#' || strcmp(card_name, card_flag)!=0) continue;
-
-    // Read numbers of given type (if MaxNum>1 read array)
-    while ((card_val=strtok(NULL," \t\n")) != NULL && Count++<MaxNum) {
-      switch (Type) {
-	case 'I': *(((int *&) store)++) = (int) strtol(card_val, NULL, 10);
-	      	  break;
-	case 'i': *(((short *&) store)++) = (short) strtol(card_val, NULL, 10);
-	      	  break;
-	case 'U': *(((unsigned int *&) store)++) = (unsigned int) strtoul(card_val, NULL, 10);
-	      	  break;
-	case 'u': *(((unsigned short *&) store)++) = (unsigned short) strtoul(card_val, NULL, 10);
-	      	  break;
-	case 'f': *(((float *&) store)++) = atof(card_val);
-	      	  break;
-	case 'd': *(((double *&) store)++) = atof(card_val);
-	      	  break;
-	case 's': sprintf((char *) store, "%s", card_val);
-	      	  break;
-	case 'c': *((char *) store) = card_val[0];
-	      	  break;
-	default:  fprintf(stderr,"Warning: Unknown type '%c' for reading of configuration file\n", Type);
-	      	  return false;
-      }
-    }
-    return true;  // Finished reading data for card name
-    
-  }
-  fprintf(stderr,"Warning: Configuration value %s not found\n", card_flag);
-  return false;
-}
-
 
 /********************************************************************\
@@ -1368,9 +1329,6 @@
 
   // Write run summary to slow data file
-  m->SlowDataClass->NewEntry("Runinfo");
-  m->SlowDataClass->AddToEntry("%d %s %s %d %d %s", m->RunNumber, WriteError?"Error":"OK", daq_runtype_str[m->daq_runtype], m->NumEvents, m->FileNumber, m->RHeader->Description);
-  if(m->SlowDataClass->ErrorCode != 0) {
-    m->PrintMessage("Error: Could not write DAQ slow data to file (%s), file closed\n", strerror(m->SlowDataClass->ErrorCode));
-  }
+  //m->SlowDataClass->NewEntry("Runinfo");
+  //m->SlowDataClass->AddToEntry("%d %s %s %d %d %s", m->RunNumber, WriteError?"Error":"OK", daq_runtype_str[m->daq_runtype], m->NumEvents, m->FileNumber, m->RHeader->Description);
 
   // Print run statistics
Index: /drsdaq/DAQReadout.h
===================================================================
--- /drsdaq/DAQReadout.h	(revision 181)
+++ /drsdaq/DAQReadout.h	(revision 182)
@@ -14,4 +14,5 @@
 #include <sys/vfs.h>
 #include <signal.h>
+#include <sys/time.h>
 
 #include "RawDataCTX.h"
@@ -32,5 +33,5 @@
 enum runtype_enum {data, pedestal, reserved, test};
 
-class DAQReadout : public DRS, public DRSCallback {
+class DAQReadout : public DRS, public DRSCallback, public EvidenceServer {
     time_t StartTime;
 
@@ -39,5 +40,4 @@
 
     unsigned int CmdNumber;
-    FILE *Logfile;    
     void PrintUsage();
 	
@@ -52,12 +52,8 @@
     int Rawfile;
     class HVFeedback* HVFB;
-    class SlowData *SlowDataClass; 
 
     // Configuration data
-    char fLogFile[MAX_PATH];
-    char fSlowDataPath[MAX_PATH];
-    char fCalibDataPath[MAX_PATH];
-    unsigned int fMaxLogLines;
-    char fRawDataPath[MAX_PATH];
+    char *fCalibDataPath;
+    char *fRawDataPath;
     int fMinDiskSpaceMB;   // Minimum required disk space in MBytes
     int fMaxFileSizeMB;    // Maximum File size in Bytes 
@@ -65,5 +61,4 @@
     unsigned int fSamples;
     int fCCPort;
-    char fHVFeedbackConfig[MAX_PATH];
     double fDefaultFrequency;
     
@@ -92,8 +87,8 @@
     char FileName[MAX_PATH];
     char Prompt[MAX_COM_SIZE];
-    bool ConfigOK;
+    char CalibInfoFilename[MAX_PATH];
        
     // Public functions
-    DAQReadout(const char*);
+    DAQReadout();
     ~DAQReadout();
 
@@ -149,5 +144,4 @@
 int ParseInput(char*, const char *Param[]);
 int CheckDisk(char*);
-bool ReadCard(const char *, void *, char, FILE *, unsigned int=1);
 
 #endif
Index: /drsdaq/DRS/DRS.cc
===================================================================
--- /drsdaq/DRS/DRS.cc	(revision 181)
+++ /drsdaq/DRS/DRS.cc	(revision 182)
@@ -183,8 +183,8 @@
 #endif
       /* check all VME slave slots */
-      for (index = 2; index <= 10; index++) {      
+      for (index = 2; index <= 9; index++) {      
 #ifdef CT_VME 
 	MasterMap.vmebus_address	= GEVPC_BASE_ADDR + index * GEVPC_WINSIZE; // VME board base address
-	MasterMapVME(&MasterMapping[index]);
+	if (MasterMapVME(&MasterMapping[index]) != VME_SUCCESS) continue;
 #endif
       
@@ -4857,5 +4857,5 @@
 
    // use following lines to save calibration into an ASCII file
-#if 1
+#if 0
    FILE *fh;
 
@@ -6907,5 +6907,5 @@
   if ((ErrorCode = VME_Open()) != VME_SUCCESS) {
     VME_ErrorString(ErrorCode,ErrorString); 
-    printf("Error: %s\n",ErrorString);
+    printf("VME_Open()  %s\n",ErrorString);
   }  
   return ErrorCode;
@@ -6917,5 +6917,5 @@
   if (ErrorCode = VME_MasterMap(&MasterMap, MMap)) {
     VME_ErrorString(ErrorCode,ErrorString); 
-    printf("Error: %s\n",ErrorString);
+    printf("VME_MasterMap()  %s\n",ErrorString);
   }
   return(ErrorCode);
@@ -6927,5 +6927,5 @@
   if (ErrorCode = VME_MasterUnmap(MMap)) {
     VME_ErrorString(ErrorCode,ErrorString); 
-    printf("Error: %s\n",ErrorString);
+    printf("VME_MasterUnmap()  %s\n",ErrorString);
   }  
   return(ErrorCode);  
@@ -6937,5 +6937,5 @@
   if ((ErrorCode = VME_Close()) != VME_SUCCESS) {    
     VME_ErrorString(ErrorCode,ErrorString);
-    printf("Error: %s\n",ErrorString);
+    printf("VME_Close()  %s\n",ErrorString);
   }
   return ErrorCode;
@@ -6947,5 +6947,5 @@
   if ((ErrorCode = CMEM_Open()) != CMEM_RCC_SUCCESS) {
     VME_ErrorString(ErrorCode,ErrorString); 
-    printf("Error: %s\n",ErrorString);
+    printf("CMEM_Open()  %s\n",ErrorString);
   }
   return ErrorCode;
@@ -6957,5 +6957,5 @@
   if ((ErrorCode = CMEM_Close()) != CMEM_RCC_SUCCESS) {  
     VME_ErrorString(ErrorCode,ErrorString);
-    printf("Error: %s\n",ErrorString);
+    printf("CMEM_Close  %s\n",ErrorString);
   }
   return ErrorCode;
@@ -6966,5 +6966,5 @@
   if ((ErrorCode = CMEM_SegmentAllocate(SegSize, "DMA_BUFFER", CMEM_SegIdentifier)) != CMEM_RCC_SUCCESS) {
     VME_ErrorString(ErrorCode,ErrorString); 
-    printf("Error: %s\n",ErrorString);
+    printf("CMEM_SegmentAllocate()  %s\n",ErrorString);
   }
   return ErrorCode;
@@ -6976,5 +6976,5 @@
   if ((ErrorCode = CMEM_SegmentPhysicalAddress(CMEM_SegIdentifier, PCIAddress)) != CMEM_RCC_SUCCESS) {
     VME_ErrorString(ErrorCode,ErrorString);
-    printf("Error: %s\n",ErrorString);
+    printf("CMEM_SegmentPhysicalAddress()  %s\n",ErrorString);
   }
   return ErrorCode;
@@ -6986,5 +6986,5 @@
   if ((ErrorCode = CMEM_SegmentVirtualAddress(CMEM_SegIdentifier, VirtualAddress)) != CMEM_RCC_SUCCESS) {
     VME_ErrorString(ErrorCode,ErrorString);
-    printf("Error: %s\n",ErrorString);
+    printf("CMEM_SegmentVirtualAddress()  %s\n",ErrorString);
   }
   return ErrorCode;
@@ -6996,5 +6996,5 @@
   if ((ErrorCode = CMEM_SegmentFree(CMEM_SegIdentifier)) != CMEM_RCC_SUCCESS) {
     VME_ErrorString(ErrorCode,ErrorString); 
-    printf("Error: %s\n",ErrorString);
+    printf("CMEM_SegmentFree()  %s\n",ErrorString);
   }  
   return ErrorCode;
Index: /drsdaq/HVFeedback.cc
===================================================================
--- /drsdaq/HVFeedback.cc	(revision 181)
+++ /drsdaq/HVFeedback.cc	(revision 182)
@@ -25,11 +25,11 @@
 // Constructor: Initialise feedback 
 //
-HVFeedback::HVFeedback(DAQReadout* DAQClass, char* Configfile):
-			EvidenceServer(SERVER_NAME){
+HVFeedback::HVFeedback(DAQReadout* DAQClass){//:
+			//EvidenceServer(SERVER_NAME){
 
   m = DAQClass;
 
-  fNumberOfChannels = m->fNumberOfChannels;
-  fNumberOfChips = m->fNumberOfChips;  
+  fNumberOfChannels = m->GetBoard(0)->GetNumberOfChannels();
+  fNumberOfChips = m->GetBoard(0)->GetNumberOfChips();  
 
   PixMap = new PixelMap(PIXMAP_LOCATION, false);
@@ -45,25 +45,28 @@
   DIMSigma   = new float [m->NumBoards][kNumberOfChipsMax][kNumberOfChannelsMax]();
 
-  // Read configuration file
-  FILE *File;
-  if ((File = fopen(Configfile,"r")) == NULL) {
-    printf("Error: Could not open feedback configuration file '%s'\n", Configfile);
-  }
-  else {
-    printf("Reading feedback configuration file %s\n", Configfile);
-    ReadCard("TrigBoard",           &fLedTrigBoard,      'I', File);
-    ReadCard("TrigChannel",         &fLedTrigChannel,    'I', File);
-    ReadCard("TrigChip",            &fLedTrigChip,       'I', File);
-    ReadCard("TrigSample",          &fLedTrigSample,     'I', File);
-    ReadCard("TrigThreshold",       &fLedTrigThreshold,  'f', File);
-    ReadCard("SignalSample",        &fLedSignalSample,   'I', File);
-    ReadCard("BaselineSample",      &fLedBaselineSample, 'I', File);
-    ReadCard("IntHalfWidth",        &fIntHalfWidth, 	 'U', File);
-    ReadCard("DefaultNumAverage",   &fDefaultNumAverage, 'I', File);
-    ReadCard("DefaultResponse",      Response,      	 'f', File, m->NumBoards*fNumberOfChips*fNumberOfChannels);
-    ReadCard("DefaultTarget",        Target,      	 'f', File, m->NumBoards*fNumberOfChips*fNumberOfChannels);
-    // Add also initial gain to configuration parameters
-    fclose(File);
-  }
+  // Get configuration data
+  fLedTrigBoard = atoi(m->GetConfig("TrigBoard"));
+  fLedTrigChannel = atoi(m->GetConfig("TrigChannel"));
+  fLedTrigChip = atoi(m->GetConfig("TrigChip"));
+  fLedTrigSample = atoi(m->GetConfig("TrigSample"));
+  fLedTrigThreshold = atoi(m->GetConfig("TrigThreshold"));
+  fLedSignalSample = atoi(m->GetConfig("SignalSample"));
+  fLedBaselineSample = atoi(m->GetConfig("BaselineSample"));
+  fIntHalfWidth = atoi(m->GetConfig("IntHalfWidth"));
+  fDefaultNumAverage = atoi(m->GetConfig("DefaultNumAverage"));
+
+  char *Token = strtok(m->GetConfig("DefaultResponse"), " \t");
+  for (int i=0; i<m->NumBoards*fNumberOfChips*fNumberOfChannels; i++) {
+	if (Token == NULL) break;
+    *(&Response[0][0][0]+i) = (float) atof(Token);
+	Token = strtok(NULL, " \t");
+  }
+  Token = strtok(m->GetConfig("DefaultTarget"), " \t");
+  for (int i=0; i<m->NumBoards*fNumberOfChips*fNumberOfChannels; i++) {
+	if (Token == NULL) break;
+    *(&Target[0][0][0]+i) = (float) atof(Token);
+	Token = strtok(NULL, " \t");
+  }
+
   PrintConfig(MsgToLog);
 
@@ -76,5 +79,5 @@
 
   // Initial state
-  Gain = 0.2;
+  Gain = atoi(m->GetConfig("DefaultGain"));
   SetFBMode(FB_Off);
   SetNumAverages(fDefaultNumAverage);
@@ -94,4 +97,6 @@
 
   delete[] Average;   	delete[] Response;
+  delete[] DIMAverage;   	delete[] DIMSigma;
+  delete[] Sigma;
   delete[] Target;   	delete[] Buffer;
   delete PixMap;
@@ -256,6 +261,6 @@
   else {
     FBMode = Mode;
-	if (Mode != FB_ResponseFirst) State(INFO, "%s", FBState_Description[FBMode]);
-	else State(INFO, "%s (voltage difference %.3f)", FBState_Description[FBMode], DiffVoltage);
+	if (Mode != FB_ResponseFirst) m->State(m->INFO, "%s", FBState_Description[FBMode]);
+	else m->State(m->INFO, "%s (voltage difference %.3f)", FBState_Description[FBMode], DiffVoltage);
     ClearAverages();
   }
Index: /drsdaq/HVFeedback.h
===================================================================
--- /drsdaq/HVFeedback.h	(revision 181)
+++ /drsdaq/HVFeedback.h	(revision 182)
@@ -13,10 +13,7 @@
 #include "DAQReadout.h"
 
-#define kNumberOfChipsMax 2
-#define kNumberOfChannelsMax 10
-
 enum FBState {FB_Off, FB_Active, FB_Targets, FB_ResponseFirst, FB_ResponseSecond};
 
-class HVFeedback: public EvidenceServer {
+class HVFeedback: public DimServer {//EvidenceServer {
 
     class DAQReadout *m;
@@ -60,5 +57,5 @@
     
   public:
-    HVFeedback(class DAQReadout*, char*);
+    HVFeedback(class DAQReadout*);
     ~HVFeedback();
 
Index: /drsdaq/History.txt
===================================================================
--- /drsdaq/History.txt	(revision 181)
+++ /drsdaq/History.txt	(revision 182)
@@ -59,3 +59,4 @@
 9/3/2010	Feedback now depended on DIM for communication with bias server.
 			Started migration to DRS4 (last tested revision as daqct3 for DRS2 is 161). DRS class will not run anymore with DRS2 FPGA firmware.
-			
+11/3/2010	Removed SlowData class.			
+12/3/2010	Removed local configuration and logging.
Index: /drsdaq/Makefile
===================================================================
--- /drsdaq/Makefile	(revision 181)
+++ /drsdaq/Makefile	(revision 182)
@@ -10,5 +10,5 @@
 CC  	= g++   	# Compiler to use
 
-SOURCES = HVFeedback.cc DAQReadout.cc RawDataCTX.cc SlowData.cc ../pixelmap/Pixel.cc ../pixelmap/PixelMap.cc DRS/DRS.cc DRS/mxml.c DRS/strlcpy.c drsdaq.cpp ../Evidence/Evidence.cc 
+SOURCES = HVFeedback.cc DAQReadout.cc RawDataCTX.cc ../pixelmap/Pixel.cc ../pixelmap/PixelMap.cc DRS/DRS.cc DRS/mxml.c DRS/strlcpy.c drsdaq.cpp ../Evidence/Evidence.cc 
 OBJECTS = $(addsuffix .o, $(basename $(SOURCES)))
 INCDIRS   = -I. -IDRS -I../pixelmap -I../Evidence -I$(DIMDIR)/dim
Index: sdaq/SlowData.cc
===================================================================
--- /drsdaq/SlowData.cc	(revision 181)
+++ 	(revision )
@@ -1,100 +1,0 @@
-/********************************************************************\
-
-  SlowData.cc
-
-  Class handling the writing of slow data. Strings to be written in the
-  slow data file are checked that they do not contain control characters.
-  
-  1. Call constructor with desired identification and directory
-     for slow data file. The public ErrorCode variable will be zero 
-     if successful, otherwise contain the relevant errno.
-  2. Use NewEntry() to start a new entry with given variable name. A text
-     as second argument is optional.
-  3. If text should be added to an open entry, use AddToEntry(). It can
-     process printf()-style formatting.
-  4. The slow data file will be closed upon destruction of the instance.  
-    
-  Oliver Grimm
-
-\********************************************************************/
-
-#include "SlowData.h"
-
-//
-// Constructor: Open slow data file (filename generate using current date)
-//
-SlowData::SlowData(const char* IssuerName, const char* Direcory) {
-
-  time_t rawtime;
-  struct tm *timeinfo;
-  char Filename[MAX_PATH];
-
-  Issuer = IssuerName;
-  NewEntryCalled = false;
-  InternalCall = false;
-  
-  time(&rawtime);
-  timeinfo = gmtime(&rawtime);
-  if(timeinfo->tm_hour>=13) rawtime += 12*60*60;
-  timeinfo = gmtime(&rawtime);
-  snprintf(Filename, sizeof(Filename), "%s/%s_%d%02d%02d.slow", Direcory, Issuer, timeinfo->tm_year+1900,timeinfo->tm_mon+1,timeinfo->tm_mday);
-
-  if ((SlowdataFile = fopen(Filename, "a")) == NULL) ErrorCode = errno;
-  else ErrorCode = 0;
-}
-
-//
-// Destructor
-//
-SlowData::~SlowData() {
-  if(SlowdataFile!=NULL) fclose(SlowdataFile);  
-}
-
-//
-// Add a new entry to slow data file
-//
-bool SlowData::NewEntry(const char *Variable, const char *Text) {
-
-  time_t RawTime;
-  struct tm *TM;
-  struct timeval Time;
-
-  time(&RawTime);
-  TM = localtime(&RawTime);
-  gettimeofday(&Time, NULL);
-  InternalCall = true;
-  NewEntryCalled = AddToEntry("\n%s %s %d %d %d %d %d %d %d %lu ", Issuer, Variable, TM->tm_year+1900,TM->tm_mon+1,TM->tm_mday,TM->tm_hour,TM->tm_min,TM->tm_sec, Time.tv_usec/1000, Time.tv_sec);
-  InternalCall = false;
-  if(Text != NULL && NewEntryCalled == true) NewEntryCalled = AddToEntry("%s", Text);
-
-  return NewEntryCalled;
-}
-
-//
-// Add data to an open entry
-//
-bool SlowData::AddToEntry(const char *Format, ...) {
-
-  char Textbuffer[MAX_ENTRY_SIZE];
-  va_list ArgumentPointer;
-
-  if(SlowdataFile==NULL || (!NewEntryCalled && !InternalCall)) return false;  
-
-  va_start(ArgumentPointer, Format); 
-  vsnprintf(Textbuffer, sizeof(Textbuffer), Format, ArgumentPointer);
-  va_end(ArgumentPointer);
-
-  if(!InternalCall)
-    for(unsigned int i=0; i<strlen(Textbuffer); i++)
-      if (iscntrl(Textbuffer[i])) return false;
-
-  if(fprintf(SlowdataFile, "%s", Textbuffer) == -1) {
-    ErrorCode = errno;
-    fclose(SlowdataFile);
-    SlowdataFile = NULL;  
-    return false;
-  }
-  fflush(SlowdataFile);
-  ErrorCode = 0;
-  return true;
-}
Index: sdaq/SlowData.h
===================================================================
--- /drsdaq/SlowData.h	(revision 181)
+++ 	(revision )
@@ -1,32 +1,0 @@
-#ifndef SLOWDATA_H_SEEN
-#define SLOWDATA_H_SEEN
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <time.h>
-#include <errno.h>
-#include <stdarg.h>
-#include <string.h>
-#include <sys/time.h>
-#include <ctype.h>
-
-#define MAX_PATH 256
-#define MAX_ENTRY_SIZE 10000
-
-class SlowData {
-
-    const char *Issuer;
-    FILE *SlowdataFile;
-    bool NewEntryCalled;
-    bool InternalCall;
-	   	    	  
-  public:
-    SlowData(const char*, const char*);
-    ~SlowData();
-
-    int ErrorCode;	// Set to errno if an error occured, zero otherwise
-    bool NewEntry(const char*, const char* = NULL);
-    bool AddToEntry(const char*, ...);
-};
-
-#endif
Index: /drsdaq/drsdaq.cpp
===================================================================
--- /drsdaq/drsdaq.cpp	(revision 181)
+++ /drsdaq/drsdaq.cpp	(revision 182)
@@ -30,4 +30,5 @@
 void SignalHandler(int);
 void CrashHandler(int);
+void ExitFunction();
 
 // ================
@@ -84,7 +85,8 @@
   signal(SIGINT, &CrashHandler);
   signal(SIGHUP, &CrashHandler);
-    
+  atexit(&ExitFunction);
+
   // Construct main instance and create mutex for thread synchronization
-  DAQReadout dreadout(argc==3 ? argv[2] : DEFAULT_CONFIG);
+  DAQReadout dreadout;
   if (pthread_mutex_init(&dreadout.control_mutex, NULL) != 0) {
     perror("pthread_mutex_init failed");
@@ -92,25 +94,22 @@
   }
 
-  if (dreadout.ConfigOK) { // Normal program execution only if configuration was complete
-    // Create threads
-    if (pthread_mutex_init(&dreadout.control_mutex, NULL) != 0) {
-      perror("pthread_mutex_init failed");
-      throw;
-    }
-    if ((pthread_create(&thread_ConsoleCommand, NULL, (void * (*)(void *)) ConsoleCommand,(void *) &dreadout)) != 0) {
-      perror("pthread_create failed with console thread");
-      throw;
-    }
-    if ((pthread_create(&thread_CCCommand, NULL, (void * (*)(void *)) CCCommand,(void *) &dreadout)) != 0) {
-      perror("pthread_create failed with socket thread");
-      dreadout.SocketThread = NULL;
-    }
-    else dreadout.SocketThread = &thread_CCCommand;  // Thread should be accessible for sending signals  
-
-    // Wait for threads to quit
-    pthread_join(thread_ConsoleCommand, NULL);
-    if(dreadout.SocketThread != NULL) pthread_join(thread_CCCommand, NULL);
-  }
-  else printf("Error: Configuration parameter missing in %s, terminating.\n", argc==3 ? argv[2] : DEFAULT_CONFIG);
+  // Create threads
+  if (pthread_mutex_init(&dreadout.control_mutex, NULL) != 0) {
+    perror("pthread_mutex_init failed");
+    throw;
+  }
+  if ((pthread_create(&thread_ConsoleCommand, NULL, (void * (*)(void *)) ConsoleCommand,(void *) &dreadout)) != 0) {
+    perror("pthread_create failed with console thread");
+    throw;
+  }
+  if ((pthread_create(&thread_CCCommand, NULL, (void * (*)(void *)) CCCommand,(void *) &dreadout)) != 0) {
+    perror("pthread_create failed with socket thread");
+    dreadout.SocketThread = NULL;
+  }
+  else dreadout.SocketThread = &thread_CCCommand;  // Thread should be accessible for sending signals  
+
+  // Wait for threads to quit
+  pthread_join(thread_ConsoleCommand, NULL);
+  if(dreadout.SocketThread != NULL) pthread_join(thread_CCCommand, NULL);
   
   // Destruct mutex and main instance
@@ -282,2 +281,8 @@
   return;
 }
+
+// This function will be implicitly called by exit()
+void ExitFunction() {
+  remove(LOCKFILE);
+  return;          
+}
