| 1 | #include <string>
|
|---|
| 2 |
|
|---|
| 3 | #include <QtGui>
|
|---|
| 4 | #include <QtNetwork/QTcpSocket>
|
|---|
| 5 | #include <QtNetwork/QAbstractSocket>
|
|---|
| 6 |
|
|---|
| 7 | #include <qwt_plot.h>
|
|---|
| 8 | #include <qwt_plot_curve.h>
|
|---|
| 9 | #include <qwt_plot_grid.h>
|
|---|
| 10 | #include <qwt_plot_zoomer.h>
|
|---|
| 11 | #include <qwt_plot_panner.h>
|
|---|
| 12 | #include <qwt_plot_spectrogram.h>
|
|---|
| 13 | #include <qwt_raster_data.h>
|
|---|
| 14 | #include <qwt_scale_widget.h>
|
|---|
| 15 | #include <qwt_plot_layout.h>
|
|---|
| 16 | #include <qwt_color_map.h>
|
|---|
| 17 |
|
|---|
| 18 | #include "../../drsdaq/RawDataCTX.h"
|
|---|
| 19 | #include "../../pixelmap/PixelMap.h"
|
|---|
| 20 |
|
|---|
| 21 | #define SOCKET_TIMEOUT 10000 // Milliseconds to wait for socket connection
|
|---|
| 22 | #define MAX_OUTPUT_LINES 200 // Maximum number of lines in socket output window
|
|---|
| 23 | #define MAX_COM_SIZE 10000
|
|---|
| 24 | #define INITIAL_DIRECTORY ""
|
|---|
| 25 |
|
|---|
| 26 | // Main window class
|
|---|
| 27 | class ddd : public QMainWindow {
|
|---|
| 28 | Q_OBJECT
|
|---|
| 29 |
|
|---|
| 30 | QPushButton *GetButton, *SocketButton, *Connect, *M0Display;
|
|---|
| 31 | QCheckBox *ContinuousBox;
|
|---|
| 32 | QToolButton *LoadButton;
|
|---|
| 33 | QLineEdit *FilenameBox, *IPAddress, *Command, *PixelID;
|
|---|
| 34 | QSpinBox *EventNo, *ChannelNo, *BoardNo, *Port;
|
|---|
| 35 | QPlainTextEdit *RunHeaderDisplay, *EventHeaderDisplay, *SocketOutput;
|
|---|
| 36 | QTabWidget *TabWidget;
|
|---|
| 37 | QTcpSocket *Socket;
|
|---|
| 38 | QWidget *SocketWindow, *Central, *M0Window;
|
|---|
| 39 | QAction *OpenAction, *ConnectAction;
|
|---|
| 40 | QGridLayout *SocketLayout, *MainLayout, *M0Layout;
|
|---|
| 41 | QFormLayout *CommandLayout, *PortLayout, *AddressLayout, *FormLayout, *SpinLayout;
|
|---|
| 42 |
|
|---|
| 43 | QwtPlot *Graph, *Graph2D;
|
|---|
| 44 | QwtPlotZoomer *Zoomer;
|
|---|
| 45 | QwtPlotCurve *Signal;
|
|---|
| 46 | QwtPlotPanner *Panner;
|
|---|
| 47 | QwtPlotGrid *Grid;
|
|---|
| 48 | QwtPlotSpectrogram *Signal2D;
|
|---|
| 49 | QwtLinearColorMap colorMap;
|
|---|
| 50 |
|
|---|
| 51 | void closeEvent(QCloseEvent *);
|
|---|
| 52 |
|
|---|
| 53 | bool ManualDisconnect, WaitForData;
|
|---|
| 54 | RawDataCTX *RD;
|
|---|
| 55 | PixelMap *PixMap;
|
|---|
| 56 |
|
|---|
| 57 | public:
|
|---|
| 58 | ddd();
|
|---|
| 59 | ~ddd();
|
|---|
| 60 | void CloseDatafile();
|
|---|
| 61 |
|
|---|
| 62 | private slots:
|
|---|
| 63 | void OpenDatafile();
|
|---|
| 64 | void DisplayEvent(int=0);
|
|---|
| 65 | void FileDialog();
|
|---|
| 66 | void OpenSocketWindow();
|
|---|
| 67 | void OpenM0Window();
|
|---|
| 68 | void GetSignalFromSocket();
|
|---|
| 69 | void MakeConnection();
|
|---|
| 70 | void SendToSocket();
|
|---|
| 71 | void ReadFromSocket();
|
|---|
| 72 | void GotDisconnected();
|
|---|
| 73 | void TranslatePixelID();
|
|---|
| 74 |
|
|---|
| 75 | void MenuSave();
|
|---|
| 76 | void MenuPrint();
|
|---|
| 77 | void MenuHelp();
|
|---|
| 78 | void MenuAbout();
|
|---|
| 79 | };
|
|---|
| 80 |
|
|---|
| 81 | //Data class for 2D spectrogram (MO display specific)
|
|---|
| 82 | class SpectrogramDataM0: public QwtRasterData {
|
|---|
| 83 |
|
|---|
| 84 | private:
|
|---|
| 85 |
|
|---|
| 86 | double _z[6][6];
|
|---|
| 87 | double _zmin;
|
|---|
| 88 | double _zmax;
|
|---|
| 89 |
|
|---|
| 90 | public:
|
|---|
| 91 |
|
|---|
| 92 | SpectrogramDataM0(const double z[6][6]): QwtRasterData(QwtDoubleRect(0, 0, 6, 6)) {
|
|---|
| 93 | for (int i = 0; i<6; i++){
|
|---|
| 94 | for (int j = 0; j<6; j++){
|
|---|
| 95 | _z[i][j] = z[i][j];
|
|---|
| 96 | if (z[i][j] > _zmax) _zmax = z[i][j];
|
|---|
| 97 | if (z[i][j] < _zmin) _zmin = z[i][j];
|
|---|
| 98 | }
|
|---|
| 99 | }
|
|---|
| 100 | }
|
|---|
| 101 |
|
|---|
| 102 | virtual QwtRasterData *copy() const {
|
|---|
| 103 | return new SpectrogramDataM0(_z);
|
|---|
| 104 | }
|
|---|
| 105 |
|
|---|
| 106 | virtual QwtDoubleInterval range() const {
|
|---|
| 107 | return QwtDoubleInterval(_zmin, _zmax);
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|
| 110 | virtual void initRaster(const QwtDoubleRect = QwtDoubleRect(0, 0, 6, 6),
|
|---|
| 111 | const QSize =QSize(1,1)) {};
|
|---|
| 112 |
|
|---|
| 113 | virtual double value(double x, double y) const {
|
|---|
| 114 |
|
|---|
| 115 | unsigned int first = (unsigned int)x;
|
|---|
| 116 | unsigned int second = (unsigned int)y;
|
|---|
| 117 |
|
|---|
| 118 | const double v = _z[first][second];
|
|---|
| 119 | return v;
|
|---|
| 120 |
|
|---|
| 121 | }
|
|---|
| 122 |
|
|---|
| 123 | };
|
|---|