Index: /Evidence/Alarm.cc
===================================================================
--- /Evidence/Alarm.cc	(revision 254)
+++ /Evidence/Alarm.cc	(revision 255)
@@ -124,7 +124,10 @@
   // Identify status service
   for (int i=0; i<List.size(); i++) if (getInfo() == List[i].Subscription) {
-	// Update level: unavailable or current severity of status  
+	// Update level: unavailable or current severity of status (safely extracted)  
 	if (!ServiceOK(getInfo())) List[i].Level = 4;
-	else if (getInfo()->getInt() > List[i].Level) List[i].Level = getInfo()->getInt();
+	else {
+	  int Severity = atoi(ToString(getInfo()->getFormat(), getInfo()->getData(), getInfo()->getSize()).c_str());
+	  if (Severity > List[i].Level) List[i].Level = Severity;
+	}
   }
 
@@ -140,9 +143,10 @@
   if (getCommand() != Command || Server.empty()) return;
  
-  // Reset alarm level and publish/log action
+  // Reset alarm level, publish/log action and reset server message severity
   for (int i=0; i<List.size(); i++) if (List[i].Server == Server) {
     Message(INFO, "Alarm level of server %s reset by %s (ID %d)", Server.c_str(), getClientName(), getClientId());
 	List[i].Level = 0;
 	List[i].WarnedLevel = 0;
+	if (Server != "DIS_DNS") sendCommandNB((Server+"/EXIT").c_str(), (int) 0);
   }
   
@@ -155,5 +159,5 @@
 
   ostringstream Buf;
-  int Alarm, Ret;  
+  int Alarm = 0, Ret;  
 
   Lock();
@@ -223,5 +227,5 @@
       }
 	  if (!Exist) Alarm.List[i].Level = 4;
-	  else if (Alarm.List[i].Level = -1) Alarm.List[i].Level = 0;
+	  else if (Alarm.List[i].Level == -1) Alarm.List[i].Level = 0;
     }
     
Index: /Evidence/Doc/Evidence.tex
===================================================================
--- /Evidence/Doc/Evidence.tex	(revision 254)
+++ /Evidence/Doc/Evidence.tex	(revision 255)
@@ -39,5 +39,5 @@
 \maketitle
 
-This report describes the design and basic functionality of the \E control system. This essentially is a C++ class and a set of programs running on Linux for controlling small scale experiments. It is based on CERN's DIM library for interprocess communication over TCP/IP connections.
+This report describes the design and basic functionality of the \E control system. This essentially is a C++ class and a set of programs running on Linux for controlling small scale experiments. It is based on CERN's DIM library for interprocess communication over TCP/IP connections. \lstinline{$Rev$}
 
 \tableofcontents
@@ -130,5 +130,6 @@
 \item Provides a method for configuration requests. If the configuration data is not available, the application terminates with a  message of FATAL severity unless default data is given.
 \item Provides a method for safely translating DIM service data into text.
-\item Implements the virtual DIM methods \lstinline{exitHandler()} and \lstinline{errorHandler()}. The exit handler can be called through a standard DIM command and will, upon first invocation, just set the flag \lstinline{ExitRequest} which then should be handled by the application. Upon second invocation, it will call \lstinline{exit()}. The error handler will issue a message with ERROR severity.The user application can override these handlers.
+\item Implements the virtual DIM methods \lstinline{exitHandler()}. It can be called through a standard DIM command \lstinline{SvrName/EXIT}, taking a single integer as argument. Upon first invocation, the handler just sets the flag \lstinline{ExitRequest} which should be handled by the application. Upon second invocation, it will call \lstinline{exit()}. A special functionality is given to the argument value 0: it instructs the server to reset its message severity to INFO, without exiting. This is used by the \lstinline{Alarm} server if it receives a command to reset an alarm level, but is also available to the user. The user application can override this handler.
+\item Implements the virtual DIM methods \lstinline{errorHandler()}. The error handler will issue a message with ERROR severity that contains the DIM error code. The user application can override this handler.
 \item Installs signal handler for SIGQUIT (ctrl-backspace), SIGTERM, SIGINT (ctrl-c), and SIGHUP (terminal closed). The signal handler sets first \lstinline{ExitRequest}, and on second invocation calls \lstinline{exit()}. After instantiating the class, the programmer may override the handlers.
 \item Catches un-handled C++ exceptions and extracts as much information from the exception as possible.\footnote{This termination handler is taken directly from the code of the \lstinline{g++} compiler and is thus compiler specific.} That information is also published as a message.
