Changeset 10904 for fact/tools
- Timestamp:
- 06/03/11 15:42:44 (13 years ago)
- Location:
- fact/tools/Edd
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/Edd/Edd.cc
r10642 r10904 22 22 23 23 // Constructor 24 EventScope::EventScope(QWidget *P): EddBasePlot(P), PixelMap(PixelMapText, false) { 25 24 EventScope::EventScope(class TP_DAQ *Page, QWidget *P): EddBasePlot(P), PixelMap(PixelMapText, false) { 25 26 // Initalise 27 LastPath = "."; 26 28 Name = DRSBoard+"/EventData"; 27 29 DAQPage = Page; 30 Active = false; 31 32 // Open temporary files 28 33 Tmpfile = tmpfile(); 29 34 if(Tmpfile == NULL) { 30 35 QMessageBox::warning(this, "Edd Message", "Could not open temporary file.", QMessageBox::Ok); 36 return; 37 } 38 39 if (!File.open()) { 40 QMessageBox::warning(this, "Edd Message","Could not open temporary file.",QMessageBox::Ok); 41 return; 31 42 } 32 43 … … 49 60 AddTrace(0,0,0); 50 61 51 // Connect to DIM handler52 if (connect(Handler, SIGNAL(YEP(QString, int, QByteArray, QString, QString)), SLOT(Update(QString, int, QByteArray, QString, QString))) == false) {53 printf("Failed connection for %s\n", Name.toAscii().data());54 }55 62 SetActive(true); 56 63 } … … 116 123 disconnect(Handler, SIGNAL(YEP(QString, int, QByteArray, QString, QString)), this, SLOT(Update(QString, int, QByteArray, QString, QString))); 117 124 118 // Open tempory file and write event data to this file 119 QTemporaryFile File; 120 if (!File.open()) { 121 QMessageBox::warning(this, "Edd Message","Could not open temporary file.",QMessageBox::Ok); 122 return; 123 } 125 // Clear temporary file and write event data to this file 126 File.resize(0); 124 127 if (File.write(Data) == -1) { 125 128 QMessageBox::warning(this, "Edd Message","Could not write data to temporary file.",QMessageBox::Ok); … … 127 130 } 128 131 132 // Open temporary raw data file 133 OpenRawFile(File.fileName()); 134 135 // Reconnect after processing 136 connect(Handler, SIGNAL(YEP(QString, int, QByteArray, QString, QString)), SLOT(Update(QString, int, QByteArray, QString, QString))); 137 } 138 139 140 // New event number selected in raw data browser 141 void EventScope::OpenRawFile(QString Filename) { 142 143 // Request filename to open if none given 144 if (Filename.isEmpty()) { 145 Filename = QFileDialog::getOpenFileName(this, "Open raw file", LastPath, "Raw data files (*.raw);; All files (*)"); 146 if (Filename == NULL) return; 147 } 148 149 DAQPage->FilenameBox->setText(Filename); 150 LastPath = QFileInfo(Filename).absolutePath(); 151 129 152 // Prepare temporary file for run header 130 153 ftruncate(fileno(Tmpfile), 0); 131 154 rewind(Tmpfile); 132 155 133 // Open file with RawDataCTX 134 switch (ErrCode = RD->OpenDataFile(File.fileName().toAscii().data(), Tmpfile)) { 135 case CTX_FOPEN: QMessageBox::warning(this, "Edd Message","Could not open file.",QMessageBox::Ok); 136 return; 137 case CTX_RHEADER: QMessageBox::warning(this, "Edd Message","Could not read run header.",QMessageBox::Ok); 138 return; 139 case CTX_BSTRUCT: QMessageBox::warning(this, "Edd Message","Could not read board structures.",QMessageBox::Ok); 140 return; 141 default: break; 142 } 143 144 // Emit signal containing run header 156 // Write run header to temporary file 157 switch (ErrCode = RD->OpenDataFile(Filename.toAscii().data(), Tmpfile)) { 158 case CTX_FOPEN: QMessageBox::warning(this, "Edd Message","Could not open file.",QMessageBox::Ok); 159 return; 160 case CTX_RHEADER: QMessageBox::warning(this, "Edd Message","Could not read run header.",QMessageBox::Ok); 161 return; 162 case CTX_BSTRUCT: QMessageBox::warning(this, "Edd Message","Could not read board structures.",QMessageBox::Ok); 163 return; 164 default: break; 165 } 166 RunHeader *R = RD->RHeader; 167 168 if (R->MagicNum == MAGICNUM_OPEN) { 169 QMessageBox::warning(this, "Edd Message","Magic number in run header indicates that the file has not been closed properly.",QMessageBox::Ok); 170 } 171 if (R->MagicNum == MAGICNUM_ERROR) { 172 QMessageBox::warning(this, "Edd Message","Magic number in run header indicates that an error occurred while writing the file.",QMessageBox::Ok); 173 } 174 175 // Print run header to display 145 176 rewind(Tmpfile); 146 QTextStream Stream(Tmpfile); 147 emit(RunHeaderChanged(Stream.readAll())); 177 QTextStream in(Tmpfile); 178 QString text = in.readAll(); 179 DAQPage->RunHeaderDisplay->setPlainText(text); 180 181 // Update spin box ranges on DAQ page 182 DAQPage->Event->setRange(0, R->Events-1); 183 DAQPage->Event->setEnabled(true); 184 185 DAQPage->Channel->setRange(0, R->NChannels-1); 186 DAQPage->Chip->setRange(0, R->NChips-1); 187 DAQPage->Board->setRange(0, R->NBoards-1); 188 189 // Display first event 190 NewEventNum(0); 191 } 192 193 // New event number selected in raw data browser 194 void EventScope::NewEventNum(int Event) { 148 195 149 196 // Prepare temporary file for event header … … 151 198 rewind(Tmpfile); 152 199 153 // Write event header text to file 154 if (RD->ReadEvent(0, Tmpfile) != CTX_OK) { 155 QMessageBox::warning(this, "Edd Warning","Could not read event.",QMessageBox::Ok); 200 // Read event 201 if (RD->ReadEvent(Event, Tmpfile) != CTX_OK) { 202 QMessageBox::warning(this, "Edd Message","Could not read event.",QMessageBox::Ok); 203 DAQPage->EventHeaderDisplay->clear(); 156 204 return; 157 205 } 158 159 // Add trigger cells to file 160 fprintf(Tmpfile, "\nTrigger cells:"); 161 int *TrigCells = (int *) RD->Data; 162 for (unsigned int i=0; i<RD->RHeader->NBoards; i++) { 163 fprintf(Tmpfile, "\n Board %d ", i); 164 for (unsigned int j=0; j<RD->RHeader->NChips; j++) fprintf(Tmpfile, "%d ", *(TrigCells++)); 165 } 166 167 // Emit signal containing run header 168 rewind(Tmpfile); 169 emit(EventHeaderChanged(Stream.readAll())); 170 171 // Update display 206 207 // Plot traces for event 172 208 PlotTraces(); 173 174 // Reconnect after processing175 connect(Handler, SIGNAL(YEP(QString, int, QByteArray, QString, QString)), SLOT(Update(QString, int, QByteArray, QString, QString)));176 209 } 177 210 … … 182 215 unsigned int Cell, Trig; 183 216 static int Last = 0; 184 217 185 218 // Only process if valid data in RawDataCTX class 186 219 if (ErrCode != CTX_OK) return; 220 221 // Print event header and trigger cell information from event data 222 rewind(Tmpfile); 223 QTextStream in(Tmpfile); 224 QString text = in.readAll(); 225 226 text.append("\nTrigger cells: "); 227 for (unsigned int i=0; i<RD->RHeader->NBoards*RD->RHeader->NChips; i++) { 228 QString a; 229 text.append(a.sprintf("%d ", *((int *)RD->Data + i))); 230 } 231 DAQPage->EventHeaderDisplay->setPlainText(text); 187 232 188 233 // Set x axis title … … 268 313 void EventScope::SetActive(bool State) { 269 314 270 static bool Active = false; 271 272 if (State && !Active) Handler->Subscribe(DRSBoard+"/EventData"); 273 if (!State && Active) Handler->Unsubscribe(DRSBoard+"/EventData"); 315 if (State && !Active) { 316 Handler->Subscribe(DRSBoard+"/EventData"); 317 connect(Handler, SIGNAL(YEP(QString, int, QByteArray, QString, QString)), SLOT(Update(QString, int, QByteArray, QString, QString))); 318 } 319 if (!State && Active) { 320 Handler->Unsubscribe(DRSBoard+"/EventData"); 321 disconnect(Handler, SIGNAL(YEP(QString, int, QByteArray, QString, QString)), this, SLOT(Update(QString, int, QByteArray, QString, QString))); 322 } 274 323 Active = State; 275 324 } … … 494 543 // Event scope page 495 544 // 496 TP_DAQ::TP_DAQ( ) {545 TP_DAQ::TP_DAQ(bool IsBrowser) { 497 546 498 547 EddLineDisplay *Line; … … 501 550 QGridLayout *Layout = new QGridLayout(this); 502 551 503 // Run-related information504 Line = new EddLineDisplay("drsdaq/RunNumber");505 Line->setMaximumWidth(100);506 Layout->addWidget(Line, 0, 1, 1, 1);507 Line = new EddLineDisplay(DRSBoard+"/EventNumber");508 Line->setMaximumWidth(100);509 Layout->addWidget(Line, 0, 2, 1, 1);510 Line = new EddLineDisplay("drsdaq/RunSizeMB");511 Line->setMaximumWidth(100);512 Layout->addWidget(Line, 0, 3, 1, 1);513 Line = new EddLineDisplay("drsdaq/FileSizeMB");514 Line->setMaximumWidth(100);515 Layout->addWidget(Line, 0, 4, 1, 1);516 Line = new EddLineDisplay("drsdaq/FileName");517 Line->setMaximumWidth(200);518 Layout->addWidget(Line, 0, 5, 1, 1);519 520 // Message service521 Line = new EddLineDisplay(DRSBoard+"/Message");522 Line->setMaximumWidth(200);523 Layout->addWidget(Line, 1, 1, 1, 2);524 525 552 // Event scope 526 Scope = new EventScope ;553 Scope = new EventScope(this); 527 554 Scope->setMinimumWidth(700); 555 556 if (IsBrowser) Scope->SetActive(false); 557 558 // FilenameBox must exist also for online browser (but not added to layout) 559 FilenameBox = new QLineEdit(); 560 561 if (!IsBrowser) { 562 // Message service 563 Line = new EddLineDisplay(DRSBoard+"/Message"); 564 Line->setMinimumWidth(500); 565 Layout->addWidget(Line, 0, 1, 1, 6); 566 567 // Run-related information 568 Line = new EddLineDisplay(DRSBoard+"/EventNumber"); 569 Line->setMaximumWidth(100); 570 Layout->addWidget(Line, 0, 8, 1, 1); 571 Line = new EddLineDisplay(DRSBoard+"/FileSizeMB"); 572 Line->setMaximumWidth(100); 573 Layout->addWidget(Line, 0, 9, 1, 1); 574 } 575 else { 576 // Filename box 577 Layout->addWidget(FilenameBox, 0, 1, 1, 6); 578 connect(FilenameBox, SIGNAL(returnPressed()), SLOT(OpenDataFile())); 579 FilenameBox->setToolTip("Raw data file name"); 580 581 // Browse botton 582 QToolButton *LoadButton = new QToolButton(); 583 LoadButton->setToolButtonStyle (Qt::ToolButtonTextOnly); 584 LoadButton->setText("..."); 585 Layout->addWidget(LoadButton, 0, 7, 1, 1); 586 connect(LoadButton, SIGNAL(clicked()), Scope, SLOT(OpenRawFile())); 587 LoadButton->setToolTip("Open file dialog to select raw data file"); 588 } 528 589 529 590 // Text boxes for run and event header … … 538 599 TabWidget->addTab(RunHeaderDisplay, "&Run Header"); 539 600 TabWidget->addTab(EventHeaderDisplay, "&Event Header"); 540 Layout->addWidget(TabWidget, 2, 1, 6, 5);601 Layout->addWidget(TabWidget, 1, 1, 7, 12); 541 602 542 603 // Channel number 543 604 Channel = new QSpinBox; 544 605 connect(Channel, SIGNAL(valueChanged(int)), SLOT(UpdateScope(int))); 545 Channel->setToolTip(" DRS channel number");606 Channel->setToolTip("Channel number"); 546 607 547 608 // Chip number 548 609 Chip = new QSpinBox; 549 610 connect(Chip, SIGNAL(valueChanged(int)), SLOT(UpdateScope(int))); 550 Chip->setToolTip(" DRS chip number");611 Chip->setToolTip("Chip number"); 551 612 552 613 // Board number 553 614 Board = new QSpinBox; 554 615 connect(Board, SIGNAL(valueChanged(int)), SLOT(UpdateScope(int))); 555 Board->setToolTip(" DRS board number");616 Board->setToolTip("Board number"); 556 617 557 618 // Pixel ID … … 562 623 connect(PixelID, SIGNAL(valueChanged(int)), SLOT(TranslatePixelID(int))); 563 624 PixelID->setToolTip("Pixel identification"); 625 626 // Add trace permanently 627 QPushButton *Button = new QPushButton("Keep trace"); 628 Button->setToolTip("Keep trace in display"); 629 Button->setMaximumWidth(80); 630 connect(Button, SIGNAL(clicked()), SLOT(KeepCurrent())); 564 631 565 632 // Layout of pixel addressing widgets … … 570 637 FormLayout->addRow("Channel", Channel); 571 638 FormLayout->addRow("Pixel ID", PixelID); 639 FormLayout->addRow("", Button); 572 640 Layout->addLayout(FormLayout, 0, 0, 4, 1); 573 574 // Add trace permanently 575 QPushButton *Button = new QPushButton("Keep trace"); 576 Button->setToolTip("Keep trace in display"); 577 Button->setMaximumWidth(80); 578 Layout->addWidget(Button, 4, 0); 579 connect(Button, SIGNAL(clicked()), SLOT(KeepCurrent())); 580 581 // Stop/start 641 642 // Spin box for event number 643 Event = new QSpinBox; 644 Event->setToolTip("Event number"); 645 Event->setEnabled (false); 646 647 // Stop/start button 582 648 StartStopButton = new QPushButton("Stop"); 583 649 StartStopButton->setToolTip("Start/stop display"); … … 589 655 StartStopButton->setPalette(Palette); 590 656 StartStopButton->setFont(QFont("Times", 10, QFont::Bold)); 591 Layout->addWidget(StartStopButton, 6, 0); 592 connect(StartStopButton, SIGNAL(toggled(bool)), SLOT(StartStop(bool))); 593 594 657 658 if (IsBrowser) { 659 FormLayout = new QFormLayout(); 660 FormLayout->setRowWrapPolicy(QFormLayout::WrapAllRows); 661 FormLayout->addRow("Event Num", Event); 662 Layout->addLayout(FormLayout, 6, 0); 663 connect(Event, SIGNAL(valueChanged(int)), Scope, SLOT(NewEventNum(int))); 664 } 665 else { 666 Layout->addWidget(StartStopButton, 6, 0); 667 connect(StartStopButton, SIGNAL(toggled(bool)), SLOT(StartStop(bool))); 668 } 669 595 670 // Event display page 596 671 EddWindow *New = new EddWindow("Pixel display", "Edd - Event display"); … … 620 695 621 696 // Connect slots for updating displays 622 connect(Scope, SIGNAL(RunHeaderChanged(QString)), RunHeaderDisplay, SLOT(setPlainText(QString))); 623 connect(Scope, SIGNAL(EventHeaderChanged(QString)), EventHeaderDisplay, SLOT(setPlainText(QString))); 624 625 StartStop(false); 697 if (!IsBrowser) StartStop(false); 626 698 connect(Scope, SIGNAL(PixelData(QVector<double>)), SLOT(SetPixelData(QVector<double>))); 627 699 … … 662 734 Scope->SetActive(!State); 663 735 StartStopButton->setText(State ? "Start" : "Stop"); 664 if (!State) connect(Handler, SIGNAL(YEP(QString, int, QByteArray, QString, QString)), Scope, SLOT(Update(QString, int, QByteArray, QString, QString))); 665 else disconnect(Handler, SIGNAL(YEP(QString, int, QByteArray, QString, QString)), Scope, SLOT(Update(QString, int, QByteArray, QString, QString))); 736 //if (!State) connect(Handler, SIGNAL(YEP(QString, int, QByteArray, QString, QString)), Scope, SLOT(Update(QString, int, QByteArray, QString, QString))); 737 //else disconnect(Handler, SIGNAL(YEP(QString, int, QByteArray, QString, QString)), Scope, SLOT(Update(QString, int, QByteArray, QString, QString))); 738 } 739 740 // Open raw data file 741 void TP_DAQ::OpenDataFile() { 742 743 Scope->OpenRawFile(FilenameBox->text()); 666 744 } 667 745 … … 794 872 TabWidget->setTabsClosable(true); 795 873 connect(TabWidget, SIGNAL(tabCloseRequested(int)), SLOT(DetachTab(int))); 796 TabWidget->addTab(new TP_DAQ , "Event scope");874 TabWidget->addTab(new TP_DAQ(false), "Event scope"); 797 875 TabWidget->addTab(new TP_FADctrl, "FADctrl"); 798 876 TabWidget->addTab(new TP_Bias, "Bias"); … … 803 881 // Set features of main window 804 882 setStatusBar(new QStatusBar(this)); 805 setWindowTitle("Edd - Evidence Data Display - Node: " + QString( getenv("DIM_DNS_NODE")));883 setWindowTitle("Edd - Evidence Data Display - Node: " + QString(DimServer::getDnsNode()) + ":" + QString::number(DimServer::getDnsPort())); 806 884 setCentralWidget(TabWidget); 807 885 … … 809 887 QMenu* Menu = menuBar()->addMenu("&Menu"); 810 888 Menu->addAction("New history plot", this, SLOT(MenuNewHistory())); 889 Menu->addAction("Raw data browser", this, SLOT(MenuRawDataBrowser())); 811 890 Menu->addSeparator(); 812 891 Menu->addAction("About", this, SLOT(MenuAbout())); … … 820 899 //setMaximumSize(QApplication::desktop()->screenGeometry(this).size()*0.9); 821 900 TabWidget->resize(Size); 822 TabWidget->setMaximumSize(QApplication::desktop()->screenGeometry(this).size()*0.9);901 TabWidget->setMaximumSize(QApplication::desktop()->screenGeometry(this).size()*0.9); 823 902 show(); 824 903 … … 867 946 } 868 947 948 // Raw data browser 949 void GUI::MenuRawDataBrowser() { 950 951 DetachTab(0, true); 952 } 953 869 954 // Open tab as separate window 870 void GUI::DetachTab(int Tab ) {955 void GUI::DetachTab(int Tab, bool IsDAQBrowser) { 871 956 872 957 QWidget *W = NULL; … … 877 962 878 963 switch(Tab) { 879 case 0: W = new TP_DAQ; break; 880 case 1: W = new TP_Bias; break; 881 case 2: W = new TP_Feedback; break; 882 case 3: W = new TP_Environment; break; 883 case 4: W = new TP_Evidence; break; 964 case 0: W = new TP_DAQ(IsDAQBrowser); break; 965 case 1: W = new TP_FADctrl; break; 966 case 2: W = new TP_Bias; break; 967 case 3: W = new TP_Feedback; break; 968 case 4: W = new TP_Environment; break; 969 case 5: W = new TP_Evidence; break; 884 970 default: break; 885 971 } … … 892 978 893 979 W->setParent(M); 980 W->resize(size()); 894 981 M->resize(size()); 895 M->setWindowTitle("Edd - " + TabWidget->tabText(Tab)); 982 if (!IsDAQBrowser) M->setWindowTitle("Edd - " + TabWidget->tabText(Tab)); 983 else M->setWindowTitle("Edd - Raw Data Browser"); 896 984 M->show(); 985 986 return; 897 987 } 898 988 -
fact/tools/Edd/Edd.h
r10280 r10904 7 7 8 8 #define SVN_REVISION "$Revision: 10143 $" 9 10 class TP_DAQ; 9 11 10 12 // Event oscilloscope … … 20 22 QList<struct ItemDetails> List; 21 23 24 class TP_DAQ *DAQPage; 22 25 QString Name; 23 RawDataCTX *RD; 24 CTX_ErrCode ErrCode; 26 bool Active; 25 27 QAction *PhysPipeAction; 26 28 QAction *PersistanceAction; 27 29 FILE *Tmpfile; 30 QTemporaryFile File; 31 QString LastPath; 28 32 29 33 public: 30 EventScope( QWidget * = NULL);34 EventScope(class TP_DAQ *, QWidget * = NULL); 31 35 ~EventScope(); 32 36 … … 35 39 void SetActive(bool); 36 40 QString ToPixel(unsigned int, unsigned int, unsigned int, unsigned int); 41 RawDataCTX *RD; 42 CTX_ErrCode ErrCode; 37 43 38 44 private slots: … … 40 46 void PlotTraces(); 41 47 void DeleteCurve(QwtPlotCurve *); 48 void NewEventNum(int); 49 50 public slots: 51 void OpenRawFile(QString=QString()); 42 52 43 53 signals: 44 void RunHeaderChanged(QString);45 void EventHeaderChanged(QString);46 54 void PixelData(QVector<double>); 47 55 }; … … 82 90 83 91 private: 84 EventScope *Scope;85 QPlainTextEdit *RunHeaderDisplay, *EventHeaderDisplay;86 87 QSpinBox *Channel, *Chip, *Board, *PixelID;88 92 QFormLayout *FormLayout; 89 93 QWidget *Display; … … 98 102 void ShowPixelDisplay(); 99 103 void SetPixelData(QVector<double>); 104 void OpenDataFile(); 100 105 101 106 public: 102 TP_DAQ(); 103 ~TP_DAQ(); 107 TP_DAQ(bool); 108 ~TP_DAQ(); 109 110 EventScope *Scope; 111 QSpinBox *Channel, *Chip, *Board, *PixelID, *Event; 112 QPlainTextEdit *RunHeaderDisplay, *EventHeaderDisplay; 113 QLineEdit *FilenameBox; 104 114 }; 105 115 … … 132 142 void MenuAbout(); 133 143 void MenuNewHistory(); 134 void DetachTab(int); 144 void MenuRawDataBrowser(); 145 void DetachTab(int, bool=false); 135 146 void CheckAlarm(); 136 147 };
Note:
See TracChangeset
for help on using the changeset viewer.