Skip to content

Commit 4f16050

Browse files
authored
Ticket-5848: First level nested components detected by OMSens (#775)
* Ticket-5848: First level nested components is now detected by the OMSens plugin
1 parent 034e66b commit 4f16050

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

OMEdit/OMEditLIB/MainWindow.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4464,6 +4464,7 @@ AboutOMEditDialog::AboutOMEditDialog(MainWindow *pMainWindow)
44644464
"<li>Dietmar Winkler</li>"
44654465
"<li>Anatoly Severin<li>"
44664466
"<li>Adrian Pop - <u><a href=\"mailto:adrian.pop@liu.se\">adrian.pop@liu.se</a></u></li>"
4467+
"<li>John Tinnerholm - <u><a href=\"mailto:john.tinnerholm@liu.se\">john.tinnerholm@liu.se</a></u></li>"
44674468
"</ul>")
44684469
.arg(Helper::applicationName,
44694470
Helper::applicationIntroText,

OMEdit/OMEditLIB/Modeling/ModelWidgetContainer.cpp

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6201,33 +6201,46 @@ void ModelWidget::associateBusWithConnectors(QString busName)
62016201
/*!
62026202
* \brief ModelWidget::toOMSensJson
62036203
* Creates a list of QVariant containing the model information needed by OMSens.
6204+
* Currently only works for REAL types (OMSens currently have similar limitations)
62046205
* \return
62056206
*/
62066207
QList<QVariant> ModelWidget::toOMSensData()
62076208
{
6209+
QList<QVariant> omSensData;
6210+
if (!mpDiagramGraphicsView) {
6211+
return omSensData;
6212+
}
62086213
QStringList inputVariables;
62096214
QStringList outputVariables;
62106215
QStringList parameters;
62116216
QStringList auxVariables;
6212-
6213-
if (mpDiagramGraphicsView) {
6214-
foreach (Component *pComponent, mpDiagramGraphicsView->getComponentsList()) {
6215-
ComponentInfo *pComponentInfo = pComponent->getComponentInfo();
6216-
if ((pComponentInfo->getCausality().compare("input") == 0) && ((pComponentInfo->getClassName().compare("Real") == 0)
6217-
|| (pComponentInfo->getClassName().compare("Modelica.Blocks.Interfaces.RealInput") == 0))) {
6218-
inputVariables.append(pComponentInfo->getName());
6219-
} else if ((pComponentInfo->getCausality().compare("output") == 0) && ((pComponentInfo->getClassName().compare("Real") == 0)
6220-
|| (pComponentInfo->getClassName().compare("Modelica.Blocks.Interfaces.RealOutput") == 0))) {
6221-
outputVariables.append(pComponentInfo->getName());
6222-
} else if ((pComponentInfo->getVariablity().compare("parameter") == 0) && (pComponentInfo->getClassName().compare("Real") == 0)) {
6217+
const QString modelicaBlocksInterfacesRealInput = "Modelica.Blocks.Interfaces.RealInput";
6218+
const QString modelicaBlocksInterfacesRealOutput = "Modelica.Blocks.Interfaces.RealOutput";
6219+
QList<Component*> pInheritedAndComposedComponents;
6220+
QList<Component*> pTopMostComponents = mpDiagramGraphicsView->getComponentsList() + mpDiagramGraphicsView->getInheritedComponentsList();
6221+
for (Component *pComponent : pTopMostComponents) {
6222+
pInheritedAndComposedComponents = pComponent->getComponentsList() + pComponent->getInheritedComponentsList();
6223+
pInheritedAndComposedComponents.append(pComponent);
6224+
for (auto component : pInheritedAndComposedComponents) {
6225+
ComponentInfo *pComponentInfo = component->getComponentInfo();
6226+
auto causality = pComponentInfo->getCausality();
6227+
auto variability = pComponentInfo->getVariablity();
6228+
const bool classNameIsReal = pComponentInfo->getClassName().compare(QStringLiteral("Real")) == 0;
6229+
if (causality.compare(QStringLiteral("input")) == 0) {
6230+
if (classNameIsReal || pComponentInfo->getClassName().compare(modelicaBlocksInterfacesRealInput) == 0) {
6231+
inputVariables.append(pComponentInfo->getName());
6232+
}
6233+
} else if (causality.compare(QStringLiteral("output")) == 0) {
6234+
if (classNameIsReal || pComponentInfo->getClassName().compare(modelicaBlocksInterfacesRealOutput) == 0) {
6235+
outputVariables.append(pComponentInfo->getName());
6236+
}
6237+
} else if(classNameIsReal && variability.compare(QStringLiteral("parameter")) == 0) {
62236238
parameters.append(pComponentInfo->getName());
6224-
} else if (pComponentInfo->getClassName().compare("Real") == 0) {
6239+
} /* Otherwise we are dealing with an auxiliarly variable */else if (classNameIsReal) {
62256240
auxVariables.append(pComponentInfo->getName());
62266241
}
62276242
}
62286243
}
6229-
6230-
QList<QVariant> omSensData;
62316244
omSensData << inputVariables << outputVariables << auxVariables << parameters << mpLibraryTreeItem->getFileName() << mpLibraryTreeItem->getNameStructure();
62326245
return omSensData;
62336246
}

0 commit comments

Comments
 (0)