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

TrimRangeTest.h

00001 #ifndef TRIMRANGETEST_H
00002 #define TRIMRANGETEST_H
00003 
00004 #include "../ipc/TestRequest.h"
00005 #include "../ipc/CalibrationController.h"
00006 #include "../ipc/ScanLibrary.h"
00007 #include "../ipc/Sct_CalibrationController.hh"
00008 #include "../CalibrationControllerImpl.h"
00009 
00010 #include "../SctApiAccessException.h"
00011 #include "Sct/LogicErrors.h"
00012 #include "../SctApiCall.h"
00013 
00014 #include <CommonWithDsp/ABCD/ABCDscans.h>
00015 #include <iostream>
00016 #include <vector>
00017 
00018 using namespace std;
00019 using namespace SctCalibrationController::Ipc;
00020 using namespace SctCalibrationController;
00021 using namespace Sct;
00022 
00023 namespace SctCalibrationController {
00024 namespace Scripts {
00025     
00026 class TrimRangeTest : public TestRequestImpl {
00027 public: 
00028     static TrimRangeTest& instance() {
00029     static TrimRangeTest tr;
00030     return tr;
00031     }
00032     
00033     virtual void startTest(Sct_SctApi_T_SctApi& inapi, string& name, unsigned short& testVariable, unsigned long& nScans, vector<double>& testPoints) { 
00034     this->api = &inapi;
00035 
00036         // Compression mode X1X
00037         APICALL(api, modifyABCDVar(&st, ST_COMPRESSION, 1), "TrimRangeTest::startTest can't set compression")
00038 
00039         // Edge detect off
00040         APICALL(api, modifyABCDVar(&st, ST_EDGE_DETECT, 0), "TrimRangeTest::startTest can't set edge detect")
00041 
00042         // No masked channels
00043         APICALL(api, modifyABCDVar(&st, ST_SEND_MASK, 0), "TrimRangeTest::startTest can't set send mask")
00044 
00045         // QCAL (fC)
00046         APICALL(api, modifyABCDVar(&st, ST_QCAL, 1), "TrimRangeTest::startTest can't set qcal")
00047 
00048     name = "TrimRangeTest";
00049     testVariable=ST_TRIM_RANGE;
00050     for (unsigned int i=0; i<28; ++i) {
00051         testPoints.push_back(getValue(i));
00052     }
00053     nScans = testPoints.size();
00054     }
00055 
00056     virtual ScanRequest* getNextScan(unsigned long index) {
00057     if (isFirstPoint(index)) {
00058             // set trim range
00059         APICALL(api, modifyABCDVar(&st, ST_TRIM_RANGE, getRange(index)), "TrimRangeTest::getNextScan")
00060     }
00061         // set trim value
00062     APICALL(api, modifyABCDVar(&st, ST_TRIM, getValue(index)), "TrimRangeTest::getNextScan")
00063 
00064     ScanLibrary& sl = CalibrationControllerImpl::instance().getScanLibrary();
00065     double offset = ranges[getRange(index)] * getValue(index);
00066     return &sl.thresholdScanfCOffset(400, 1.0, offset);  // trim at 1 fC, but give it an offset
00067     }
00068 
00069     unsigned int getRange(unsigned int index) {
00070     if (index<16) return 0;
00071     else return (index-16)/4+1;
00072     }
00073     
00074     bool isFirstPoint(unsigned int index) {
00075     return (index-16)%4 == 0;
00076     }
00077     
00078     unsigned int getValue(unsigned int index) {
00079     if (index < 16) return index;
00080     unsigned int pointInRange = (index-16)%4;
00081     return (pointInRange+1)*4-1;
00082     }
00083     
00084     virtual bool canFeedback() {
00085     return true;
00086     }    
00087 
00088     virtual void endTest() {
00089     api = 0;
00090     }
00091         
00092 private:
00093     TrimRangeTest() {}
00094     Sct_SctApi_T_SctApi* api;
00095     static double ranges[4];
00096 };
00097 double TrimRangeTest::ranges[4] = {3.5, 6.5, 10, 13};
00098 }
00099 }
00100 #endif //TRIMRANGETEST_H

Generated on Thu Jul 15 09:51:01 2004 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5