Opened 14 years ago

Last modified 14 years ago

#1244 closed defect (worksforme)

Can't find matching inner

Reported by: Peter Aronsson Owned by: Peter Aronsson
Priority: critical Milestone: Red October
Component: Version:
Keywords: Cc: Peter Aronsson, Adrian Pop

Description

After looking more into this example I have actually managed to simplify it and triggered the problem (thus reopening the issue).

Consider the following package:

package MyPackage
  package Effects
    package Internal
      model ParticleEffect2
        outer MyPackage.UpdateVisualization myEnvironment1;
      end ParticleEffect2;

    end Internal;

    model ParticleEffect1
      MyPackage.Effects.Internal.ParticleEffect2 particleEffect2;
    end ParticleEffect1;

  end Effects;

  package Examples
    package Effects
      model ParticleEffect
        MyPackage.Effects.ParticleEffect1 particleEffect1;
        inner MyPackage.UpdateVisualization updateVisualization;
      end ParticleEffect;

    end Effects;

  end Examples;

  model UpdateVisualization
  end UpdateVisualization;

end MyPackage;

Checking of MyPackage.Examples.Effects.ParticleEffect works fine:

Check of MyPackage.Examples.Effects.ParticleEffect completed successfully.
Class MyPackage.Examples.Effects.ParticleEffect has 0 equation(s) and 0 variable(s).
0 of these are trivial equation(s).

However, if UpdateVisualization is not an empty class:

  model UpdateVisualization
    parameter Real x=1;
    parameter Real y=3;
  end UpdateVisualization;

Then we fail to find the matching inner:

[44] 18:09:04 Validation of class MyPackage.Examples.Effects.ParticleEffect
[<interactive>:11:7-11:65:readonly] Warning: Variable particleEffect1.particleEffect2: No corresponding 'inner' declaration found for component particleEffect1.particleEffect2.myEnvironment1 declared as 'outer '. Please declare an 'inner' component with the same name in the top scope. Continuing flattening by only considering the 'outer' component declaration.

Check of MyPackage.Examples.Effects.ParticleEffect completed.
Class MyPackage.Examples.Effects.ParticleEffect has 0 equation(s) and 0 variable(s) whereof 2 variables declared as 'outer'

This is a simplified version of a typical model from DLRs Visualization library.

Attachments (1)

ParticleEffectTotal.mo (101.9 KB ) - added by Adrian Pop 14 years ago.
test

Download all attachments as: .zip

Change History (9)

by Adrian Pop, 14 years ago

Attachment: ParticleEffectTotal.mo added

test

comment:2 by Martin Sjölund, 14 years ago

Did Adrian get part of these files sent via email?
The attached file is just a package, and the bug doesn't say which model in that package that has the issue.

comment:3 by Jan Brugård, 14 years ago

I have now tested it again and the problem was that the corresponding inner was declared with incorrect name (or some times not declared). In both ocasions Dymola adds new inners automatically, thus failing to detect the error.

(Btw, if modifications are done in the incorrectly named model they won't affect the model and it will be hard for the user to detect the reason, therefore the Dymola solution is bad and should not ne used by OpenModelica)

comment:4 by Adrian Pop, 14 years ago

OpenModelica warns if an inner cannot be found and continues by just instantiating the outer.
I think this solution is rather OK for now as people can see where is an inner/outer mismatch.

comment:5 by Jan Brugård, 14 years ago

Adrian, should this be fixed as part of Red October? I guess it should?

comment:6 by Adrian Pop, 14 years ago

Your model is wrong\\
The name of the outer component myEnvironment1 is not the same name as the name of the inner component updateVisualization.
The warning is perfectly valid in this case.

If you change: myEnvironment1 to updateVisualization then everything works fine:

package MyPackage
  package Effects
    package Internal
      model ParticleEffect2
        outer MyPackage.UpdateVisualization updateVisualization;
      end ParticleEffect2;

    end Internal;

    model ParticleEffect1
      MyPackage.Effects.Internal.ParticleEffect2 particleEffect2;
    end ParticleEffect1;

  end Effects;

  package Examples
    package Effects
      model ParticleEffect
        MyPackage.Effects.ParticleEffect1 particleEffect1;
        inner MyPackage.UpdateVisualization updateVisualization;
      end ParticleEffect;

    end Effects;

  end Examples;

  model UpdateVisualization
    parameter Real x=1;
    parameter Real y=3;
  end UpdateVisualization;
end MyPackage;

Then you get:

adrpo@kafka ~/dev/OpenModelica/build/bin
$ ./omc Visualization.mos
true
""
"Check of MyPackage.Examples.Effects.ParticleEffect completed successfully.


Class MyPackage.Examples.Effects.ParticleEffect has 0 equation(s) and 0 variable(s).
0 of these are trivial equation(s).
"
""

comment:7 by Adrian Pop, 14 years ago

What I can probably do is improve the error message.
I can say that these are the only inners defined in the model and give a list of them.
This way you can see if you misspelled an outer or not.

comment:8 by Adrian Pop, 14 years ago

Ok, I changed the warning message to give more info. Now for this model:

package MyPackage
  package Effects
    package Internal
      model ParticleEffect2
        outer MyPackage.UpdateVisualization updateVisualization2; // misspelled
      end ParticleEffect2;

    end Internal;

    model ParticleEffect1
      inner outer MyPackage.UpdateVisualization updateVisualization;
      MyPackage.Effects.Internal.ParticleEffect2 particleEffect2;
    end ParticleEffect1;

  end Effects;

  package Examples
    package Effects
      model ParticleEffect
        MyPackage.Effects.ParticleEffect1 particleEffect1;
        inner MyPackage.UpdateVisualization updateVisualization;
      end ParticleEffect;

    end Effects;

  end Examples;

  model UpdateVisualization
    parameter Real x=1;
    parameter Real y=3;
  end UpdateVisualization;
end MyPackage;

You get this warning:

adrpo@kafka ~/dev/OpenModelica/build/bin
$ ./omc Visualization.mos
true
""
"Check of MyPackage.Examples.Effects.ParticleEffect completed successfully.

[Visualization.mo:12:7-12:65:readonly] Warning: Variable particleEffect1.particleEffect2: No corresponding 'inner' declaration found for component particleEffect1.particleEffect2.updateVisualization2 declared as 'outer '.
  The existing 'inner' components are: 
    MyPackage.UpdateVisualization updateVisualization; defined in scope: MyPackage.Examples.Effects.ParticleEffect. Referenced by 'outer' components: {particleEffect1.updateVisualization}
    MyPackage.UpdateVisualization particleEffect1.updateVisualization; defined in scope: MyPackage.Effects.ParticleEffect1.
  Check if you have not misspelled the 'outer' component name.
  Please declare an 'inner' component with the same name in the top scope.
  Continuing flattening by only considering the 'outer' component declaration.

Class MyPackage.Examples.Effects.ParticleEffect has 0 equation(s) and 0 variable(s).
0 of these are trivial equation(s).
"
""

Of course, you can tailor the error message to your wish.

Note: See TracTickets for help on using tickets.