Index: fact/Evidence/Alarm.cc
===================================================================
--- fact/Evidence/Alarm.cc	(revision 9840)
+++ fact/Evidence/Alarm.cc	(revision 9852)
@@ -10,5 +10,6 @@
     The states are described in LevelStr[].
   - A master alarm (indicating most severe of individual alarms) is published. 
-    
+  - The server can be switched on/off with the command 'Alarm/Switch'.
+      
   A mutex is used because UpdateAlarmSummary() may be called from DIM handler thread and
   from main thread.
@@ -32,8 +33,10 @@
 class AlarmHandler: public DimClient, public EvidenceServer {
     
-	DimCommand *Command;
+	DimCommand *ResetCommand;
+	DimCommand *SwitchCommand;
 	DimService *Summary, *Master;
 	char *AlarmText;
 	int MasterAlarm;
+	bool Active;
 
     void infoHandler();
@@ -66,5 +69,6 @@
   MasterAlarm = 0;
   AlarmText = NULL;
-  
+  Active = true;
+
   // Handling of servies will only start after start()
   autoStartOff();
@@ -97,5 +101,6 @@
 
   // Provide command to reset Level   
-  Command = new DimCommand("ResetAlarm", (char *) "C", this);
+  ResetCommand = new DimCommand(SERVER_NAME"/ResetAlarm", (char *) "C", this);
+  SwitchCommand = new DimCommand(SERVER_NAME"/Switch", (char *) "C", this);
   
   // List set up, can start handling
@@ -107,5 +112,6 @@
 AlarmHandler::~AlarmHandler() {
 
-  delete Command;
+  delete SwitchCommand;
+  delete ResetCommand;
 
   for (int i=0; i<List.size(); i++) {
@@ -136,17 +142,25 @@
 
 
-// Reset alarm level of given server
+// Handle commands
 void AlarmHandler::commandHandler() {
 
-  // Safety check
-  string Server = ToString((char *) "C", getCommand()->getData(), getCommand()->getSize());
-  if (getCommand() != Command || Server.empty()) return;
- 
+  string Text = ToString((char *) "C", getCommand()->getData(), getCommand()->getSize());
+
   // 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;
-	sendCommandNB((Server+"/ResetMessage").c_str(), (int) 0);
+  if (getCommand() == ResetCommand) {
+	for (int i=0; i<List.size(); i++) if (List[i].Server == Text) {
+      Message(INFO, "Alarm level of server %s reset by %s (ID %d)", Text.c_str(), getClientName(), getClientId());
+	  List[i].Level = 0;
+	  List[i].WarnedLevel = 0;
+	  sendCommandNB((Text+"/ResetMessage").c_str(), (int) 0);
+	}
+  }
+
+  // Switch Alarm server on/off and publish/log action
+  if (getCommand() == SwitchCommand) {
+    if (Text == "off") Active = false;
+	else Active = true;
+
+    Message(INFO, "Alarm server switched %s by %s (ID %d)", Active ? "ON":"OFF", getClientName(), getClientId());
   }
   
@@ -159,9 +173,10 @@
 
   ostringstream Buf;
-  int Alarm = 0, Ret;  
+  int Alarm = -1, Ret;  
 
   Lock();
 
-  for (int i=0; i<List.size(); i++) {
+  if (!Active) Buf << "Alarm server inactive";
+  else for (int i=0; i<List.size(); i++) {
 	// Alarm level description
 	Buf << List[i].Server << ": " << (List[i].Level>=0 && List[i].Level<=4 ? LevelStr[List[i].Level] : "unknown");
@@ -210,26 +225,27 @@
 int main() {
     
-  DimBrowser Browser;
+  DimBrowser B;
   char *Server, *Node;
   bool Exist;
   
   // Static declaration ensures calling of destructor by exit()
-  static AlarmHandler Alarm; 
-  
-  // Check periodically if servers are up
-  while(!Alarm.ExitRequest) {
-
-    for (int i=0; i<Alarm.List.size(); i++) {
+  static AlarmHandler A; 
+  
+  while(!A.ExitRequest) {
+    for (int i=0; i<A.List.size(); i++) {
+	  // Check if server exists
       Exist = false;
-      Browser.getServers();
-      while (Browser.getNextServer(Server, Node) == 1) {
-        if (Alarm.List[i].Server == Server) Exist = true;
+      B.getServers();
+      while (B.getNextServer(Server, Node) == 1) {
+        if (A.List[i].Server == Server) Exist = true;
       }
-	  if (!Exist) Alarm.List[i].Level = 4;
-	  else if (Alarm.List[i].Level == -1) Alarm.List[i].Level = 0;
+	  if (!Exist) A.List[i].Level = 4;
+
+	  // Check if standard service available in case server not yet chcked (Level is -1)
+	  if (B.getServices((A.List[i].Server+"/VERSION_NUMBER").c_str())>0 && A.List[i].Level==-1) A.List[i].Level = 0;
     }
     
-    Alarm.UpdateAlarmSummary();
-    sleep(atoi(Alarm.GetConfig("period").c_str()));
-  }
-}
+    A.UpdateAlarmSummary();
+    sleep(atoi(A.GetConfig("period").c_str()));
+  }
+}
Index: fact/Evidence/readme.txt
===================================================================
--- fact/Evidence/readme.txt	(revision 9840)
+++ fact/Evidence/readme.txt	(revision 9852)
@@ -1,5 +1,2 @@
-
-This directory contains the backbone of the control system. See directory Doc for documentation.
-
 
 Version history
@@ -48,2 +45,3 @@
 			ConfigChanged() is called as separate thread when configuration file changes. Thread ID
 			is checked in GetConfig() and also from this thread it will make blocking requests.
+12/8/2010	Added command to switch alarm server on/off (command 'Alarm/Switch').
