diff --git a/Code/Mantid/Framework/Algorithms/src/AddSampleLog.cpp b/Code/Mantid/Framework/Algorithms/src/AddSampleLog.cpp index d3ae6983714902c4d045b1af55bf02cbc1aededc..6590c645c27cbb8341b390c522b2c18d9003c7ec 100644 --- a/Code/Mantid/Framework/Algorithms/src/AddSampleLog.cpp +++ b/Code/Mantid/Framework/Algorithms/src/AddSampleLog.cpp @@ -21,6 +21,12 @@ void AddSampleLog::initDocs() { this->setWikiSummary("Used to insert a value into the sample logs in a workspace."); this->setOptionalMessage("Used to insert a value into the sample logs in a workspace."); + this->setWikiDescription( + "Workspaces contain information in logs. Often these detail what happened to the sample during the experiment. This algorithm allows one named log to be entered. " + "\n\n" + "The log can be either a String, a Number, or a Number Series. If you select Number Series, the current time will be used " + "as the time of the log entry, and the number in the text used as the (only) value." + ); } using namespace Kernel; diff --git a/Code/Mantid/Framework/Crystal/src/SaveIsawPeaks.cpp b/Code/Mantid/Framework/Crystal/src/SaveIsawPeaks.cpp index e042998a53bc24efcb17ec900372f802b529ad80..6ec0bbd16b04deadcc70d6113febecadff10cb63 100644 --- a/Code/Mantid/Framework/Crystal/src/SaveIsawPeaks.cpp +++ b/Code/Mantid/Framework/Crystal/src/SaveIsawPeaks.cpp @@ -85,8 +85,9 @@ namespace Crystal out << "Version: 2.0 Facility: SNS " ; out << " Instrument: " << inst->getName() << " Date: " ; - //TODO: Fill in instrument date - Kernel::DateAndTime expDate = Kernel::DateAndTime::get_current_time(); + //TODO: The experiment date might be more useful than the instrument date. + // For now, this allows the proper instrument to be loaded back after saving. + Kernel::DateAndTime expDate = inst->getValidFromDate() + 1.0; out << expDate.to_ISO8601_string() << std::endl; out << "This is the header format:" << std::endl; diff --git a/Code/Mantid/Framework/DataHandling/src/LoadInstrument.cpp b/Code/Mantid/Framework/DataHandling/src/LoadInstrument.cpp index 97cac4cd2a3ce79fb529798b4ea7ea5c3afdab80..1a42b1e4fc16ccd4f03b59ba8452e218097cee6a 100644 --- a/Code/Mantid/Framework/DataHandling/src/LoadInstrument.cpp +++ b/Code/Mantid/Framework/DataHandling/src/LoadInstrument.cpp @@ -165,6 +165,7 @@ namespace Mantid try { DateAndTime d(pRootElem->getAttribute("valid-from")); + m_instrument->setValidFromDate(d); } catch(...) { @@ -174,6 +175,8 @@ namespace Mantid if ( !pRootElem->hasAttribute("valid-to") ) { + DateAndTime d = DateAndTime::get_current_time(); + m_instrument->setValidToDate(d); // Ticket #2335: no required valid-to date. //throw Kernel::Exception::InstrumentDefinitionError("<instrument> element must contain a valid-to tag", m_filename); } @@ -182,6 +185,7 @@ namespace Mantid try { DateAndTime d(pRootElem->getAttribute("valid-to")); + m_instrument->setValidToDate(d); } catch(...) { diff --git a/Code/Mantid/Framework/DataHandling/test/LoadInstrumentTest.h b/Code/Mantid/Framework/DataHandling/test/LoadInstrumentTest.h index 5c7cd94820f0de527cbb682de253d2c4d7366b54..bfde5db0d0720fe07a4179f69f548390aaf14f9f 100644 --- a/Code/Mantid/Framework/DataHandling/test/LoadInstrumentTest.h +++ b/Code/Mantid/Framework/DataHandling/test/LoadInstrumentTest.h @@ -138,6 +138,12 @@ public: TS_ASSERT_THROWS_NOTHING( loadAgain.execute() ); TS_ASSERT_EQUALS( output->getBaseInstrument(), i ); + // Valid-from/to + Kernel::DateAndTime validFrom("1900-01-31T23:59:59"); + Kernel::DateAndTime validTo("2100-01-31 23:59:59"); + TS_ASSERT_EQUALS( i->getValidFromDate(), validFrom); + TS_ASSERT_EQUALS( i->getValidToDate(), validTo); + AnalysisDataService::Instance().remove(wsName); } diff --git a/Code/Mantid/Framework/Geometry/inc/MantidGeometry/IInstrument.h b/Code/Mantid/Framework/Geometry/inc/MantidGeometry/IInstrument.h index 0c904cfef62d233ec7d4516a41e35cf44ab741fc..92d3b0b737f6887023a92e1222839fdcaa67abf9 100644 --- a/Code/Mantid/Framework/Geometry/inc/MantidGeometry/IInstrument.h +++ b/Code/Mantid/Framework/Geometry/inc/MantidGeometry/IInstrument.h @@ -11,6 +11,7 @@ #include <boost/shared_ptr.hpp> #include <map> #include <string> +#include "MantidKernel/DateAndTime.h" namespace Mantid { @@ -61,6 +62,8 @@ public: virtual std::string getName() const = 0; + + /// Returns a pointer to the geometrical object representing the source virtual Geometry::IObjComponent_sptr getSource() const = 0; @@ -122,6 +125,30 @@ public: virtual void getInstrumentParameters(double & l1, Geometry::V3D & beamline, double & beamline_norm, Geometry::V3D & samplePos) const = 0; + + /// @return the date from which the instrument definition begins to be valid. + Kernel::DateAndTime getValidFromDate() const + { return m_ValidFrom; } + + /// @return the date at which the instrument definition is no longer valid. + Kernel::DateAndTime getValidToDate() const + { return m_ValidTo; } + + /// Set the date from which the instrument definition begins to be valid. + /// @param val :: date + void setValidFromDate(const Kernel::DateAndTime val) + { m_ValidFrom = val; } + + /// Set the date at which the instrument definition is no longer valid. + /// @param val :: date + void setValidToDate(const Kernel::DateAndTime val) + { m_ValidTo = val; } + +protected: + /// the date from which the instrument definition begins to be valid. + Kernel::DateAndTime m_ValidFrom; + /// the date at which the instrument definition is no longer valid. + Kernel::DateAndTime m_ValidTo; }; /// Shared pointer to IInstrument diff --git a/Code/Mantid/Framework/Geometry/test/InstrumentTest.h b/Code/Mantid/Framework/Geometry/test/InstrumentTest.h index 2da3b18bc59520c865db0ddff596e7519917beae..6064b772359ba6a2a21bde93c27e7044ccd4d85f 100644 --- a/Code/Mantid/Framework/Geometry/test/InstrumentTest.h +++ b/Code/Mantid/Framework/Geometry/test/InstrumentTest.h @@ -237,6 +237,17 @@ public: TS_ASSERT_EQUALS(dets.size(), 36*5); } + void test_getValidFromDate() + { + IInstrument_sptr inst = ComponentCreationHelper::createTestInstrumentRectangular(5, 6); + Kernel::DateAndTime validFrom("1900-01-31T23:59:59"); + Kernel::DateAndTime validTo("2100-01-31 23:59:59"); + inst->setValidFromDate(validFrom); + inst->setValidToDate(validTo); + TS_ASSERT_EQUALS( inst->getValidFromDate(), validFrom); + TS_ASSERT_EQUALS( inst->getValidToDate(), validTo); + + } private: Instrument instrument;