Changeset 16772 for trunk/FACT++
- Timestamp:
- 06/08/13 12:27:45 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/ratecontrol.cc
r16565 r16772 130 130 } 131 131 132 // RETUNR VALUE 132 133 void Step(int idx, float step) 133 134 { … … 239 240 Step(i*4+j, step); 240 241 } 242 // SET_SELECTED_THRESHOLDS 243 241 244 } 242 245 } … … 371 374 PrintThresholds(sdata); 372 375 376 if (GetCurrentState()==RateControl::State::kSettingGlobalThreshold && fCalibrateByCurrent) 377 { 378 if (fThresholds.empty()) 379 return RateControl::State::kSettingGlobalThreshold; 380 381 if (!std::equal(sdata.fThreshold, sdata.fThreshold+160, fThresholds.begin())) 382 return RateControl::State::kSettingGlobalThreshold; 383 384 return RateControl::State::kGlobalThresholdSet; 385 } 386 373 387 fThresholds.assign(sdata.fThreshold, sdata.fThreshold+160); 374 388 … … 436 450 return GetCurrentState(); 437 451 452 // We are not setting thresholds at all 438 453 if (GetCurrentState()!=RateControl::State::kSettingGlobalThreshold) 454 return GetCurrentState(); 455 456 // Target thresholds have been assigned already 457 if (!fThresholds.empty()) 439 458 return GetCurrentState(); 440 459 … … 498 517 int counter = 1; 499 518 500 const int32_t val[2] = { -1, fThresholdMin };501 Dim::SendCommandNB("FTM_CONTROL/SET_THRESHOLD", val);502 503 519 double avg2 = 0; 504 520 for (int i=0; i<160; i++) … … 511 527 fThresholds[i] = max(uint16_t(40.5*pow(vec[i], 0.642)+164), fThresholdReference); 512 528 513 const int32_t dat[2] = { i, fThresholds[i] };514 Dim::SendCommandNB("FTM_CONTROL/SET_THRESHOLD", dat);515 516 fBlock[i/4] = true;517 518 529 counter++; 519 530 } 520 531 } 521 522 532 avg2 /= 160; 533 534 535 vector<int32_t> val(160, fThresholdMin); 536 std::copy(fThresholds.begin(), fThresholds.end(), val.begin()); 537 Dim::SendCommandNB("FTM_CONTROL/SET_ALL_THRESHOLDS", val.data(), val.size()*sizeof(int32_t)); 538 523 539 524 540 const RateControl::DimThreshold data = { fThresholdMin, fCalibrationTimeStart.Mjd(), Time().Mjd() }; … … 526 542 fDimThreshold.Update(data); 527 543 528 Info("Sent a total of "+to_string(counter)+" commands for threshold setting");544 //Info("Sent a total of "+to_string(counter)+" commands for threshold setting"); 529 545 530 546 ostringstream out; … … 532 548 out << "Measured average current " << avg << "uA +- " << rms << "uA [N=" << fCurrentsMed.size() << "]... mininum threshold set to " << fThresholdMin; 533 549 Info(out); 550 Info("Set "+to_string(counter)+" individual thresholds."); 534 551 535 552 fTriggerOn = false; 536 553 fPhysTriggerEnabled = false; 537 return RateControl::State::kGlobalThresholdSet; 554 555 return RateControl::State::kSettingGlobalThreshold; 538 556 } 539 557 … … 587 605 fCalibrationTimeStart = Time(); 588 606 fBlock.assign(160, false); 607 608 fThresholds.clear(); 589 609 590 610 ostringstream out;
Note:
See TracChangeset
for help on using the changeset viewer.