Skip to content

Commit

Permalink
Re #9958. Set spectra list via listener's property.
Browse files Browse the repository at this point in the history
  • Loading branch information
mantid-roman committed Sep 1, 2014
1 parent 6a65050 commit 8154ae3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 22 deletions.
25 changes: 14 additions & 11 deletions Code/Mantid/Framework/LiveData/src/ISISHistoDataListener.cpp
Expand Up @@ -9,6 +9,7 @@
#include "MantidKernel/ConfigService.h"
#include "MantidKernel/Exception.h"
#include "MantidKernel/UnitFactory.h"
#include "MantidKernel/ArrayProperty.h"
#include "MantidGeometry/Instrument.h"

#include "LoadDAE/idc.h"
Expand Down Expand Up @@ -38,7 +39,8 @@ namespace LiveData
/// Constructor
ISISHistoDataListener::ISISHistoDataListener() : ILiveListener(), isInitilized(false), m_daeHandle( NULL ), m_timeRegime(-1)
{
declareProperty( "Stuff", 12, "Some dummy property" );
declareProperty(new Kernel::ArrayProperty<specid_t>("SpectraList",""),
"An optional list of spectra to load. If blank, all available spectra will be loaded.");
}

/// Destructor
Expand Down Expand Up @@ -67,8 +69,13 @@ namespace LiveData
*/
bool ISISHistoDataListener::connect(const Poco::Net::SocketAddress& address)
{
int stuff = getProperty("Stuff");
std::cerr << "Stuff = " << stuff << std::endl;

// Set the spectra list to load
std::vector<specid_t> spectra = getProperty("SpectraList");
if ( !spectra.empty() )
{
setSpectra( spectra );
}

m_daeName = address.toString();
// remove the port part
Expand All @@ -88,7 +95,7 @@ namespace LiveData
}

m_numberOfPeriods = getInt("NPER");
g_log.notice() << "Number of periods " << m_numberOfPeriods << std::endl;
g_log.debug() << "Number of periods " << m_numberOfPeriods << std::endl;

loadSpectraMap();

Expand Down Expand Up @@ -133,7 +140,7 @@ namespace LiveData
if ( m_timeRegime < 0 )
{
m_timeRegime = getTimeRegimeToLoad();
g_log.notice() << "Loading spectra for time regime " << m_timeRegime + 1 << std::endl;
g_log.debug() << "Loading spectra for time regime " << m_timeRegime + 1 << std::endl;
}


Expand Down Expand Up @@ -501,7 +508,7 @@ namespace LiveData

// number of monitors
int nmon = getInt( "NMON" );
// indices of monitors in m_detIDs and m_specIDs
// indices of monitors in m_detIDs and m_specIDs ( +1 )
std::vector<int> monitorIndices;
getIntArray("MDET",monitorIndices,nmon);

Expand All @@ -514,7 +521,7 @@ namespace LiveData
m_monitorSpectra.resize( nmon );
for(size_t i = 0; i < nmon; ++i)
{
m_monitorSpectra[i] = m_specIDs[monitorIndices[i]];
m_monitorSpectra[i] = m_specIDs[monitorIndices[i] - 1];
}

for(auto mon = m_monitorSpectra.begin(); mon != m_monitorSpectra.end(); ++mon)
Expand Down Expand Up @@ -558,15 +565,11 @@ namespace LiveData
{
if ( ! m_specList.empty() )
{
g_log.notice() << "Spectrum list provided." << std::endl;
if ( m_monitorSpectra.empty() ) return 0;
g_log.notice() << "There are some monitors." << std::endl;
int regime = -1;
for( auto specIt = m_specList.begin(); specIt != m_specList.end(); ++specIt )
{
bool isMonitor = std::find(m_monitorSpectra.begin(),m_monitorSpectra.end(), *specIt) != m_monitorSpectra.end();
if ( !isMonitor )
g_log.warning() << "Spectrum " << *specIt << " is not a monitor." << std::endl;
int specRegime = isMonitor? 1 : 0;
if ( regime < 0 )
{
Expand Down
3 changes: 0 additions & 3 deletions Code/Mantid/Framework/LiveData/src/LiveDataAlgorithm.cpp
Expand Up @@ -123,9 +123,6 @@ namespace LiveData
declareProperty(new PropertyWithValue<std::string>("LastTimeStamp","",Direction::Output),
"The time stamp of the last event, frame or pulse recorded.\n"
"Date/time is in UTC time, in ISO8601 format, e.g. 2010-09-14T04:20:12.95");

declareProperty(new ArrayProperty<specid_t>("SpectraList",""),
"An optional list of spectra to load. If blank, all available spectra will be loaded.");
}


Expand Down
7 changes: 0 additions & 7 deletions Code/Mantid/Framework/LiveData/src/StartLiveData.cpp
Expand Up @@ -129,13 +129,6 @@ namespace
"The effective start time is therefore 'now'.");
}

// Set the spectra list to load
std::vector<specid_t> spectra = getProperty("SpectraList");
if ( !spectra.empty() )
{
listener->setSpectra( spectra );
}

auto loadAlg = boost::dynamic_pointer_cast<LoadLiveData>(createChildAlgorithm("LoadLiveData"));
if ( ! loadAlg ) throw std::logic_error("Error creating LoadLiveData - contact the Mantid developer team");
// Copy settings from THIS to LoadAlg
Expand Down
Expand Up @@ -483,8 +483,19 @@ QGroupBox::title { background-color: transparent; subcontrol-position: top cent
</item>
<item>
<widget class="QGroupBox" name="listenerProps">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">QGroupBox { border: 1px solid gray; border-radius: 4px; font-weight: bold; margin-top: 4px; margin-bottom: 4px; padding-top: 16px; }
QGroupBox::title { background-color: transparent; subcontrol-position: top center; padding-top:4px; padding-bottom:4px; }
</string>
</property>
<property name="title">
<string>GroupBox</string>
<string>Listener Properties</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit 8154ae3

Please sign in to comment.