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/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 private:
00028 static const bool registeredInTestLibrary;
00029
00030 public:
00031 static Sct_CalibrationController::TestRequest_ptr instance() {
00032 static QuickTrimRangeTest tr;
00033 return tr._this();
00034 }
00035
00036 virtual void startTestRealImpl(Sct_SctApi::SctApiIPC_ptr inapi, string& name, unsigned short& testVariable, unsigned long& nScans, vector<double>& testPoints) {
00037 this->api = Sct_SctApi::SctApiIPC::_duplicate(inapi);
00038
00039
00040 APICALL(api, modifyABCDVar(ST_COMPRESSION, 1), "QuickTrimRangeTest::startTest can't set compression")
00041
00042
00043 APICALL(api, modifyABCDVar(ST_EDGE_DETECT, 0), "QuickTrimRangeTest::startTest can't set edge detect")
00044
00045
00046 APICALL(api, modifyABCDVar(ST_SEND_MASK, 0), "QuickTrimRangeTest::startTest can't set send mask")
00047
00048
00049 APICALL(api, modifyABCDVar(ST_QCAL, 1), "QuickTrimRangeTest::startTest can't set qcal")
00050
00051 name = "TrimRangeTest";
00052 testVariable=ST_TRIM_RANGE;
00053 for (unsigned int i=0; i<6; ++i) {
00054 testPoints.push_back(getValue(i));
00055 }
00056 nScans = testPoints.size();
00057 }
00058
00059 virtual Sct_CalibrationController::ScanRequest_ptr getNextScanRealImpl(unsigned long index) {
00060 if (isFirstPoint(index)) {
00061
00062 APICALL(api, modifyABCDVar(ST_TRIM_RANGE, getRange(index)), "QuickTrimRangeTest::getNextScan")
00063 }
00064
00065 APICALL(api, modifyABCDVar(ST_TRIM, getValue(index)), "QuickTrimRangeTest::getNextScan")
00066
00067 Sct_CalibrationController::ScanLibrary_var sl = CalibrationControllerImpl::instance()->getScanLibrary();
00068 double offset = ranges[getRange(index)] * getValue(index);
00069 return sl->thresholdScanfCOffset(200, 1.0, offset);
00070 }
00071
00072 unsigned int getRange(unsigned int index) {
00073 return index<3 ? 0 : 1;
00074 }
00075
00076 bool isFirstPoint(unsigned int index) {
00077 return index%3 == 0;
00078 }
00079
00080 unsigned int getValue(unsigned int index) {
00081 switch (index%3) {
00082 case 0: return 1;
00083 case 1: return 6;
00084 case 2: return 15;
00085 }
00086 }
00087
00088 virtual bool canFeedbackRealImpl() {
00089 return true;
00090 }
00091
00092 virtual void endTestRealImpl() {
00093 api = Sct_SctApi::SctApiIPC::_nil();
00094 }
00095
00096 private:
00097 QuickTrimRangeTest() {}
00098 Sct_SctApi::SctApiIPC_var api;
00099 static double ranges[4];
00100 };
00101 }
00102 }
00103 #endif //TRIMRANGETEST_H