@@ -140,5 +141,5 @@
 \label{EvidenceServer-Methods}
 
-The \lstinline{public} part of the header file \lstinline{Evidence.h} is as follows. The namespace designation \lstinline{std} has been left out for clarity in this listing. 
+The \lstinline{public} part of the header file \lstinline{Evidence.h} is as follows. The namespace designation \lstinline{std} has been left out for clarity in this listing.
 
 \begin{lstlisting}[numbers=left,numberstyle=\tiny,stepnumber=2,numbersep=5pt]
@@ -180,5 +181,5 @@
 \underline{\lstinline{ActivateSignal()}} is used to define a signal that should be emitted to the main thread in case the configuration file changes. See Sect.\,\ref{ConfigHandling} for details. No signal will be emitted if not set by this routine.
 
-The methods \underline{\lstinline{Lock()}} and \underline{\lstinline{Unlock()}} work on an internal mutex.\footnote{Its type is \lstinline{PTHREAD_MUTEX_ERRORCHECK}. In case an already locked mutex is re-locked, the corresponding system call will therefore return a error and thus avoid dead-locking.} They are used by \lstinline{GetConfig()} but are also available for the user application to serialize access from multiple threads. If a signal is set by \lstinline{ActivateSignal()}, it is masked before locking and unmasked after unlocking. 
+The methods \underline{\lstinline{Lock()}} and \underline{\lstinline{Unlock()}} work on an internal mutex.\footnote{Its type is \lstinline{PTHREAD_MUTEX_ERRORCHECK}. In case an already locked mutex is re-locked, the corresponding system call will therefore return a error and thus avoid dead-locking. Error messages from \lstinline{Lock()} and \lstinline{Unlock()} are written to the console and to the log file. They are not published using \lstinline{Message()} since this method itself uses locking and calling it would result in an infinite recursion.} They are used by \lstinline{GetConfig()} but are also available for the user application to serialize access from multiple threads. If a signal is set by \lstinline{ActivateSignal()}, it is masked before locking and unmasked after unlocking. Calling functions in the locked state should be avoided as it might result in re-locking.
 
 The static method \underline{\lstinline{ToString()}} translates the contents of a DIM service safely into a string that is returned. As no consistency between a service format and the contained data is guaranteed by DIM, precautions are necessary to avoid buffer overruns. The method currently handles the standardized message format \lstinline{"I:1;C"}, arrays of numbers and strings. All other formats are translated into a hex representation. The arguments are the DIM service format, a pointer to the service data and the data size in bytes. It is thread safe as it uses only the arguments and dynamically allocated storage.
Index: /Evidence/Evidence.cc
===================================================================
--- /Evidence/Evidence.cc	(revision 254)
+++ /Evidence/Evidence.cc	(revision 255)
@@ -122,6 +122,6 @@
 	  // Return current value
 	  Result = List[Item].Value;
-	  This->Unlock();
 	}
+	This->Unlock();
   }
 
@@ -200,6 +200,9 @@
 void EvidenceServer::exitHandler(int Code) {
 
-  Message(INFO, "Exit handler called (DIM exit code %d)", Code);
-  exit(EXIT_SUCCESS);
+  if (Code == 0) Message(INFO, "Message cleared by %s (ID %d)", getClientName(), getClientId());
+  else {
+	Message(INFO, "Exit handler called (DIM exit code %d)", Code);
+	exit(EXIT_SUCCESS);
+  }
 }
 
@@ -241,20 +244,19 @@
   }
 
-  // Terminate if severity if FATAL  
-  if (Severity == FATAL) exit(EXIT_FAILURE);
-
   // Delete old message
-  // Note that Lock()/Unlock() might fail with a FATAL message. To avoid an infinite loop,
-  // check for FATAL severity is done before here.
   Lock();
   delete[] MessageData;
   MessageData = NewMsg;
   Unlock();  
-}
-
-
-// Set to central logging server with non-blocking command (may be used in DIM handler)
+
+  // Terminate if severity if FATAL  
+  if (Severity == FATAL) exit(EXIT_FAILURE);
+}
+
+
+// Send to central logging server with non-blocking command
 void EvidenceServer::SendToLog(const char *Format, ...) {
 
+  static char ErrorString[] = "vasprintf() failed in SendToLog()";
   char *Buffer;
   int Ret;
@@ -271,5 +273,5 @@
 	free (Buffer);
   }
-  else Message(ERROR, "Could not create logging text in SendToLog(), vasprintf() failed");
+  else DimClient::sendCommandNB("DColl/Log", ErrorString);
 }
 
