Changeset 13956
- Timestamp:
- 05/29/12 12:42:40 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/ratecontrol.cc
r13915 r13956 16 16 17 17 #include "HeadersFTM.h" 18 #include "HeadersRateScan.h" 18 19 #include "HeadersRateControl.h" 19 20 … … 41 42 DimDescribedState fDimFTM; 42 43 DimDescribedState fDimRS; 44 45 DimDescribedService fDimThreshold; 43 46 44 47 float fTargetRate; … … 218 221 } 219 222 220 voidProcessCamera(const FTM::DimTriggerRates &sdata)223 int ProcessCamera(const FTM::DimTriggerRates &sdata) 221 224 { 222 225 if (fCounter++==0) 223 return ;226 return GetCurrentState(); 224 227 225 228 // Caluclate Median and deviation … … 241 244 { 242 245 Warn("The median or the deviation of all board rates is zero... cannot calibrate."); 243 return ;246 return GetCurrentState(); 244 247 } 245 248 … … 283 286 { 284 287 fThresholds.assign(160, fThresholdMin); 285 return; 288 fDimThreshold.Update(fThresholdMin); 289 return RateControl::State::kGlobalThresholdSet; 286 290 } 287 291 … … 292 296 const uint16_t diff = fThresholdMin+int16_t(truncf(step)); 293 297 if (diff<=fThresholdMin) 294 return; 298 { 299 fDimThreshold.Update(fThresholdMin); 300 return RateControl::State::kGlobalThresholdSet; 301 } 295 302 296 303 if (fVerbose) … … 306 313 307 314 fThresholdMin = diff; 315 316 return GetCurrentState(); 308 317 } 309 318 … … 328 337 return GetCurrentState(); 329 338 330 if (!fTriggerOn && !fEnabled) 331 return GetCurrentState(); 332 333 if (fDimRS.state()>=5) 339 if (GetCurrentState()<=RateControl::State::kConnected || 340 GetCurrentState()==RateControl::State::kGlobalThresholdSet) 334 341 return GetCurrentState(); 335 342 … … 340 347 341 348 if (GetCurrentState()==RateControl::State::kSettingGlobalThreshold) 342 ProcessCamera(sdata);349 return ProcessCamera(sdata); 343 350 344 351 if (GetCurrentState()==RateControl::State::kInProgress) … … 363 370 fThresholdMin = fThresholdReference; 364 371 fTriggerRate = -1; 365 fEnabled = true;366 372 fCounter = 0; 367 373 … … 385 391 } 386 392 387 int SetEnabled(const EventImp &evt)388 {389 if (!CheckEventSize(evt, 1))390 return kSM_FatalError;391 392 fEnabled = evt.GetBool();393 394 return GetCurrentState();395 }396 397 393 int SetMinThreshold(const EventImp &evt) 398 394 { … … 438 434 int Execute() 439 435 { 440 // Dispatch (execute) at most one handler from the queue. In contrary441 // to run_one(), it doesn't wait until a handler is available442 // which can be dispatched, so poll_one() might return with 0443 // handlers dispatched. The handlers are always dispatched/executed444 // synchronously, i.e. within the call to poll_one()445 //poll_one();446 447 436 if (!fDim.online()) 448 437 return RateControl::State::kDimNetworkNA; … … 453 442 454 443 if (GetCurrentState()==RateControl::State::kSettingGlobalThreshold) 455 { 456 if (fTriggerRate<0 || fTriggerRate>fTargetRate) 457 return RateControl::State::kSettingGlobalThreshold; 458 444 return RateControl::State::kSettingGlobalThreshold; 445 446 if (GetCurrentState()==RateControl::State::kGlobalThresholdSet) 459 447 return RateControl::State::kGlobalThresholdSet; 460 } 461 462 if (GetCurrentState()==RateControl::State::kGlobalThresholdSet) 463 { 464 if (!fTriggerOn) 465 return RateControl::State::kGlobalThresholdSet; 466 //return RateControl::State::kInProgress; 467 } 468 469 // At least one subsystem is not connected 470 // if (fDimFTM.state()>=FTM::kConnected) 471 return fTriggerOn && fEnabled && fDimRS.state()<5 ? RateControl::State::kInProgress : RateControl::State::kConnected; 448 449 if (fEnabled && fTriggerOn && fDimRS.state()<RateScan::State::kConfiguring) 450 return RateControl::State::kInProgress; 451 452 return RateControl::State::kConnected; 472 453 } 473 454 … … 476 457 fTriggerOn(false), fBlock(40), 477 458 fDimFTM("FTM_CONTROL"), 478 fDimRS("RATE_SCAN") 459 fDimRS("RATE_SCAN"), 460 fDimThreshold("THRESHOLD", "S:1", "Resulting threshold after calibration|threshold[dac]:Resulting threshold from calibration") 479 461 { 480 462 // ba::io_service::work is a kind of keep_alive for the loop. … … 514 496 (""); 515 497 516 AddEvent("START", "" )498 AddEvent("START", "", RateControl::State::kConnected, RateControl::State::kGlobalThresholdSet) 517 499 (bind(&StateMachineRateControl::StartRC, this)) 518 500 (""); 519 501 520 AddEvent("STOP", "" )502 AddEvent("STOP", "", RateControl::State::kSettingGlobalThreshold, RateControl::State::kInProgress) 521 503 (bind(&StateMachineRateControl::StopRC, this)) 522 504 ("");
Note:
See TracChangeset
for help on using the changeset viewer.