Skip to content

Commit

Permalink
Instantiate OMSimulator model when simulate button is clicked
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed Jun 23, 2020
1 parent bd4b2d5 commit b858490
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 21 deletions.
25 changes: 7 additions & 18 deletions OMEdit/OMEditLIB/MainWindow.cpp
Expand Up @@ -708,7 +708,13 @@ void MainWindow::simulate(LibraryTreeItem *pLibraryTreeItem)
if (!mpOMSSimulationDialog) {
mpOMSSimulationDialog = new OMSSimulationDialog(this);
}
mpOMSSimulationDialog->simulate(pTopLevelLibraryTreeItem);
const QString modelName = pTopLevelLibraryTreeItem->getNameStructure();
instantiateOMSModel(pTopLevelLibraryTreeItem, !pTopLevelLibraryTreeItem->isOMSModelInstantiated());
// get the top level LibraryTreeItem again since instantiateOMSModel redraws them
LibraryTreeItem *pTopLevelLibraryTreeItem = mpLibraryWidget->getLibraryTreeModel()->findLibraryTreeItemOneLevel(modelName);
if (pTopLevelLibraryTreeItem) {
mpOMSSimulationDialog->simulate(pTopLevelLibraryTreeItem);
}
}
}
}
Expand Down Expand Up @@ -819,23 +825,6 @@ void MainWindow::instantiateOMSModel(LibraryTreeItem *pLibraryTreeItem, bool che
}
}

/*!
* \brief MainWindow::simulateOMSModel
* Simulates the OMSimulator model.
* \param pLibraryTreeItem
*/
void MainWindow::simulateOMSModel(LibraryTreeItem *pLibraryTreeItem)
{
// get the top level LibraryTreeItem
LibraryTreeItem *pTopLevelLibraryTreeItem = mpLibraryWidget->getLibraryTreeModel()->getTopLevelLibraryTreeItem(pLibraryTreeItem);
if (pTopLevelLibraryTreeItem) {
if (!mpOMSSimulationDialog) {
mpOMSSimulationDialog = new OMSSimulationDialog(this);
}
mpOMSSimulationDialog->simulate(pTopLevelLibraryTreeItem);
}
}

void MainWindow::instantiateModel(LibraryTreeItem *pLibraryTreeItem)
{
/* if Modelica text is changed manually by user then validate it before saving. */
Expand Down
1 change: 0 additions & 1 deletion OMEdit/OMEditLIB/MainWindow.h
Expand Up @@ -227,7 +227,6 @@ class MainWindow : public QMainWindow
#endif
void simulationSetup(LibraryTreeItem *pLibraryTreeItem);
void instantiateOMSModel(LibraryTreeItem *pLibraryTreeItem, bool checked);
void simulateOMSModel(LibraryTreeItem *pLibraryTreeItem);
void instantiateModel(LibraryTreeItem *pLibraryTreeItem);
void checkModel(LibraryTreeItem *pLibraryTreeItem);
void checkAllModels(LibraryTreeItem *pLibraryTreeItem);
Expand Down
2 changes: 1 addition & 1 deletion OMEdit/OMEditLIB/Modeling/ModelWidgetContainer.cpp
Expand Up @@ -8113,7 +8113,7 @@ void ModelWidgetContainer::currentModelWidgetChanged(QMdiSubWindow *pSubWindow)
MainWindow::instance()->getBitmapShapeAction()->setEnabled(enabled && modelica && !textView);
MainWindow::instance()->getConnectModeAction()->setEnabled(enabled && (modelica || compositeModel || (oms && !(omsSubmodel || omsConnector))) && !textView);
MainWindow::instance()->getTransitionModeAction()->setEnabled(enabled && (modelica) && !textView);
MainWindow::instance()->getSimulateModelAction()->setEnabled(enabled && ((modelica && pLibraryTreeItem->isSimulationAllowed()) || (oms && isOMSModelInstantiated)));
MainWindow::instance()->getSimulateModelAction()->setEnabled(enabled && ((modelica && pLibraryTreeItem->isSimulationAllowed()) || (oms)));
MainWindow::instance()->getSimulateWithTransformationalDebuggerAction()->setEnabled(enabled && modelica && pLibraryTreeItem->isSimulationAllowed());
MainWindow::instance()->getSimulateWithAlgorithmicDebuggerAction()->setEnabled(enabled && modelica && pLibraryTreeItem->isSimulationAllowed());
#if !defined(WITHOUT_OSG)
Expand Down
1 change: 0 additions & 1 deletion OMEdit/OMEditLIB/OMS/OMSSimulationDialog.cpp
Expand Up @@ -240,7 +240,6 @@ void OMSSimulationDialog::simulationFinished(const QString &resultFilePath, QDat
Helper::scriptingKind, Helper::errorLevel));
return;
}
qDebug() << resultFilePath << resultFileLastModifiedDateTime << resultFileInfo.lastModified();
VariablesWidget *pVariablesWidget = MainWindow::instance()->getVariablesWidget();
OMCProxy *pOMCProxy = MainWindow::instance()->getOMCProxy();
QStringList list = pOMCProxy->readSimulationResultVars(resultFileInfo.absoluteFilePath());
Expand Down

0 comments on commit b858490

Please sign in to comment.