00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef TGO4DABCMONITOR_H
00015 #define TGO4DABCMONITOR_H
00016
00017 #include <qvariant.h>
00018
00019 #include "QGo4Widget.h"
00020 #include "ui_TGo4DabcMonitor.h"
00021
00022 #include <vector>
00023 #include <deque>
00024 #include "dic.hxx"
00025 #include <QTableWidget>
00026
00027 class TGo4DabcMonitor;
00028 class TGo4DabcInfo;
00029 class TGo4DabcNodesInfo;
00030 class TGo4DabcServiceInfo;
00031 class TGo4DabcStateInfo;
00032 class TGo4DabcRateInfo;
00033 class TGo4DabcState;
00034 class TGo4DabcRate;
00035 class TH1;
00036 class QTimer;
00037
00038 #define DABCMON_NODE_NODECOL 0
00039 #define DABCMON_NODE_STATECOL 1
00040 #define DABCMON_NODE_CHECKCOL 3
00041 #define DABCMON_NODE_LOGCOL 4
00042 #define DABCMON_NODE_INDEXCOL 2
00043
00044 #define DABCMON_RATE_NAMECOL 0
00045 #define DABCMON_RATE_RATECOL 1
00046 #define DABCMON_RATE_TRENDCOL 3
00047 #define DABCMON_RATE_STATSCOL 4
00048 #define DABCMON_RATE_INDEXCOL 2
00049
00050
00051 namespace dabc {
00052
00053 typedef struct{
00054 int severity;
00055 char color[16];
00056 char status[16];
00057 } StatusRec;
00058
00059
00060
00061 typedef struct{
00062 float value;
00063 int displaymode;
00064 float lower;
00065 float upper;
00066 float alarmlower;
00067 float alarmupper;
00068 char color[16];
00069 char alarmcolor[16];
00070 char units[16];
00071 } RateRec;
00072
00073
00074
00075
00076 enum RateDisplayMode {
00077 DISPLAY_ARC = 0,
00078 DISPLAY_BAR = 1,
00079 DISPLAY_TREND = 2,
00080 DISPLAY_STAT = 3 };
00081 }
00082
00083 static dabc::RateRec gNolinkRateRecord;
00084 static dabc::StatusRec gNolinkStateRecord;
00085
00089 class TGo4DabcInfo : public DimStampedInfo {
00090 public:
00091 TGo4DabcInfo(const char* name, int time, char* nolink, TGo4DabcMonitor* owner)
00092 : fxOwner(owner), fxType("char"),DimStampedInfo (name, time, nolink) {;}
00093 TGo4DabcInfo(const char* name, int time, void* nolink, int size, const char* type, TGo4DabcMonitor* owner)
00094 : fxOwner(owner), fxType(type),DimStampedInfo (name, time, nolink, size) {;}
00095 TGo4DabcInfo(const char* name, int time, int nolink, TGo4DabcMonitor* owner)
00096 : fxOwner(owner), fxType("int"),DimStampedInfo (name, time, nolink) {;}
00097 TGo4DabcInfo(const char* name, int time, float nolink, TGo4DabcMonitor* owner)
00098 : fxOwner(owner), fxType("float"),DimStampedInfo (name, time, nolink) {;}
00099 TGo4DabcInfo(const char* name, int time, double nolink, TGo4DabcMonitor* owner)
00100 : fxOwner(owner), fxType("double"),DimStampedInfo (name, time, nolink) {;}
00101
00102 virtual ~TGo4DabcInfo(){;}
00103
00104 virtual void infoHandler();
00105
00106 const QString& getServiceType(){return fxType;}
00107 protected:
00108 TGo4DabcMonitor* fxOwner;
00109 QString fxType;
00110
00111 };
00112
00113 class TGo4DabcNodesInfo : public TGo4DabcInfo{
00114 public:
00115 TGo4DabcNodesInfo(const char* name, int time, char* nolink, TGo4DabcMonitor* owner):TGo4DabcInfo(name,time,nolink,owner){;}
00116 virtual ~TGo4DabcNodesInfo(){;}
00117
00118 virtual void infoHandler();
00119
00120 };
00121
00122 class TGo4DabcServiceInfo : public TGo4DabcInfo{
00123 public:
00124 TGo4DabcServiceInfo(const char* name, int time, char* nolink, TGo4DabcMonitor* owner):TGo4DabcInfo(name,time,nolink,owner){;}
00125 virtual ~TGo4DabcServiceInfo(){;}
00126 virtual void infoHandler();
00127
00128 };
00129
00130 class TGo4DabcStateInfo : public TGo4DabcInfo{
00131 public:
00132 TGo4DabcStateInfo(const char* name, int time, void* nolink, int size, TGo4DabcMonitor* owner):TGo4DabcInfo(name, time, nolink, size, "StateInfo", owner){;}
00133 virtual ~TGo4DabcStateInfo(){;}
00134
00135 virtual void infoHandler();
00136
00137 };
00138
00139 class TGo4DabcRateInfo : public TGo4DabcInfo{
00140 public:
00141 TGo4DabcRateInfo(const char* name, int time, void* nolink, int size, TGo4DabcMonitor* owner):TGo4DabcInfo(name, time, nolink, size, "RateInfo" , owner){;}
00142 virtual ~TGo4DabcRateInfo(){;}
00143 virtual void infoHandler();
00144
00145 };
00146
00150 class TGo4DabcState{
00151 public:
00152 TGo4DabcState():fxSeverity(-1),fxState("not defined"), fxColor("Black"){;}
00153 TGo4DabcState(dabc::StatusRec* rec)
00154 {
00155 if(rec==0) return;
00156 fxSeverity=rec->severity;
00157 fxState=rec->status;
00158 fxState.truncate(16);
00159 fxColor=rec->color;
00160 fxColor.truncate(16);
00161 }
00162 int fxSeverity;
00163 QString fxState;
00164 QString fxColor;
00165 };
00166
00167 class TGo4DabcRate{
00168
00169 public:
00170 TGo4DabcRate():fxRate(-1),fxName("not defined"), fxColor("Black"){;}
00171 TGo4DabcRate(dabc::RateRec* rec, const QString& name)
00172 {
00173 if(rec==0) return;
00174 fxRate=rec-> value;
00175 fxDisplaymode=rec->displaymode;
00176 fxLower=rec->lower;
00177 fxUpper=rec->upper;
00178 fxAlarmlower=rec->alarmlower;
00179 fxAlarmupper=rec->alarmupper;
00180 fxColor=rec->color;
00181 fxColor.truncate(16);
00182 fxAlarmcolor=rec->alarmcolor;
00183 fxAlarmcolor.truncate(16);
00184 fxUnits=rec->units;
00185 fxUnits.truncate(16);
00186 fxName=name;
00187 }
00188 float fxRate;
00189 int fxDisplaymode;
00190 float fxLower;
00191 float fxUpper;
00192 float fxAlarmlower;
00193 float fxAlarmupper;
00194 QString fxColor;
00195 QString fxAlarmcolor;
00196 QString fxUnits;
00197 QString fxName;
00198 };
00199
00200
00201
00202
00203
00204 class TGo4DabcMonitor : public QGo4Widget , public Ui::TGo4DabcMonitor
00205 {
00206 Q_OBJECT
00207
00208 public:
00209 TGo4DabcMonitor( QWidget* parent = 0, const char* name = 0 );
00210 virtual ~TGo4DabcMonitor();
00211
00212
00213
00214 virtual void infoUpdated( TGo4DabcInfo * info );
00215 virtual void nodesUpdated( TGo4DabcNodesInfo * info );
00216 virtual void servicesUpdated( TGo4DabcServiceInfo * info );
00217 virtual void stateUpdated( TGo4DabcStateInfo * info );
00218 virtual void rateUpdated( TGo4DabcRateInfo * info );
00219
00220 public slots:
00221 virtual void storeSettings();
00222 virtual void refreshDIMSlot();
00223 virtual void logDIMSlot();
00224 virtual void histogramCheckToggled( bool val );
00225 virtual void averageCheckToggled( bool val );
00226 virtual void binsizeChanged( int val );
00227 virtual void nodeTableChangedSlot( int row, int column );
00228 virtual void rateTableChangedSlot( int row, int column );
00229 virtual void createLogServices( int nodeindex );
00230 virtual void displaySampleHistograms();
00231 virtual void displayAverageHistograms();
00232 virtual void displayAll();
00233 virtual void updateTrending( int nodeix, int rateix, int hisix, double value );
00234 virtual void IncTrending( TH1 * histo, double value, bool forwards );
00235 virtual void updateStats( int nodeix, int rateix, int hix, double value );
00236
00237 protected:
00238
00239 bool fbHistogramming;
00240 bool fbDisplayRateTable;
00241 bool fbDisplayNodeTable;
00242 bool fbDisplayHistograms;
00243 bool fbRebuildNodeTable;
00244 bool fbRebuildRateTable;
00245 bool fbTrendingForward;
00246
00247 bool fbTableBeingCreated;
00248
00249
00250
00251 unsigned int fxLastTimestamp;
00252 QStringList fxNodelist;
00253 QString fxDnsNode;
00254 TGo4DabcNodesInfo* fxServerInfo;
00255
00256 std::vector< std::vector <unsigned int> > fxRateCount;
00257 std::vector< std::vector <float> > fxRateSum;
00258
00259 int fiStatBins;
00260 std::vector < std::vector <std::vector <bool> > > fbStatsInit;
00261 std::vector< std::vector <bool> > fxStatsFlags;
00262 int fiTrendBins;
00263 std::vector< std::vector <std::vector <bool> > > fbTrendingInit;
00264 std::vector<std::vector<bool> > fxTrendingFlags;
00265
00266
00267 std::vector<std::vector<TGo4DabcRate> > fxRateRecords;
00268 std::vector<std::vector<TGo4DabcRateInfo*> > fxRates;
00269 std::vector<TGo4DabcStateInfo*> fxStates;
00270 std::vector<TGo4DabcServiceInfo*> fxServices;
00271 std::vector<TGo4DabcState> fxStateRecords;
00272 std::vector<QString> fxDabcNodes;
00273 std::vector<bool> fxShowRateFlags;
00274 std::vector<bool> fxShowLogFlags;
00275
00276 std::vector < std::vector <std::vector < QString> > > fxTrendHistoRefnames;
00277 std::vector < std::vector <std::vector<QString > > > fxStatHistoRefnames;
00278 std::vector < std::vector < std::deque <float> > > fxRateQueues;
00279
00280
00281 QTimer* fxDisplayTimer;
00282 QTimer* fxAverageTimer;
00283
00284 virtual void refreshNodes();
00285 virtual void clearStates();
00286 virtual void clearServices();
00287 virtual void clearRates();
00288 virtual void createRateServices( int nodeindex );
00289 virtual void deleteRateServices( int nodeindex );
00290 virtual void displayNodeTable();
00291 virtual void fillNodeTableRow( int tableindex, int nodeindex, bool createnew );
00292 virtual void displayRateTable();
00293 virtual void fillRateTableRow( int tableindex, int nodeindex, int rateindex, bool createnew );
00294 virtual bool getRateIndices( int tablerow, int & nodeix, int & rateix );
00295
00296
00297
00298 };
00299
00300 #endif // TGO4DABCMONITOR_H