Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages

RxThresholdBasedOnConfigRegisterConfigUpdater.cpp

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     unsigned partition, crate, rod, channel;
00023     SctApi::Utility::getpcrc(mid, partition, crate, rod, channel);
00024   
00025     if (RxThresholdBasedOnConfigRegisterTestResult::StreamResult::isGoodPhysicalRxThresh(threshold)) {
00026       std::ostringstream os;
00027       os << "Setting Register " << REGISTER << " for link " << linkNumber << " of module " << mid << " named " << name << " in prcc " << partition << "/" << crate << "/" << rod << "/" << channel << " to " << threshold;
00028       SctNames::Mrs() << "CC_UPDATE" << MRS_INFORMATION << MRS_TEXT(os.str()) << ENDM;
00029 
00030       APICALL(api, modifyBOCParam(partition, crate, rod, channel, REGISTER, threshold ), "RxThresholdBasedOnConfigRegisterConfigUpdater failed to set threshold") ;
00031 
00032     } else {
00033       std::ostringstream os;
00034       os << "Warning: was unable to set the RxThreshold for link "<<linkNumber<<" of module " << mid << " named " << name << " in prcc " << partition << "/" << crate << "/" << rod << "/" << channel << " as the test was not able to determine a sensible value for it! ["<<threshold<<"]";
00035       SctNames::Mrs() << "CC_UPDATE" << MRS_WARNING << MRS_TEXT(os.str()) << ENDM;
00036     };
00037   };
00038 
00039 void RxThresholdBasedOnConfigRegisterConfigUpdater::update(const TestResult& testresult, Sct_SctApi::SctApiIPC_ptr api) const {
00040     const RxThresholdBasedOnConfigRegisterTestResult& t = dynamic_cast<const RxThresholdBasedOnConfigRegisterTestResult&> (testresult);
00041 
00042     unsigned long mid = getMID(t, api);
00043     SctNames::Mrs() << "CC_UPDATE" << MRS_TEXT("CalibrationController updating RxThresholdBasedOnConfigRegister") << MRS_PARAM<long>("ModuleID", mid) << MRS_DIAGNOSTIC << ENDM;
00044 
00045     const int link0Thresh = t.getStreamResult(0).bestRxThresh();
00046     const int link1Thresh = t.getStreamResult(1).bestRxThresh();
00047     
00048     const std::string & name = t.getModuleName();
00049 
00050     this->updateUsing(ST_RX_THRESHOLD0, link0Thresh, 0, api, mid, name);
00051     this->updateUsing(ST_RX_THRESHOLD1, link1Thresh, 1, api, mid, name);    
00052 }
00053     
00054 }

Generated on Fri Dec 16 19:38:17 2005 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5