Index: /fact/Evidence/Edd/Edd.cc
===================================================================
--- /fact/Evidence/Edd/Edd.cc	(revision 10078)
+++ /fact/Evidence/Edd/Edd.cc	(revision 10079)
@@ -22,5 +22,5 @@
 
 class EddDim *Handler;
-
+QString DRSBoard = "drsdaq";
 
 // History chooser function (opens plot for numeric data, TextHist for all other)
@@ -292,7 +292,11 @@
 void EddPlot::Update(QString Name, int Time, QByteArray, QString Format, QString Text) {
 
+  bool DoUpdate = false;
+
   // Determine which plot item this call belongs to
   int ItemNo;
   for (ItemNo=0; ItemNo<List.size(); ItemNo++) if (List[ItemNo].Name == Name) {
+
+	DoUpdate = true;
 
 	// If size limit reached, clear buffer
@@ -335,5 +339,5 @@
   }
 
-  UpdatePlot();
+  if (DoUpdate) UpdatePlot();
 }
 
@@ -414,4 +418,5 @@
   Zoomer = new QwtPlotZoomer(QwtPlot::xBottom,QwtPlot::yLeft,canvas());
   connect(Zoomer, SIGNAL(zoomed(const QwtDoubleRect &)), this, SLOT(HandleZoom(const QwtDoubleRect &)));
+  connect(Zoomer, SIGNAL(zoomed(const QwtDoubleRect &)), this, SLOT(ReDoStats()));
 
   Magnifier = new QwtPlotMagnifier(canvas());
@@ -422,4 +427,5 @@
   Panner = new QwtPlotPanner(canvas());
   Panner->setMouseButton(Qt::LeftButton, Qt::ShiftModifier);
+  connect(Panner, SIGNAL(panned(int, int)), this, SLOT(ReDoStats()));
 
   Picker = new QwtPicker(QwtPicker::CornerToCorner|QwtPicker::RectSelection, QwtPicker::RectRubberBand, QwtPicker::AlwaysOff, this);
@@ -432,4 +438,11 @@
   
   insertLegend(new QwtLegend(), QwtPlot::TopLegend, 0.3);
+
+  // Marker for statistics text
+  Stats = new QwtPlotMarker();
+  Stats->setLineStyle(QwtPlotMarker::NoLine);
+  Stats->setLabelAlignment(Qt::AlignLeft | Qt::AlignBottom);
+  Stats->hide();
+  Stats->attach(this);
 
   // Context menu
@@ -444,4 +457,6 @@
   StyleAction = Menu->addAction("Draw dots", this, SLOT(UpdatePlot()));
   StyleAction->setCheckable(true);
+  StatisticsAction = Menu->addAction("Statistics", this, SLOT(ReDoStats()));
+  StatisticsAction->setCheckable(true);
   Menu->addAction("Zoom out", this, SLOT(MenuZoomOut()));
   Menu->addAction("Single trace", this, SLOT(MenuSingleTrace()));
@@ -458,4 +473,49 @@
   for (int i=0; i<Items.size(); i++) delete Items[i].Signal;
   delete Grid;
+}
+
+// Print statistics to plot if requested
+void EddBasePlot::ReDoStats() {
+
+  QString Text;
+  double Mean, Sigma;
+  unsigned long Count = 0;
+
+  // Set visibility of statistics box
+  Stats->setVisible(StatisticsAction->isChecked());
+
+  for (int i=0; i<Items.size(); i++) {
+	Mean = 0;
+	Sigma = 0;
+	Count = 0;
+
+    // Calculate mean and sigma for data points currently visible	
+	for (int j=0; j<Items[i].y.size(); j++) {
+	  if (!axisScaleDiv(QwtPlot::xBottom)->contains(Items[i].x[j])) continue;
+	  Mean += Items[i].y[j];
+	  Sigma += Items[i].y[j]*Items[i].y[j];
+	  Count++;
+	}
+	
+	if (Count == 0) Mean = 0;
+	else Mean /= Count;
+	if (Count < 2) Sigma = 0;
+	else Sigma = sqrt(Count/(Count-1)*(Sigma/Count-Mean*Mean));
+  
+	// Prepare string
+	Text += Items[i].Signal->title().text() + ": m " + QString::number(Mean, 'f', 2) + ", s " + QString::number(Sigma, 'f', 2) + "\n";
+  }
+
+  // Replot once to get axis correct
+  replot();
+
+  // Print string to plot
+  QwtText text(Text);
+  text.setFont(QFont("Helvetica", 7));
+  Stats->setValue(axisScaleDiv(QwtPlot::xBottom)->upperBound(), axisScaleDiv(QwtPlot::yLeft)->upperBound());
+  Stats->setLabel(text);
+
+  // Replot again to update text
+  replot();
 }
 
@@ -522,5 +582,5 @@
   else setCanvasBackground(EddPlotBackgroundColor);
 
-  replot();
+  ReDoStats();
 }
 
@@ -629,4 +689,6 @@
     setAxisAutoScale(QwtPlot::yLeft);
   }
+  
+  UpdatePlot();
 }
     
@@ -717,5 +779,6 @@
     "Pan\tShift and left mouse button\n\n"
 	"ESC cancels selection\n"
-    "Cursor keys move mouse");
+    "Cursor keys move mouse\n\n"
+	"Statistics are calculated over the current x axis extend");
 }
 
