Skip to content

Commit

Permalink
-A preliminary dialog to modify CoSimulation settings
Browse files Browse the repository at this point in the history
  • Loading branch information
alash325 committed Mar 14, 2016
1 parent 6247798 commit 6da40e1
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 0 deletions.
30 changes: 30 additions & 0 deletions OMEdit/OMEditGUI/MainWindow.cpp
Expand Up @@ -202,6 +202,8 @@ MainWindow::MainWindow(QSplashScreen *pSplashScreen, bool debug, QWidget *parent
mpSimulationDialog = new SimulationDialog(this);
// Create TLM co-simulation dialog
mpTLMCoSimulationDialog = new TLMCoSimulationDialog(this);
// Create TLM co-simulation experiment setting dialog
mpTLMCoSimulationExperimentSettingDialog = new TLMCoSimulationExperimentSettingDialog(this);
// Create an object of PlotWindowContainer
mpPlotWindowContainer = new PlotWindowContainer(this);
// create an object of VariablesWidget
Expand Down Expand Up @@ -618,6 +620,7 @@ void MainWindow::beforeClosingMainWindow()
delete mpDebuggerMainWindow;
delete mpSimulationDialog;
delete mpTLMCoSimulationDialog;
delete mpTLMCoSimulationExperimentSettingDialog;
/* save the TransformationsWidget last window geometry and splitters state. */
QSettings *pSettings = OpenModelica::getApplicationSettings();
QHashIterator<QString, TransformationsWidget*> transformationsWidgets(mTransformationsWidgetHash);
Expand Down Expand Up @@ -954,6 +957,16 @@ void MainWindow::fetchInterfaceData(LibraryTreeItem *pLibraryTreeItem)
}
}

/*!
* \brief MainWindow::TLMCoSimulationExperimentSettings
* \param pLibraryTreeItem
* Showsthe TLM co-simulation experiment setting dialog.
*/
void MainWindow::TLMCoSimulationExperimentSettings(LibraryTreeItem *pLibraryTreeItem)
{
mpTLMCoSimulationExperimentSettingDialog->show(pLibraryTreeItem);
}

/*!
* \brief MainWindow::TLMSimulate
* \param pLibraryTreeItem
Expand Down Expand Up @@ -1974,6 +1987,19 @@ void MainWindow::exportToClipboard()
exportModelAsImage(true);
}

/*!
* \brief MainWindow::TLMCoSimulationExperimentSettings
* Slot activated when mpTLMCoSimulationExperimentSettingAction triggered signal is raised.
* Calls the function that opens the TLM Co-Simulation experiment setting dialog.
*/
void MainWindow::TLMCoSimulationExperimentSettings()
{
ModelWidget *pModelWidget = mpModelWidgetContainer->getCurrentModelWidget();
if (pModelWidget) {
TLMCoSimulationExperimentSettings(pModelWidget->getLibraryTreeItem());
}
}

