00001 #ifndef THREEPOINTGAINTEST_H
00002 #define THREEPOINTGAINTEST_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 "../SctApiException.h"
00011 #include "Sct/LogicErrors.h"
00012
00013 #include <CommonWithDsp/ABCD/ABCDscans.h>
00014 #include <iostream>
00015 #include <vector>
00016
00017 using namespace Sct;
00018 using namespace std;
00019 using namespace SctCalibrationController::Ipc;
00020
00021 namespace SctCalibrationController {
00022 namespace Scripts {
00023
00024 class ThreePointGainTest : public TestRequestImpl {
00025 public:
00026 static ThreePointGainTest& instance() {
00027 static ThreePointGainTest rc;
00028 return rc;
00029 }
00030
00031 virtual void startTest(Sct_SctApi_T_SctApi& api, string& name, unsigned short& testVariable, unsigned long& nScans, vector<double>& testPoints) {
00032 this->api = &api;
00033
00034 Sct_SctApiStatus status;
00035 api.modifyABCDVar(&status, ST_COMPRESSION, 1);
00036 if (status.returnCode != 0)
00037 throw SctApiException(status.returnCode, "ThreePointGainTest::startTest", __FILE__, __LINE__);
00038
00039 api.modifyABCDVar(&status, ST_EDGE_DETECT, 0);
00040 if (status.returnCode != 0)
00041 throw SctApiException(status.returnCode, "ThreePointGainTest::startTest", __FILE__, __LINE__);
00042
00043 api.modifyABCDVar(&status, ST_SEND_MASK, 0);
00044 if (status.returnCode != 0)
00045 throw SctApiException(status.returnCode, "ThreePointGainTest::startTest", __FILE__, __LINE__);
00046
00047 name = "NPtGainTest";
00048 testVariable = ST_QCAL;
00049
00050 charges.push_back(1.5);
00051 charges.push_back(2);
00052 charges.push_back(2.5);
00053
00054 testPoints = charges;
00055 nScans = testPoints.size();
00056 }
00057
00058 virtual Sct_SctApi_T_Scan* getNextScan(unsigned long index) {
00059 if (api == 0)
00060 throw InvariantViolatedError("Api pointer is 0 in getNextScan!", __FILE__, __LINE__);
00061
00062 ScanLibrary& sl = CalibrationControllerImpl::instance().getScanLibrary();
00063
00064 Sct_SctApiStatus status;
00065 api->modifyABCDVar(&status, ST_QCAL, charges[index]);
00066 if (status.returnCode != 0)
00067 throw SctApiException(status.returnCode, "ThreePointGainTest::getNextScan", __FILE__, __LINE__);
00068
00069 return &sl.thresholdScanfC(1000, charges[index]);
00070 }
00071
00072 virtual bool canFeedback() {
00073 return false;
00074 }
00075
00076 virtual void endTest() {
00077 api = 0;
00078 charges.clear();
00079 }
00080
00081
00082 private:
00083 ThreePointGainTest() {}
00084 Sct_SctApi_T_SctApi* api;
00085 vector<double> charges;
00086 };
00087 }
00088 }
00089 #endif //THREEPOINTGAINTEST_H