Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
49b93c1b
Commit
49b93c1b
authored
9 years ago
by
Matthew D Jones
Browse files
Options
Downloads
Patches
Plain Diff
Re #14178 Made Owen's suggested changes
parent
d09c500a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Framework/Algorithms/src/AddSampleLog.cpp
+29
-17
29 additions, 17 deletions
Framework/Algorithms/src/AddSampleLog.cpp
Framework/Algorithms/test/AddSampleLogTest.h
+5
-5
5 additions, 5 deletions
Framework/Algorithms/test/AddSampleLogTest.h
with
34 additions
and
22 deletions
Framework/Algorithms/src/AddSampleLog.cpp
+
29
−
17
View file @
49b93c1b
...
@@ -10,6 +10,17 @@
...
@@ -10,6 +10,17 @@
#include
"MantidKernel/PropertyWithValue.h"
#include
"MantidKernel/PropertyWithValue.h"
#include
<string>
#include
<string>
namespace
{
static
const
std
::
string
intTypeOption
=
"Int"
;
static
const
std
::
string
doubleTypeOption
=
"Double"
;
static
const
std
::
string
autoTypeOption
=
"AutoDetect"
;
static
const
std
::
string
stringLogOption
=
"String"
;
static
const
std
::
string
numberLogOption
=
"Number"
;
static
const
std
::
string
numberSeriesLogOption
=
"Number Series"
;
}
namespace
Mantid
{
namespace
Mantid
{
namespace
Algorithms
{
namespace
Algorithms
{
...
@@ -30,19 +41,19 @@ void AddSampleLog::init() {
...
@@ -30,19 +41,19 @@ void AddSampleLog::init() {
declareProperty
(
"LogText"
,
""
,
"The content of the log"
);
declareProperty
(
"LogText"
,
""
,
"The content of the log"
);
std
::
vector
<
std
::
string
>
propOptions
;
std
::
vector
<
std
::
string
>
propOptions
;
propOptions
.
push_back
(
"S
tring
"
);
propOptions
.
push_back
(
s
tring
LogOption
);
propOptions
.
push_back
(
"N
umber
"
);
propOptions
.
push_back
(
n
umber
LogOption
);
propOptions
.
push_back
(
"N
umber
Series
"
);
propOptions
.
push_back
(
n
umberSeries
LogOption
);
declareProperty
(
"LogType"
,
"S
tring
"
,
declareProperty
(
"LogType"
,
s
tring
LogOption
,
boost
::
make_shared
<
StringListValidator
>
(
propOptions
),
boost
::
make_shared
<
StringListValidator
>
(
propOptions
),
"The type that the log data will be."
);
"The type that the log data will be."
);
declareProperty
(
"LogUnit"
,
""
,
"The units of the log"
);
declareProperty
(
"LogUnit"
,
""
,
"The units of the log"
);
std
::
vector
<
std
::
string
>
typeOptions
;
std
::
vector
<
std
::
string
>
typeOptions
;
typeOptions
.
push_back
(
"Int"
);
typeOptions
.
push_back
(
intTypeOption
);
typeOptions
.
push_back
(
"D
ouble
"
);
typeOptions
.
push_back
(
d
ouble
TypeOption
);
typeOptions
.
push_back
(
""
);
typeOptions
.
push_back
(
autoTypeOption
);
declareProperty
(
"NumberType"
,
""
,
declareProperty
(
"NumberType"
,
autoTypeOption
,
boost
::
make_shared
<
StringListValidator
>
(
typeOptions
),
boost
::
make_shared
<
StringListValidator
>
(
typeOptions
),
"Force LogText to be interpreted as a number of type 'int' "
"Force LogText to be interpreted as a number of type 'int' "
"or 'double'."
);
"or 'double'."
);
...
@@ -62,10 +73,11 @@ void AddSampleLog::exec() {
...
@@ -62,10 +73,11 @@ void AddSampleLog::exec() {
std
::
string
propType
=
getPropertyValue
(
"LogType"
);
std
::
string
propType
=
getPropertyValue
(
"LogType"
);
std
::
string
propNumberType
=
getPropertyValue
(
"NumberType"
);
std
::
string
propNumberType
=
getPropertyValue
(
"NumberType"
);
if
(
!
propNumberType
.
empty
()
&&
if
((
propNumberType
!=
autoTypeOption
)
&&
((
propType
!=
"Number"
)
&&
(
propType
!=
"Number Series"
)))
{
((
propType
!=
numberLogOption
)
&&
(
propType
!=
numberSeriesLogOption
)))
{
throw
std
::
invalid_argument
(
"You may only use NumberType property if "
throw
std
::
invalid_argument
(
"LogType is 'Number' or 'Number Series'"
);
"You may only use NumberType 'Int' or 'Double' options if "
"LogType is 'Number' or 'Number Series'"
);
}
}
// Remove any existing log
// Remove any existing log
...
@@ -73,7 +85,7 @@ void AddSampleLog::exec() {
...
@@ -73,7 +85,7 @@ void AddSampleLog::exec() {
theRun
.
removeLogData
(
propName
);
theRun
.
removeLogData
(
propName
);
}
}
if
(
propType
==
"S
tring
"
)
{
if
(
propType
==
s
tring
LogOption
)
{
theRun
.
addLogData
(
new
PropertyWithValue
<
std
::
string
>
(
propName
,
propValue
));
theRun
.
addLogData
(
new
PropertyWithValue
<
std
::
string
>
(
propName
,
propValue
));
theRun
.
getProperty
(
propName
)
->
setUnits
(
propUnit
);
theRun
.
getProperty
(
propName
)
->
setUnits
(
propUnit
);
return
;
return
;
...
@@ -83,8 +95,8 @@ void AddSampleLog::exec() {
...
@@ -83,8 +95,8 @@ void AddSampleLog::exec() {
double
dblVal
;
double
dblVal
;
bool
value_is_int
=
false
;
bool
value_is_int
=
false
;
if
(
!
propNumberType
.
empty
()
)
{
if
(
propNumberType
!=
autoTypeOption
)
{
value_is_int
=
(
propNumberType
==
"Int"
);
value_is_int
=
(
propNumberType
==
intTypeOption
);
if
(
value_is_int
)
{
if
(
value_is_int
)
{
if
(
!
Strings
::
convert
(
propValue
,
intVal
))
{
if
(
!
Strings
::
convert
(
propValue
,
intVal
))
{
throw
std
::
invalid_argument
(
"Error interpreting string '"
+
propValue
+
throw
std
::
invalid_argument
(
"Error interpreting string '"
+
propValue
+
...
@@ -103,12 +115,12 @@ void AddSampleLog::exec() {
...
@@ -103,12 +115,12 @@ void AddSampleLog::exec() {
}
}
}
}
if
(
propType
==
"N
umber
"
)
{
if
(
propType
==
n
umber
LogOption
)
{
if
(
value_is_int
)
if
(
value_is_int
)
theRun
.
addLogData
(
new
PropertyWithValue
<
int
>
(
propName
,
intVal
));
theRun
.
addLogData
(
new
PropertyWithValue
<
int
>
(
propName
,
intVal
));
else
else
theRun
.
addLogData
(
new
PropertyWithValue
<
double
>
(
propName
,
dblVal
));
theRun
.
addLogData
(
new
PropertyWithValue
<
double
>
(
propName
,
dblVal
));
}
else
if
(
propType
==
"N
umber
Series
"
)
{
}
else
if
(
propType
==
n
umberSeries
LogOption
)
{
Kernel
::
DateAndTime
startTime
;
Kernel
::
DateAndTime
startTime
;
try
{
try
{
startTime
=
theRun
.
startTime
();
startTime
=
theRun
.
startTime
();
...
...
This diff is collapsed.
Click to expand it.
Framework/Algorithms/test/AddSampleLogTest.h
+
5
−
5
View file @
49b93c1b
...
@@ -105,11 +105,11 @@ public:
...
@@ -105,11 +105,11 @@ public:
}
}
template
<
typename
T
>
template
<
typename
T
>
void
ExecuteAlgorithm
(
MatrixWorkspace_sptr
testWS
,
std
::
string
LogName
,
void
std
::
string
LogType
,
std
::
string
Log
Text
,
ExecuteAlgorithm
(
MatrixWorkspace_sptr
testWS
,
std
::
string
Log
Name
,
T
expectedValue
,
bool
fails
=
fals
e
,
std
::
string
LogType
,
std
::
string
LogText
,
T
expectedValu
e
,
std
::
string
LogUnit
=
""
,
std
::
string
NumberType
=
""
,
bool
fails
=
false
,
std
::
string
LogUnit
=
""
,
bool
throws
=
false
)
{
std
::
string
NumberType
=
"AutoDetect"
,
bool
throws
=
false
)
{
// add the workspace to the ADS
// add the workspace to the ADS
AnalysisDataService
::
Instance
().
addOrReplace
(
"AddSampleLogTest_Temporary"
,
AnalysisDataService
::
Instance
().
addOrReplace
(
"AddSampleLogTest_Temporary"
,
testWS
);
testWS
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment