source: fact/Evidence/Edd/Edd.h@ 10079

Last change on this file since 10079 was 10079, checked in by ogrimm, 12 years ago
Alarm window opens if Alarm/MasterAlarm increases
  • Property svn:keywords set to Revision
File size: 7.6 KB
Line 
1#ifndef EDD_H_SEEN
2#define EDD_H_SEEN
3
4#include <QtGui>
5
6#include <qwt_plot.h>
7#include <qwt_plot_curve.h>
8#include <qwt_plot_grid.h>
9#include <qwt_plot_zoomer.h>
10#include <qwt_plot_magnifier.h>
11#include <qwt_plot_panner.h>
12#include <qwt_scale_engine.h>
13#include <qwt_analog_clock.h>
14#include <qwt_scale_widget.h>
15#include <qwt_plot_layout.h>
16#include <qwt_legend.h>
17#include <qwt_legend_item.h>
18#include <qwt_symbol.h>
19#include <qwt_plot_marker.h>
20#include <qwt_data.h>
21#include <qwt_color_map.h>
22
23#include <limits.h>
24#include <float.h>
25
26#include "dic.hxx"
27#include "Evidence.h"
28#include "RawDataCTX.h"
29#include "PixelMap.h"
30
31#define SVN_REVISION "$Revision: 10079 $"
32
33const QColor EddPlotBackgroundColor(Qt::yellow);
34
35QWidget *OpenHistory(char *, int);
36bool SetStatus(QWidget *, QString, int, QString, int = -1);
37
38
39// Base class for Edd plot
40// DeleteCurve() is pure virtual and needs to be implemented iin the application class
41class EddBasePlot: public QwtPlot {
42 Q_OBJECT
43
44 protected:
45 QMenu *Menu;
46 QAction *StripAction;
47
48 private:
49 struct PlotItem {
50 QwtPlotCurve *Signal;
51 QVector<double> x;
52 QVector<double> y;
53 double Smallest;
54 double Largest;
55 double Mean;
56 double Sigma;
57 };
58 QList<struct PlotItem> Items;
59
60 QAction *YLogAction;
61 QAction *NormAction;
62 QAction *StyleAction;
63 QAction *StatisticsAction;
64
65 QwtPlotPanner *Panner;
66 QwtPlotGrid *Grid;
67 QwtPlotZoomer *Zoomer;
68 QwtPlotMagnifier *Magnifier;
69 QwtPicker *Picker;
70 QwtDoubleRect BBox;
71 QwtPlotMarker *Stats;
72
73 public:
74 EddBasePlot(QWidget * = NULL);
75 ~EddBasePlot();
76
77 QwtPlotCurve *NewCurve(QwtText);
78 void ClearCurve(unsigned int);
79 void AddPoint(unsigned int, double, double);
80 virtual void DeleteCurve(QwtPlotCurve *) = 0;
81
82 protected slots:
83 void UpdatePlot();
84
85 private slots:
86 void ReDoStats();
87 void HandleZoom(const QwtDoubleRect &);
88 void MouseSelection(const QwtPolygon &);
89 void contextMenuEvent(QContextMenuEvent *);
90 void MenuSingleTrace();
91 void MenuZoomOut();
92 void MenuSaveASCII();
93 void MenuSave();
94 void MenuPrint();
95 void MenuPlotHelp();
96};
97
98// General indicator for DIM service
99class EddLineDisplay: public QLineEdit {
100 Q_OBJECT
101
102 QMenu *Menu;
103 QPoint dragStart;
104 QWidget *LastHist;
105
106 QString ServiceName;
107 int Index;
108
109 void mousePressEvent(QMouseEvent *);
110 void mouseReleaseEvent(QMouseEvent *);
111 void mouseMoveEvent(QMouseEvent *);
112
113 public:
114 EddLineDisplay(QString, int=0, QWidget * = NULL);
115 ~EddLineDisplay();
116
117 bool ShowAsTime;
118
119 private slots:
120 void Update(QString, int, QByteArray, QString, QString);
121 void contextMenuEvent(QContextMenuEvent *);
122 void MenuOpenHistory();
123 void MenuCopyService();
124 void MenuCopyData();
125};
126
127// Sending command to DIM server
128class EddCommand: public QLineEdit {
129 Q_OBJECT
130
131 QString Name;
132
133 public:
134 EddCommand(QString, QWidget * = NULL);
135
136 private slots:
137 void SendCommand();
138};
139
140// Graph class for history display
141class EddPlot: public EddBasePlot {
142 Q_OBJECT
143
144 // Time scale for axis
145 class EddTimeScale: public QwtScaleDraw {
146
147 public:
148 EddTimeScale() {}
149
150 virtual QwtText label(double v) const {
151 // Adapt text format to time span
152 QString Format;
153 if (scaleDiv().range() < 60*60) Format = "hh' h\n'mm:ss";
154 else if (scaleDiv().range() < 24*60*60) Format = "hh:mm";
155 else if (scaleDiv().range() < 30*24*60*60) Format = "h' h\n'd-MMM";
156 else Format = "d-MMM'\n'yyyy";
157
158 // Generate text
159 QwtText Text = QDateTime::fromTime_t((int) v).toString(Format);
160 QFont Font = Text.font();
161 Font.setPointSize(7);
162 Text.setFont(Font);
163
164 return Text;
165 }
166 };
167
168 struct ItemDetails {
169 QString Name;
170 int Index;
171 QwtPlotCurve *Signal;
172 };
173 QList<struct ItemDetails> List;
174
175 private:
176 QwtLegend *Legend;
177 int SizeLimit;
178
179 void dragEnterEvent(QDragEnterEvent *);
180 void dropEvent(QDropEvent *);
181 void paintEvent(QPaintEvent *);
182
183 public:
184 EddPlot(QString = QString(), int = 0, QWidget * = NULL);
185 ~EddPlot();
186 void AddService(QString, int = 0);
187 void DeleteCurve(QwtPlotCurve *);
188
189 private slots:
190 void Update(QString, int, QByteArray, QString, QString);
191 void LegendClicked(QwtPlotItem *);
192 void MenuPasteService();
193};
194
195
196// Text history and output class
197class EddText: public QTextEdit {
198 Q_OBJECT
199
200 private:
201 QString Name;
202 bool Pure;
203
204 public:
205 EddText(QString, bool = false, QWidget * = NULL);
206 ~EddText();
207
208 bool Accumulate;
209
210 private slots:
211 void Update(QString, int, QByteArray, QString, QString);
212};
213
214
215// Interface to DIM system
216class EddDim: public QObject, public DimInfo {
217 Q_OBJECT
218
219 private:
220 struct Item {
221 DimStampedInfo *DIMService;
222 int Count;
223 int TimeStamp;
224 QByteArray ByteArray;
225 QString Format;
226 QString Text;
227 };
228 QMap<QString, struct Item> ServiceList;
229 QMutex *Mutex;
230
231 struct HistItem {
232 int Count;
233 int LastUpdate;
234 class EvidenceHistory *HistClass;
235 };
236 QMap<QString, struct HistItem> HistoryList;
237
238 long long Volume;
239
240 void infoHandler();
241
242 private slots:
243 void Update(QString, int, QByteArray, QString, QString);
244 void UpdateStatistics();
245
246 public:
247 EddDim();
248 ~EddDim();
249
250 void Subscribe(QString);
251 void Unsubscribe (QString);
252 class EvidenceHistory *GetHistory(QString);
253 void DropHistory(QString);
254
255 signals:
256 void YEP(QString, int, QByteArray = QByteArray(), QString = QString(), QString = QString());
257 void INT(QString, int, QByteArray = QByteArray(), QString = QString(), QString = QString());
258};
259
260//
261//
262// ====== FACT specific part ======
263//
264//
265
266// Event oscilloscope
267class EventScope: public EddBasePlot, public PixelMap {
268 Q_OBJECT
269
270 private:
271 struct ItemDetails {
272 unsigned int Board, Chip, Channel;
273 QwtPlotCurve *Signal;
274 QwtPlotMarker *Trigger;
275 };
276 QList<struct ItemDetails> List;
277
278 QString Name;
279 RawDataCTX *RD;
280 CTX_ErrCode ErrCode;
281 QAction *PhysPipeAction;
282 FILE *Tmpfile;
283 bool Active;
284
285 public:
286 EventScope(QWidget * = NULL);
287 ~EventScope();
288
289 void UpdateFirst(int, int, int);
290 void AddTrace(int, int, int);
291 void SetActive(bool);
292
293 private slots:
294 void Update(QString, int, QByteArray, QString, QString);
295 void PlotTraces();
296 void DeleteCurve(QwtPlotCurve *);
297
298 signals:
299 void RunHeaderChanged(QString);
300 void EventHeaderChanged(QString);
301 void PixelData(QVector<double>);
302};
303
304
305// Tab page classes
306class TP_Environment: public QWidget {
307 Q_OBJECT
308
309 public:
310 TP_Environment();
311};
312
313class TP_Bias: public QWidget {
314 Q_OBJECT
315
316 private slots:
317 void BiasCurrents();
318
319 public:
320 TP_Bias();
321};
322
323class TP_Feedback: public QWidget {
324 Q_OBJECT
325
326 private slots:
327 void FeedbackDetails();
328
329 public:
330 TP_Feedback();
331};
332
333class TP_DAQ: public QWidget {
334 Q_OBJECT
335 static const int MAXPIXEL = 1440;
336
337 private:
338 EventScope *Scope;
339 QPlainTextEdit *RunHeaderDisplay, *EventHeaderDisplay;
340
341 QSpinBox *Channel, *Chip, *Board;
342 QLineEdit *PixelID;
343 QFormLayout *FormLayout;
344 QWidget *Display;
345 QPushButton **Pixel;
346 QPushButton *StartStopButton;
347
348 private slots:
349 void TranslatePixelID();
350 void UpdateScope(int);
351 void KeepCurrent();
352 void StartStop(bool);
353 void ShowPixelDisplay();
354 void SetPixelData(QVector<double>);
355
356 public:
357 TP_DAQ();
358 ~TP_DAQ();
359};
360
361class TP_Evidence: public QWidget {
362 Q_OBJECT
363
364 private slots:
365 void ToggleAlarm(bool);
366 void StartDIMBrowser();
367 void StartELog();
368
369 public:
370 TP_Evidence();
371};
372
373
374// Main window class
375class GUI: public QMainWindow, public DimBrowser {
376 Q_OBJECT
377
378 private:
379 QWidget *Central;
380 QTabWidget *TabWidget;
381
382 void closeEvent(QCloseEvent *);
383
384 public:
385 GUI();
386 ~GUI();
387
388 private slots:
389 void MenuAbout();
390 void MenuNewHistory();
391 void DetachTab(int);
392 void CheckAlarm();
393};
394
395#endif
Note: See TracBrowser for help on using the repository browser.