GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4AnalysisStatusMonitor.cpp
Go to the documentation of this file.
1 // $Id: TGo4AnalysisStatusMonitor.cpp 1944 2016-08-26 11:55:07Z adamczew $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
15 #include <math.h>
16 
17 #include <qstatusbar.h>
18 //#include <iostream>
19 
21 #include "TGo4Ratemeter.h"
22 #include "TGo4BrowserProxy.h"
23 #include "TSystem.h"
24 
25 
26 TGo4AnalysisStatusMonitor::TGo4AnalysisStatusMonitor(QWidget *parent, const char* name) :
27  QGo4Widget(parent, name)
28 {
29  setupUi(this);
30  setAcceptDrops(false);
31  fxRunMovie = new QMovie(":/icons/go4logorun4.gif");
32 
33 #if QT_VERSION >= QT_VERSION_CHECK(4,6,0)
34  LCDCurrentRate->setDigitCount(8);
35  LCDAverageRate->setDigitCount(8);
36  LCDTime->setDigitCount(8);
37  LCDProcessedEvents->setDigitCount(9);
38 #else
39  LCDCurrentRate->setNumDigits(8);
40  LCDAverageRate->setNumDigits(8);
41  LCDTime->setNumDigits(8);
42  LCDProcessedEvents->setNumDigits(9);
43 #endif
44 }
45 
47 {
48  delete fxRunMovie;
49 }
50 
52 {
53  AddLink(slot, "Ratemeter");
54 }
55 
56 void TGo4AnalysisStatusMonitor::linkedObjectUpdated( const char * linkname, TObject * obj )
57 {
58  TGo4AnalysisClientStatus* status = dynamic_cast<TGo4AnalysisClientStatus*> (obj);
59  TGo4Ratemeter* rate = dynamic_cast<TGo4Ratemeter*> (obj);
60 
61  // JAM2016
62  //std::cout <<"linkedObjectUpdated" <<std::endl;
63  QStatusBar* guistatusbar=dynamic_cast<QStatusBar*>(parentWidget());
64  if(guistatusbar){
65  guistatusbar->clearMessage(); // JAM2016: always wipe out old gui messages when updating ratemeter
66  }
67 
68  if ((status==0) && (rate==0)) {
69  // this is indication of lost connection to the server
70  if (obj) LCDCurrentRate->setStyleSheet("QFrame { background-color:rgb(127,127,127) }");
71  return;
72  }
73 
74  double Rate = status ? status->GetRate() : rate->GetRate();
75  if (Rate>10) LCDCurrentRate->display(floor(Rate));
76  else LCDCurrentRate->display(Rate);
77 
78  double AvRate = status ? status->GetAvRate() : rate->GetAvRate();
79  if(AvRate>10) LCDAverageRate->display(floor(AvRate));
80  else LCDAverageRate->display(AvRate);
81 
82  int stime = status ? (int) status->GetTime() : (int) rate->GetTime();
83  LCDTime->display(stime);
84  ulong hh = stime/3600;
85  ulong mm = (stime-hh*3600)/60;
86  ulong ss = (stime-hh*3600-mm*60);
87  QString tooltip = QString("Time since last reset [sec] = %1:%2:%3 [hours:min:sec]").arg(hh).arg(mm).arg(ss);
88  LCDTime->setToolTip(tooltip);
89 
90  QString scnt = QString("%1").arg(status ? status->GetCurrentCount() : rate->GetCurrentCount());
91 
92 #if QT_VERSION >= QT_VERSION_CHECK(4,6,0)
93  if (scnt.length() > LCDProcessedEvents->digitCount())
94  LCDProcessedEvents->setDigitCount(scnt.length());
95 #else
96  if (scnt.length() > LCDProcessedEvents->numDigits())
97  LCDProcessedEvents->setNumDigits(scnt.length());
98 #endif
99 
100  LCDProcessedEvents->display(scnt);
101 
102  const char* color = "QFrame { background-color:rgb(255,0,0) }";
103 
104  Bool_t running = status ? status->IsAnalysisRunning() : rate->IsRunning();
105 
106  if(!running) {
107  Go4Pix->setWindowIcon( QIcon(":/icons/go4logo2.png"));
108  fxRunMovie->stop();
109  } else {
110  color = "QFrame { background-color:rgb(0,255,0) }";
111  Go4Pix->clear();
112  Go4Pix->setMovie(fxRunMovie);
113  fxRunMovie->start();
114  }
115 
116  LCDCurrentRate->setStyleSheet(color);
117 
118  SourceLabel->setText(status ? status->GetCurrentSource() : rate->GetCurrentSource());
119  DateLabel->setText(status ? status->GetDateTime() : rate->GetDateTime());
120 }
121 
123 {
124  // in any case deletion of this slot means closing of widget
125 
126  // if (Browser()) Browser()->ToggleMonitoring(0);
127 
129 }
Double_t GetTime() const
Definition: TGo4Ratemeter.h:52
virtual void linkedObjectUpdated(const char *linkname, TObject *obj)
const char * GetCurrentSource() const
Definition: TGo4Ratemeter.h:60
void ShootCloseWidget(bool closeparent=false)
Definition: QGo4Widget.cpp:69
Bool_t IsRunning() const
Definition: TGo4Ratemeter.h:48
const char * GetDateTime() const
Definition: TGo4Ratemeter.h:58
Double_t GetAvRate() const
Definition: TGo4Ratemeter.h:56
virtual void linkedObjectRemoved(const char *linkname)
Double_t GetRate() const
Definition: TGo4Ratemeter.h:50
TGo4AnalysisStatusMonitor(QWidget *parent=0, const char *name=0)
const char * GetDateTime() const
ULong64_t GetCurrentCount() const
Definition: TGo4Ratemeter.h:54
void AddLink(const char *itemname, const char *linkname)
Definition: QGo4Widget.cpp:121
virtual void WorkWithRatemeter(TGo4Slot *slot)
const char * GetCurrentSource() const