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