/*!
* \brief MainWindow::fetchInterfaceData
* Slot activated when mpFetchInterfaceDataAction triggered signal is raised.
Expand Down Expand Up @@ -2816,6 +2842,10 @@ void MainWindow::createActions()
mpTLMCoSimulationAction->setStatusTip(Helper::tlmCoSimulationSetupTip);
mpTLMCoSimulationAction->setEnabled(false);
connect(mpTLMCoSimulationAction, SIGNAL(triggered()), SLOT(TLMSimulate()));
// Set TLM Co-Simulation experiment setting
mpTLMCoSimulationExperimentSettingAction = new QAction(Helper::tlmCoSimulationExperimentSetting, this);
mpTLMCoSimulationExperimentSettingAction->setStatusTip(Helper::tlmCoSimulationExperimentSettingTip);
connect(mpTLMCoSimulationExperimentSettingAction, SIGNAL(triggered()), SLOT(TLMCoSimulationExperimentSettings()));
}

//! Creates the menus
Expand Down
6 changes: 6 additions & 0 deletions OMEdit/OMEditGUI/MainWindow.h
Expand Up @@ -84,6 +84,7 @@ class DocumentationWidget;
class VariablesWidget;
class SimulationDialog;
class TLMCoSimulationDialog;
class TLMCoSimulationExperimentSettingDialog;
class PlotWindowContainer;
class ModelWidgetContainer;
class DebuggerMainWindow;
Expand Down Expand Up @@ -155,6 +156,7 @@ class MainWindow : public QMainWindow
QAction* getConnectModeAction();
QAction* getFetchInterfaceDataAction() {return mpFetchInterfaceDataAction;}
QAction* getTLMSimulationAction() {return mpTLMCoSimulationAction;}
QAction* getTLMCoSimulationExperimentSettingAction() {return mpTLMCoSimulationExperimentSettingAction;}
void addRecentFile(const QString &fileName, const QString &encoding);
void updateRecentFileActions();
void closeEvent(QCloseEvent *event);
Expand All @@ -174,6 +176,7 @@ class MainWindow : public QMainWindow
void exportModelFigaro(LibraryTreeItem *pLibraryTreeItem);
void fetchInterfaceData(LibraryTreeItem *pLibraryTreeItem);
void TLMSimulate(LibraryTreeItem *pLibraryTreeItem);
void TLMCoSimulationExperimentSettings(LibraryTreeItem *pLibraryTreeItem);
void exportModelToOMNotebook(LibraryTreeItem *pLibraryTreeItem);
void createOMNotebookTitleCell(LibraryTreeItem *pLibraryTreeItem, QDomDocument xmlDocument, QDomElement domElement);
void createOMNotebookImageCell(LibraryTreeItem *pLibraryTreeItem, QDomDocument xmlDocument, QDomElement domElement, QString filePath);
Expand Down Expand Up @@ -203,6 +206,7 @@ class MainWindow : public QMainWindow
QDockWidget *mpVariablesDockWidget;
SimulationDialog *mpSimulationDialog;
TLMCoSimulationDialog *mpTLMCoSimulationDialog;
TLMCoSimulationExperimentSettingDialog *mpTLMCoSimulationExperimentSettingDialog;
PlotWindowContainer *mpPlotWindowContainer;
QList<Qt::WindowStates> mPlotWindowsStatesList;
QList<QByteArray> mPlotWindowsGeometriesList;
Expand Down Expand Up @@ -314,6 +318,7 @@ class MainWindow : public QMainWindow
// TLM Simulation Action
QAction *mpFetchInterfaceDataAction;
QAction *mpTLMCoSimulationAction;
QAction *mpTLMCoSimulationExperimentSettingAction;
// Toolbars
QMenu *mpRecentFilesMenu;
QMenu *mpLibrariesMenu;
Expand Down Expand Up @@ -376,6 +381,7 @@ public slots:
void exportToClipboard();
void fetchInterfaceData();
void TLMSimulate();
void TLMCoSimulationExperimentSettings();
void openWorkingDirectory();
void openTerminal();
void openConfigurationOptions();
Expand Down
17 changes: 17 additions & 0 deletions OMEdit/OMEditGUI/Modeling/LibraryTreeWidget.cpp
Expand Up @@ -2271,6 +2271,10 @@ void LibraryTreeView::createActions()
mpTLMCoSimulationAction = new QAction(QIcon(":/Resources/icons/tlm-simulate.svg"), Helper::tlmCoSimulationSetup, this);
mpTLMCoSimulationAction->setStatusTip(Helper::tlmCoSimulationSetupTip);
connect(mpTLMCoSimulationAction, SIGNAL(triggered()), SLOT(TLMSimulate()));
// Set TLM Co-Simulation experiment setting
mpTLMCoSimulationExperimentSettingAction = new QAction(Helper::tlmCoSimulationExperimentSetting, this);
mpTLMCoSimulationExperimentSettingAction->setStatusTip(Helper::tlmCoSimulationExperimentSettingTip);
connect(mpTLMCoSimulationExperimentSettingAction, SIGNAL(triggered()), SLOT(TLMCoSimulationExperimentSetting()));
}

/*!
Expand Down Expand Up @@ -2407,6 +2411,7 @@ void LibraryTreeView::showContextMenu(QPoint point)
menu.addAction(mpUnloadMetaModelFileAction);
break;
case LibraryTreeItem::MetaModel:
menu.addAction(mpTLMCoSimulationExperimentSettingAction);
menu.addAction(mpFetchInterfaceDataAction);
menu.addAction(mpTLMCoSimulationAction);
menu.addSeparator();
Expand Down Expand Up @@ -2709,6 +2714,18 @@ void LibraryTreeView::updateBindings()
}
}

/*!
* \brief LibraryTreeView::TLMCoSimulate experiment setting
* Opens the TLM co-simulation experimet setting dialog for the selected LibraryTreeItem.
*/
void LibraryTreeView::TLMCoSimulationExperimentSetting()
{
LibraryTreeItem *pLibraryTreeItem = getSelectedLibraryTreeItem();
if (pLibraryTreeItem) {
mpLibraryWidget->getMainWindow()->TLMCoSimulationExperimentSettings(pLibraryTreeItem);
}
}

