@@ -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 */
62066207QList<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