@@ -300,6 +302,7 @@
 
 
-// Locking and unlocking for list access
-// Signal blocked before locking to avoid dead-lock by calling GetConfig() from ConfigChanged().
+// Locking and unlocking functions.
+// Signal blocked before locking (pthread_mutex_lock() not asynch-signal safe).
+// Message() is not used to avoid infinite recursion
 void EvidenceServer::Lock() {
 
@@ -312,9 +315,15 @@
 	Ret += abs(pthread_sigmask(SIG_BLOCK, &Set, NULL));
 
-	if (Ret != 0) Message(FATAL, "Signal masking failed in Lock()");
+	if (Ret != 0) {
+	  printf("Signal masking failed in Lock()");
+	  SendToLog("Signal masking failed in Lock()");
+	  exit(EXIT_FAILURE);
+	}
   }
 
   if ((Ret = pthread_mutex_lock(&Mutex)) != 0) {
-	Message(FATAL, "pthread_mutex_lock() failed in Lock() (%s)", strerror(Ret));
+	printf("pthread_mutex_lock() failed in Lock() (%s)", strerror(Ret));
+	SendToLog("pthread_mutex_lock() failed in Lock() (%s)", strerror(Ret));
+	exit(EXIT_FAILURE);
   }
 }
@@ -326,5 +335,7 @@
 
   if ((Ret = pthread_mutex_unlock(&Mutex)) != 0) {
-	Message(FATAL, "pthread_mutex_unlock() failed in Unlock() (%s)", strerror(Ret));
+	printf("pthread_mutex_unlock() failed in Unlock() (%s)", strerror(Ret));
+	SendToLog("pthread_mutex_unlock() failed in Unlock() (%s)", strerror(Ret));
+	exit(EXIT_FAILURE);
   }
   
@@ -334,5 +345,9 @@
 	Ret += abs(pthread_sigmask(SIG_UNBLOCK, &Set, NULL));
 
-	if (Ret != 0) Message(FATAL, "Signal unmasking failed in Unlock()");
+	if (Ret != 0) {
+	  printf("Signal unmasking failed in Unlock()");
+	  SendToLog("Signal unmasking failed in Unlock()");
+	  exit(EXIT_FAILURE);
+	}
   }
 }
Index: /Evidence/readme.txt
===================================================================
--- /Evidence/readme.txt	(revision 254)
+++ /Evidence/readme.txt	(revision 255)
@@ -1,3 +1,2 @@
-Short description of Evidence control system
 
 This directory contains the backbone of the control system. See directory Doc for documentation.
@@ -44,3 +43,8 @@
 			second-last message will not be freed correctly if severity is FATAL). Added
 			History server configuration parameters to adjust buffer size.
