Skip to content

Commit

Permalink
Re #5366. Forbid accumulating chunks by adding for histograms.
Browse files Browse the repository at this point in the history
  • Loading branch information
RussellTaylor committed Feb 6, 2013
1 parent 353f855 commit 99af862
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Code/Mantid/Framework/DataHandling/src/LiveDataAlgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,20 @@ namespace DataHandling
std::map<std::string, std::string> LiveDataAlgorithm::validateInputs()
{
std::map<std::string, std::string> out;

const std::string instrument = getPropertyValue("Instrument");
try {
const bool eventListener = LiveListenerFactory::Instance().create(instrument)->buffersEvents();
if ( !eventListener && getPropertyValue("AccumulationMethod") == "Add" )
{
out["AccumulationMethod"] = "The " + instrument + " live stream produces histograms. Add is not a sensible accumulation method.";
}
}
catch ( std::runtime_error& )
{
out["Instrument"] = "Unable to connect to live stream for " + instrument;
}

if (this->getPropertyValue("OutputWorkspace").empty())
out["OutputWorkspace"] = "Must specify the OutputWorkspace.";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ class LiveDataAlgorithmTest : public CxxTest::TestSuite
TS_ASSERT( alg.isInitialized() )
TS_ASSERT( !alg.hasPostProcessing() );

TSM_ASSERT("Can't connect", !alg.validateInputs()["Instrument"].empty() );
alg.setPropertyValue("Instrument","FakeEventDataListener");

TSM_ASSERT("No OutputWorkspace", !alg.validateInputs()["OutputWorkspace"].empty() );
alg.setPropertyValue("OutputWorkspace", "out_ws");
TSM_ASSERT("Is OK now", alg.validateInputs().empty() );
Expand All @@ -84,6 +87,10 @@ class LiveDataAlgorithmTest : public CxxTest::TestSuite

alg.setPropertyValue("AccumulationWorkspace", "out_ws");
TSM_ASSERT("AccumulationWorkspace == OutputWorkspace", !alg.validateInputs()["AccumulationWorkspace"].empty() );

alg.setPropertyValue("Instrument", "ISISHistoDataListener");
alg.setPropertyValue("AccumulationMethod","Add");
TSM_ASSERT("Shouldn't add histograms", !alg.validateInputs()["AccumulationMethod"].empty() );
}

/** Test creating the processing algorithm.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ void StartLiveDataDialog::initLayout()

// ========== Set previous values from history =============
fillAndSetComboBox("Instrument", ui.cmbInstrument);
tie(ui.cmbInstrument, "Instrument", ui.horizontalLayout_5);
tie(ui.edtUpdateEvery, "UpdateEvery", ui.layoutUpdateEvery);
fillAndSetComboBox("AccumulationMethod", ui.cmbAccumulationMethod);

Expand Down

0 comments on commit 99af862

Please sign in to comment.