00001 #ifndef TIMEWALKTEST_H
00002 #define TIMEWALKTEST_H
00003
00004 #include "../ipc/TestRequest.h"
00005 #include "../ipc/CalibrationController.h"
00006 #include "../ipc/ScanLibrary.h"
00007 #include "../ipc/Sct_CalibrationController.hh"
00008
00009 #include "../SctApiException.h"
00010
00011 #include <CommonWithDsp/ABCD/ABCDscans.h>
00012 #include <iostream>
00013 #include <vector>
00014
00015 using namespace Sct;
00016 using namespace std;
00017 using namespace SctCalibrationController::Ipc;
00018 using namespace SctCalibrationController;
00019
00020 namespace SctCalibrationController {
00021 namespace Scripts {
00022
00023 class TimeWalkTest : public TestRequestImpl {
00024 public:
00025 static TimeWalkTest& instance() {
00026 static TimeWalkTest tw;
00027 return tw;
00028 }
00029
00030 virtual void startTest(Sct_SctApi_T_SctApi& api, string& name, unsigned short& testVariable, unsigned long& nScans, vector<double>& testPoints) {
00031 this->api = &api;
00032
00033 Sct_SctApiStatus status;
00034
00035 api.modifyABCDVar(&status, ST_COMPRESSION, 2);
00036 if (status.returnCode != 0)
00037 throw SctApiException(status.returnCode, "TimeWalkTest::startTest", __FILE__, __LINE__);
00038
00039 api.modifyABCDVar(&status, ST_EDGE_DETECT, 1);
00040 if (status.returnCode != 0)
00041 throw SctApiException(status.returnCode, "TimeWalkTest::startTest", __FILE__, __LINE__);
00042
00043 api.modifyABCDVar(&status, ST_QTHR, 1);
00044 if (status.returnCode != 0)
00045 throw SctApiException(status.returnCode, "TimeWalkTest::startTest", __FILE__, __LINE__);
00046
00047 api.modifyABCDVar(&status, ST_SEND_MASK, 0);
00048 if (status.returnCode != 0)
00049 throw SctApiException(status.returnCode, "TimeWalkTest::startTest", __FILE__, __LINE__);
00050
00051 name = "TimeWalkTest";
00052 testVariable = ST_QCAL;
00053
00054 charges.push_back(1.25);
00055 charges.push_back(1.50);
00056 charges.push_back(1.75);
00057 charges.push_back(2.00);
00058 charges.push_back(3.0);
00059 charges.push_back(4.00);
00060 charges.push_back(5.00);
00061 charges.push_back(6.00);
00062 charges.push_back(8.00);
00063 charges.push_back(10.00);
00064
00065 testPoints = charges;
00066 nScans = testPoints.size();
00067 }
00068
00069 virtual Sct_SctApi_T_Scan* getNextScan(unsigned long index) {
00070 if (api == 0)
00071 throw InvariantViolatedError("Api pointer is 0 in getNextScan!", __FILE__, __LINE__);
00072
00073 Sct_SctApiStatus status;
00074 api->modifyABCDVar(&status, ST_QCAL, charges[index]);
00075 if (status.returnCode != 0)
00076 throw SctApiException(status.returnCode, "TimeWalkTest::getNextScan", __FILE__, __LINE__);
00077
00078 ScanLibrary& sl = CalibrationControllerImpl::instance().getScanLibrary();
00079 return &sl.strobeDelayScan(1000);
00080 }
00081
00082 virtual bool canFeedback() {
00083 return false;
00084 }
00085
00086 virtual void endTest() {
00087 charges.clear();
00088 api = 0;
00089 }
00090
00091 private:
00092 TimeWalkTest() {}
00093 Sct_SctApi_T_SctApi* api;
00094 std::vector<double> charges;
00095 };
00096 }
00097 }
00098 #endif //TIMEWALKTEST_H