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(currentIndexChanged(
const QString &)),
this,
208 connect(
ui.cmbConnListener, SIGNAL(currentIndexChanged(
const QString &)),
this,
210 connect(
ui.cmbInstrument, SIGNAL(currentIndexChanged(
const QString &)),
this,
212 connect(
ui.cmbInstrument, SIGNAL(currentIndexChanged(
const QString &)),
this,
215 connect(
ui.cmbConnection, SIGNAL(currentIndexChanged(
const QString &)),
this,
219 ui.mainLayout->addLayout(buttonLayout);
262 ui.processingAlgo->saveInput();
263 ui.postAlgo->saveInput();
293 ui.lblPreserveEventsWarning->setVisible(
ui.chkPreserveEvents->isChecked());
300 Algorithm_sptr alg =
ui.processingAlgo->getAlgorithm();
310 Algorithm_sptr alg =
ui.postAlgo->getAlgorithm();
322 if (listener.isEmpty())
326 int addIndex =
ui.cmbAccumulationMethod->findText(
"Add");
327 ui.cmbAccumulationMethod->setItemData(addIndex, QVariant(Qt::ItemIsSelectable | Qt::ItemIsEnabled),
334 if (!Mantid::API::LiveListenerFactory::Instance().create(info,
false)->buffersEvents()) {
336 if (
ui.cmbAccumulationMethod->currentIndex() == addIndex) {
337 int replaceIndex =
ui.cmbAccumulationMethod->findText(
"Replace");
338 ui.cmbAccumulationMethod->setCurrentIndex(replaceIndex);
341 ui.cmbAccumulationMethod->setItemData(addIndex,
false, Qt::UserRole - 1);
362 if (inst ==
"TOPAZ") {
363 ui.groupBox->setEnabled(
false);
364 ui.radNow->setChecked(
true);
366 ui.groupBox->setEnabled(
true);
378 DateAndTime startTime = DateAndTime::getCurrentTime() -
ui.dateTimeEdit->value() * 60.0;
379 std::string starttime = startTime.toISO8601String();
382 QString propertyname = QString::fromStdString(
"StartTime");
383 QString propertyvalue = QString::fromStdString(starttime);
396 auto props =
m_algorithm->getPropertiesInGroup(
"ListenerProperties");
397 for (
const auto &prop : props) {
398 QString propName = QString::fromStdString((*prop).name());
405 if (
ui.cmbInstrument->currentText().toStdString() !=
"") {
407 QLayout *layout =
ui.listenerProps->layout();
409 QGridLayout *listenerPropLayout =
new QGridLayout(
ui.listenerProps);
410 layout = listenerPropLayout;
413 while ((child = layout->takeAt(0)) !=
nullptr) {
414 child->widget()->close();
421 m_algorithm->setPropertyValue(
"Instrument",
ui.cmbInstrument->currentText().toStdString());
422 m_algorithm->setPropertyValue(
"Listener", listener.toStdString());
424 props =
m_algorithm->getPropertiesInGroup(
"ListenerProperties");
428 ui.listenerProps->setVisible(
false);
432 auto gridLayout =
static_cast<QGridLayout *
>(layout);
434 for (
auto prop = props.begin(); prop != props.end(); ++prop) {
435 int row =
static_cast<int>(std::distance(props.begin(), prop));
436 QString propName = QString::fromStdString((**prop).name());
437 gridLayout->addWidget(
new QLabel(propName), row, 0);
438 QLineEdit *propWidget =
new QLineEdit();
439 gridLayout->addWidget(propWidget, row, 1);
443 tie(propWidget, propName, gridLayout);
445 ui.listenerProps->setVisible(
true);
456 ui.cmbConnection->clear();
460 const auto &inst = ConfigService::Instance().getInstrument(inst_name.toStdString());
461 for (
const auto &listener : inst.liveListenerInfoList()) {
462 ui.cmbConnection->addItem(QString::fromStdString(listener.name()));
467 auto selectName = QString::fromStdString(inst.liveListenerInfo().name());
468 auto index =
ui.cmbConnection->findText(selectName);
469 ui.cmbConnection->setCurrentIndex(
index);
470 }
catch (std::runtime_error &) {
483 ui.cmbConnListener->setEnabled(
true);
484 ui.edtConnAddress->setEnabled(
true);
489 ui.cmbConnListener->setEnabled(
false);
490 ui.edtConnAddress->setEnabled(
false);
493 const auto &inst = ConfigService::Instance().getInstrument(
ui.cmbInstrument->currentText().toStdString());
494 const auto &info = inst.liveListenerInfo(connection.toStdString());
497 auto listener = QString::fromStdString(info.listener());
498 auto index =
ui.cmbConnListener->findText(listener);
499 ui.cmbConnListener->setCurrentIndex(
index);
502 auto address = QString::fromStdString(info.address());
503 ui.edtConnAddress->setText(address);
504 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...