| 1 | /* ============================================================
|
|---|
| 2 |
|
|---|
| 3 | DRS Data Display
|
|---|
| 4 |
|
|---|
| 5 | Qt-based graphical user interface for displaying data taken with
|
|---|
| 6 | the drsdaq program.
|
|---|
| 7 | There are two operation modes: inspection of a raw data file and
|
|---|
| 8 | data taking via the socket interface. Connecting to a socket server
|
|---|
| 9 | automatically disables raw data file operation and closes any open
|
|---|
| 10 | file.
|
|---|
| 11 |
|
|---|
| 12 | Oliver Grimm
|
|---|
| 13 |
|
|---|
| 14 | ============================================================ */
|
|---|
| 15 |
|
|---|
| 16 | #include "GUI.h"
|
|---|
| 17 |
|
|---|
| 18 | ddd::ddd() {
|
|---|
| 19 |
|
|---|
| 20 | WaitForData = false;
|
|---|
| 21 |
|
|---|
| 22 | // Instantiate without console output
|
|---|
| 23 | RD = new RawDataCTX(true);
|
|---|
| 24 |
|
|---|
| 25 | // Instantiate PixelMap
|
|---|
| 26 | DimRpcInfo RPC((char *) "ConfigRequest", (char *) "");
|
|---|
| 27 | RPC.setData((char *) "Misc PixelMap");
|
|---|
| 28 | PixMap = new PixelMap(std::string(RPC.getString(), RPC.getSize()));
|
|---|
| 29 |
|
|---|
| 30 | Tmpfile = tmpfile();
|
|---|
| 31 | if(Tmpfile==NULL) {
|
|---|
| 32 | QMessageBox::warning(this, "ddd Message","Could not open temporary file.",QMessageBox::Ok);
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 | //---------------------------------------------------------------------
|
|---|
| 36 | //**************************** Main window ****************************
|
|---|
| 37 | //---------------------------------------------------------------------
|
|---|
| 38 |
|
|---|
| 39 | Central = new QWidget(this);
|
|---|
| 40 | setCentralWidget(Central);
|
|---|
| 41 |
|
|---|
| 42 | Socket = new QTcpSocket(Central);
|
|---|
| 43 | connect(Socket, SIGNAL(readyRead()), this, SLOT(ReadFromSocket()));
|
|---|
| 44 | connect(Socket, SIGNAL(disconnected()), this, SLOT(GotDisconnected()));
|
|---|
| 45 |
|
|---|
| 46 | // SpinBox for event number
|
|---|
| 47 | EventNo = new QSpinBox(Central);
|
|---|
| 48 | EventNo->setEnabled(false);
|
|---|
| 49 | connect(EventNo, SIGNAL(valueChanged(int)), this, SLOT(DisplayEvent(int)));
|
|---|
| 50 | EventNo->setToolTip("Event number in file");
|
|---|
| 51 | SpinLayout = new QFormLayout();
|
|---|
| 52 | SpinLayout->setRowWrapPolicy(QFormLayout::WrapAllRows);
|
|---|
| 53 | SpinLayout->addRow("E&vent", EventNo);
|
|---|
| 54 |
|
|---|
| 55 | // SpinBox for channel number
|
|---|
| 56 | ChannelNo = new QSpinBox(Central);
|
|---|
| 57 | ChannelNo->setEnabled(false);
|
|---|
| 58 | connect(ChannelNo, SIGNAL(valueChanged(int)), this, SLOT(DisplayEvent(int)));
|
|---|
| 59 | ChannelNo->setToolTip("DRS channel number");
|
|---|
| 60 |
|
|---|
| 61 | // SpinBox for chip number
|
|---|
| 62 | ChipNo = new QSpinBox(Central);
|
|---|
| 63 | ChipNo->setEnabled(false);
|
|---|
| 64 | connect(ChipNo, SIGNAL(valueChanged(int)), this, SLOT(DisplayEvent(int)));
|
|---|
| 65 | ChipNo->setToolTip("DRS chip number");
|
|---|
| 66 |
|
|---|
| 67 | // SpinBox for board number
|
|---|
| 68 | BoardNo = new QSpinBox(Central);
|
|---|
| 69 | BoardNo->setEnabled(false);
|
|---|
| 70 | connect(BoardNo, SIGNAL(valueChanged(int)), this, SLOT(DisplayEvent(int)));
|
|---|
| 71 | BoardNo->setToolTip("Mezzanine board number");
|
|---|
| 72 |
|
|---|
| 73 | // SpinBox for pixel ID
|
|---|
| 74 | PixelID = new QSpinBox(Central);
|
|---|
| 75 | PixelID->setEnabled(false);
|
|---|
| 76 | PixelID->setRange(-1, 9999);
|
|---|
| 77 | PixelID->setSpecialValueText("n/a");
|
|---|
| 78 | connect(PixelID, SIGNAL(valueChanged(int)), this, SLOT(TranslatePixelID(int)));
|
|---|
| 79 | PixelID->setToolTip("Pixel identification");
|
|---|
| 80 |
|
|---|
| 81 | // Layout of pixel addressing widgets
|
|---|
| 82 | FormLayout = new QFormLayout;
|
|---|
| 83 | FormLayout->setRowWrapPolicy(QFormLayout::WrapAllRows);
|
|---|
| 84 | FormLayout->addRow("&Channel", ChannelNo);
|
|---|
| 85 | FormLayout->addRow("Chip", ChipNo);
|
|---|
| 86 | FormLayout->addRow("&Board", BoardNo);
|
|---|
| 87 | FormLayout->addRow("Pixel ID", PixelID);
|
|---|
| 88 |
|
|---|
| 89 | // Socket button
|
|---|
| 90 | SocketButton = new QPushButton("Socke&t\nInterface", Central);
|
|---|
| 91 | SocketButton->setFont(QFont("Times", 10, QFont::Bold));
|
|---|
| 92 | connect(SocketButton, SIGNAL(clicked()), this, SLOT(OpenSocketWindow()));
|
|---|
| 93 | SocketButton->setToolTip("Open window for socket communication");
|
|---|
| 94 |
|
|---|
| 95 | // Acquire button and Continuous check box
|
|---|
| 96 | GetButton = new QPushButton("&Acquire", Central);
|
|---|
| 97 | GetButton->setFont(QFont("Times", 10, QFont::Bold));
|
|---|
| 98 | GetButton->setEnabled(false);
|
|---|
| 99 | connect(GetButton, SIGNAL(clicked()), this, SLOT(GetSignalFromSocket()));
|
|---|
| 100 | GetButton->setToolTip("Acquire event over socket interface");
|
|---|
| 101 | ContinuousBox = new QCheckBox("Continuous", Central);
|
|---|
| 102 | ContinuousBox->setFont(QFont("Times", 10, QFont::Bold));
|
|---|
| 103 | ContinuousBox->setToolTip("Acquire continuously");
|
|---|
| 104 |
|
|---|
| 105 | // Plot area
|
|---|
| 106 | Graph = new QwtPlot(Central);
|
|---|
| 107 | Graph->setAxisTitle(QwtPlot::yLeft, "Signal (mV)");
|
|---|
| 108 | Graph->setAutoReplot(true);
|
|---|
| 109 | Graph->setCanvasBackground(QColor(Qt::yellow));
|
|---|
| 110 | Zoomer = new QwtPlotZoomer(QwtPlot::xBottom,QwtPlot::yLeft,Graph->canvas());
|
|---|
| 111 | connect(Zoomer, SIGNAL(zoomed(const QwtDoubleRect &)), this, SLOT(HandleZoom(const QwtDoubleRect &)));
|
|---|
| 112 | Panner = new QwtPlotPanner(Graph->canvas());
|
|---|
| 113 | Panner->setMouseButton(Qt::LeftButton, Qt::ShiftModifier);
|
|---|
| 114 | Grid = new QwtPlotGrid;
|
|---|
| 115 | Grid->setMajPen(QPen(Qt::gray, 0, Qt::DotLine));
|
|---|
| 116 | Grid->attach(Graph);
|
|---|
| 117 | Signal = new QwtPlotCurve;
|
|---|
| 118 | Signal->attach(Graph);
|
|---|
| 119 | Signal->setStyle(QwtPlotCurve::Steps);
|
|---|
| 120 |
|
|---|
| 121 | // Text boxes for run and event header
|
|---|
| 122 | RunHeaderDisplay = new QPlainTextEdit(Central);
|
|---|
| 123 | EventHeaderDisplay = new QPlainTextEdit(Central);
|
|---|
| 124 | RunHeaderDisplay->setReadOnly(true);
|
|---|
| 125 | EventHeaderDisplay->setReadOnly(true);
|
|---|
| 126 |
|
|---|
| 127 | // Browse botton
|
|---|
| 128 | LoadButton = new QToolButton(Central);
|
|---|
| 129 | LoadButton->setToolButtonStyle (Qt::ToolButtonTextOnly);
|
|---|
| 130 | LoadButton->setText("...");
|
|---|
| 131 | connect(LoadButton, SIGNAL(clicked()), this, SLOT(FileDialog()));
|
|---|
| 132 | LoadButton->setToolTip("Open file dialog to select raw data file");
|
|---|
| 133 |
|
|---|
| 134 | // Filename box
|
|---|
| 135 | FilenameBox = new QLineEdit(Central);
|
|---|
| 136 | connect(FilenameBox, SIGNAL(returnPressed()), this, SLOT(OpenDatafile()));
|
|---|
| 137 | FilenameBox->setToolTip("Raw data file name");
|
|---|
| 138 |
|
|---|
| 139 | // Tab widget
|
|---|
| 140 | TabWidget = new QTabWidget(Central);
|
|---|
| 141 | TabWidget->addTab(Graph, "&Signal");
|
|---|
| 142 | TabWidget->addTab(RunHeaderDisplay, "&Run Header");
|
|---|
| 143 | TabWidget->addTab(EventHeaderDisplay, "&Event Header");
|
|---|
| 144 |
|
|---|
| 145 | // Layout of all widgets
|
|---|
| 146 | MainLayout = new QGridLayout(Central);
|
|---|
| 147 | MainLayout->addWidget(FilenameBox, 0, 0, 1, 3);
|
|---|
| 148 | MainLayout->addWidget(LoadButton, 0, 3);
|
|---|
| 149 | MainLayout->addLayout(SpinLayout, 1, 0);
|
|---|
| 150 | MainLayout->addLayout(FormLayout, 2, 0);
|
|---|
| 151 | MainLayout->addWidget(SocketButton, 6,0);
|
|---|
| 152 | MainLayout->addWidget(GetButton, 4,0);
|
|---|
| 153 | MainLayout->addWidget(ContinuousBox, 5,0);
|
|---|
| 154 | MainLayout->addWidget(TabWidget, 1, 1, 6, 5);
|
|---|
| 155 | MainLayout->setColumnStretch(1, 10);
|
|---|
| 156 |
|
|---|
| 157 | // Menu bar
|
|---|
| 158 | QMenu* Menu = menuBar()->addMenu("&Menu");
|
|---|
| 159 | OpenAction = Menu->addAction("Open data file", this, SLOT(FileDialog()));
|
|---|
| 160 | OpenAction->setShortcut(Qt::CTRL + Qt::Key_O);
|
|---|
| 161 | QAction* SaveAction = Menu->addAction("Save plot", this, SLOT(MenuSave()));
|
|---|
| 162 | SaveAction->setShortcut(Qt::CTRL + Qt::Key_S);
|
|---|
| 163 | Menu->addAction("Print plot", this, SLOT(MenuPrint()));
|
|---|
| 164 | Menu->addAction("Save waveform to ASCII", this, SLOT(MenuSaveASCII()));
|
|---|
| 165 | Menu->addSeparator();
|
|---|
| 166 | PhysPipeAction = Menu->addAction("Plot physical pipeline", this, SLOT(DisplayEvent()));
|
|---|
| 167 | PhysPipeAction->setCheckable(true);
|
|---|
| 168 | PhysPipeAction->setEnabled(false);
|
|---|
| 169 | Menu->addSeparator();
|
|---|
| 170 | ConnectAction = Menu->addAction("Connect", this, SLOT(MakeConnection()));
|
|---|
| 171 | ConnectAction->setShortcut(Qt::CTRL + Qt::Key_C);
|
|---|
| 172 | Menu->addSeparator();
|
|---|
| 173 | Menu->addAction("Help", this, SLOT(MenuHelp()));
|
|---|
| 174 | Menu->addAction("About", this, SLOT(MenuAbout()));
|
|---|
| 175 | Menu->addSeparator();
|
|---|
| 176 | QAction* QuitAction = Menu->addAction("Quit", qApp, SLOT(quit()));
|
|---|
| 177 | QuitAction->setShortcut(Qt::CTRL + Qt::Key_Q);
|
|---|
| 178 |
|
|---|
| 179 | //-----------------------------------------------------------------------
|
|---|
| 180 | //**************************** Socket window ****************************
|
|---|
| 181 | //-----------------------------------------------------------------------
|
|---|
| 182 |
|
|---|
| 183 | // Create widget (initially hidden)
|
|---|
| 184 | SocketWindow = new QWidget();
|
|---|
| 185 | SocketWindow->setWindowTitle("ddd - Socket Interface");
|
|---|
| 186 |
|
|---|
| 187 | // Edit box for IP Address
|
|---|
| 188 | IPAddress = new QLineEdit(SocketWindow);
|
|---|
| 189 | IPAddress->setText("eth-vme02");
|
|---|
| 190 | IPAddress->setToolTip("Address of socket server");
|
|---|
| 191 | AddressLayout = new QFormLayout;
|
|---|
| 192 | AddressLayout->addRow("&Remote Address", IPAddress);
|
|---|
| 193 |
|
|---|
| 194 | // SpinBox for port selection
|
|---|
| 195 | Port = new QSpinBox(SocketWindow);
|
|---|
| 196 | Port->setRange(0,65535);
|
|---|
| 197 | Port->setValue(2000);
|
|---|
| 198 | Port->setToolTip("Port number of socket server");
|
|---|
| 199 | PortLayout = new QFormLayout;
|
|---|
| 200 | PortLayout->addRow("&Port", Port);
|
|---|
| 201 |
|
|---|
| 202 | // Button to make connection
|
|---|
| 203 | Connect = new QPushButton("Connect", SocketWindow);
|
|---|
| 204 | Connect->setFont(QFont("Times", 10, QFont::Bold));
|
|---|
| 205 | connect(Connect, SIGNAL(clicked()), this, SLOT(MakeConnection()));
|
|---|
| 206 | Connect->setToolTip("Connect to server");
|
|---|
| 207 |
|
|---|
| 208 | // Edit box for command
|
|---|
| 209 | Command = new QLineEdit(SocketWindow);
|
|---|
| 210 | CommandLayout = new QFormLayout;
|
|---|
| 211 | CommandLayout->addRow("&Command", Command);
|
|---|
| 212 | Command->setEnabled(false);
|
|---|
| 213 | connect(Command, SIGNAL(returnPressed()), this, SLOT(SendToSocket()));
|
|---|
| 214 | Command->setToolTip("Command to send to socket server");
|
|---|
| 215 |
|
|---|
| 216 | // Text box for socket output
|
|---|
| 217 | SocketOutput= new QPlainTextEdit(SocketWindow);
|
|---|
| 218 | SocketOutput->setReadOnly(true);
|
|---|
| 219 | SocketOutput->setMaximumBlockCount(MAX_OUTPUT_LINES);
|
|---|
| 220 | SocketOutput->setToolTip("Output of socket server");
|
|---|
| 221 |
|
|---|
| 222 | // Layout of all widgets
|
|---|
| 223 | SocketLayout = new QGridLayout(SocketWindow);
|
|---|
| 224 | SocketLayout->addLayout(AddressLayout, 0, 0, 0, 1);
|
|---|
| 225 | SocketLayout->addLayout(PortLayout, 0, 2);
|
|---|
| 226 | SocketLayout->addWidget(Connect, 0, 3);
|
|---|
| 227 | SocketLayout->addLayout(CommandLayout, 1, 0, 1, 4);
|
|---|
| 228 | SocketLayout->addWidget(SocketOutput, 2, 0, 4, 4);
|
|---|
| 229 |
|
|---|
| 230 | }
|
|---|
| 231 |
|
|---|
| 232 | ddd::~ddd() {
|
|---|
| 233 | // Qwt items
|
|---|
| 234 | delete Grid; delete Signal;
|
|---|
| 235 | // Layout items
|
|---|
| 236 | delete PortLayout; delete CommandLayout;
|
|---|
| 237 | delete AddressLayout; delete FormLayout;
|
|---|
| 238 | delete SpinLayout;
|
|---|
| 239 | // Other items
|
|---|
| 240 | delete SocketWindow;
|
|---|
| 241 | delete PixMap; delete RD;
|
|---|
| 242 |
|
|---|
| 243 | fclose(Tmpfile);
|
|---|
| 244 | }
|
|---|
| 245 |
|
|---|
| 246 |
|
|---|
| 247 | //---------------------------------------------------------------------
|
|---|
| 248 | //**************************** Main program ***************************
|
|---|
| 249 | //---------------------------------------------------------------------
|
|---|
| 250 |
|
|---|
| 251 | int main(int argc, char *argv[]) {
|
|---|
| 252 | QApplication app(argc, argv);
|
|---|
| 253 |
|
|---|
| 254 | ddd MainWindow;
|
|---|
| 255 | MainWindow.setGeometry(100, 100, 800, 500);
|
|---|
| 256 | MainWindow.setWindowTitle("ddd - DRS Data Display");
|
|---|
| 257 | MainWindow.show();
|
|---|
| 258 |
|
|---|
| 259 | return app.exec();
|
|---|
| 260 | }
|
|---|