Changeset 10959


Ignore:
Timestamp:
06/09/11 19:42:29 (13 years ago)
Author:
tbretz
Message:
Implemented Enable/Disable all button; added the correct hw/sw-pixel mapping; added the (in?)correct hw/sw patch mapping
Location:
trunk/FACT++/gui
Files:
3 edited

Legend:

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

    r10953 r10959  
    278278    }
    279279
    280     char* GetObjectInfo(Int_t px, Int_t py) const
     280    char *GetObjectInfo(Int_t px, Int_t py) const
    281281    {
    282282        static stringstream stream;
     
    290290        stream.seekp(0);
    291291        if (idx>=0)
    292             stream << "Pixel=" << idx << "(" <</* fMapHW[idx] <<*/ ")   Data=" << fData[idx] << '\0';
     292        {
     293            stream << "Pixel=" << idx << "   Data=" << fData[idx] << '\0';
     294        }
    293295
    294296        str = stream.str();
     
    330332    valarray<int8_t> fFtuStatus;
    331333
    332 //    vector<int>  fMapHW; // Software -> Hardware
    333 //    map<int,int> fMapSW; // Hardware -> Software
     334    vector<int>  fPixelMapHW; // Software -> Hardware
     335    vector<int>  fPatchMapHW; // Software -> Hardware
     336
     337    bool fInChoosePatch; // FIXME. Find a better solution
    334338
    335339    DimStampedInfo fDimDNS;
     
    11521156
    11531157        if (fThresholdIdx->value()>=0)
    1154             fPatchRate->setValue(sdata.fRatePatch[fThresholdIdx->value()]);
     1158        {
     1159            const int isw = fThresholdIdx->value();
     1160            const int ihw = fPatchMapHW[isw];
     1161            fPatchRate->setValue(sdata.fRatePatch[ihw]);
     1162        }
    11551163
    11561164        valarray<double> dat(0., 1440);
    11571165
     1166        // fPatch converts from software id to software patch id
    11581167        for (int i=0; i<1440; i++)
    11591168            dat[i] = sdata.fRatePatch[fPatch[i]];
     
    13211330#ifdef HAVE_ROOT
    13221331        Camera *cam = (Camera*)fRatesCanv->GetCanvas()->FindObject("Camera");
    1323         for (int i=0; i<1440; i++)
    1324             cam->SetEnable(i, sdata.IsEnabled(i));
     1332        for (int isw=0; isw<1440; isw++)
     1333        {
     1334            const int ihw = fPixelMapHW[isw];
     1335            cam->SetEnable(isw, sdata.IsEnabled(ihw));
     1336        }
    13251337
    13261338        fRatesCanv->GetCanvas()->Modified();
     
    13281340#endif
    13291341
    1330         fPixelEnable->setChecked(sdata.IsEnabled(fPixelIdx->value()));
    1331 
    1332 
    1333 
    1334         const int patch1 = fThresholdIdx->value();
    1335         if (patch1>=0)
    1336             fThresholdVal->setValue(sdata.fThreshold[patch1]);
     1342        {
     1343            const int  isw = fPixelIdx->value();
     1344            const int  ihw = fPixelMapHW[isw];
     1345            const bool on  = sdata.IsEnabled(ihw);
     1346            fPixelEnable->setChecked(on);
     1347        }
     1348
     1349        if (fThresholdIdx->value()>=0)
     1350        {
     1351            const int isw = fThresholdIdx->value();
     1352            const int ihw = fPatchMapHW[isw];
     1353            fThresholdVal->setValue(sdata.fThreshold[ihw]);
     1354        }
    13371355
    13381356        fPrescalingVal->setValue(sdata.fPrescaling[0]);
     
    18371855
    18381856                Camera *cam = static_cast<Camera*>(obj);
    1839                 const int idx = cam->GetIdx(xx, yy);
    1840 
    1841                 cout << "Select: " << idx << endl;
    1842 
    1843                 fPixelIdx->setValue(idx);
    1844                 ChoosePixel(*cam, idx);
    1845 
     1857                const int isw = cam->GetIdx(xx, yy);
     1858
     1859                fPixelIdx->setValue(isw);
     1860                ChoosePixel(*cam, isw);
    18461861            }
    18471862            return;
     
    18561871
    18571872                Camera *cam = static_cast<Camera*>(obj);
    1858                 const int idx = cam->GetIdx(xx, yy);
    1859 
    1860                 cout << "Toggle: " << idx << endl;
    1861 
    1862                 ChoosePixel(*cam, idx);
    1863 
    1864                 fPixelIdx->setValue(idx);
    1865 
    1866                 Dim::SendCommand("FTM_CONTROL/TOGGLE_PIXEL", uint16_t(idx));
     1873                const int isw = cam->GetIdx(xx, yy);
     1874
     1875                ChoosePixel(*cam, isw);
     1876
     1877                fPixelIdx->setValue(isw);
     1878
     1879                const uint16_t ihw = fPixelMapHW[isw];
     1880
     1881                Dim::SendCommand("FTM_CONTROL/TOGGLE_PIXEL", ihw);
    18671882            }
    18681883
     
    18991914
    19001915            Camera *cam = static_cast<Camera*>(obj);
    1901             int idx = fPatch[cam->GetIdx(xx, yy)];
    1902 
    1903             tipText+="  Patch=";
    1904             tipText+=QString::number(idx);
     1916
     1917            const int isw = cam->GetIdx(xx, yy);
     1918            const int ihw = fPixelMapHW[isw];
     1919
     1920            const int idx = fPatch[isw];
     1921
     1922            const int patch =  ihw%4;
     1923            const int board = (ihw/4)%10;
     1924            const int crate = (ihw/4)/10;
     1925
     1926            ostringstream str;
     1927            str << "  HW=" << ihw << "  Patch=" << idx << "  (Crate=" << crate << " Board=" << board << " Patch=" << patch << ")";
     1928
     1929            tipText += str.str().c_str();
    19051930        }
    19061931
     
    19181943    }
    19191944
    1920     void ChoosePatch(Camera &cam, int idx)
     1945    void ChoosePatch(Camera &cam, int isw)
    19211946    {
    19221947        cam.Reset();
    19231948
    1924         fThresholdIdx->setValue(idx);
    1925 
    1926         const int patch = idx%4;
    1927         const int board = (idx/4)%10;
    1928         const int crate = (idx/4)/10;
     1949        fThresholdIdx->setValue(isw);
     1950
     1951        const int ihw = isw<0 ? 0 : fPatchMapHW[isw];
     1952
     1953        fPatchRate->setEnabled(isw>=0);
     1954        fThresholdCrate->setEnabled(isw>=0);
     1955        fThresholdBoard->setEnabled(isw>=0);
     1956        fThresholdPatch->setEnabled(isw>=0);
     1957
     1958        if (isw<0)
     1959            return;
     1960
     1961        const int patch = ihw%4;
     1962        const int board = (ihw/4)%10;
     1963        const int crate = (ihw/4)/10;
     1964
     1965        fInChoosePatch = true;
    19291966
    19301967        fThresholdCrate->setValue(crate);
     
    19321969        fThresholdPatch->setValue(patch);
    19331970
    1934         //fThresholdVal->setEnabled(idx>=0);
    1935         //fThresholdVolt->setEnabled(idx>=0);
    1936         fPatchRate->setEnabled(idx>=0);
    1937         if (idx<0)
    1938             return;
    1939 
    1940         fThresholdVal->setValue(fFtmStaticData.fThreshold[idx]);
    1941         fPatchRate->setValue(cam.GetData(idx));
     1971        fInChoosePatch = false;
     1972
     1973        fThresholdVal->setValue(fFtmStaticData.fThreshold[ihw]);
     1974        fPatchRate->setValue(cam.GetData(isw));
    19421975
    19431976        for (unsigned int i=0; i<fPatch.size(); i++)
    1944             if (fPatch[i]==idx)
     1977            if (fPatch[i]==isw)
    19451978                cam.SetBold(i);
    19461979    }
    19471980
    1948     void ChoosePixel(Camera &cam, int idx)
    1949     {
    1950         cam.SetWhite(idx);
    1951         ChoosePatch(cam, fPatch[idx]);
    1952 
    1953         fPixelEnable->setChecked(fFtmStaticData.IsEnabled(idx));
    1954     }
    1955 
    1956     void UpdatePatch(int idx)
     1981    void ChoosePixel(Camera &cam, int isw)
     1982    {
     1983        cam.SetWhite(isw);
     1984        ChoosePatch(cam, fPatch[isw]);
     1985
     1986        const int  ihw = fPixelMapHW[isw];
     1987        const bool on  = fFtmStaticData.IsEnabled(ihw);
     1988        fPixelEnable->setChecked(on);
     1989    }
     1990
     1991    void UpdatePatch(int isw)
    19571992    {
    19581993        Camera *cam = (Camera*)fRatesCanv->GetCanvas()->FindObject("Camera");
    1959         ChoosePatch(*cam, idx);
    1960     }
    1961 
    1962     void on_fThresholdIdx_valueChanged(int idx)
    1963     {
    1964         UpdatePatch(idx);
     1994        ChoosePatch(*cam, isw);
     1995    }
     1996
     1997    void on_fThresholdIdx_valueChanged(int isw)
     1998    {
     1999        UpdatePatch(isw);
     2000
     2001        fRatesCanv->GetCanvas()->Modified();
     2002        fRatesCanv->GetCanvas()->Update();
    19652003    }
    19662004
    19672005    void UpdateThresholdIdx()
    19682006    {
     2007        if (fInChoosePatch)
     2008            return;
     2009
    19692010        const int crate = fThresholdCrate->value();
    19702011        const int board = fThresholdBoard->value();
    19712012        const int patch = fThresholdPatch->value();
    19722013
    1973         const int id = patch + board*4 + crate*40;
    1974 
    1975         UpdatePatch(id);
     2014        const int ihw = patch + board*4 + crate*40;
     2015
     2016        int isw = 0;
     2017        for (; isw<160; isw++)
     2018            if (ihw==fPatchMapHW[isw])
     2019                break;
     2020
     2021        UpdatePatch(isw);
    19762022    }
    19772023
     
    19892035    }
    19902036
    1991     void on_fPixelIdx_valueChanged(int idx)
     2037    void on_fPixelIdx_valueChanged(int isw)
    19922038    {
    19932039        Camera *cam = (Camera*)fRatesCanv->GetCanvas()->FindObject("Camera");
    1994         ChoosePixel(*cam, idx);
     2040        ChoosePixel(*cam, isw);
    19952041
    19962042        fRatesCanv->GetCanvas()->Modified();
     
    19982044    }
    19992045#endif
     2046
     2047    void on_fPixelEnable_stateChanged(int b)
     2048    {
     2049        if (fInHandler)
     2050            return;
     2051
     2052        const uint16_t isw = fPixelIdx->value();
     2053        const uint16_t ihw = fPixelMapHW[isw];
     2054
     2055        Dim::SendCommand(b==Qt::Unchecked ?
     2056                         "FTM_CONTROL/DISABLE_PIXEL" : "FTM_CONTROL/ENABLE_PIXEL",
     2057                         ihw);
     2058    }
     2059
     2060    void on_fPixelDisableOthers_clicked()
     2061    {
     2062        const uint16_t isw = fPixelIdx->value();
     2063        const uint16_t ihw = fPixelMapHW[isw];
     2064
     2065        Dim::SendCommand("FTM_CONTROL/DISABLE_ALL_PIXELS_EXCEPT", ihw);
     2066    }
     2067
     2068    void on_fThresholdVal_valueChanged(int v)
     2069    {
     2070        fThresholdVolt->setValue(2500./4095*v);
     2071
     2072        const int32_t isw = fThresholdIdx->value();
     2073        const int32_t ihw = fPatchMapHW[isw];
     2074
     2075        const int32_t d[2] = { ihw, v };
     2076
     2077        if (!fInHandler)
     2078            Dim::SendCommand("FTM_CONTROL/SET_THRESHOLD", d);
     2079    }
    20002080
    20012081    TGraph fGraphFtmTemp[4];
     
    20332113public:
    20342114    FactGui() :
    2035         fFtuStatus(40), //fMapHW(1440)
     2115        fFtuStatus(40), fPixelMapHW(1440), fPatchMapHW(160),
     2116        fInChoosePatch(false),
    20362117        fDimDNS("DIS_DNS/VERSION_NUMBER", 1, int(0), this),
    20372118
     
    20912172
    20922173        // --------------------------------------------------------------------------
    2093 /*
    2094         ifstream fin2("FACTmapV3.txt");
     2174
     2175        ifstream fin2("MasterList-v3.txt");
    20952176
    20962177        l = 0;
     
    21022183                continue;
    21032184
    2104             int softid, hardid, geom_i, geom_j,  gapd;
     2185            int softid, hardid, dummy;
     2186
     2187            stringstream str(buf);
     2188
     2189            str >> softid;
     2190            str >> dummy;
     2191            str >> hardid;
     2192
     2193            fPixelMapHW[softid] = hardid;
     2194
     2195            l++;
     2196        }
     2197
     2198        // --------------------------------------------------------------------------
     2199
     2200        ifstream fin3("PatchList.txt");
     2201
     2202        l = 0;
     2203
     2204        while (getline(fin3, buf, '\n'))
     2205        {
     2206            buf = Tools::Trim(buf);
     2207            if (buf[0]=='#')
     2208                continue;
     2209
     2210            int softid, hardid;
    21052211
    21062212            stringstream str(buf);
     
    21082214            str >> softid;
    21092215            str >> hardid;
    2110             str >> geom_i;
    2111             str >> geom_j;
    2112             str >> gapd;
    2113 
    2114             fMapHW[softid] = hardid;
    2115             fMapSW[hardid] = softid;
     2216
     2217            fPatchMapHW[softid] = hardid-1;
    21162218
    21172219            l++;
    21182220        }
    2119 */
     2221
    21202222        // --------------------------------------------------------------------------
    21212223#ifdef HAVE_ROOT
     
    22012303        cam->Draw();
    22022304
    2203         ChoosePixel(*cam, 1);
     2305        ChoosePixel(*cam, 0);
    22042306
    22052307//        QTimer::singleShot(0, this, SLOT(slot_RootUpdate()));
  • trunk/FACT++/gui/MainWindow.cc

    r10953 r10959  
    205205}
    206206
    207 void MainWindow::on_fThresholdVal_valueChanged(int v)
    208 {
    209     fThresholdVolt->setValue(2500./4095*v);
    210 
    211     const int32_t d[2] = { fThresholdIdx->value(), v };
    212 
    213     if (!fInHandler)
    214         Dim::SendCommand("FTM_CONTROL/SET_THRESHOLD", d);
    215 }
    216 
    217207void MainWindow::on_fTriggerInterval_valueChanged(int val)
    218208{
     
    245235}
    246236
    247 void MainWindow::on_fPixelEnable_stateChanged(int b)
    248 {
    249     if (!fInHandler)
    250         Dim::SendCommand(b==Qt::Unchecked ?
    251                          "FTM_CONTROL/DISABLE_PIXEL" : "FTM_CONTROL/ENABLE_PIXEL",
    252                          uint16_t(fPixelIdx->value()));
    253 }
    254 
    255 void MainWindow::on_fPixelDisableOthers_clicked()
    256 {
    257     Dim::SendCommand("FTM_CONTROL/DISABLE_ALL_PIXELS_EXCEPT",
    258                      uint16_t(fPixelIdx->value()));
     237void MainWindow::on_fPixelEnableAll_clicked()
     238{
     239    Dim::SendCommand("FTM_CONTROL/ENABLE_PIXEL", int16_t(-1));
     240}
     241
     242void MainWindow::on_fPixelDisableAll_clicked()
     243{
     244    Dim::SendCommand("FTM_CONTROL/DISABLE_PIXEL", int16_t(-1));
    259245}
    260246
  • trunk/FACT++/gui/design.ui

    r10953 r10959  
    24912491              </item>
    24922492              <item>
     2493               <layout class="QHBoxLayout" name="horizontalLayout_24">
     2494                <property name="topMargin">
     2495                 <number>0</number>
     2496                </property>
     2497                <item>
     2498                 <widget class="QPushButton" name="fPixelEnableAll">
     2499                  <property name="text">
     2500                   <string>Enable all</string>
     2501                  </property>
     2502                 </widget>
     2503                </item>
     2504                <item>
     2505                 <widget class="QPushButton" name="fPixelDisableAll">
     2506                  <property name="text">
     2507                   <string>Disable all</string>
     2508                  </property>
     2509                 </widget>
     2510                </item>
     2511               </layout>
     2512              </item>
     2513              <item>
    24932514               <layout class="QHBoxLayout" name="horizontalLayout_22">
    24942515                <property name="topMargin">
    24952516                 <number>0</number>
    24962517                </property>
    2497                 <item>
    2498                  <spacer name="horizontalSpacer_29">
    2499                   <property name="orientation">
    2500                    <enum>Qt::Horizontal</enum>
    2501                   </property>
    2502                   <property name="sizeType">
    2503                    <enum>QSizePolicy::Minimum</enum>
    2504                   </property>
    2505                   <property name="sizeHint" stdset="0">
    2506                    <size>
    2507                     <width>40</width>
    2508                     <height>20</height>
    2509                    </size>
    2510                   </property>
    2511                  </spacer>
    2512                 </item>
    25132518                <item>
    25142519                 <widget class="QPushButton" name="fPixelDisableOthers">
     
    25582563                </property>
    25592564                <property name="maximum">
    2560                  <number>1438</number>
     2565                 <number>159</number>
    25612566                </property>
    25622567                <property name="value">
     
    25702575                 <number>0</number>
    25712576                </property>
    2572                 <item>
    2573                  <spacer name="horizontalSpacer_31">
    2574                   <property name="orientation">
    2575                    <enum>Qt::Horizontal</enum>
    2576                   </property>
    2577                   <property name="sizeType">
    2578                    <enum>QSizePolicy::Minimum</enum>
    2579                   </property>
    2580                   <property name="sizeHint" stdset="0">
    2581                    <size>
    2582                     <width>40</width>
    2583                     <height>20</height>
    2584                    </size>
    2585                   </property>
    2586                  </spacer>
    2587                 </item>
    25882577                <item>
    25892578                 <widget class="QPushButton" name="fThresholdDisableOthers">
Note: See TracChangeset for help on using the changeset viewer.