00001 #include "RxThresholdBasedOnConfigRegisterConfigUpdater.h" 00002 #include "ConfigUpdaterManager.h" 00003 #include "../SctApiAccessException.h" 00004 #include "../SctApiCall.h" 00005 00006 #include "Sct_SctApi/SctApi.hh" 00007 #include "Sct/SctParameters.h" 00008 #include "Sct/SctNames.h" 00009 #include "SctData/RxThresholdBasedOnConfigRegisterTestResult.h" 00010 #include "Sct/AbcdScans.h" 00011 #include "SctApi/utility.h" 00012 00013 using namespace Sct; 00014 using namespace SctData; 00015 00016 namespace SctCalibrationController { 00017 00018 bool RxThresholdBasedOnConfigRegisterConfigUpdater::inMap = ConfigUpdaterManager::instance().setUpdater("SctData::RxThresholdBasedOnConfigRegisterTestResult", shared_ptr<ConfigUpdater> (new RxThresholdBasedOnConfigRegisterConfigUpdater())); 00019 00020 void RxThresholdBasedOnConfigRegisterConfigUpdater::updateUsing(const int REGISTER, const int threshold, const unsigned int linkNumber, Sct_SctApi::SctApiIPC_ptr api, const unsigned long mid, const std::string & name) { 00021 00022 if (RxThresholdBasedOnConfigRegisterTestResult::StreamResult::isGoodPhysicalRxThresh(threshold)) { 00023 std::ostringstream os; 00024 os << "Setting Register " << REGISTER << " for link " << linkNumber << " of module " << mid << " named " << name << " to " << threshold; 00025 SctNames::Mrs() << "CC_UPDATE" << MRS_INFORMATION << MRS_TEXT(os.str()) << ENDM; 00026 00027 APICALL(api, modifyABCDModuleVar(mid, REGISTER, threshold ), "RxThresholdBasedOnConfigRegisterConfigUpdater failed to set threshold") ; 00028 00029 } else { 00030 std::ostringstream os; 00031 os << "Warning: was unable to set the RxThreshold for link "<<linkNumber<<" of module " << mid << " named " << name << " as the test was not able to determine a sensible value for it! ["<<threshold<<"]"; 00032 SctNames::Mrs() << "CC_UPDATE" << MRS_WARNING << MRS_TEXT(os.str()) << ENDM; 00033 }; 00034 }; 00035 00036 void RxThresholdBasedOnConfigRegisterConfigUpdater::update(const TestResult& testresult, Sct_SctApi::SctApiIPC_ptr api) const { 00037 const RxThresholdBasedOnConfigRegisterTestResult& t = dynamic_cast<const RxThresholdBasedOnConfigRegisterTestResult&> (testresult); 00038 00039 unsigned long mid = getMID(t, api); 00040 SctNames::Mrs() << "CC_UPDATE" << MRS_TEXT("CalibrationController updating RxThresholdBasedOnConfigRegister") << MRS_PARAM<long>("ModuleID", mid) << MRS_DIAGNOSTIC << ENDM; 00041 00042 const int link0Thresh = t.getStreamResult(0).bestRxThresh(); 00043 const int link1Thresh = t.getStreamResult(1).bestRxThresh(); 00044 00045 const std::string & name = t.getModuleName(); 00046 00047 this->updateUsing(ST_RX_THRESHOLD0, link0Thresh, 0, api, mid, name); 00048 this->updateUsing(ST_RX_THRESHOLD1, link1Thresh, 1, api, mid, name); 00049 } 00050 00051 }