Opened 8 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 8 years ago.

Download all attachments as: .zip

Change History (4)

by anonymous, 8 years ago

Attachment: EncapsulatedError.mo added

comment:1 by dongping.xie.tud@…, 8 years ago

Component: *unknown*Frontend
Priority: highcritical

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

Resolution: fixed
Status: newclosed

comment:3 by Francesco Casella, 4 years ago

Milestone: Future1.16.0
Note: See TracTickets for help on using tickets.