Skip to content

Commit

Permalink
refs #6667 Changed ExperimentInfo::populateInstrumentParameters
Browse files Browse the repository at this point in the history
to understand booleans, though no unit tests found for populateInstrumentParameters to check this stuff works properly
  • Loading branch information
abuts committed Jun 5, 2013
1 parent 1d3ead0 commit a3ad112
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
31 changes: 28 additions & 3 deletions Code/Mantid/Framework/API/src/ExperimentInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,21 @@ namespace API
std::string paramName;
double value; };

/** HACK -- the internal function which allows to interpret string values found in IDF parameters file as boolean
* it is hack as this funtion should be somewhere else.
*
*@param boolType -- the string representation of the boolean value one wants to compare.
*@return True if the name within of the list of true names, and false otherwise
*/
const char * TrueNames[2 ]={"True","Yes"};
bool convertBool(const std::string &boolType)
{
for(int i=0;i<2;i++)
{
if(std::strcmp(boolType.c_str(),TrueNames[i])==0)return true;
}
return false;
}

//---------------------------------------------------------------------------------------
/** Add parameters to the instrument parameter map that are defined in instrument
Expand Down Expand Up @@ -256,9 +271,13 @@ namespace API
std::string paramN = ((*it).second)->m_paramName;
std::string category = ((*it).second)->m_type;

// if category is sting no point in trying to generate a double from parameter
bool is_string_val = (category.compare("string") == 0);
bool is_bool_val = (category.compare("bool") == 0);
bool is_double_val = !(is_string_val || is_bool_val);

// if category is not double sting no point in trying to generate a double from parameter
double value = 0.0;
if ( category.compare("string") != 0 )
if ( is_double_val)
value = ((*it).second)->createParamValue(dummy);

if ( category.compare("fitting") == 0 )
Expand All @@ -270,10 +289,16 @@ namespace API
<< ((*it).second)->m_formulaUnit << " , " << ((*it).second)->m_resultUnit << " , " << (*(((*it).second)->m_interpolation));
paramMap.add("fitting",((*it).second)->m_component, paramN, str.str());
}
else if ( category.compare("string") == 0 )
else if (is_string_val)
{
paramMap.addString(((*it).second)->m_component, paramN, ((*it).second)->m_value);
}
else if (is_bool_val )
{
bool b_val = convertBool(((*it).second)->m_value);
paramMap.addBool(((*it).second)->m_component,paramN,b_val);
}

else
{
if (paramN.compare("x") == 0 || paramN.compare("y") == 0 || paramN.compare("z") == 0)
Expand Down
10 changes: 5 additions & 5 deletions Code/Mantid/instrument/MAPS_Parameters.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@
<value val="bkgd-range-min,bkgd-range-max"/>
</parameter>
<!-- Remove the count rate seen in the regions of the histograms defined as the background regions -->
<parameter name="background">
<parameter name="background" type="bool">
<value val="False"/>
</parameter>
<!-- True if background is to be checked UNUSED PROPERTY !!! -->
<parameter name="check_background">
<parameter name="check_background" type="bool">
<value val="True"/>
</parameter>

Expand Down Expand Up @@ -215,7 +215,7 @@
<value val="0"/>
</parameter>
<!-- True if the bleed tests should be run use_bleeding-->
<parameter name="diag_bleed_test">
<parameter name="diag_bleed_test" type="bool">
<value val="False"/>
</parameter>

Expand All @@ -226,7 +226,7 @@
</parameter>

<!-- if defined to true, fix incident energy to this value and do not calculate the energy from the run -->
<parameter name="fixei">
<parameter name="fixei" type="bool">
<value val="False"/>
</parameter>

Expand All @@ -236,7 +236,7 @@
</parameter>


<parameter name="sum_runs">
<parameter name="sum_runs" type="bool">
<value val="False"/>
</parameter>

Expand Down

0 comments on commit a3ad112

Please sign in to comment.