Skip to content

Commit b858490

Browse files
committed
Instantiate OMSimulator model when simulate button is clicked
1 parent bd4b2d5 commit b858490

File tree

4 files changed

+8
-21
lines changed

4 files changed

+8
-21
lines changed

OMEdit/OMEditLIB/MainWindow.cpp

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,13 @@ void MainWindow::simulate(LibraryTreeItem *pLibraryTreeItem)
708708
if (!mpOMSSimulationDialog) {
709709
mpOMSSimulationDialog = new OMSSimulationDialog(this);
710710
}
711-
mpOMSSimulationDialog->simulate(pTopLevelLibraryTreeItem);
711+
const QString modelName = pTopLevelLibraryTreeItem->getNameStructure();
712+
instantiateOMSModel(pTopLevelLibraryTreeItem, !pTopLevelLibraryTreeItem->isOMSModelInstantiated());
713+
// get the top level LibraryTreeItem again since instantiateOMSModel redraws them
714+
LibraryTreeItem *pTopLevelLibraryTreeItem = mpLibraryWidget->getLibraryTreeModel()->findLibraryTreeItemOneLevel(modelName);
715+
if (pTopLevelLibraryTreeItem) {
716+
mpOMSSimulationDialog->simulate(pTopLevelLibraryTreeItem);
717+
}
712718
}
713719
}
714720
}
@@ -819,23 +825,6 @@ void MainWindow::instantiateOMSModel(LibraryTreeItem *pLibraryTreeItem, bool che
819825
}
820826
}
821827

822-
/*!
823-
* \brief MainWindow::simulateOMSModel
824-
* Simulates the OMSimulator model.
825-
* \param pLibraryTreeItem
826-
*/
827-
void MainWindow::simulateOMSModel(LibraryTreeItem *pLibraryTreeItem)
828-
{
829-
// get the top level LibraryTreeItem
830-
LibraryTreeItem *pTopLevelLibraryTreeItem = mpLibraryWidget->getLibraryTreeModel()->getTopLevelLibraryTreeItem(pLibraryTreeItem);
831-
if (pTopLevelLibraryTreeItem) {
832-
if (!mpOMSSimulationDialog) {
833-
mpOMSSimulationDialog = new OMSSimulationDialog(this);
834-
}
835-
mpOMSSimulationDialog->simulate(pTopLevelLibraryTreeItem);
836-
}
837-
}
838-
839828
void MainWindow::instantiateModel(LibraryTreeItem *pLibraryTreeItem)
840829
{
841830
/* if Modelica text is changed manually by user then validate it before saving. */

OMEdit/OMEditLIB/MainWindow.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ class MainWindow : public QMainWindow
227227
#endif
228228
void simulationSetup(LibraryTreeItem *pLibraryTreeItem);
229229
void instantiateOMSModel(LibraryTreeItem *pLibraryTreeItem, bool checked);
230-
void simulateOMSModel(LibraryTreeItem *pLibraryTreeItem);
231230
void instantiateModel(LibraryTreeItem *pLibraryTreeItem);
232231
void checkModel(LibraryTreeItem *pLibraryTreeItem);
233232
void checkAllModels(LibraryTreeItem *pLibraryTreeItem);

OMEdit/OMEditLIB/Modeling/ModelWidgetContainer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8113,7 +8113,7 @@ void ModelWidgetContainer::currentModelWidgetChanged(QMdiSubWindow *pSubWindow)
81138113
MainWindow::instance()->getBitmapShapeAction()->setEnabled(enabled && modelica && !textView);
81148114
MainWindow::instance()->getConnectModeAction()->setEnabled(enabled && (modelica || compositeModel || (oms && !(omsSubmodel || omsConnector))) && !textView);
81158115
MainWindow::instance()->getTransitionModeAction()->setEnabled(enabled && (modelica) && !textView);
8116-
MainWindow::instance()->getSimulateModelAction()->setEnabled(enabled && ((modelica && pLibraryTreeItem->isSimulationAllowed()) || (oms && isOMSModelInstantiated)));
8116+
MainWindow::instance()->getSimulateModelAction()->setEnabled(enabled && ((modelica && pLibraryTreeItem->isSimulationAllowed()) || (oms)));
81178117
MainWindow::instance()->getSimulateWithTransformationalDebuggerAction()->setEnabled(enabled && modelica && pLibraryTreeItem->isSimulationAllowed());
81188118
MainWindow::instance()->getSimulateWithAlgorithmicDebuggerAction()->setEnabled(enabled && modelica && pLibraryTreeItem->isSimulationAllowed());
81198119
#if !defined(WITHOUT_OSG)

OMEdit/OMEditLIB/OMS/OMSSimulationDialog.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ void OMSSimulationDialog::simulationFinished(const QString &resultFilePath, QDat
240240
Helper::scriptingKind, Helper::errorLevel));
241241
return;
242242
}
243-
qDebug() << resultFilePath << resultFileLastModifiedDateTime << resultFileInfo.lastModified();
244243
VariablesWidget *pVariablesWidget = MainWindow::instance()->getVariablesWidget();
245244
OMCProxy *pOMCProxy = MainWindow::instance()->getOMCProxy();
246245
QStringList list = pOMCProxy->readSimulationResultVars(resultFileInfo.absoluteFilePath());

0 commit comments

Comments
 (0)