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

DoubleTriggerNoiseTest.h

00001 #ifndef DOUBLETRIGGERNOISETEST_H
00002 #define DOUBLETRIGGERNOISETEST_H
00003 
00004 #include <cmath>  // For fabs
00005 
00006 #include "../ipc/Sct_CalibrationController.hh"
00007 #include "../CalibrationControllerImpl.h"
00008 #include "../ipc/ScanRequest.h"
00009 #include "../SctApiAccessException.h"
00010 #include "../SctApiCall.h"
00011 #include "Sct/LogicErrors.h"
00012 
00013 #include <CommonWithDsp/ABCD/ABCDscans.h>
00014 
00015 using namespace Sct;
00016 using namespace SctCalibrationController::Ipc;
00017 namespace SctCalibrationController {
00018 namespace Scripts {
00019 
00020 class DoubleTriggerNoiseTest  : public TestRequestImpl {
00021 public:
00022     static DoubleTriggerNoiseTest& instance() {
00023       static DoubleTriggerNoiseTest dtnt;
00024       return dtnt;
00025     }
00026 
00027     virtual void startTest(Sct_SctApi_T_SctApi& api, string& name, unsigned short& testVariable, unsigned long& nScans, vector<double>& testPoints) {   
00028     this->api = &api;
00029 
00030         // Compression mode X1X
00031         APICALL(&api, modifyABCDVar(&st, ST_COMPRESSION, 1), "DoubleTriggerNoiseTest::startTest")
00032 
00033         // Edge detect off
00034         APICALL(&api, modifyABCDVar(&st, ST_EDGE_DETECT, 0), "DoubleTriggerNoiseTest::startTest")
00035 
00036         // No masked channels
00037         APICALL(&api, modifyABCDVar(&st, ST_SEND_MASK, 0), "DoubleTriggerNoiseTest::startTest")
00038 
00039         // 1 fC threshold
00040         APICALL(&api, modifyABCDVar(&st, ST_QTHR, 0.9), "DoubleTriggerNoiseTest::startTest")
00041 
00042     name = "DoubleTriggerNoiseTest";
00043     testVariable = ST_ELAPSED;
00044     nScans = 1;
00045     testPoints.push_back(0.);
00046     }
00047 
00048 
00049     virtual ScanRequest* getNextScan(unsigned long index) {
00050         ScanLibrary& sl = CalibrationControllerImpl::instance().getScanLibrary();
00051         ScanRequestImpl& request = sl.defaultScan();
00052 
00053     // Create scan
00054         Sct_SctApi_T_Scan* s = 0;
00055         APIRETCALL(api, s, createScan(&st), "DoubleTriggerNoiseTest::getNextScan")
00056         request.setScan(s);
00057 
00058         APICALL(s, setNTrigs(&st, 100000), "Failed to set triggers")
00059 
00060         // This doesn't work with group distribution which is the default otherwise
00061     APICALL(s, setOption(&st, Sct_SctApi_T_Scan_ScanOptions_distSlave, 0), "Failed to set distSlave option")
00062 
00063         // Only capture every 2nd trigger
00064     APICALL(s, setOption(&st, Sct_SctApi_T_Scan_ScanOptions_nth, 2), "Failed to set nth option")
00065 
00066         // Capture the second of the two triggers (index 0)
00067     APICALL(s, setOption(&st, Sct_SctApi_T_Scan_ScanOptions_nth_rem, 0), "Failed to set nth_rem option")
00068 
00069     // Adjust trigger
00070         Sct_SctApi_T_Trigger* t = 0;
00071         APIRETCALL(s, t, getTrigger1(&st), "Failed to get trigger1")
00072 
00073     int startDelay = 120;
00074     int delayStep = 1;
00075     int stopDelay = 160;
00076 
00077         APICALL(t, doubleL1A(&st, startDelay), "Failed to set trigger type")
00078 
00079     // Increment delay between triggers
00080     APICALL(t, setCommIncr(&st, 1, delayStep), "DoubleTriggerNoiseTest::getNextScan")
00081 
00082     // Configure scan
00083         APICALL(s, configure(&st, ST_ELAPSED, startDelay, stopDelay, delayStep), "Failed to set Scan information")
00084 
00085     return &request;
00086     }
00087 
00088     virtual bool canFeedback() {
00089     return false;
00090     }
00091 
00092     virtual void endTest() {
00093     api = 0;
00094     }
00095 
00096 private:
00097     DoubleTriggerNoiseTest() {}
00098     Sct_SctApi_T_SctApi* api;
00099 };
00100     
00101 }
00102 }
00103 
00104 #endif //DOUBLETRIGGERNOISETEST_H

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