/*!
* \brief LibraryTreeView::fetchInterfaceData
* Slot activated when mpFetchInterfaceDataAction triggered signal is raised.
Expand Down
2 changes: 2 additions & 0 deletions OMEdit/OMEditGUI/Modeling/LibraryTreeWidget.h
Expand Up @@ -307,6 +307,7 @@ class LibraryTreeView : public QTreeView
QAction *mpUpdateBindingsAction;
QAction *mpFetchInterfaceDataAction;
QAction *mpTLMCoSimulationAction;
QAction *mpTLMCoSimulationExperimentSettingAction;
void createActions();
LibraryTreeItem* getSelectedLibraryTreeItem();
void libraryTreeItemExpanded(LibraryTreeItem* pLibraryTreeItem);
Expand Down Expand Up @@ -339,6 +340,7 @@ public slots:
void updateBindings();
void fetchInterfaceData();
void TLMSimulate();
void TLMCoSimulationExperimentSetting();
protected:
virtual void mouseDoubleClickEvent(QMouseEvent *event);
virtual void startDrag(Qt::DropActions supportedActions);
Expand Down
68 changes: 68 additions & 0 deletions OMEdit/OMEditGUI/TLM/TLMCoSimulationDialog.cpp
Expand Up @@ -394,3 +394,71 @@ void TLMCoSimulationDialog::runTLMCoSimulation()
}
}
}

TLMCoSimulationExperimentSettingDialog::TLMCoSimulationExperimentSettingDialog(MainWindow *pMainWindow)
: QDialog(pMainWindow, Qt::WindowTitleHint)
{
mpMainWindow = pMainWindow;
setMinimumWidth(300);
// CoSimulation Interval
mpStartTimeLabel = new Label(tr("Start Time:"));
mpStartTimeTextBox = new QLineEdit("0");
mpStopTimeLabel = new Label(tr("Stop Time:"));
mpStopTimeTextBox = new QLineEdit("1");
// Add the validators
QDoubleValidator *pDoubleValidator = new QDoubleValidator(this);
mpStartTimeTextBox->setValidator(pDoubleValidator);
mpStopTimeTextBox->setValidator(pDoubleValidator);
// buttons
mpSaveButton = new QPushButton(Helper::save);
mpSaveButton->setToolTip(tr("Saves the Co-Simulation experiment settings"));
connect(mpSaveButton, SIGNAL(clicked()), this, SLOT(saveExperimentSettings()));
mpSaveAndCoSimulateButton = new QPushButton(tr("Save && CoSimulate"));
mpSaveAndCoSimulateButton->setToolTip(tr("Saves the Co-Simulation experiment settings and starts the Co-Simulation"));
connect(mpSaveAndCoSimulateButton, SIGNAL(clicked()), this, SLOT(saveExperimentSettingsAndCoSimulate()));
mpCancelButton = new QPushButton(Helper::cancel);
connect(mpCancelButton, SIGNAL(clicked()), SLOT(reject()));
// adds Co-Simulation Experiment Setting buttons to the button box
mpButtonBox = new QDialogButtonBox(Qt::Horizontal);
mpButtonBox->addButton(mpSaveButton, QDialogButtonBox::ActionRole);
mpButtonBox->addButton(mpSaveAndCoSimulateButton, QDialogButtonBox::ActionRole);
mpButtonBox->addButton(mpCancelButton, QDialogButtonBox::ActionRole);
// set the layout
QGridLayout *pMainLayout = new QGridLayout;
pMainLayout->setAlignment(Qt::AlignLeft | Qt::AlignTop);
pMainLayout->addWidget(mpStartTimeLabel, 0, 0);
pMainLayout->addWidget(mpStartTimeTextBox, 0, 1);
pMainLayout->addWidget(mpStopTimeLabel, 1, 0);
pMainLayout->addWidget(mpStopTimeTextBox, 1, 1);
pMainLayout->addWidget(mpButtonBox, 2, 1, 1, 1, Qt::AlignRight);
setLayout(pMainLayout);
}

/*!
Reimplementation of QDialog::show method.
\param pLibraryTreeItem - pointer to LibraryTreeItem
*/
void TLMCoSimulationExperimentSettingDialog::show(LibraryTreeItem *pLibraryTreeItem)
{
mpLibraryTreeItem = pLibraryTreeItem;
setWindowTitle(QString("%1 - %2 - %3").arg(Helper::applicationName).arg(Helper::tlmCoSimulationExperimentSetting).arg(mpLibraryTreeItem->getNameStructure()));
setVisible(true);
}

