RxThresholdBasedOnConfigRegisterTest.h

00001 #ifndef SCTCALIBRATIONCONTROLLER_RXTHRESHOLDBASEDONCONFIGREGISTERTEST_H
00002 #define SCTCALIBRATIONCONTROLLER_RXTHRESHOLDBASEDONCONFIGREGISTERTEST_H
00003 
00004 #include "../ipc/TestRequest.h"
00005 #include "../ipc/CalibrationController.h"
00006 #include "../ipc/ScanLibrary.h"
00007 #include "../ipc/CalibrationController.hh"
00008 
00009 #include "../SctApiAccessException.h"
00010 #include "../SctApiCall.h"
00011 #include "../CalibrationControllerImpl.h"
00012 #include "Sct/LogicErrors.h"
00013 #include "Sct/SctParameters.h"
00014 #include "SctApi/extraScans.h"
00015 
00016 #include <Sct/AbcdScans.h>
00017 #include <iostream>
00018 #include <vector>
00019 
00020 using namespace Sct;
00021 using namespace std;
00022 using namespace SctCalibrationController::Ipc;
00023 using namespace SctCalibrationController;
00024 
00025 namespace SctCalibrationController {
00026 namespace Scripts {
00027     
00028 class RxThresholdBasedOnConfigRegisterTest : public TestRequestImpl {
00029 private:
00030    static const bool registeredInTestLibrary;
00031 
00032 public:
00033    static Sct_CalibrationController::TestRequest_ptr instance() {
00034     static RxThresholdBasedOnConfigRegisterTest rt;
00035     rt.setFitAlgorithm("NONE");
00036     rt.setAnalysisAlgorithm("RxThresholdBasedOnConfigRegisterTest");
00037     return rt._this();
00038     }
00039    
00040    virtual void startTestRealImpl(Sct_SctApi::SctApiIPC_ptr the_api, string& name, unsigned short& testVariable, unsigned long& nScans, vector<double>& testPoints) {   
00041      this->api = Sct_SctApi::SctApiIPC::_duplicate(the_api);
00042      // No masked channels
00043      name = "RxThresholdBasedOnConfigRegisterTest";
00044      testVariable = ST_ELAPSED;
00045      nScans = 1;
00046      testPoints.push_back(nTriggers);
00047 
00048      
00049      APICALL(api, modifyABCDVar(ST_CAL_MODE,1), "DoubleTriggerNoiseTest::startTest");
00050      APICALL(api, modifyABCDVar(ST_COMPRESSION,1), "DoubleTriggerNoiseTest::startTest");
00051      APICALL(api, modifyABCDVar(ST_TRIM_RANGE,1), "DoubleTriggerNoiseTest::startTest");
00052      
00053      // set
00054      for (unsigned ichip=0; ichip<Sct::nChipLink; ++ichip){
00055        APICALL(api, modifyABCDVarAllModulesOneChip(ichip, ST_CAL_MODE,2), "DoubleTriggerNoiseTest::startTest");
00056        APICALL(api, modifyABCDVarAllModulesOneChip(ichip, ST_COMPRESSION,2), "DoubleTriggerNoiseTest::startTest");
00057        APICALL(api, modifyABCDVarAllModulesOneChip(ichip, ST_TRIM_RANGE,2), "DoubleTriggerNoiseTest::startTest");
00058      }
00059    }
00060 
00061    
00062    virtual Sct_CalibrationController::ScanRequest_ptr getNextScanRealImpl(unsigned long index) {
00063      Sct_CalibrationController::ScanLibrary_var sl = CalibrationControllerImpl::instance()->getScanLibrary();
00064      const bool issueSoftReset = true;
00065      Sct_CalibrationController::ScanRequest_ptr request = sl->rawScan(nTriggers, issueSoftReset);
00066      Sct_SctApi::Scan_var scan = request->getScanCorba();
00067        // Number of bytes to read from the conf register: There should be about 210 ish bytes.  We will read a few more just so we have some elbow room.  Rather arbitrarily, then we chose to read 256 bits:
00068      const int bitsToRead = 256;
00069      request->setWidthCorba(bitsToRead);
00070      
00071      // This next two executable lines (which disables data
00072      // mode, and thus enables SendConfRegister mode) 
00073      // is the second line which (beyond the test names!) 
00074      // should be the source of difference between THIS
00075      // test and the usual RxThresholdTest:
00076      APICALL(scan, setOption(Sct_SctApi::Scan::enableDataMode, 0), "Failed to disable dataMode (failed to enable SendConfRegIDMode)")
00077        
00078      APICALL(scan, configure(ST_RX_THRESHOLD, 0, 255, 5), "Failed to set Scan information")
00079      return request;
00080    }
00081     
00082     virtual bool canFeedbackRealImpl() {
00083     return true;
00084     }
00085     
00086     virtual void endTestRealImpl() {
00087       api = Sct_SctApi::SctApiIPC::_nil();
00088     }
00089 
00090 private:
00091     RxThresholdBasedOnConfigRegisterTest() {}
00092     Sct_SctApi::SctApiIPC_var api;    
00093     static const int nTriggers = 10;
00094 };
00095 }
00096 }
00097 #endif //SCTCALIBRATIONCONTROLLER_RXTHRESHOLDBASEDONCONFIGREGISTERTEST_H

Generated on Mon Feb 6 14:01:26 2006 for SCT DAQ/DCS Software - C++ by  doxygen 1.4.6