Opened 7 years ago

Closed 4 years ago

Last modified 4 years ago

#4205 closed defect (fixed)

Problem Importing Functions from Subpackages in a encapsulated Model

Reported by: dongping.xie.tud@… Owned by: somebody
Priority: critical Milestone: 1.16.0
Component: Frontend Version: v1.12.0
Keywords: Cc:

Description

The OpenModelica fails to import the function in a subpackage (c.f. EncapsulatedError.MainModel). Model without "encapsulated" keyword works (c.f. EncapsulatedError.MainModelNotEncapsulated) and an "encapsulated" model can import a function at the same level (c.f. EncapsulatedError.MainModelSameLevel) .

The model is also attached in the ticket.

The error message for simulating EncapsulatedError.MainModel is the following:

[1] 16:53:16 Translation Error
[EncapsulatedError: 8:5-8:34]: Class Functions.myFunction not found in scope EncapsulatedError.MainModel (looking for a function or record).

[2] 16:53:16 Translation Error
Error occurred while flattening model EncapsulatedError.MainModel
package EncapsulatedError
  encapsulated model MainModel
    import Modelica.Blocks.Sources.Ramp;
    import EncapsulatedError.Functions.myFunction;
    Ramp ramp;
    Real myOutput;
  equation
    myOutput = myFunction(ramp.y);
  end MainModel;
  model MainModelNotEncapsulated
    import Modelica.Blocks.Sources.Ramp;
    import EncapsulatedError.Functions.myFunction;
    Ramp ramp;
    Real myOutput;
  equation
    myOutput = myFunction(ramp.y);
  end MainModelNotEncapsulated;

  encapsulated model MainModelSameLevel
    import Modelica.Blocks.Sources.Ramp;
    import EncapsulatedError.myFunctionSameLevel;
    Ramp ramp;
    Real myOutput;
  equation
    myOutput = myFunctionSameLevel(ramp.y);
  end MainModelSameLevel;

  function myFunctionSameLevel
    input Real u;
    output Real y;
  algorithm
    y := 3 * u;
  end myFunctionSameLevel;
  package Functions
    function myFunction
      input Real u;
      output Real y;
    algorithm
      y := 3 * u;
    end myFunction;
  end Functions;
  annotation(
    uses(Modelica(version = "3.2.2")));
end EncapsulatedError;

Attachments (1)

EncapsulatedError.mo (1.1 KB) - added by anonymous 7 years ago.

Download all attachments as: .zip

Change History (4)

Changed 7 years ago by anonymous

comment:1 Changed 7 years ago by dongping.xie.tud@…

  • Component changed from *unknown* to Frontend
  • Priority changed from high to critical

comment:2 Changed 4 years ago by dongping.xie.tud@…

  • Resolution set to fixed
  • Status changed from new to closed

comment:3 Changed 4 years ago by casella

  • Milestone changed from Future to 1.16.0
Note: See TracTickets for help on using tickets.