-
+20/7/2010	SendToLog() does not call Message() in case of error, but writes error message to log.
+21/7/2010	Lock()/Unlock() do not report errors via Message(), but print to console and use 
+			SendToLog(). That avoids a recursion problem since Message() also uses locking.
+			The general exitHandler() will react in a special way to code 0: it will reset
+			the message severity. This feature is used by Alarm if it receives a command to
+			reset an alarm level.
Index: ols/FAD/ddd_for_fad/Makefile
===================================================================
--- /tools/FAD/ddd_for_fad/Makefile	(revision 254)
+++ 	(revision )
@@ -1,213 +1,0 @@
-#############################################################################
-# Makefile for building: fad
-# Generated by qmake (2.01a) (Qt 4.5.2) on: Mo. Jun 21 13:49:18 2010
-# Project:  fad.pro
-# Template: app
-# Command: /usr/bin/qmake -unix -o Makefile fad.pro
-#############################################################################
-
-####### Compiler, tools and options
-
-CC            = gcc
-CXX           = g++
-DEFINES       = -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED
-CFLAGS        = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
-CXXFLAGS      = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
-INCPATH       = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtNetwork -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I/usr/local/qwt-5.2.1-svn/include -I.
-LINK          = g++
-LFLAGS        = -Wl,-O1
-LIBS          = $(SUBLIBS)  -L/usr/lib -L/usr/local/qwt-5.2.1-svn/lib -lqwt -lQtGui -lQtNetwork -lQtCore -lpthread
-AR            = ar cqs
-RANLIB        = 
-QMAKE         = /usr/bin/qmake
-TAR           = tar -cf
-COMPRESS      = gzip -9f
-COPY          = cp -f
-SED           = sed
-COPY_FILE     = $(COPY)
-COPY_DIR      = $(COPY) -r
-INSTALL_FILE  = install -m 644 -p
-INSTALL_DIR   = $(COPY_DIR)
-INSTALL_PROGRAM = install -m 755 -p
-DEL_FILE      = rm -f
-SYMLINK       = ln -sf
-DEL_DIR       = rmdir
-MOVE          = mv -f
-CHK_DIR_EXISTS= test -d
-MKDIR         = mkdir -p
-
-####### Output directory
-
-OBJECTS_DIR   = ./
-
-####### Files
-
-SOURCES       = Functions.cpp \
-		GUI.cpp moc_GUI.cpp
-OBJECTS       = Functions.o \
-		GUI.o \
-		moc_GUI.o
-DIST          = /usr/share/qt4/mkspecs/common/g++.conf \
-		/usr/share/qt4/mkspecs/common/unix.conf \
-		/usr/share/qt4/mkspecs/common/linux.conf \
-		/usr/share/qt4/mkspecs/qconfig.pri \
-		/usr/share/qt4/mkspecs/features/qt_functions.prf \
-		/usr/share/qt4/mkspecs/features/qt_config.prf \
-		/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
-		/usr/share/qt4/mkspecs/features/default_pre.prf \
-		/usr/share/qt4/mkspecs/features/release.prf \
-		/usr/share/qt4/mkspecs/features/default_post.prf \
-		/usr/share/qt4/mkspecs/features/warn_on.prf \
-		/usr/share/qt4/mkspecs/features/qt.prf \
-		/usr/share/qt4/mkspecs/features/unix/thread.prf \
-		/usr/share/qt4/mkspecs/features/moc.prf \
-		/usr/share/qt4/mkspecs/features/resources.prf \
-		/usr/share/qt4/mkspecs/features/uic.prf \
-		/usr/share/qt4/mkspecs/features/yacc.prf \
-		/usr/share/qt4/mkspecs/features/lex.prf \
-		/usr/share/qt4/mkspecs/features/include_source_dir.prf \
-		fad.pro
-QMAKE_TARGET  = fad
-DESTDIR       = 
-TARGET        = fad
-
-first: all
-####### Implicit rules
-
-.SUFFIXES: .o .c .cpp .cc .cxx .C
-
-.cpp.o:
-	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
-
-.cc.o:
-	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
-
-.cxx.o:
-	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
-
-.C.o:
-	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
-
-.c.o:
-	$(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
-
-####### Build rules
-
-all: Makefile $(TARGET)
-
-$(TARGET):  $(OBJECTS)  
-	$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
-
-Makefile: fad.pro  /usr/share/qt4/mkspecs/linux-g++/qmake.conf /usr/share/qt4/mkspecs/common/g++.conf \
-		/usr/share/qt4/mkspecs/common/unix.conf \
-		/usr/share/qt4/mkspecs/common/linux.conf \
-		/usr/share/qt4/mkspecs/qconfig.pri \
-		/usr/share/qt4/mkspecs/features/qt_functions.prf \
-		/usr/share/qt4/mkspecs/features/qt_config.prf \
-		/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
-		/usr/share/qt4/mkspecs/features/default_pre.prf \
-		/usr/share/qt4/mkspecs/features/release.prf \
-		/usr/share/qt4/mkspecs/features/default_post.prf \
-		/usr/share/qt4/mkspecs/features/warn_on.prf \
-		/usr/share/qt4/mkspecs/features/qt.prf \
-		/usr/share/qt4/mkspecs/features/unix/thread.prf \
-		/usr/share/qt4/mkspecs/features/moc.prf \
-		/usr/share/qt4/mkspecs/features/resources.prf \
-		/usr/share/qt4/mkspecs/features/uic.prf \
-		/usr/share/qt4/mkspecs/features/yacc.prf \
-		/usr/share/qt4/mkspecs/features/lex.prf \
-		/usr/share/qt4/mkspecs/features/include_source_dir.prf \
-		/usr/lib/libQtGui.prl \
-		/usr/lib/libQtNetwork.prl \
-		/usr/lib/libQtCore.prl
-	$(QMAKE) -unix -o Makefile fad.pro
-/usr/share/qt4/mkspecs/common/g++.conf:
-/usr/share/qt4/mkspecs/common/unix.conf:
-/usr/share/qt4/mkspecs/common/linux.conf:
-/usr/share/qt4/mkspecs/qconfig.pri:
-/usr/share/qt4/mkspecs/features/qt_functions.prf:
-/usr/share/qt4/mkspecs/features/qt_config.prf:
-/usr/share/qt4/mkspecs/features/exclusive_builds.prf:
-/usr/share/qt4/mkspecs/features/default_pre.prf:
-/usr/share/qt4/mkspecs/features/release.prf:
-/usr/share/qt4/mkspecs/features/default_post.prf:
-/usr/share/qt4/mkspecs/features/warn_on.prf:
-/usr/share/qt4/mkspecs/features/qt.prf:
-/usr/share/qt4/mkspecs/features/unix/thread.prf:
-/usr/share/qt4/mkspecs/features/moc.prf:
-/usr/share/qt4/mkspecs/features/resources.prf:
-/usr/share/qt4/mkspecs/features/uic.prf:
-/usr/share/qt4/mkspecs/features/yacc.prf:
-/usr/share/qt4/mkspecs/features/lex.prf:
-/usr/share/qt4/mkspecs/features/include_source_dir.prf:
-/usr/lib/libQtGui.prl:
-/usr/lib/libQtNetwork.prl:
-/usr/lib/libQtCore.prl:
-qmake:  FORCE
-	@$(QMAKE) -unix -o Makefile fad.pro
-
-dist: 
-	@$(CHK_DIR_EXISTS) .tmp/fad1.0.0 || $(MKDIR) .tmp/fad1.0.0 
-	$(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/fad1.0.0/ && $(COPY_FILE) --parents GUI.h .tmp/fad1.0.0/ && $(COPY_FILE) --parents Functions.cpp GUI.cpp .tmp/fad1.0.0/ && (cd `dirname .tmp/fad1.0.0` && $(TAR) fad1.0.0.tar fad1.0.0 && $(COMPRESS) fad1.0.0.tar) && $(MOVE) `dirname .tmp/fad1.0.0`/fad1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/fad1.0.0
-
-
-clean:compiler_clean 
-	-$(DEL_FILE) $(OBJECTS)
-	-$(DEL_FILE) *~ core *.core
-
-
-####### Sub-libraries
-
-distclean: clean
-	-$(DEL_FILE) $(TARGET) 
-	-$(DEL_FILE) Makefile
-
-
-mocclean: compiler_moc_header_clean compiler_moc_source_clean
-
-mocables: compiler_moc_header_make_all compiler_moc_source_make_all
-
-compiler_moc_header_make_all: moc_GUI.cpp
-compiler_moc_header_clean:
-	-$(DEL_FILE) moc_GUI.cpp
-moc_GUI.cpp: GUI.h
-	/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) GUI.h -o moc_GUI.cpp
-
-compiler_rcc_make_all:
-compiler_rcc_clean:
-compiler_image_collection_make_all: qmake_image_collection.cpp
-compiler_image_collection_clean:
-	-$(DEL_FILE) qmake_image_collection.cpp
-compiler_moc_source_make_all:
-compiler_moc_source_clean:
-compiler_uic_make_all:
-compiler_uic_clean:
-compiler_yacc_decl_make_all:
-compiler_yacc_decl_clean:
-compiler_yacc_impl_make_all:
-compiler_yacc_impl_clean:
-compiler_lex_make_all:
-compiler_lex_clean:
-compiler_clean: compiler_moc_header_clean 
-
-####### Compile
-
-Functions.o: Functions.cpp GUI.h \
-		SocketClient.h \
-		ViewEvent.h
-	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o Functions.o Functions.cpp
-
-GUI.o: GUI.cpp GUI.h
-	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o GUI.o GUI.cpp
-
-moc_GUI.o: moc_GUI.cpp 
-	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_GUI.o moc_GUI.cpp
-
-####### Install
-
-install:   FORCE
-
-uninstall:   FORCE
-
-FORCE:
-
Index: /tools/FAD/ddd_for_fad/fad.pro
===================================================================
--- /tools/FAD/ddd_for_fad/fad.pro	(revision 254)
+++ /tools/FAD/ddd_for_fad/fad.pro	(revision 255)
@@ -6,9 +6,9 @@
 TARGET = 
 DEPENDPATH += .
-INCLUDEPATH += . /usr/local/qwt-5.2.1-svn/include
+INCLUDEPATH += . /ihp/local/qwt-5.2.1/include
 
 # Input
 HEADERS += GUI.h
 SOURCES += Functions.cpp GUI.cpp 
-LIBS += -L/usr/local/qwt-5.2.1-svn/lib -lqwt
+LIBS += -L/ihp/local/qwt-5.2.1/lib -lqwt
 QT += network
