21#include "qboxlayout.h"
30using Mantid::Types::Core::DateAndTime;
36 ~LiveDataAlgInputHistoryImpl()
override =
default;
52 ~LiveDataPostProcessingAlgInputHistoryImpl()
override =
default;
63using LiveDataPostProcessingAlgInputHistory =
79 :
AlgorithmDialog(parent), m_scrollbars(this), m_useProcessAlgo(false), m_useProcessScript(false),
80 m_usePostProcessAlgo(false), m_usePostProcessScript(false) {
82 LiveDataAlgInputHistory::Instance();
88 LiveDataAlgInputHistory::Instance().save();
89 LiveDataPostProcessingAlgInputHistory::Instance().save();
103 ui.processingAlgo->setInputHistory(history1);
105 ui.postAlgo->setInputHistory(history2);
109 tie(
ui.edtUpdateEvery,
"UpdateEvery",
ui.layoutUpdateEvery);
112 tie(
ui.radNow,
"FromNow");
113 tie(
ui.radStartOfRun,
"FromStartOfRun");
114 tie(
ui.radAbsoluteTime,
"FromTime");
117 tie(
ui.chkPreserveEvents,
"PreserveEvents");
120 tie(
ui.cmbRunTransitionBehavior,
"RunTransitionBehavior");
123 tie(
ui.editAccumulationWorkspace,
"AccumulationWorkspace",
ui.gridLayout);
124 tie(
ui.editOutputWorkspace,
"OutputWorkspace",
ui.gridLayout);
127 ui.processingAlgo->update();
128 ui.postAlgo->update();
131 ui.tabWidget->setCurrentIndex(0);
132 ui.splitterMain->setStretchFactor(0, 0);
133 ui.splitterMain->setStretchFactor(1, 1);
136 for (
int i = 0; i < 2; i++) {
138 QString prefix =
"Processing";
141 prefix =
"PostProcessing";
142 QString algo = AlgorithmInputHistory::Instance().previousInput(
"StartLiveData", prefix +
"Algorithm");
143 QString script = AlgorithmInputHistory::Instance().previousInput(
"StartLiveData", prefix +
"Script");
147 ui.radProcessAlgorithm->setChecked(
true);
148 else if (!script.isEmpty())
149 ui.radProcessScript->setChecked(
true);
151 ui.radProcessNone->setChecked(
true);
154 ui.processingAlgo->setScriptText(script);
155 ui.processingAlgo->setSelectedAlgorithm(algo);
159 ui.radPostProcessAlgorithm->setChecked(
true);
160 else if (!script.isEmpty())
161 ui.radPostProcessScript->setChecked(
true);
163 ui.radPostProcessNone->setChecked(
true);
166 ui.postAlgo->setScriptText(script);
167 ui.postAlgo->setSelectedAlgorithm(algo);
174 ui.cmbConnListener->clear();
175 std::vector<std::string> listeners = Mantid::API::LiveListenerFactory::Instance().getKeys();
176 for (
const auto &listener : listeners) {
177 ui.cmbConnListener->addItem(QString::fromStdString(listener));
206 connect(
ui.cmbConnListener, SIGNAL(currentTextChanged(
const QString &)),
this,
208 connect(
ui.cmbConnListener, SIGNAL(currentTextChanged(
const QString &)),
this,
210 connect(
ui.cmbInstrument, SIGNAL(currentTextChanged(
const QString &)),
this, SLOT(
updateUiElements(
const QString &)));
211 connect(
ui.cmbInstrument, SIGNAL(currentTextChanged(
const QString &)),
this,
214 connect(
ui.cmbConnection, SIGNAL(currentTextChanged(
const QString &)),
this,
218 ui.mainLayout->addLayout(buttonLayout);
261 ui.processingAlgo->saveInput();
262 ui.postAlgo->saveInput();
292 ui.lblPreserveEventsWarning->setVisible(
ui.chkPreserveEvents->isChecked());
299 Algorithm_sptr alg =
ui.processingAlgo->getAlgorithm();
309 Algorithm_sptr alg =
ui.postAlgo->getAlgorithm();
321 if (listener.isEmpty())
325 int addIndex =
ui.cmbAccumulationMethod->findText(
"Add");
326 ui.cmbAccumulationMethod->setItemData(addIndex, QVariant(Qt::ItemIsSelectable | Qt::ItemIsEnabled),
333 if (!Mantid::API::LiveListenerFactory::Instance().create(info,
false)->buffersEvents()) {
335 if (
ui.cmbAccumulationMethod->currentIndex() == addIndex) {
336 int replaceIndex =
ui.cmbAccumulationMethod->findText(
"Replace");
337 ui.cmbAccumulationMethod->setCurrentIndex(replaceIndex);
340 ui.cmbAccumulationMethod->setItemData(addIndex,
false, Qt::UserRole - 1);
361 if (inst ==
"TOPAZ") {
362 ui.groupBox->setEnabled(
false);
363 ui.radNow->setChecked(
true);
365 ui.groupBox->setEnabled(
true);
377 DateAndTime startTime = DateAndTime::getCurrentTime() -
ui.dateTimeEdit->value() * 60.0;
378 std::string starttime = startTime.toISO8601String();
381 QString propertyname = QString::fromStdString(
"StartTime");
382 QString propertyvalue = QString::fromStdString(starttime);
395 auto props =
m_algorithm->getPropertiesInGroup(
"ListenerProperties");
396 for (
const auto &prop : props) {
397 QString propName = QString::fromStdString((*prop).name());
404 if (
ui.cmbInstrument->currentText().toStdString() !=
"") {
406 QLayout *layout =
ui.listenerProps->layout();
408 QGridLayout *listenerPropLayout =
new QGridLayout(
ui.listenerProps);
409 layout = listenerPropLayout;
412 while ((child = layout->takeAt(0)) !=
nullptr) {
413 child->widget()->close();
420 m_algorithm->setPropertyValue(
"Instrument",
ui.cmbInstrument->currentText().toStdString());
421 m_algorithm->setPropertyValue(
"Listener", listener.toStdString());
423 props =
m_algorithm->getPropertiesInGroup(
"ListenerProperties");
427 ui.listenerProps->setVisible(
false);
431 auto gridLayout =
static_cast<QGridLayout *
>(layout);
433 for (
auto prop = props.begin(); prop != props.end(); ++prop) {
434 int row =
static_cast<int>(std::distance(props.begin(), prop));
435 QString propName = QString::fromStdString((**prop).name());
436 gridLayout->addWidget(
new QLabel(propName), row, 0);
437 QLineEdit *propWidget =
new QLineEdit();
438 gridLayout->addWidget(propWidget, row, 1);
442 tie(propWidget, propName, gridLayout);
444 ui.listenerProps->setVisible(
true);
455 ui.cmbConnection->clear();
459 const auto &inst = ConfigService::Instance().getInstrument(inst_name.toStdString());
460 for (
const auto &listener : inst.liveListenerInfoList()) {
461 ui.cmbConnection->addItem(QString::fromStdString(listener.name()));
466 auto selectName = QString::fromStdString(inst.liveListenerInfo().name());
467 auto index =
ui.cmbConnection->findText(selectName);
468 ui.cmbConnection->setCurrentIndex(
index);
469 }
catch (std::runtime_error &) {
482 ui.cmbConnListener->setEnabled(
true);
483 ui.edtConnAddress->setEnabled(
true);
488 ui.cmbConnListener->setEnabled(
false);
489 ui.edtConnAddress->setEnabled(
false);
492 const auto &inst = ConfigService::Instance().getInstrument(
ui.cmbInstrument->currentText().toStdString());
493 const auto &info = inst.liveListenerInfo(connection.toStdString());
496 auto listener = QString::fromStdString(info.listener());
497 auto index =
ui.cmbConnListener->findText(listener);
498 ui.cmbConnListener->setCurrentIndex(
index);
501 auto address = QString::fromStdString(info.address());
502 ui.edtConnAddress->setText(address);
503 ui.edtConnAddress->home(
false);
#define DECLARE_DIALOG(classname)
std::map< DeltaEMode::Type, std::string > index
This abstract class deals with the loading and saving of previous algorithm property values to/from M...
This class should be the basis for all customised algorithm dialogs.
void fillAndSetComboBox(const QString &propName, QComboBox *optionsBox) const
Fill a combo box for the named algorithm's allowed values.
Mantid::API::IAlgorithm_sptr m_algorithm
The algorithm associated with this dialog.
QLayout * createDefaultButtonLayout(const QString &helpText=QString("?"), const QString &loadText=QString("Run"), const QString &cancelText=QString("Close"), const QString &keepOpenText=QString("Keep Open"))
Create a row layout of buttons with specified text.
void storePropertyValue(const QString &name, const QString &value)
Adds a property (name,value) pair to the stored map.
QWidget * tie(QWidget *widget, const QString &property, QLayout *parent_layout=nullptr, bool readHistory=true)
Tie a widget to a property.
QStringList m_algProperties
The properties associated with this dialog.
void accept() override
A default slot that can be used for an OK button.
Ui::StartLiveDataDialog ui
The form generated by Qt Designer.
bool m_usePostProcessScript
void chkPreserveEventsToggled()
Slot called when the preserve events checkbox changes.
void initListenerPropLayout(const QString &listener)
Update the Listener Properties group box for the current LiveListener.
void parseInput() override
Parse the input from the dialog when it has been accepted.
Mantid::API::Algorithm_sptr m_postProcessingAlg
The algorithm for processing the accumulated workspace.
static const QString CUSTOM_CONNECTION
Constant used for custom listener connection setups.
void radioTimeClicked()
Slot called when one of the radio buttons in "starting time" are picked.
StartLiveDataDialog(QWidget *parent=nullptr)
Default Constructor.
~StartLiveDataDialog() override
Destructor.
void changePostProcessingAlgorithm()
Slot called when picking a different algorithm in the AlgorithmSelectorWidget.
void initLayout() override
Initialize the layout.
void updateConnectionChoices(const QString &inst_name)
Slot to update list of available connections when instrument is changed.
void radioPostProcessClicked()
Slot called when one of the radio buttons in "processing" are picked.
Mantid::API::Algorithm_sptr m_processingAlg
The algorithm for processing chunks.
void changeProcessingAlgorithm()
Slot called when picking a different algorithm in the AlgorithmSelectorWidget.
void radioProcessClicked()
Slot called when one of the radio buttons in "processing" are picked.
void updateUiElements(const QString &)
Another slot called when picking a different instrument.
void updateConnectionDetails(const QString &connection)
Slot to update connection parameters when connection selected.
API::WidgetScrollbarDecorator m_scrollbars
This dialog needs scrollbars on small screens.
bool m_usePostProcessAlgo
void setDefaultAccumulationMethod(const QString &)
Slot called when picking a different instrument.
Exception for when an item is not found in a collection.
A class that holds information about a LiveListener connection.
Manage the lifetime of a class intended to be a singleton.
Mantid::Kernel::SingletonHolder< AlgorithmManagerImpl > AlgorithmManager
std::shared_ptr< Algorithm > Algorithm_sptr
Typedef for a shared pointer to an Algorithm.
Mantid::Kernel::SingletonHolder< ConfigServiceImpl > ConfigService
Policy class controlling creation of the singleton Implementation classes should mark their default c...