/*!
Saves the TLM Co-Simulation experiment setting.
Slot activated when mpSave button clicked signal is raised.
*/
void TLMCoSimulationExperimentSettingDialog::saveExperimentSettings()
{

}

/*!
Saves the TLM Co-Simulation experiment setting and start the co-simulation.
Slot activated when mpSaveAndCoSimulateButton clicked signal is raised.
*/
void TLMCoSimulationExperimentSettingDialog::saveExperimentSettingsAndCoSimulate()
{

}
22 changes: 22 additions & 0 deletions OMEdit/OMEditGUI/TLM/TLMCoSimulationDialog.h
Expand Up @@ -97,4 +97,26 @@ private slots:
void runTLMCoSimulation();
};

class TLMCoSimulationExperimentSettingDialog : public QDialog
{
Q_OBJECT
public:
TLMCoSimulationExperimentSettingDialog(MainWindow *pMainWindow);
void show(LibraryTreeItem *pLibraryTreeItem);
private:
MainWindow *mpMainWindow;
LibraryTreeItem *mpLibraryTreeItem;
Label *mpStartTimeLabel;
QLineEdit *mpStartTimeTextBox;
Label *mpStopTimeLabel;
QLineEdit *mpStopTimeTextBox;
QPushButton *mpSaveButton;
QPushButton *mpSaveAndCoSimulateButton;
QPushButton *mpCancelButton;
QDialogButtonBox *mpButtonBox;
private slots:
void saveExperimentSettings();
void saveExperimentSettingsAndCoSimulate();
};

#endif // TLMCOSIMULATIONDIALOG_H
4 changes: 4 additions & 0 deletions OMEdit/OMEditGUI/Util/Helper.cpp
Expand Up @@ -295,6 +295,8 @@ QString Helper::fetchInterfaceDataTip;
QString Helper::tlmCoSimulationSetup;
QString Helper::tlmCoSimulationSetupTip;
QString Helper::tlmCoSimulation;
QString Helper::tlmCoSimulationExperimentSetting;
QString Helper::tlmCoSimulationExperimentSettingTip;
QString Helper::running;
QString Helper::finished;
QString Helper::newVariable;
Expand Down Expand Up @@ -491,6 +493,8 @@ void Helper::initHelperVariables()
Helper::tlmCoSimulationSetup = tr("TLM Co-Simulation Setup");
Helper::tlmCoSimulationSetupTip = tr("Opens the TLM co-simulation setup");
Helper::tlmCoSimulation = tr("TLM Co-Simulation");
Helper::tlmCoSimulationExperimentSetting = tr("Edit Experiment Setting");
Helper::tlmCoSimulationExperimentSettingTip = tr("Opens the TLM co-simulation experiment setting");
Helper::running = tr("Running");
Helper::finished = tr("Finished");
Helper::newVariable = tr("<New Variable>");
Expand Down
2 changes: 2 additions & 0 deletions OMEdit/OMEditGUI/Util/Helper.h
Expand Up @@ -302,6 +302,8 @@ class Helper : public QObject
static QString tlmCoSimulationSetup;
static QString tlmCoSimulationSetupTip;
static QString tlmCoSimulation;
static QString tlmCoSimulationExperimentSetting;
static QString tlmCoSimulationExperimentSettingTip;
static QString running;
static QString finished;
static QString newVariable;
Expand Down

0 comments on commit 6da40e1

Please sign in to comment.