00001 #ifndef SYNCH_DOUBLETRIGGERNOISETEST_H
00002 #define SYNCH_DOUBLETRIGGERNOISETEST_H
00003 
00004 #include <cmath>  
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 
00016 using namespace Sct;
00017 using namespace SctCalibrationController::Ipc;
00018 namespace SctCalibrationController {
00019 namespace Scripts {
00020 
00021 class SynchDoubleTriggerNoiseTest  : public TestRequestImpl {
00022 private:
00023    static const bool registeredInTestLibrary;
00024 
00025 public:
00026     static Sct_CalibrationController::TestRequest_ptr instance() {
00027       static SynchDoubleTriggerNoiseTest dtnt;
00028       dtnt.setFitAlgorithm("NONE");
00029       dtnt.setAnalysisAlgorithm("DoubleTriggerNoiseTest");
00030       return dtnt._this();
00031     }
00032 
00033     virtual void startTestRealImpl(Sct_SctApi::SctApiIPC_ptr api, string& name, unsigned short& testVariable, unsigned long& nScans, vector<double>& testPoints) {  
00034     this->api = Sct_SctApi::SctApiIPC::_duplicate(api);
00035 
00036         
00037         APICALL(api, modifyABCDVar(ST_COMPRESSION, 1), "SynchDoubleTriggerNoiseTest::startTest")
00038 
00039         
00040         APICALL(api, modifyABCDVar(ST_EDGE_DETECT, 0), "SynchDoubleTriggerNoiseTest::startTest")
00041 
00042         
00043         APICALL(api, modifyABCDVar(ST_SEND_MASK, 0), "SynchDoubleTriggerNoiseTest::startTest")
00044 
00045         
00046         APICALL(api, modifyABCDVar(ST_QTHR, 1.0), "SynchDoubleTriggerNoiseTest::startTest")
00047 
00048     name = "SynchDoubleTriggerNoiseTest";
00049     testVariable = ST_ELAPSED;
00050     nScans = 1;
00051     testPoints.push_back(0.);
00052     }
00053 
00054 
00055     virtual Sct_CalibrationController::ScanRequest_ptr getNextScanRealImpl(unsigned long index) {
00056         Sct_CalibrationController::ScanLibrary_var sl = CalibrationControllerImpl::instance()->getScanLibrary();
00057         Sct_CalibrationController::ScanRequest_ptr request = sl->defaultScan();
00058 
00059     
00060         Sct_SctApi::Scan_var s;
00061         APIRETCALL(api, s, createScan(), "SynchDoubleTriggerNoiseTest::getNextScan")
00062         request->setScanCorba(s);
00063 
00064         APICALL(s, setNTrigs(10000), "Failed to set triggers")
00065 
00066         
00067     APICALL(s, setOption(Sct_SctApi::Scan::distSlave, 0), "Failed to set distSlave option")
00068 
00069         
00070     APICALL(s, setOption(Sct_SctApi::Scan::nth, 2), "Failed to set nth option")
00071 
00072         
00073     
00074     
00075     
00076     APICALL(s, setOption(Sct_SctApi::Scan::nth_rem, 0), "Failed to set nth_rem option")
00077 
00078         
00079     APICALL(s, setOption(Sct_SctApi::Scan::ope, 1), "Failed to set ope option")
00080 
00081     
00082     APICALL(s, setOption(Sct_SctApi::Scan::tim, 1), "Failed to set tim option")
00083 
00084     
00085         Sct_SctApi::Trigger_var t;
00086         APIRETCALL(s, t, getTrigger1(), "Failed to get trigger1")
00087 
00088         APICALL(t, doubleL1A(110), "Failed to set trigger type")
00089         APICALL(t, setFrequency(1.3), "Failed to set trigger frequency")
00090         APICALL(t, setRandom(2), "Failed to set trigger random")
00091         APICALL(t, setSource(::Sct_SctApi::Trigger::SOURCE_TIM_INTERNAL), "Failed to set trigger random")
00092 
00093     
00094     APICALL(t, setCommIncr(1, 1), "SynchDoubleTriggerNoiseTest::getNextScan")
00095 
00096     
00097     
00098         
00099         APICALL(s, configure(ST_TRIG_DELAY1, 110, 140, 1), "Failed to set Scan information")
00100 
00101     return request;
00102     }
00103 
00104     virtual bool canFeedbackRealImpl() {
00105     return false;
00106     }
00107 
00108     virtual void endTestRealImpl() {
00109     api = Sct_SctApi::SctApiIPC::_nil();
00110     }
00111 
00112 private:
00113     SynchDoubleTriggerNoiseTest() {}
00114     Sct_SctApi::SctApiIPC_var api;
00115 };
00116     
00117 }
00118 }
00119 
00120 #endif //SYNCH_DOUBLETRIGGERNOISETEST_H