00001 #ifndef QUICKTRIMRANGETEST_H
00002 #define QUICKTRIMRANGETEST_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 std;
00019 using namespace SctCalibrationController::Ipc;
00020 using namespace SctCalibrationController;
00021 using namespace Sct;
00022
00023 namespace SctCalibrationController {
00024 namespace Scripts {
00025
00026 class QuickTrimRangeTest : public TestRequestImpl {
00027 public:
00028 static QuickTrimRangeTest& instance() {
00029 static QuickTrimRangeTest tr;
00030 return tr;
00031 }
00032
00033 virtual void startTest(Sct_SctApi_T_SctApi& inapi, string& name, unsigned short& testVariable, unsigned long& nScans, vector<double>& testPoints) {
00034 this->api = &inapi;
00035
00036
00037 APICALL(api, modifyABCDVar(&st, ST_COMPRESSION, 1), "QuickTrimRangeTest::startTest can't set compression")
00038
00039
00040 APICALL(api, modifyABCDVar(&st, ST_EDGE_DETECT, 0), "QuickTrimRangeTest::startTest can't set edge detect")
00041
00042
00043 APICALL(api, modifyABCDVar(&st, ST_SEND_MASK, 0), "QuickTrimRangeTest::startTest can't set send mask")
00044
00045
00046 APICALL(api, modifyABCDVar(&st, ST_QCAL, 1), "QuickTrimRangeTest::startTest can't set qcal")
00047
00048 name = "TrimRangeTest";
00049 testVariable=ST_TRIM_RANGE;
00050 for (unsigned int i=0; i<6; ++i) {
00051 testPoints.push_back(getValue(i));
00052 }
00053 nScans = testPoints.size();
00054 }
00055
00056 virtual ScanRequest* getNextScan(unsigned long index) {
00057 if (isFirstPoint(index)) {
00058
00059 APICALL(api, modifyABCDVar(&st, ST_TRIM_RANGE, getRange(index)), "QuickTrimRangeTest::getNextScan")
00060 }
00061
00062 APICALL(api, modifyABCDVar(&st, ST_TRIM, getValue(index)), "QuickTrimRangeTest::getNextScan")
00063
00064 ScanLibrary& sl = CalibrationControllerImpl::instance().getScanLibrary();
00065 double offset = ranges[getRange(index)] * getValue(index);
00066 return &sl.thresholdScanfCOffset(200, 1.0, offset);
00067 }
00068
00069 unsigned int getRange(unsigned int index) {
00070 return index<3 ? 0 : 1;
00071 }
00072
00073 bool isFirstPoint(unsigned int index) {
00074 return index%3 == 0;
00075 }
00076
00077 unsigned int getValue(unsigned int index) {
00078 switch (index%3) {
00079 case 0: return 1;
00080 case 1: return 6;
00081 case 2: return 15;
00082 }
00083 }
00084
00085 virtual bool canFeedback() {
00086 return true;
00087 }
00088
00089 virtual void endTest() {
00090 api = 0;
00091 }
00092
00093 private:
00094 QuickTrimRangeTest() {}
00095 Sct_SctApi_T_SctApi* api;
00096 static double ranges[4];
00097 };
00098 double QuickTrimRangeTest::ranges[4] = {3.5, 6.5, 10, 13};
00099 }
00100 }
00101 #endif //TRIMRANGETEST_H