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