GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4DabcMonitor.h
Go to the documentation of this file.
1 // $Id: TGo4DabcMonitor.h 1134 2014-01-22 14:53:40Z 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 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 
14 #ifndef TGO4DABCMONITOR_H
15 #define TGO4DABCMONITOR_H
16 
17 #include <qvariant.h>
18 
19 #include "QGo4Widget.h"
20 #include "ui_TGo4DabcMonitor.h"
21 
22 #include <vector>
23 #include <deque>
24 #include "dic.hxx"
25 #include <QTableWidget>
26 
27 class TGo4DabcMonitor;
28 class TGo4DabcInfo;
29 class TGo4DabcNodesInfo;
31 class TGo4DabcStateInfo;
32 class TGo4DabcRateInfo;
33 class TGo4DabcState;
34 class TGo4DabcRate;
35 class TH1;
36 class QTimer;
37 
38 #define DABCMON_NODE_NODECOL 0
39 #define DABCMON_NODE_STATECOL 1
40 #define DABCMON_NODE_CHECKCOL 3
41 #define DABCMON_NODE_LOGCOL 4
42 #define DABCMON_NODE_INDEXCOL 2
43 
44 #define DABCMON_RATE_NAMECOL 0
45 #define DABCMON_RATE_RATECOL 1
46 #define DABCMON_RATE_TRENDCOL 3
47 #define DABCMON_RATE_STATSCOL 4
48 #define DABCMON_RATE_INDEXCOL 2
49 
50 
51 namespace dabc {
52 
53 typedef struct{
54  int severity; // (0=success, 1=warning, 2=error, 3=fatal)
55  char color[16]; // (color name: Red, Green, Blue, Cyan, Yellow, Magenta)
56  char status[16]; // status name
57  } StatusRec;
58 
59 
60 
61  typedef struct{
62  float value;
63  int displaymode; // one of the DISPLAY_x
64  float lower; // limit. If limits are equal, use autoscale
65  float upper; // limit
66  float alarmlower; // alarm
67  float alarmupper; // alarm
68  char color[16]; // (color name: Red, Green, Blue, Cyan, Yellow, Magenta)
69  char alarmcolor[16]; // (color name: Red, Green, Blue, Cyan, Yellow, Magenta)
70  char units[16];
71  } RateRec;
72 
73 
74 
75 
80  DISPLAY_STAT = 3 };
81 } // end namespace dabc
82 
85 
89 class TGo4DabcInfo : public DimStampedInfo {
90  public:
91  TGo4DabcInfo(const char* name, int time, char* nolink, TGo4DabcMonitor* owner)
92  : fxOwner(owner), fxType("char"),DimStampedInfo (name, time, nolink) {;}
93  TGo4DabcInfo(const char* name, int time, void* nolink, int size, const char* type, TGo4DabcMonitor* owner)
94  : fxOwner(owner), fxType(type),DimStampedInfo (name, time, nolink, size) {;}
95  TGo4DabcInfo(const char* name, int time, int nolink, TGo4DabcMonitor* owner)
96  : fxOwner(owner), fxType("int"),DimStampedInfo (name, time, nolink) {;}
97  TGo4DabcInfo(const char* name, int time, float nolink, TGo4DabcMonitor* owner)
98  : fxOwner(owner), fxType("float"),DimStampedInfo (name, time, nolink) {;}
99  TGo4DabcInfo(const char* name, int time, double nolink, TGo4DabcMonitor* owner)
100  : fxOwner(owner), fxType("double"),DimStampedInfo (name, time, nolink) {;}
101 
102  virtual ~TGo4DabcInfo(){;}
103 
104  virtual void infoHandler();
105 
106  const QString& getServiceType(){return fxType;}
107  protected:
109  QString fxType;
110 
111 };
112 
114  public:
115  TGo4DabcNodesInfo(const char* name, int time, char* nolink, TGo4DabcMonitor* owner):TGo4DabcInfo(name,time,nolink,owner){;}
116  virtual ~TGo4DabcNodesInfo(){;}
117 
118  virtual void infoHandler();
119 
120 };
121 
123  public:
124  TGo4DabcServiceInfo(const char* name, int time, char* nolink, TGo4DabcMonitor* owner):TGo4DabcInfo(name,time,nolink,owner){;}
125  virtual ~TGo4DabcServiceInfo(){;}
126  virtual void infoHandler();
127 
128 };
129 
131  public:
132  TGo4DabcStateInfo(const char* name, int time, void* nolink, int size, TGo4DabcMonitor* owner):TGo4DabcInfo(name, time, nolink, size, "StateInfo", owner){;}
133  virtual ~TGo4DabcStateInfo(){;}
134 
135  virtual void infoHandler();
136 
137 };
138 
140  public:
141  TGo4DabcRateInfo(const char* name, int time, void* nolink, int size, TGo4DabcMonitor* owner):TGo4DabcInfo(name, time, nolink, size, "RateInfo" , owner){;}
142  virtual ~TGo4DabcRateInfo(){;}
143  virtual void infoHandler();
144 
145 };
146 
151 public:
152  TGo4DabcState():fxSeverity(-1),fxState("not defined"), fxColor("Black"){;}
154  {
155  if(rec==0) return;
156  fxSeverity=rec->severity;
157  fxState=rec->status;
158  fxState.truncate(16);
159  fxColor=rec->color;
160  fxColor.truncate(16);
161  }
163  QString fxState;
164  QString fxColor;
165 };
166 
168 
169 public:
170  TGo4DabcRate():fxRate(-1),fxName("not defined"), fxColor("Black"){;}
171  TGo4DabcRate(dabc::RateRec* rec, const QString& name)
172  {
173  if(rec==0) return;
174  fxRate=rec-> value;
176  fxLower=rec->lower;
177  fxUpper=rec->upper;
180  fxColor=rec->color;
181  fxColor.truncate(16);
183  fxAlarmcolor.truncate(16);
184  fxUnits=rec->units;
185  fxUnits.truncate(16);
186  fxName=name;
187  }
188  float fxRate;
189  int fxDisplaymode; // one of the DISPLAY_x
190  float fxLower; // limit. If limits are equal, use autoscale
191  float fxUpper; // limit
192  float fxAlarmlower; // alarm
193  float fxAlarmupper; // alarm
194  QString fxColor; // (color name: Red, Green, Blue, Cyan, Yellow, Magenta)
195  QString fxAlarmcolor; // (color name: Red, Green, Blue, Cyan, Yellow, Magenta)
196  QString fxUnits;
197  QString fxName;
198  };
199 
200 
201 
202 
203 
204 class TGo4DabcMonitor : public QGo4Widget , public Ui::TGo4DabcMonitor
205 {
206  Q_OBJECT
207 
208 public:
209  TGo4DabcMonitor( QWidget* parent = 0, const char* name = 0 );
210  virtual ~TGo4DabcMonitor();
211 
212 
213 
214  virtual void infoUpdated( TGo4DabcInfo * info );
215  virtual void nodesUpdated( TGo4DabcNodesInfo * info );
216  virtual void servicesUpdated( TGo4DabcServiceInfo * info );
217  virtual void stateUpdated( TGo4DabcStateInfo * info );
218  virtual void rateUpdated( TGo4DabcRateInfo * info );
219 
220 public slots:
221  virtual void storeSettings();
222  virtual void refreshDIMSlot();
223  virtual void logDIMSlot();
224  virtual void histogramCheckToggled( bool val );
225  virtual void averageCheckToggled( bool val );
226  virtual void binsizeChanged( int val );
227  virtual void nodeTableChangedSlot( int row, int column );
228  virtual void rateTableChangedSlot( int row, int column );
229  virtual void createLogServices( int nodeindex );
230  virtual void displaySampleHistograms();
231  virtual void displayAverageHistograms();
232  virtual void displayAll();
233  virtual void updateTrending( int nodeix, int rateix, int hisix, double value );
234  virtual void IncTrending( TH1 * histo, double value, bool forwards );
235  virtual void updateStats( int nodeix, int rateix, int hix, double value );
236 
237 protected:
238 
246 
248 
249 
250 
251  unsigned int fxLastTimestamp;
252  QStringList fxNodelist;
253  QString fxDnsNode;
255 
256  std::vector< std::vector <unsigned int> > fxRateCount;
257  std::vector< std::vector <float> > fxRateSum;
258  // flags and bins for statistics/trending histograms:
260  std::vector < std::vector <std::vector <bool> > > fbStatsInit;
261  std::vector< std::vector <bool> > fxStatsFlags;
263  std::vector< std::vector <std::vector <bool> > > fbTrendingInit;
264  std::vector<std::vector<bool> > fxTrendingFlags;
265 
266 
267  std::vector<std::vector<TGo4DabcRate> > fxRateRecords;
268  std::vector<std::vector<TGo4DabcRateInfo*> > fxRates;
269  std::vector<TGo4DabcStateInfo*> fxStates;
270  std::vector<TGo4DabcServiceInfo*> fxServices;
271  std::vector<TGo4DabcState> fxStateRecords;
272  std::vector<QString> fxDabcNodes;
273  std::vector<bool> fxShowRateFlags;
274  std::vector<bool> fxShowLogFlags;
275 
276  std::vector < std::vector <std::vector < QString> > > fxTrendHistoRefnames;
277  std::vector < std::vector <std::vector<QString > > > fxStatHistoRefnames;
278  std::vector < std::vector < std::deque <float> > > fxRateQueues;
279 
280 
281  QTimer* fxDisplayTimer;
282  QTimer* fxAverageTimer;
283 
284  virtual void refreshNodes();
285  virtual void clearStates();
286  virtual void clearServices();
287  virtual void clearRates();
288  virtual void createRateServices( int nodeindex );
289  virtual void deleteRateServices( int nodeindex );
290  virtual void displayNodeTable();
291  virtual void fillNodeTableRow( int tableindex, int nodeindex, bool createnew );
292  virtual void displayRateTable();
293  virtual void fillRateTableRow( int tableindex, int nodeindex, int rateindex, bool createnew );
294  virtual bool getRateIndices( int tablerow, int & nodeix, int & rateix );
295 
296 
297 
298 };
299 
300 #endif // TGO4DABCMONITOR_H
TGo4DabcInfo(const char *name, int time, double nolink, TGo4DabcMonitor *owner)
virtual ~TGo4DabcMonitor()
std::vector< TGo4DabcStateInfo * > fxStates
virtual void updateStats(int nodeix, int rateix, int hix, double value)
virtual void clearRates()
virtual void infoHandler()
std::vector< bool > fxShowLogFlags
static dabc::StatusRec gNolinkStateRecord
std::vector< std::vector< std::vector< bool > > > fbTrendingInit
virtual void refreshNodes()
std::vector< std::vector< float > > fxRateSum
std::vector< bool > fxShowRateFlags
virtual ~TGo4DabcNodesInfo()
virtual void histogramCheckToggled(bool val)
virtual void createRateServices(int nodeindex)
std::vector< std::vector< std::deque< float > > > fxRateQueues
TGo4DabcInfo(const char *name, int time, int nolink, TGo4DabcMonitor *owner)
QTimer * fxDisplayTimer
std::vector< TGo4DabcServiceInfo * > fxServices
virtual void rateTableChangedSlot(int row, int column)
virtual bool getRateIndices(int tablerow, int &nodeix, int &rateix)
TGo4DabcInfo(const char *name, int time, void *nolink, int size, const char *type, TGo4DabcMonitor *owner)
TGo4DabcStateInfo(const char *name, int time, void *nolink, int size, TGo4DabcMonitor *owner)
virtual void averageCheckToggled(bool val)
std::vector< std::vector< TGo4DabcRate > > fxRateRecords
virtual void fillNodeTableRow(int tableindex, int nodeindex, bool createnew)
std::vector< std::vector< unsigned int > > fxRateCount
std::vector< std::vector< std::vector< bool > > > fbStatsInit
QTimer * fxAverageTimer
virtual void displayRateTable()
virtual void deleteRateServices(int nodeindex)
virtual void rateUpdated(TGo4DabcRateInfo *info)
virtual void infoHandler()
virtual void displaySampleHistograms()
virtual ~TGo4DabcInfo()
virtual void displayAll()
const QString & getServiceType()
virtual void infoHandler()
virtual void createLogServices(int nodeindex)
virtual void IncTrending(TH1 *histo, double value, bool forwards)
virtual void refreshDIMSlot()
TGo4DabcState(dabc::StatusRec *rec)
std::vector< std::vector< bool > > fxStatsFlags
TGo4DabcMonitor * fxOwner
TGo4DabcNodesInfo(const char *name, int time, char *nolink, TGo4DabcMonitor *owner)
virtual void infoHandler()
std::vector< QString > fxDabcNodes
TGo4DabcRate(dabc::RateRec *rec, const QString &name)
virtual void displayNodeTable()
QStringList fxNodelist
unsigned int fxLastTimestamp
TGo4DabcInfo(const char *name, int time, float nolink, TGo4DabcMonitor *owner)
virtual ~TGo4DabcRateInfo()
TGo4DabcServiceInfo(const char *name, int time, char *nolink, TGo4DabcMonitor *owner)
virtual void stateUpdated(TGo4DabcStateInfo *info)
TGo4DabcMonitor(QWidget *parent=0, const char *name=0)
static dabc::RateRec gNolinkRateRecord
virtual void nodesUpdated(TGo4DabcNodesInfo *info)
TGo4DabcNodesInfo * fxServerInfo
virtual void clearServices()
std::vector< TGo4DabcState > fxStateRecords
virtual void displayAverageHistograms()
virtual void infoHandler()
std::vector< std::vector< std::vector< QString > > > fxStatHistoRefnames
std::vector< std::vector< bool > > fxTrendingFlags
virtual void servicesUpdated(TGo4DabcServiceInfo *info)
TGo4DabcRateInfo(const char *name, int time, void *nolink, int size, TGo4DabcMonitor *owner)
std::vector< std::vector< std::vector< QString > > > fxTrendHistoRefnames
virtual void infoUpdated(TGo4DabcInfo *info)
virtual ~TGo4DabcStateInfo()
virtual void binsizeChanged(int val)
virtual void clearStates()
TGo4DabcInfo(const char *name, int time, char *nolink, TGo4DabcMonitor *owner)
virtual ~TGo4DabcServiceInfo()
QString fxAlarmcolor
std::vector< std::vector< TGo4DabcRateInfo * > > fxRates
virtual void storeSettings()
virtual void logDIMSlot()
virtual void fillRateTableRow(int tableindex, int nodeindex, int rateindex, bool createnew)
char alarmcolor[16]
virtual void updateTrending(int nodeix, int rateix, int hisix, double value)
virtual void nodeTableChangedSlot(int row, int column)