Skip to content

Commit

Permalink
Add empty banks to parameter file re #7617
Browse files Browse the repository at this point in the history
Also tidied up the child algorithm code with help of Martyn

Signed-off-by: Karl Palmen <karl.palmen@stfc.ac.uk>
  • Loading branch information
KarlPalmen committed Sep 13, 2013
1 parent 8819f68 commit c02bd67
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
35 changes: 23 additions & 12 deletions Code/Mantid/Framework/DataHandling/src/ConvertFullprofToXML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,23 +106,27 @@ namespace DataHandling
//vector<int> outputbankids = getProperty("Banks");

// Load with LoadFullprofResolution
LoadFullprofResolution loader;
loader.initialize();
loader.setProperty("Filename",datafile);
loader.setProperty("OutputWorkspace","ParamTable");

loader.executeAsChildAlg();
//LoadFullprofResolution loader;
//loader.initialize();
auto loader = createChildAlgorithm("LoadFullprofResolution");
loader->setProperty("Filename",datafile);
loader->executeAsChildAlg();

// Write into Parameter File
// This code will later go into a child algorithm to enable it to be used by other algorithms
// CODE INCOMPLETE

// Set up access to table workspace ParamTable
API::ITableWorkspace_sptr paramTable = loader->getProperty("OutputWorkspace");

// Set up access to Output file
std::ofstream outFile(paramfile.c_str());
if (!outFile)
{
throw Mantid::Kernel::Exception::FileError("Unable to open file:", paramfile);
}

// Set up writer to Paremeter file
DOMWriter writer;
writer.setNewLine("\n");
writer.setOptions(XMLWriter::PRETTY_PRINT);
Expand All @@ -138,16 +142,23 @@ namespace DataHandling
rootElem->setAttribute("date", ISOdateShort);
mDoc->appendChild(rootElem);

Element* gElem = mDoc->createElement("test-element");
gElem->setAttribute("name", "name value");
rootElem->appendChild(gElem);
if(paramTable->columnCount() < 2){
throw std::runtime_error("No banks found");
}
size_t num_banks = paramTable->columnCount()-1;

for( size_t i=0; i<num_banks; ++i)
{
std::ostringstream bankName;
bankName << "Bank" << (i+1);
Element* bankElem = mDoc->createElement(bankName.str());
rootElem->appendChild(bankElem);
}


// Write document structure into file
writer.writeNode(outFile, mDoc);

// Remove table workspace after use
AnalysisDataService::Instance().remove("ParamTable");

return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace DataHandling
"Path to an Fullprof .irf file to load.");

// Output workspace
auto wsprop = new WorkspaceProperty<TableWorkspace>("OutputWorkspace", "", Direction::Output);
auto wsprop = new WorkspaceProperty<API::ITableWorkspace>("OutputWorkspace", "", Direction::Output);
declareProperty(wsprop, "Name of the output TableWorkspace containing profile parameters or bank information. ");

// Bank to import
Expand Down Expand Up @@ -171,7 +171,7 @@ namespace DataHandling
}

// Generate output table workspace
TableWorkspace_sptr outws = genTableWorkspace(bankparammap);
API::ITableWorkspace_sptr outws = genTableWorkspace(bankparammap);

// 6. Output
setProperty("OutputWorkspace", outws);
Expand Down

0 comments on commit c02bd67

Please sign in to comment.