12#include "boost/date_time/local_time/posix_time_zone.hpp"
17using namespace Kernel;
18using Types::Core::DateAndTime;
29void createOrUpdateValue(API::Run &run,
const std::string &name,
const std::string &time,
const std::string &
value) {
30 TimeSeriesProperty<std::string> *timeSeries(
nullptr);
31 if (run.hasProperty(name)) {
32 timeSeries =
dynamic_cast<TimeSeriesProperty<std::string> *
>(run.getLogData(name));
34 throw std::invalid_argument(
"Log '" + name +
"' already exists but the values are a different type.");
36 timeSeries =
new TimeSeriesProperty<std::string>(name);
37 run.addProperty(timeSeries);
39 timeSeries->addValue(time,
value);
61const std::string
AddNote::summary()
const {
return "Adds a timestamped note to a workspace."; }
68 "An InOut workspace that will store the new log information");
71 "A String name for either a new time series log to be "
72 "created or an existing name to update",
75 auto dtv = std::make_shared<DateTimeValidator>();
76 dtv->allowEmpty(
true);
79 "An ISO formatted date/time string specifying the timestamp for "
80 "the given log value, for example 2010-09-14T04:20:12 \n"
81 "If left blank, this will default to the current Date and Time",
87 declareProperty(
"DeleteExisting",
false,
"If true and the named log exists then the whole log is removed first.",
96 const bool deleteExisting =
getProperty(
"DeleteExisting");
97 auto &run = logWS->mutableRun();
98 if (deleteExisting && run.hasProperty(
name)) {
111 deleter->setProperty(
"Workspace", logWS);
112 deleter->setProperty(
"Name",
name);
113 deleter->executeAsChildAlg();
124 namespace pt = boost::posix_time;
125 auto dateTimeObj = DateAndTime(pt::second_clock::local_time());
126 time = dateTimeObj.toISO8601String();
130 createOrUpdateValue(run,
name, time,
value);
#define DECLARE_ALGORITHM(classname)
double value
The value of the point.
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
virtual std::shared_ptr< Algorithm > createChildAlgorithm(const std::string &name, const double startProgress=-1., const double endProgress=-1., const bool enableLogging=true, const int &version=-1)
Create a Child Algorithm.
This class stores information regarding an experimental run as a series of log entries.
A property class for workspaces.
An Algorithm that adds a timestamped note to a workspace.
const std::string summary() const override
Algorithm's summary for use in the GUI and help.
void init() override
Initialize the algorithm's properties.
int version() const override
Algorithm's version for identification.
void exec() override
Executes the algorithm.
void removeExisting(API::MatrixWorkspace_sptr &, const std::string &)
Remove an existing log of the given name.
void createOrUpdate(API::Run &, const std::string &)
Create or update the named log entry.
const std::string name() const override
Algorithms name for identification.
const std::string category() const override
Algorithm's category for identification.
Validator to check that a property is not left empty.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
@ InOut
Both an input & output workspace.
@ Input
An input workspace.