Changeset 16778 for trunk/FACT++


Ignore:
Timestamp:
06/08/13 12:56:21 (11 years ago)
Author:
tbretz
Message:
Set all thresholds at once after the steps have been calculated using the new SET_SELCTED_THRESHOLDS
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/ratecontrol.cc

    r16772 r16778  
    131131
    132132    // RETUNR VALUE
    133     void Step(int idx, float step)
     133    int32_t Step(int idx, float step)
    134134    {
    135135        uint16_t diff = fThresholds[idx]+int16_t(truncf(step));
     
    138138
    139139        if (diff==fThresholds[idx])
    140             return;
     140            return -1;
    141141
    142142        if (fVerbose)
     
    147147        }
    148148
    149         const uint32_t val[2] = { idx,  diff };
    150         Dim::SendCommandNB("FTM_CONTROL/SET_THRESHOLD", val);
     149        //const uint32_t val[2] = { idx,  diff };
     150        //Dim::SendCommandNB("FTM_CONTROL/SET_THRESHOLD", val);
    151151
    152152        fBlock[idx/4] = true;
     153
     154        return diff;
    153155    }
    154156
     
    186188        if (fVerbose)
    187189            Out() << Tools::Form("Board: Med=%3.1f +- %3.1f   Patch: Med=%3.1f +- %3.1f", mb, db, mp, dp) << endl;
     190
     191        vector<int32_t> newth(160, -1);
    188192
    189193        for (int i=0; i<40; i++)
     
    225229                    const float step = (log10(sdata.fPatchRate[i*4+j])-log10(mp+3.5*dp))/0.039;
    226230                    //  * (dif-5)/dif
    227                     Step(i*4+j, step);
     231                    newth[i*4+j] = Step(i*4+j, step);
    228232                    continue;
    229233                }
     
    233237                {
    234238                    const float step = (log10(sdata.fPatchRate[i*4+j])-log10(mp+3.5*dp))/0.039;
    235                     Step(i*4+j, step);
     239                    newth[i*4+j] = Step(i*4+j, step);
    236240                    continue;
    237241                }
    238242
    239243                const float step =  -1.5*(log10(mp+dp)-log10(mp))/0.039;
    240                 Step(i*4+j, step);
     244                newth[i*4+j] = Step(i*4+j, step);
    241245            }
    242             // SET_SELECTED_THRESHOLDS
    243 
    244         }
     246        }
     247
     248        // WARNING: By _not_ updating fThresholds here, we assume
     249        // the the returned static data block is received before the
     250        // next update. If not, we will just skip these patches (block
     251        // condition) and send the same update next time again.
     252        if (std::count(newth.begin(), newth.end(), -1)!=160)
     253            Dim::SendCommandNB("FTM_CONTROL/SET_SELECTED_THRESHOLDS", newth);
    245254    }
    246255
     
    535544        vector<int32_t> val(160, fThresholdMin);
    536545        std::copy(fThresholds.begin(), fThresholds.end(), val.begin());
    537         Dim::SendCommandNB("FTM_CONTROL/SET_ALL_THRESHOLDS", val.data(), val.size()*sizeof(int32_t));
     546        Dim::SendCommandNB("FTM_CONTROL/SET_ALL_THRESHOLDS", val);
    538547
    539548
Note: See TracChangeset for help on using the changeset viewer.