Changeset 10678 for trunk/FACT++


Ignore:
Timestamp:
05/12/11 19:04:11 (14 years ago)
Author:
tbretz
Message:
Implemented a fix which should avoid that the GUI is playing ping-pong with e.g. the ftmctrl. This is done through a wrapper around all infoHandlers. In ceratin circumstances (mainly when signals of the kind valueChanged are emitted) it is advicable to not send the values back to the emitter if their origin is the handler.
Location:
trunk/FACT++/gui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/gui/FactGui.h

    r10665 r10678  
    13691369    }
    13701370
     1371    void CallInfoHandler(void (FactGui::*handler)(const DimData&), const DimData &d)
     1372    {
     1373        fInHandler = true;
     1374        (this->*handler)(d);
     1375        fInHandler = false;
     1376    }
     1377
     1378    /*
     1379    void CallInfoHandler(const boost::function<void()> &func)
     1380    {
     1381        // This ensures that newly received values are not sent back to the emitter
     1382        // because changing the value emits the valueChanged signal (or similar)
     1383        fInHandler = true;
     1384        func();
     1385        fInHandler = false;
     1386    }*/
     1387
    13711388    void PostInfoHandler(void (FactGui::*handler)(const DimData&))
    13721389    {
    1373         QApplication::postEvent(this,
    1374                                 new FunctionEvent(boost::bind(handler, this, DimData(getInfo()))));
     1390        //const boost::function<void()> f = boost::bind(handler, this, DimData(getInfo()));
     1391
     1392        FunctionEvent *evt = new FunctionEvent(boost::bind(&FactGui::CallInfoHandler, this, handler, DimData(getInfo())));
     1393        // FunctionEvent *evt = new FunctionEvent(boost::bind(&FactGui::CallInfoHandler, this, f));
     1394        // FunctionEvent *evt = new FunctionEvent(boost::bind(handler, this, DimData(getInfo()))));
     1395
     1396        QApplication::postEvent(this, evt);
    13751397    }
    13761398
  • trunk/FACT++/gui/MainWindow.cc

    r10657 r10678  
    22
    33#include <iostream>
     4#include <sstream>
    45
    56#include <QTimer>
     
    3637    // Initialize the 40 FTU Leds as a copy of the prototype LED
    3738    fFtuLED[0] = fFtuLEDPrototype;
     39    fFtuLED[0]->setToolTip("Crate 0, Board 0, Index 0");
    3840
    3941    for (int i=1; i<40; i++)
     
    4951        b->setFlat(fFtuLEDPrototype->isFlat());
    5052
     53        ostringstream str;
     54        str << "Crate " << i/10 << ", Board " << i%10 << ", Index " << i;
     55        b->setToolTip(str.str().c_str());
     56
    5157        fFtuLedLayout->addWidget(b, i/10+1, i%10+1, 1, 1);
    5258
     
    126132    {
    127133        uint8_t(fTriggerSeqPed->value()),
    128         uint8_t(fTriggerSeqLPint->value()),
    129         uint8_t(fTriggerSeqLPext->value())
     134        uint8_t(fTriggerSeqLPext->value()),
     135        uint8_t(fTriggerSeqLPint->value())
    130136    };
    131137
    132     Dim::SendCommand("FTM_CONTROL/SET_TRIGGER_SEQUENCE", d);
     138    if (!fInHandler)
     139        Dim::SendCommand("FTM_CONTROL/SET_TRIGGER_SEQUENCE", d);
    133140}
    134141
     
    153160}
    154161
    155 void MainWindow::SetTriggerCoincidence()
    156 {
    157     const uint16_t d[2] =
    158     {
    159         uint16_t(fPhysicsCoincidence->value()),
    160         uint16_t(fPhysicsWindow->value()/4-2)
    161     };
    162 
    163     Dim::SendCommand("FTM_CONTROL/SET_TRIGGER_COINCIDENCE", d);
    164 }
    165 
    166 void MainWindow::SetCalibCoincidence()
    167 {
    168     const uint16_t d[2] =
    169     {
    170         uint16_t(fCalibCoincidence->value()),
    171         uint16_t(fCalibWindow->value()/4-2)
    172     };
    173 
    174     Dim::SendCommand("FTM_CONTROL/SET_CALIBRATION_COINCIDENCE", d);
     162void MainWindow::on_fPhysicsCoincidence_valueChanged(int v)
     163{
     164    if (!fInHandler)
     165        Dim::SendCommand("FTM_CONTROL/SET_TRIGGER_COINCIDENCE", v);
     166}
     167
     168void MainWindow::on_fPhysicsWindow_valueChanged(int v)
     169{
     170    if (!fInHandler)
     171        Dim::SendCommand("FTM_CONTROL/SET_TRIGGER_WINDOW", v/4-2);
     172}
     173
     174void MainWindow::on_fCalibCoincidence_valueChanged(int v)
     175{
     176    if (!fInHandler)
     177        Dim::SendCommand("FTM_CONTROL/SET_CALIBRATION_COINCIDENCE", v);
     178}
     179
     180void MainWindow::on_fCalibWindow_valueChanged(int v)
     181{
     182    if (!fInHandler)
     183        Dim::SendCommand("FTM_CONTROL/SET_CALIBRATION_WINDOW", v/4-2);
    175184}
    176185
     
    180189
    181190    const int32_t d[2] = { fThresholdIdx->value(), v };
    182     Dim::SendCommand("FTM_CONTROL/SET_THRESHOLD", d);
     191
     192    if (!fInHandler)
     193        Dim::SendCommand("FTM_CONTROL/SET_THRESHOLD", d);
    183194}
    184195
    185196void MainWindow::on_fTriggerInterval_valueChanged(int val)
    186197{
    187     Dim::SendCommand("FTM_CONTROL/SET_TRIGGER_INTERVAL", val);
     198    if (!fInHandler)
     199        Dim::SendCommand("FTM_CONTROL/SET_TRIGGER_INTERVAL", val);
    188200}
    189201
    190202void MainWindow::on_fTriggerDelay_valueChanged(int val)
    191203{
    192     Dim::SendCommand("FTM_CONTROL/SET_TRIGGER_DELAY", val/4-2);
     204    if (!fInHandler)
     205        Dim::SendCommand("FTM_CONTROL/SET_TRIGGER_DELAY", val/4-2);
    193206}
    194207
    195208void MainWindow::on_fTimeMarkerDelay_valueChanged(int val)
    196209{
    197     Dim::SendCommand("FTM_CONTROL/SET_TIME_MARKER_DELAY", val/4-2);
     210    if (!fInHandler)
     211        Dim::SendCommand("FTM_CONTROL/SET_TIME_MARKER_DELAY", val/4-2);
    198212}
    199213
    200214void MainWindow::on_fDeadTime_valueChanged(int val)
    201215{
    202     Dim::SendCommand("FTM_CONTROL/SET_DEAD_TIME", val/4-2);
     216    if (!fInHandler)
     217        Dim::SendCommand("FTM_CONTROL/SET_DEAD_TIME", val/4-2);
    203218}
    204219
    205220void MainWindow::on_fPrescalingVal_valueChanged(int val)
    206221{
    207     Dim::SendCommand("FTM_CONTROL/SET_PRESCALING", val);
     222    if (!fInHandler)
     223        Dim::SendCommand("FTM_CONTROL/SET_PRESCALING", val);
    208224}
    209225
  • trunk/FACT++/gui/MainWindow.h

    r10641 r10678  
    2020protected:
    2121    QPushButton *fFtuLED[40];
     22
     23    bool fInHandler;
    2224
    2325public:
     
    5153    void on_fTriggerSeqLPext_valueChanged(int) { SetTriggerSequence(); }
    5254
    53 
    54     void on_fPhysicsCoincidence_valueChanged(int) { SetTriggerCoincidence(); }
    55     void on_fPhysicsWindow_valueChanged(int)      { SetTriggerCoincidence(); }
    56 
    57     void on_fCalibCoincidence_valueChanged(int) { SetCalibCoincidence(); }
    58     void on_fCalibWindow_valueChanged(int)      { SetCalibCoincidence(); }
     55    void on_fPhysicsCoincidence_valueChanged(int);
     56    void on_fPhysicsWindow_valueChanged(int);
     57    void on_fCalibCoincidence_valueChanged(int);
     58    void on_fCalibWindow_valueChanged(int);
    5959
    6060    void on_fTriggerInterval_valueChanged(int);
Note: See TracChangeset for help on using the changeset viewer.