Ignore:
Timestamp:
01/21/11 13:54:00 (12 years ago)
Author:
ogrimm
Message:
Added persistance mode to event scope
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fact/Evidence/Edd/Edd.cc

    r10105 r10112  
    549549    int DataPoints = Items[ItemNo].x.size();   
    550550        if (DataPoints == 0) continue;
    551  
     551
    552552    // Normalize y scale if requested
    553553    double *y = new double [DataPoints];
     
    562562      } 
    563563    }
    564 
     564 
    565565    // Plot data
    566566    Items[ItemNo].Signal->setData(Items[ItemNo].x.data(), y, DataPoints);
     
    735735    Stream << QString("# ") + Items[ItemNo].Signal->title().text() + ".hist" << endl;
    736736    for (int i=0; i<Items[ItemNo].Signal->dataSize(); i++) {
    737       Stream << (int) Items[ItemNo].x.at(i) << " " << Items[ItemNo].Signal->y(i) << endl;
     737      Stream << Items[ItemNo].x.at(i) << " " << Items[ItemNo].Signal->y(i) << endl;
    738738    }
    739739  }
     
    10191019
    10201020  Name = DRSBoard+"/EventData";
    1021   Active = false;
    10221021
    10231022  Tmpfile = tmpfile();
     
    10311030
    10321031  // Context menu
    1033   PhysPipeAction = new QAction("Plot physical pipeline", this);
     1032  PhysPipeAction = new QAction("Physical pipeline", this);
    10341033  PhysPipeAction->setCheckable(true);
    10351034  connect(PhysPipeAction, SIGNAL(triggered()), SLOT(PlotTraces()));
    10361035  Menu->insertAction(StripAction, PhysPipeAction);
     1036
     1037  PersistanceAction = new QAction("Persistance", this);
     1038  PersistanceAction->setCheckable(true);
     1039  Menu->insertAction(StripAction, PersistanceAction);
    10371040  Menu->removeAction(StripAction);
    10381041
     
    10841087  if (List.isEmpty()) return;
    10851088 
     1089  // Clear in case persistance was activated
     1090  ClearCurve(0);
     1091
    10861092  List.first().Signal->setTitle(QString::number(Board)+","+QString::number(Chip)+","+ QString::number(Channel) + " (" + DRS_to_Pixel(Board, Chip, Channel).c_str() + ")");
    10871093  List.first().Board = Board;
     
    10941100// Update event buffer
    10951101void EventScope::Update(QString Name, int Time, QByteArray Data, QString Format, QString) {
    1096 
     1102 
    10971103  if (Name != this->Name) return;
    10981104
     
    11001106  if (!SetStatus(this, Name, Time, Format)) return;
    11011107  if (Data.size() < (int) sizeof(RunHeader)) return;
     1108 
     1109  // Disconnect while processing to avoid queing of events
     1110  disconnect(Handler, SIGNAL(YEP(QString, int, QByteArray, QString, QString)), this, SLOT(Update(QString, int, QByteArray, QString, QString)));
    11021111 
    11031112  // Open tempory file and write event data to this file
     
    11541163  emit(EventHeaderChanged(Stream.readAll()));
    11551164
     1165  // Update display
    11561166  PlotTraces();
     1167 
     1168  // Reconnect after processing
     1169  connect(Handler, SIGNAL(YEP(QString, int, QByteArray, QString, QString)), SLOT(Update(QString, int, QByteArray, QString, QString)));
    11571170}
    11581171
     
    11621175  double x,y;
    11631176  unsigned int Cell, Trig;
     1177  static int Last = 0;
    11641178 
    11651179  // Only process if valid data in RawDataCTX class
    1166   if (!Active || ErrCode != CTX_OK) return;
     1180  if (ErrCode != CTX_OK) return;
    11671181 
    11681182  // Set x axis title
    11691183  if (PhysPipeAction->isChecked()) setAxisTitle(QwtPlot::xBottom, "Time from start of pipeline (ns)");
    11701184  else setAxisTitle(QwtPlot::xBottom, "Time from trigger minus one revolution (ns)");
    1171  
     1185
    11721186  // Loop through event data to update event scope
    11731187  RunHeader *R = RD->RHeader;
    11741188  for (int i=0; i<List.size(); i++) {
    11751189
    1176         ClearCurve(i);
     1190        if (PersistanceAction->isChecked()) List[i].Signal->setStyle(QwtPlotCurve::Dots);
     1191        else {
     1192          ClearCurve(i);
     1193          List[i].Signal->setStyle(QwtPlotCurve::Lines);
     1194        }
    11771195
    11781196        // Check if current event contains requested trace
     
    11851203        Trig = *((int *) RD->Data + List[i].Board*R->NChips + List[i].Chip);
    11861204
     1205        // Calulate point of curve
    11871206        for (unsigned int j=0; j<R->Samples; j++) {
    11881207
     
    12021221  }
    12031222
    1204   UpdatePlot();
     1223  // Limit update rate in persistance mode
     1224  if (!PersistanceAction->isChecked() || time(NULL) > Last) {
     1225    UpdatePlot();
     1226    Last = time(NULL);
     1227  }
     1228
    12051229
    12061230  // Loop through event data for pixel display
     
    12371261// Set display active (if inactive, disconnect from server)
    12381262void EventScope::SetActive(bool State) {
     1263
     1264  static bool Active = false;
    12391265
    12401266  if (State && !Active) Handler->Subscribe(DRSBoard+"/EventData");
     
    15291555  }
    15301556
     1557  connect(Scope, SIGNAL(RunHeaderChanged(QString)), RunHeaderDisplay, SLOT(setPlainText(QString)));
     1558  connect(Scope, SIGNAL(EventHeaderChanged(QString)), EventHeaderDisplay, SLOT(setPlainText(QString)));
     1559
    15311560  StartStop(false);
    15321561  connect(Scope, SIGNAL(PixelData(QVector<double>)), SLOT(SetPixelData(QVector<double>)));
     
    15621591  Scope->SetActive(!State);
    15631592  StartStopButton->setText(State ? "Start" : "Stop");
    1564   if (!State) {
    1565         connect(Scope, SIGNAL(RunHeaderChanged(QString)), RunHeaderDisplay, SLOT(setPlainText(QString)));
    1566         connect(Scope, SIGNAL(EventHeaderChanged(QString)), EventHeaderDisplay, SLOT(setPlainText(QString)));
    1567   }
    1568   else {
    1569         disconnect(Scope, SIGNAL(RunHeaderChanged(QString)), RunHeaderDisplay, SLOT(setPlainText(QString)));
    1570         disconnect(Scope, SIGNAL(EventHeaderChanged(QString)), EventHeaderDisplay, SLOT(setPlainText(QString)));
    1571   }
     1593  if (!State) connect(Handler, SIGNAL(YEP(QString, int, QByteArray, QString, QString)), Scope, SLOT(Update(QString, int, QByteArray, QString, QString)));
     1594  else disconnect(Handler, SIGNAL(YEP(QString, int, QByteArray, QString, QString)), Scope, SLOT(Update(QString, int, QByteArray, QString, QString)));
    15721595}
    15731596
Note: See TracChangeset for help on using the changeset viewer.