From 455e782e08b63666b9fcf0a09674f0ff7e741f15 Mon Sep 17 00:00:00 2001 From: Nick Draper Date: Thu, 28 May 2015 18:11:30 +0100 Subject: [PATCH] Error 4: from above the instrument parameter loading is fixed re #11818 --- .../DataHandling/src/LoadEventNexus.cpp | 5 +++++ .../DataHandling/src/LoadInstrument.cpp | 22 +++++-------------- .../DataHandling/src/LoadParameterFile.cpp | 13 +++++------ 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/Code/Mantid/Framework/DataHandling/src/LoadEventNexus.cpp b/Code/Mantid/Framework/DataHandling/src/LoadEventNexus.cpp index 16e56ec9f5e7..631a9f35d091 100644 --- a/Code/Mantid/Framework/DataHandling/src/LoadEventNexus.cpp +++ b/Code/Mantid/Framework/DataHandling/src/LoadEventNexus.cpp @@ -1771,6 +1771,7 @@ EventWorkspace_sptr LoadEventNexus::createEmptyEventWorkspace() { file.openGroup(entry_name, "NXentry"); // get the title + try { file.openData("title"); if (file.getInfo().type == ::NeXus::CHAR) { string title = file.getStrData(); @@ -1778,6 +1779,10 @@ EventWorkspace_sptr LoadEventNexus::createEmptyEventWorkspace() { WS->setTitle(title); } file.closeData(); + } catch (std::exception&) + { + //don't set the title if the field is not loaded + } // get the notes try { diff --git a/Code/Mantid/Framework/DataHandling/src/LoadInstrument.cpp b/Code/Mantid/Framework/DataHandling/src/LoadInstrument.cpp index 9a2fcf760b63..48603e96d33d 100644 --- a/Code/Mantid/Framework/DataHandling/src/LoadInstrument.cpp +++ b/Code/Mantid/Framework/DataHandling/src/LoadInstrument.cpp @@ -6,19 +6,8 @@ #include "MantidAPI/Progress.h" #include "MantidDataHandling/LoadInstrument.h" #include "MantidGeometry/Instrument.h" -#include "MantidGeometry/Instrument/Component.h" -#include "MantidGeometry/Instrument/Detector.h" -#include "MantidGeometry/Instrument/ObjCompAssembly.h" -#include "MantidGeometry/Instrument/RectangularDetector.h" -#include "MantidGeometry/Objects/ShapeFactory.h" -#include "MantidGeometry/Rendering/vtkGeometryCacheReader.h" -#include "MantidGeometry/Rendering/vtkGeometryCacheWriter.h" #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/ConfigService.h" -#include "MantidKernel/DateAndTime.h" -#include "MantidKernel/Interpolation.h" -#include "MantidKernel/PhysicalConstants.h" -#include "MantidKernel/UnitFactory.h" #include #include @@ -272,10 +261,11 @@ void LoadInstrument::runLoadParameterFile() { /// found, else return "". // directoryName must include a final '/'. std::string LoadInstrument::getFullPathParamIDF(std::string directoryName) { + Poco::Path directoryPath (directoryName); + directoryPath.makeDirectory(); // Remove the path from the filename - const std::string::size_type stripPath = m_filename.find_last_of("\\/"); - std::string instrumentFile = - m_filename.substr(stripPath + 1, m_filename.size()); + Poco::Path filePath (m_filename); + std::string instrumentFile = filePath.getFileName(); // First check whether there is a parameter file whose name is the same as the // IDF file, @@ -295,11 +285,11 @@ std::string LoadInstrument::getFullPathParamIDF(std::string directoryName) { // Assemble parameter file name std::string fullPathParamIDF = - directoryName + prefix + "_Parameters" + suffix; + directoryPath.setFileName(prefix + "_Parameters" + suffix).toString(); if (Poco::File(fullPathParamIDF).exists() == false) { // No such file exists, so look for file based on instrument ID // given by the prefix - fullPathParamIDF = directoryName + "/" + prefix + "_Parameters.xml"; + fullPathParamIDF = directoryPath.setFileName(prefix + "_Parameters.xml").toString(); } if (Poco::File(fullPathParamIDF).exists() == diff --git a/Code/Mantid/Framework/DataHandling/src/LoadParameterFile.cpp b/Code/Mantid/Framework/DataHandling/src/LoadParameterFile.cpp index 606420fb5283..a67fe8f8bb29 100644 --- a/Code/Mantid/Framework/DataHandling/src/LoadParameterFile.cpp +++ b/Code/Mantid/Framework/DataHandling/src/LoadParameterFile.cpp @@ -2,14 +2,10 @@ // Includes //---------------------------------------------------------------------- #include "MantidDataHandling/LoadParameterFile.h" -#include "MantidDataHandling/LoadInstrument.h" #include "MantidGeometry/Instrument.h" -#include "MantidAPI/InstrumentDataService.h" -#include "MantidGeometry/Instrument/Detector.h" #include "MantidGeometry/Instrument/Component.h" #include "MantidAPI/Progress.h" #include "MantidAPI/FileProperty.h" -#include "MantidKernel/ArrayProperty.h" #include #include @@ -19,7 +15,6 @@ #include #include #include -#include #include "MantidGeometry/Instrument/InstrumentDefinitionParser.h" using Poco::XML::DOMParser; @@ -118,9 +113,11 @@ void LoadParameterFile::exec() { // First see if the file exists Poco::File ipfFile(filename); if(!ipfFile.exists()) { - std::string directoryName = - Kernel::ConfigService::Instance().getInstrumentDirectory(); - filename = directoryName + "/" + filename; + Poco::Path filePath(filename); + filename = Poco::Path(Kernel::ConfigService::Instance().getInstrumentDirectory()) + .makeDirectory(). + setFileName(filePath.getFileName()). + toString(); } g_log.information() << "Parsing from XML file: " << filename << std::endl;