GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
TGo4AnalysisStatusMonitor.cpp
Go to the documentation of this file.
1// $Id$
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
22TGo4AnalysisStatusMonitor::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 LCDCurrentRate->setDigitCount(8);
30 LCDAverageRate->setDigitCount(8);
31 LCDTime->setDigitCount(8);
32 LCDProcessedEvents->setDigitCount(9);
33}
34
39
41{
42 AddLink(slot, "Ratemeter");
43}
44
45void TGo4AnalysisStatusMonitor::linkedObjectUpdated(const char *linkname, TObject *obj)
46{
47 TGo4AnalysisClientStatus* status = dynamic_cast<TGo4AnalysisClientStatus*> (obj);
48 TGo4Ratemeter* rate = dynamic_cast<TGo4Ratemeter*> (obj);
49
50 // JAM2016
51 QStatusBar* guistatusbar = dynamic_cast<QStatusBar*>(parentWidget());
52 if(guistatusbar){
53 guistatusbar->clearMessage(); // JAM2016: always wipe out old gui messages when updating ratemeter
54 }
55
56 if (!status && !rate) {
57 // this is indication of lost connection to the server
58 if (obj) LCDCurrentRate->setStyleSheet("QFrame { background-color:rgb(127,127,127) }");
59 return;
60 }
61
62 double Rate = status ? status->GetRate() : rate->GetRate();
63 if (Rate>10) LCDCurrentRate->display(floor(Rate));
64 else LCDCurrentRate->display(Rate);
65
66 double AvRate = status ? status->GetAvRate() : rate->GetAvRate();
67 if(AvRate>10) LCDAverageRate->display(floor(AvRate));
68 else LCDAverageRate->display(AvRate);
69
70 int stime = status ? (int) status->GetTime() : (int) rate->GetTime();
71 LCDTime->display(stime);
72 ulong hh = stime/3600;
73 ulong mm = (stime-hh*3600)/60;
74 ulong ss = (stime-hh*3600-mm*60);
75 QString tooltip = QString("Time since last reset [sec] = %1:%2:%3 [hours:min:sec]").arg(hh).arg(mm).arg(ss);
76 LCDTime->setToolTip(tooltip);
77
78 QString scnt = QString("%1").arg(status ? status->GetCurrentCount() : rate->GetCurrentCount());
79
80 if (scnt.length() > LCDProcessedEvents->digitCount())
81 LCDProcessedEvents->setDigitCount(scnt.length());
82
83 LCDProcessedEvents->display(scnt);
84
85 const char *color = "QFrame { background-color:rgb(255,0,0) }";
86
87 Bool_t running = status ? status->IsAnalysisRunning() : rate->IsRunning();
88
89 if(!running) {
90 Go4Pix->setWindowIcon( QIcon(":/icons/go4logo2.png"));
91 fxRunMovie->stop();
92 } else {
93 color = "QFrame { background-color:rgb(0,255,0) }";
94 Go4Pix->clear();
95 Go4Pix->setMovie(fxRunMovie);
96 fxRunMovie->start();
97 }
98
99 LCDCurrentRate->setStyleSheet(color);
100
101 SourceLabel->setText(status ? status->GetCurrentSource() : rate->GetCurrentSource());
102 DateLabel->setText(status ? status->GetDateTime() : rate->GetDateTime());
103}
104
106{
107 // in any case deletion of this slot means closing of widget
108
109 // if (Browser()) Browser()->ToggleMonitoring(0);
110
112}
void ShootCloseWidget(bool closeparent=false)
QGo4Widget(QWidget *parent=nullptr, const char *name=nullptr, Qt::WindowFlags f=Qt::Widget)
void AddLink(const char *itemname, const char *linkname)
create link for item with name linkname
const char * GetCurrentSource() const
void linkedObjectUpdated(const char *linkname, TObject *obj) override
virtual void WorkWithRatemeter(TGo4Slot *slot)
TGo4AnalysisStatusMonitor(QWidget *parent=nullptr, const char *name=nullptr)
void linkedObjectRemoved(const char *linkname) override
Class containing event counter and ratemeter services.
Double_t GetRate() const
ULong64_t GetCurrentCount() const
const char * GetDateTime() const
Bool_t IsRunning() const
Double_t GetTime() const
const char * GetCurrentSource() const
Double_t GetAvRate() const