TimClockDelayTest.h

00001 #ifndef TIMCLOCKDELAYTEST_H
00002 #define TIMCLOCKDELAYTEST_H
00003 
00004 #include <cmath>  // For fabs
00005 
00006 #include "../ipc/TestRequest.h"
00007 #include "../ipc/CalibrationController.hh"
00008 #include "../CalibrationControllerImpl.h"
00009 #include "../ipc/ScanRequest.h"
00010 #include "../SctApiAccessException.h"
00011 #include "../SctApiCall.h"
00012 #include "Sct/LogicErrors.h"
00013 
00014 #include <Sct/AbcdScans.h>
00015 #include <SctApi/extraScans.h>
00016 
00017 using namespace Sct;
00018 using namespace SctCalibrationController::Ipc;
00019 namespace SctCalibrationController {
00020 namespace Scripts {
00021 
00022 class TimClockDelayTest  : public TestRequestImpl {
00023 private:
00024    static const bool registeredInTestLibrary;
00025 
00026 public:
00027     static Sct_CalibrationController::TestRequest_ptr instance() {
00028       static TimClockDelayTest stnt;
00029       stnt.setFitAlgorithm("NONE");
00030       stnt.setAnalysisAlgorithm("DoubleTriggerNoiseTest");
00031       return stnt._this();
00032     }
00033 
00034     virtual void startTestRealImpl(Sct_SctApi::SctApiIPC_ptr api, string& name, unsigned short& testVariable, unsigned long& nScans, vector<double>& testPoints) {  
00035     this->api = Sct_SctApi::SctApiIPC::_duplicate(api);
00036 
00037         // Compression mode X1X
00038         APICALL(api, modifyABCDVar(ST_COMPRESSION, 1), "TimClockDelayTest::startTest")
00039 
00040         // Edge detect off
00041         APICALL(api, modifyABCDVar(ST_EDGE_DETECT, 0), "TimClockDelayTest::startTest")
00042 
00043         // No masked channels
00044         APICALL(api, modifyABCDVar(ST_SEND_MASK, 0), "TimClockDelayTest::startTest")
00045 
00046         // TIM external trigger and clock input
00047 #warning "Not needed if this was in SctApi"
00048         APICALL(api, timWriteRegister(0, 0, 0x00,0x300), "PreTriggerNoiseTest::startTest")
00049 
00050     name = "TimClockDelayTest";
00051     testVariable = ST_ELAPSED;
00052     nScans = 1;
00053     testPoints.push_back(0.);
00054     }
00055 
00056 
00057     virtual Sct_CalibrationController::ScanRequest_ptr getNextScanRealImpl(unsigned long index) {
00058         Sct_CalibrationController::ScanLibrary_var sl = CalibrationControllerImpl::instance()->getScanLibrary();
00059         Sct_CalibrationController::ScanRequest_ptr request = sl->defaultScan();
00060 
00061     // Create scan
00062         Sct_SctApi::Scan_var s;
00063         APIRETCALL(api, s, createScan(), "TimClockDelayTest::getNextScan")
00064         request->setScanCorba(s);
00065 
00066         // This doesn't work with group distribution which is the default otherwise
00067     APICALL(s, setOption(Sct_SctApi::Scan::distSlave, 0), "Failed to set distSlave option")
00068       
00069         const unsigned nth_trigger=1;
00070     APICALL(s, setOption(Sct_SctApi::Scan::tim, 8), "Failed to set TIM option")
00071     APICALL(s, setOption(Sct_SctApi::Scan::nth, nth_trigger), "Failed to set nth option")
00072 
00073         // request occupancy per event
00074     APICALL(s, setOption(Sct_SctApi::Scan::ope, 1), "Failed to set ope option")
00075 
00076     // Adjust trigger
00077         Sct_SctApi::Trigger_var t;
00078         APIRETCALL(s, t, getTrigger1(), "Failed to get trigger1")
00079         APICALL(t, singleL1A(), "Failed to set trigger type")
00080 
00081     // Configure scan - 0->25 ns in 0.5 ns steps (1 unit=0.5 ns).
00082         APICALL(s, configure(SCT_TIM_CLOCK_DELAY, 0, 50, 1), "Failed to set Scan information")
00083       
00084         // set the number of triggers
00085         APICALL(s, setNTrigs(10), "Failed to set triggers")
00086 
00087     return request;
00088     }
00089 
00090     virtual bool canFeedbackRealImpl() {
00091     return false;
00092     }
00093 
00094     virtual void endTestRealImpl() {
00095 
00096         // TIM internal triggers
00097         APICALL(api, timWriteRegister(0, 0,0x0,0x0), "PreTriggerNoiseTest::startTest")
00098 
00099     api = Sct_SctApi::SctApiIPC::_nil();
00100     }
00101 
00102 private:
00103     TimClockDelayTest() {}
00104     Sct_SctApi::SctApiIPC_var api;
00105 };
00106     
00107 }
00108 }
00109 
00110 #endif //TIMCLOCKDELAYTEST_H

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