@@ -955,5 +1018,5 @@
 EventScope::EventScope(QWidget *P): EddBasePlot(P), PixelMap("../../config/PixelMap.txt", false) {
 
-  Name = "drsdaq/EventData";
+  Name = DRSBoard+"/EventData";
   Active = false;
 
@@ -1166,6 +1229,6 @@
 void EventScope::SetActive(bool State) {
 
-  if (State && !Active) Handler->Subscribe("drsdaq/EventData");
-  if (!State && Active) Handler->Unsubscribe("drsdaq/EventData");
+  if (State && !Active) Handler->Subscribe(DRSBoard+"/EventData");
+  if (!State && Active) Handler->Unsubscribe(DRSBoard+"/EventData");
   Active = State;
 }
@@ -1286,5 +1349,5 @@
   Layout->addWidget(Plot, 0, 4, 12, 10);
 
-  Line = new EddLineDisplay("drsdaq/Message");
+  Line = new EddLineDisplay("Feedback/Message");
   Line->setMaximumWidth(200);
   Layout->addWidget(Line, 0, 0, 1, 2);      
@@ -1632,5 +1695,5 @@
   TabWidget->setTabsClosable(true);
   connect(TabWidget, SIGNAL(tabCloseRequested(int)), SLOT(DetachTab(int)));
-  TabWidget->addTab(new TP_DAQ, "Event scope");
+  TabWidget->addTab(new TP_DAQ, "Event scope " + DRSBoard);
   TabWidget->addTab(new TP_Bias, "Bias");
   TabWidget->addTab(new TP_Feedback, "Feedback");
@@ -1650,4 +1713,9 @@
   resize(TabWidget->sizeHint()*1.1);
   show();
+
+  // Set timer to regularly check the master alarm
+  QTimer *Timer = new QTimer(this);
+  connect(Timer, SIGNAL(timeout()), this, SLOT(CheckAlarm()));
+  Timer->start(5000);
 }  
     
@@ -1724,6 +1792,55 @@
 }
 
+// Check alarm level and if Alarm server is alive
+void GUI::CheckAlarm() {
+
+  static int WarnedLevel = 0;
+  static bool AlarmServerWarned = false;
+
+  // === Check service Alarm/MasterAlarm ===
+  DimCurrentInfo MasterAlarm("Alarm/MasterAlarm", -1);
+
+  if (MasterAlarm.getInt() > WarnedLevel) {
+	QSound::play(QApplication::applicationDirPath() + "/Error.wav");
+
+    // Construct warning message box
+	QMessageBox Box;
+	Box.setWindowTitle("Edd Alarm");
+	Box.setText("Service 'Alarm/MasterAlarm' is at " + QString::number(MasterAlarm.getInt()));
+	Box.setInformativeText("Shall the warning level be reset?");
+	Box.setIcon(QMessageBox::Warning);
+	Box.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
+	Box.setDefaultButton(QMessageBox::No);
+
+	// Check if user wants to reset warned level
+	if (Box.exec() == QMessageBox::Yes) WarnedLevel = 0;
+	else WarnedLevel = MasterAlarm.getInt();
+  }
+
+  // If MasterAlam decreased, lower also warned level
+  if (MasterAlarm.getInt() < WarnedLevel && MasterAlarm.getInt() >=0 ) WarnedLevel = MasterAlarm.getInt();
+  
+  // === Check Alarm server ===
+  DimCurrentInfo ServerList("DIS_DNS/SERVER_LIST", NO_LINK);
+  std::string Result = EvidenceServer::ToString((char *) "C", ServerList.getData(), ServerList.getSize());
+  
+  // Warn if SERVER_LIST does not contain alarm server
+  if (Result.find("Alarm@") == std::string::npos && !AlarmServerWarned) {
+	QMessageBox Box;
+	Box.setWindowTitle("Edd Alarm");
+	Box.setText("Alarm server is unavailable or in error");
+	Box.setIcon(QMessageBox::Critical);
+	Box.setStandardButtons(QMessageBox::Ok);
+	Box.setDefaultButton(QMessageBox::Ok);
+
+	AlarmServerWarned = true;
+  }
+  
+  if (Result.find("Alarm@") != std::string::npos) AlarmServerWarned = false; 
+}
+
 // Quit application when clicking close button on window
 void GUI::closeEvent(QCloseEvent *) {
+
   qApp->quit();
 }
@@ -1733,4 +1850,6 @@
 int main(int argc, char *argv[]) {
 
+  if (argc > 1) DRSBoard = "FADctrl";
+
   QApplication app(argc, argv); 
   GUI MainWindow;
Index: /fact/Evidence/Edd/Edd.h
===================================================================
--- /fact/Evidence/Edd/Edd.h	(revision 10078)
+++ /fact/Evidence/Edd/Edd.h	(revision 10079)
@@ -52,5 +52,7 @@
 	  QVector<double> y;
       double Smallest;
-      double Largest;	  
+      double Largest;
+	  double Mean;
+	  double Sigma;
     };
     QList<struct PlotItem> Items;
@@ -59,5 +61,6 @@
     QAction *NormAction;
     QAction *StyleAction;
-    
+    QAction *StatisticsAction;
+
     QwtPlotPanner *Panner;
     QwtPlotGrid *Grid;
@@ -66,4 +69,5 @@
     QwtPicker *Picker;
 	QwtDoubleRect BBox;
+	QwtPlotMarker *Stats;
 	 	
   public:
@@ -80,4 +84,5 @@
 
   private slots:
+	void ReDoStats();
     void HandleZoom(const QwtDoubleRect &);
 	void MouseSelection(const QwtPolygon &);
@@ -385,4 +390,5 @@
     void MenuNewHistory();
 	void DetachTab(int);
+	void CheckAlarm();
 };
 
