Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | 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/Sct_SctApi.hh"
00007 #include "Sct/SctParameters.h"
00008 #include "Sct/SctNames.h"
00009 #include "SctData/RxThresholdBasedOnConfigRegisterTestResult.h"
00010 #include "CommonWithDsp/ABCD/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_T_SctApi& api, const unsigned long mid, const std::string & name) {
00021     if (RxThresholdBasedOnConfigRegisterTestResult::StreamResult::isValidRxThresh(threshold)) {
00022       
00023       unsigned partition, crate, rod, channel;
00024       SctApi::Utility::getpcrc(mid, partition, crate, rod, channel);
00025   
00026       APICALL(&api, modifyBOCParam(&st, partition, crate, rod, channel, REGISTER, threshold ), "RxDelayConfigUpdater failed to set delay") ;
00027       std::ostringstream os;
00028       os << "Setting Register " << REGISTER << " for link " << linkNumber << " of module " << mid << " named " << name << " to " << threshold << endl;
00029       os << "Partition=" << partition << "; Crate=" << crate << "; Rod=" << rod << "; Chan=" << channel << endl;
00030       SctNames::Mrs() << "CC_UPDATE" << MRS_INFORMATION << MRS_TEXT(os.str()) << ENDM;
00031     } else {
00032       std::ostringstream os;
00033       os << "Warning: was unable to set the RxThreshold for link "<<linkNumber<<" of module " << mid << " as the test was not able to determine a sensible value for it!";
00034       SctNames::Mrs() << "CC_UPDATE" << MRS_WARNING << MRS_TEXT(os.str()) << ENDM;
00035     };
00036   };
00037 
00038 void RxThresholdBasedOnConfigRegisterConfigUpdater::update(const TestResult& testresult, Sct_SctApi_T_SctApi& api) const {
00039     const RxThresholdBasedOnConfigRegisterTestResult& t = dynamic_cast<const RxThresholdBasedOnConfigRegisterTestResult&> (testresult);
00040 
00041     unsigned long mid = getMID(t, api);
00042     SctNames::Mrs() << "CC_UPDATE" << MRS_TEXT("CalibrationController updating RxThresholdBasedOnConfigRegister") << MRS_PARAM<long>("ModuleID", mid) << MRS_DIAGNOSTIC << ENDM;
00043 
00044     const int link0Thresh = t.getStreamResult(0).bestRxThresh();
00045     const int link1Thresh = t.getStreamResult(1).bestRxThresh();
00046     
00047     const std::string & name = t.getModuleName();
00048 
00049     this->updateUsing(ST_RX_THRESHOLD0, link0Thresh, 0, api, mid, name);
00050     this->updateUsing(ST_RX_THRESHOLD1, link1Thresh, 1, api, mid, name);    
00051 }
00052     
00053 }

Generated on Fri Jan 14 12:47:06 2005 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5