GSI Object Oriented Online Offline (Go4)  GO4-6.1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4AnalysisStatusMonitor.cpp
Go to the documentation of this file.
1 // $Id: TGo4AnalysisStatusMonitor.cpp 3117 2021-03-30 07:12:07Z linev $
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 fuer 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 
16 #include <QStatusBar>
17 #include <QMovie>
18 
20 #include "TGo4Ratemeter.h"
21 
22 TGo4AnalysisStatusMonitor::TGo4AnalysisStatusMonitor(QWidget *parent, const char* name) :
23  QGo4Widget(parent, name)
24 {
25  setupUi(this);
26  setAcceptDrops(false);
27  fxRunMovie = new QMovie(":/icons/go4logorun4.gif");
28 
29 #if QT_VERSION >= QT_VERSION_CHECK(4,6,0)
30  LCDCurrentRate->setDigitCount(8);
31  LCDAverageRate->setDigitCount(8);
32  LCDTime->setDigitCount(8);
33  LCDProcessedEvents->setDigitCount(9);
34 #else
35  LCDCurrentRate->setNumDigits(8);
36  LCDAverageRate->setNumDigits(8);
37  LCDTime->setNumDigits(8);
38  LCDProcessedEvents->setNumDigits(9);
39 #endif
40 }
41 
43 {
44  delete fxRunMovie;
45 }
46 
48 {
49  AddLink(slot, "Ratemeter");
50 }
51 
52 void TGo4AnalysisStatusMonitor::linkedObjectUpdated( const char * linkname, TObject * obj )
53 {
54  TGo4AnalysisClientStatus* status = dynamic_cast<TGo4AnalysisClientStatus*> (obj);
55  TGo4Ratemeter* rate = dynamic_cast<TGo4Ratemeter*> (obj);
56 
57  // JAM2016
58  //std::cout <<"linkedObjectUpdated" <<std::endl;
59  QStatusBar* guistatusbar=dynamic_cast<QStatusBar*>(parentWidget());
60  if(guistatusbar){
61  guistatusbar->clearMessage(); // JAM2016: always wipe out old gui messages when updating ratemeter
62  }
63 
64  if ((status==0) && (rate==0)) {
65  // this is indication of lost connection to the server
66  if (obj) LCDCurrentRate->setStyleSheet("QFrame { background-color:rgb(127,127,127) }");
67  return;
68  }
69 
70  double Rate = status ? status->GetRate() : rate->GetRate();
71  if (Rate>10) LCDCurrentRate->display(floor(Rate));
72  else LCDCurrentRate->display(Rate);
73 
74  double AvRate = status ? status->GetAvRate() : rate->GetAvRate();
75  if(AvRate>10) LCDAverageRate->display(floor(AvRate));
76  else LCDAverageRate->display(AvRate);
77 
78  int stime = status ? (int) status->GetTime() : (int) rate->GetTime();
79  LCDTime->display(stime);
80  ulong hh = stime/3600;
81  ulong mm = (stime-hh*3600)/60;
82  ulong ss = (stime-hh*3600-mm*60);
83  QString tooltip = QString("Time since last reset [sec] = %1:%2:%3 [hours:min:sec]").arg(hh).arg(mm).arg(ss);
84  LCDTime->setToolTip(tooltip);
85 
86  QString scnt = QString("%1").arg(status ? status->GetCurrentCount() : rate->GetCurrentCount());
87 
88 #if QT_VERSION >= QT_VERSION_CHECK(4,6,0)
89  if (scnt.length() > LCDProcessedEvents->digitCount())
90  LCDProcessedEvents->setDigitCount(scnt.length());
91 #else
92  if (scnt.length() > LCDProcessedEvents->numDigits())
93  LCDProcessedEvents->setNumDigits(scnt.length());
94 #endif
95 
96  LCDProcessedEvents->display(scnt);
97 
98  const char* color = "QFrame { background-color:rgb(255,0,0) }";
99 
100  Bool_t running = status ? status->IsAnalysisRunning() : rate->IsRunning();
101 
102  if(!running) {
103  Go4Pix->setWindowIcon( QIcon(":/icons/go4logo2.png"));
104  fxRunMovie->stop();
105  } else {
106  color = "QFrame { background-color:rgb(0,255,0) }";
107  Go4Pix->clear();
108  Go4Pix->setMovie(fxRunMovie);
109  fxRunMovie->start();
110  }
111 
112  LCDCurrentRate->setStyleSheet(color);
113 
114  SourceLabel->setText(status ? status->GetCurrentSource() : rate->GetCurrentSource());
115  DateLabel->setText(status ? status->GetDateTime() : rate->GetDateTime());
116 }
117 
119 {
120  // in any case deletion of this slot means closing of widget
121 
122  // if (Browser()) Browser()->ToggleMonitoring(0);
123 
125 }
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:70
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:122
virtual void WorkWithRatemeter(TGo4Slot *slot)
const char * GetCurrentSource() const