00001 #include "TestResult.h" 00002 #include "FitScanResult.h" 00003 #include "RawScanResult.h" 00004 #include "ConfigurationVariable.h" 00005 #include "NullVariable.h" 00006 #include "Sct/UniqueID.h" 00007 #include "OpeResult.h" 00008 #include "Sct/SctNames.h" 00009 #include "Sct/IS/IOManagerIS.h" 00010 #include "Sct/IS/IONameIS.h" 00011 #include <algorithm> 00012 #include <sstream> 00013 00014 using namespace std; 00015 using namespace Sct; 00016 using namespace Sct::IS; 00017 using namespace boost; 00018 00019 namespace SctData { 00020 00021 TestResult::TestResult(const unsigned int runNumber, const string & moduleName, 00022 const ConfigurationVariable& testVariable, const ConfigurationVariable& scanVariable) throw () 00023 : header(0, runNumber, moduleName, scanVariable), testVariable(&testVariable), 00024 passed(false), problem(false) { 00025 } 00026 00027 00028 TestResult::TestResult() throw() : testVariable(&NullVariable::instance()), 00029 passed(false), problem(false) { 00030 } 00031 00032 const ResultHeader& TestResult::getHeader() const { 00033 return header; 00034 } 00035 00036 ResultHeader& TestResult::getHeader() { 00037 return header; 00038 } 00039 00040 unsigned int TestResult::getRunNumber() const throw() { 00041 return getHeader().getRunNumber(); 00042 } 00043 00044 void TestResult::setRunNumber(unsigned int runNumber) throw() { 00045 getHeader().setRunNumber(runNumber); 00046 } 00047 00048 string TestResult::getModuleName() const throw() { 00049 return getHeader().getModuleName(); 00050 } 00051 00052 void TestResult::setModuleName(string name) throw() { 00053 getHeader().setModuleName(name); 00054 } 00055 00056 const DefectList& TestResult::getDefects() const throw() { 00057 return defects; 00058 } 00059 00060 DefectList& TestResult::getDefects() throw() { 00061 return defects; 00062 } 00063 00064 const ConfigurationVariable& TestResult::getScanVariable() const throw() { 00065 return getHeader().getVariable(); 00066 } 00067 00068 void TestResult::setScanVariable(const ConfigurationVariable& scanVariable) throw() { 00069 getHeader().setVariable(scanVariable); 00070 } 00071 00072 const ConfigurationVariable& TestResult::getTestVariable() const throw() { 00073 return *testVariable; 00074 } 00075 00076 void TestResult::setTestVariable(const ConfigurationVariable& testVariable) throw() { 00077 this->testVariable = &testVariable; 00078 } 00079 00080 bool TestResult::getPassed() const throw() { 00081 return passed; 00082 } 00083 00084 void TestResult::setPassed(bool passed) throw() { 00085 this->passed = passed; 00086 } 00087 00088 bool TestResult::getProblem() const throw() { 00089 return problem; 00090 } 00091 00092 void TestResult::setProblem(bool problem) throw() { 00093 this->problem = problem; 00094 } 00095 00096 vector<string> TestResult::getComments() const throw() { 00097 return comments; 00098 } 00099 00100 void TestResult::addComment(string comment) throw() { 00101 comments.push_back(comment); 00102 } 00103 00104 void TestResult::addScan(const unsigned int scanNumber, const double testPoint) throw(LogicError) { 00105 if (data.size() == 0) { 00106 getHeader().setScanNumber(scanNumber); 00107 } 00108 data.push_back(ScanData(scanNumber, testPoint)); 00109 sort(data.begin(), data.end()); 00110 } 00111 00112 Sct::UniqueID TestResult::getUniqueID() const throw(LogicError) { 00113 if (data.size() > 0) { 00114 return getHeader().getUniqueID(); 00115 } 00116 throw IllegalStateError("TestResult::getUniqueID() : empty test result", __FILE__, __LINE__); 00117 } 00118 00119 unsigned TestResult::getScanNumberAt(unsigned int i) const throw(LogicError) { 00120 if ( i>=data.size() ) 00121 throw OutOfRangeError<unsigned>("TestPoint::getScanNumberAt", __FILE__, __LINE__,i,0,data.size()-1); 00122 return data[i].scanNumber; 00123 } 00124 00125 double TestResult::getTestPointAt(unsigned int i) const throw(LogicError) { 00126 if ( i>=data.size() ) 00127 throw OutOfRangeError<unsigned>("TestPoint::getTestPointAt", __FILE__, __LINE__,i,0,data.size()-1); 00128 return data[i].testPoint; 00129 } 00130 00131 unsigned int TestResult::getIndex(unsigned int scanNumber) const throw(LogicError) { 00132 vector<ScanData>::const_iterator i=find(data.begin(), data.end(), scanNumber); 00133 if (i==data.end() ) { 00134 ostringstream text; 00135 text << "TestResult::findScanData scan not found scanNumber="<< scanNumber; 00136 throw InvalidArgumentError( text.str(), __FILE__, __LINE__ ); 00137 } 00138 return i-data.begin(); 00139 } 00140 00142 TestResult::ScanData::ScanData(const unsigned int scanNumber, const double testPoint) throw() 00143 : scanNumber(scanNumber), testPoint(testPoint) {} 00144 00145 bool TestResult::ScanData::operator<(const ScanData& s) const throw() { 00146 if (this->scanNumber<s.scanNumber) 00147 return true; 00148 return false; 00149 } 00150 00151 bool TestResult::ScanData::operator>(const ScanData& s) const throw() { 00152 if (this->scanNumber>s.scanNumber) 00153 return true; 00154 return false; 00155 } 00156 00157 bool TestResult::ScanData::operator==(const unsigned int aScanNumber) const throw() { 00158 if (this->scanNumber==aScanNumber) 00159 return true; 00160 return false; 00161 } 00162 00163 void TestResult::setDcsData(boost::shared_ptr<const DcsData> data){ 00164 m_dcsData = data; 00165 } 00166 00167 boost::shared_ptr<const DcsData> TestResult::getDcsData() const { 00168 return m_dcsData; 00169 } 00170 00171 void TestResult::setOpeResult(boost::shared_ptr<const OpeResult> ope){ 00172 m_opeResult = ope; 00173 } 00174 00175 boost::shared_ptr<const OpeResult> TestResult::getOpeResult() const { 00176 return m_opeResult; 00177 } 00178 00179 00180 }