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";
148 ui.radProcessAlgorithm->setChecked(
true);
149 else if (!script.isEmpty())
150 ui.radProcessScript->setChecked(
true);
152 ui.radProcessNone->setChecked(
true);
155 ui.processingAlgo->setScriptText(script);
156 ui.processingAlgo->setSelectedAlgorithm(algo);
160 ui.radPostProcessAlgorithm->setChecked(
true);
161 else if (!script.isEmpty())
162 ui.radPostProcessScript->setChecked(
true);
164 ui.radPostProcessNone->setChecked(
true);
167 ui.postAlgo->setScriptText(script);
168 ui.postAlgo->setSelectedAlgorithm(algo);
175 ui.cmbConnListener->clear();
177 for (
const auto &listener : listeners) {
178 ui.cmbConnListener->addItem(QString::fromStdString(listener));
207 connect(
ui.cmbConnListener, SIGNAL(currentIndexChanged(
const QString &)),
this,
209 connect(
ui.cmbConnListener, SIGNAL(currentIndexChanged(
const QString &)),
this,
211 connect(
ui.cmbInstrument, SIGNAL(currentIndexChanged(
const QString &)),
this,
213 connect(
ui.cmbInstrument, SIGNAL(currentIndexChanged(
const QString &)),
this,
216 connect(
ui.cmbConnection, SIGNAL(currentIndexChanged(
const QString &)),
this,
220 ui.mainLayout->addLayout(buttonLayout);
263 ui.processingAlgo->saveInput();
264 ui.postAlgo->saveInput();
294 ui.lblPreserveEventsWarning->setVisible(
ui.chkPreserveEvents->isChecked());
301 Algorithm_sptr alg =
ui.processingAlgo->getAlgorithm();
311 Algorithm_sptr alg =
ui.postAlgo->getAlgorithm();
323 if (listener.isEmpty())
327 int addIndex =
ui.cmbAccumulationMethod->findText(
"Add");
328 ui.cmbAccumulationMethod->setItemData(addIndex, QVariant(Qt::ItemIsSelectable | Qt::ItemIsEnabled),
337 if (
ui.cmbAccumulationMethod->currentIndex() == addIndex) {
338 int replaceIndex =
ui.cmbAccumulationMethod->findText(
"Replace");
339 ui.cmbAccumulationMethod->setCurrentIndex(replaceIndex);
342 ui.cmbAccumulationMethod->setItemData(addIndex,
false, Qt::UserRole - 1);
363 if (inst ==
"TOPAZ") {
364 ui.groupBox->setEnabled(
false);
365 ui.radNow->setChecked(
true);
367 ui.groupBox->setEnabled(
true);
379 DateAndTime startTime = DateAndTime::getCurrentTime() -
ui.dateTimeEdit->value() * 60.0;
380 std::string starttime = startTime.toISO8601String();
383 QString propertyname = QString::fromStdString(
"StartTime");
384 QString propertyvalue = QString::fromStdString(starttime);
397 auto props =
m_algorithm->getPropertiesInGroup(
"ListenerProperties");
398 for (
auto &prop : props) {
399 QString propName = QString::fromStdString((*prop).name());
406 if (
ui.cmbInstrument->currentText().toStdString() !=
"") {
408 QLayout *layout =
ui.listenerProps->layout();
410 QGridLayout *listenerPropLayout =
new QGridLayout(
ui.listenerProps);
411 layout = listenerPropLayout;
414 while ((child = layout->takeAt(0)) !=
nullptr) {
415 child->widget()->close();
421 props =
m_algorithm->getPropertiesInGroup(
"ListenerProperties");
425 ui.listenerProps->setVisible(
false);
429 auto gridLayout =
static_cast<QGridLayout *
>(layout);
431 for (
auto prop = props.begin(); prop != props.end(); ++prop) {
432 int row =
static_cast<int>(std::distance(props.begin(), prop));
433 QString propName = QString::fromStdString((**prop).name());
434 gridLayout->addWidget(
new QLabel(propName), row, 0);
435 QLineEdit *propWidget =
new QLineEdit();
436 gridLayout->addWidget(propWidget, row, 1);
440 tie(propWidget, propName, gridLayout);
442 ui.listenerProps->setVisible(
true);
453 ui.cmbConnection->clear();
457 const auto &inst = ConfigService::Instance().getInstrument(inst_name.toStdString());
458 for (
const auto &listener : inst.liveListenerInfoList()) {
459 ui.cmbConnection->addItem(QString::fromStdString(listener.name()));
464 auto selectName = QString::fromStdString(inst.liveListenerInfo().name());
465 auto index =
ui.cmbConnection->findText(selectName);
466 ui.cmbConnection->setCurrentIndex(
index);
467 }
catch (std::runtime_error &) {
480 ui.cmbConnListener->setEnabled(
true);
481 ui.edtConnAddress->setEnabled(
true);
486 ui.cmbConnListener->setEnabled(
false);
487 ui.edtConnAddress->setEnabled(
false);
490 const auto &inst = ConfigService::Instance().getInstrument(
ui.cmbInstrument->currentText().toStdString());
491 const auto &info = inst.liveListenerInfo(connection.toStdString());
494 auto listener = QString::fromStdString(info.listener());
495 auto index =
ui.cmbConnListener->findText(listener);
496 ui.cmbConnListener->setCurrentIndex(
index);
499 auto address = QString::fromStdString(info.address());
500 ui.edtConnAddress->setText(address);
501 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 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 initListenerPropLayout()
Update the Listener Properties group box for the current LiveListener.
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.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
std::shared_ptr< Algorithm > Algorithm_sptr
Typedef for a shared pointer to an Algorithm.
Policy class controlling creation of the singleton Implementation classes should mark their default c...