Changeset 129


Ignore:
Timestamp:
Dec 8, 2009, 2:42:27 PM (11 years ago)
Author:
ogrimm
Message:
Saving of waveform to text and plotting of physical pipeline added
Location:
tools/ddd
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • tools/ddd/Functions.cpp

    r109 r129  
    5656  M0Start->setEnabled(true);
    5757  M0Stop->setEnabled(true);
     58  PhysPipeAction->setEnabled(true);
    5859  EventNo->setRange(1, RD->RHeader->Events);
    5960  M0Start->setRange(0,(RD->RHeader->Samples)-1); 
     
    7374    M0Start->setEnabled(false);
    7475    M0Stop->setEnabled(false);
     76        PhysPipeAction->setEnabled(false);
    7577    RunHeaderDisplay->clear();
    7678    EventHeaderDisplay->clear();
     
    8587  if(Socket->state() == QAbstractSocket::ConnectedState) return; // do not execute if socket is open
    8688 
     89  if (PhysPipeAction->isChecked()) {
     90    Graph->setAxisTitle(QwtPlot::xBottom, "Time from start of physical pipeline (ns)");
     91  }
     92  else {
     93    Graph->setAxisTitle(QwtPlot::xBottom, "Time from trigger (ns)");
     94  }
     95
    8796  // Read event
    8897  ftruncate(fileno(Tmpfile),0);
     
    112121  for (unsigned int i=0; i<RD->RHeader->Samples; i++) {
    113122    x[i] = (double) (i/RD->BStruct[BoardNo->value()].NomFreq);
    114     y[i] = (double) *((short *) (RD->Data + RD->RHeader->NBoards*RD->RHeader->NChips*sizeof(int)) + BoardNo->value()*RD->RHeader->NChips*RD->RHeader->NChannels *
    115              RD->RHeader->Samples+ChannelNo->value()*RD->RHeader->Samples+i)*RD->BStruct[BoardNo->value()].ScaleFactor;
     123        if (PhysPipeAction->isChecked()) {
     124      y[(i + *((int *) RD->Data + BoardNo->value()*RD->RHeader->NChips+ChannelNo->value()/RD->RHeader->NChannels))%1024] = (double) *((short *) (RD->Data + RD->RHeader->NBoards*RD->RHeader->NChips*sizeof(int)) + BoardNo->value()*RD->RHeader->NChips*RD->RHeader->NChannels * RD->RHeader->Samples + ChannelNo->value()*RD->RHeader->Samples + i)*RD->BStruct[BoardNo->value()].ScaleFactor;
     125        }
     126        else {
     127      y[i] = (double) *((short *) (RD->Data + RD->RHeader->NBoards*RD->RHeader->NChips*sizeof(int)) + BoardNo->value()*RD->RHeader->NChips*RD->RHeader->NChannels * RD->RHeader->Samples+ChannelNo->value()*RD->RHeader->Samples+(i))*RD->BStruct[BoardNo->value()].ScaleFactor;
     128        }
    116129  }
    117130
     
    236249  else {
    237250    if (RD->IsFileOpen() && QMessageBox::question(this, "ddd Request","Connecting will close current data file. Proceed?",
    238         QMessageBox::No, QMessageBox::Yes) != QMessageBox::Yes) return;   
     251        QMessageBox::No, QMessageBox::Yes) != QMessageBox::Yes) return;
     252               
     253        PhysPipeAction->setChecked(false);
     254           
    239255    Socket->connectToHost(IPAddress->text(),Port->value());
    240256    Connect->setEnabled(false);  // While waiting for connection, button not available
     
    314330      Signal->show();
    315331      Zoomer->setZoomBase(Signal->boundingRect());
     332          Graph->setAxisTitle(QwtPlot::xBottom, "Time from trigger (ns)");
    316333    } 
    317334    delete[] x;   delete[] y;
     
    400417}
    401418
     419void ddd::MenuSaveASCII() {
     420  QString Filename = QFileDialog::getSaveFileName(this,
     421     "Filename", ".", "Text files (*.txt *.ascii *.asc);;All files (*)");
     422  if (Filename.length()>0) {
     423    QFile File(Filename);
     424        if (File.open(QFile::WriteOnly | QIODevice::Text | QFile::Truncate)) {
     425      QTextStream Stream(&File);
     426          for (int i=0; i<Signal->dataSize(); i++) {
     427        Stream << Signal->y(i) << endl;
     428          }
     429        }
     430        else {
     431          QMessageBox::warning(this, "ddd Message","Could not write data to file.",QMessageBox::Ok);
     432    }
     433  }
     434}
     435
    402436void ddd::MenuHelp() {
    403437  QMessageBox Message;
  • tools/ddd/GUI.cpp

    r82 r129  
    9898  // Plot area
    9999  Graph = new QwtPlot(Central);
    100   Graph->setAxisTitle(QwtPlot::xBottom, "Time (ns)");
    101100  Graph->setAxisTitle(QwtPlot::yLeft, "Signal (mV)");
    102101  Graph->setAutoReplot(true);
     
    157156  SaveAction->setShortcut(Qt::CTRL + Qt::Key_S);
    158157  Menu->addAction("Print plot", this, SLOT(MenuPrint()));
     158  Menu->addAction("Save waveform to ASCII", this, SLOT(MenuSaveASCII()));
     159  Menu->addSeparator();
     160  PhysPipeAction = Menu->addAction("Plot physical pipeline", this, SLOT(DisplayEvent()));
     161  PhysPipeAction->setCheckable(true);
     162  PhysPipeAction->setEnabled(false);
    159163  Menu->addSeparator();
    160164  ConnectAction = Menu->addAction("Connect", this, SLOT(MakeConnection()));
  • tools/ddd/GUI.h

    r82 r129  
    3737    QTcpSocket *Socket;
    3838    QWidget *SocketWindow, *Central, *M0Window;
    39     QAction *OpenAction, *ConnectAction;
     39    QAction *OpenAction, *ConnectAction, *PhysPipeAction;
    4040    QGridLayout *SocketLayout, *MainLayout, *M0Layout;
    4141    QFormLayout *CommandLayout, *PortLayout, *AddressLayout, *FormLayout, *SpinLayout, *M0StartLayout, *M0StopLayout;
     
    7777    void MenuSave();
    7878    void MenuPrint();
     79    void MenuSaveASCII();
    7980    void MenuHelp();
    8081    void MenuAbout();
Note: See TracChangeset for help on using the changeset viewer.