Opened 11 years ago

Closed 11 years ago

#2657 closed defect (fixed)

Include annotation still ignored when using functions defined outside package

Reported by: Francesco Casella Owned by: Adrian Pop
Priority: high Milestone: 1.9.1
Component: Frontend Version: trunk
Keywords: Cc:

Description

After ticket #2412 was fixed, all the test cases in ExternalMedia started to work properly, without any need of copying the .h and .lib files to the OMC installation directories.

However, all those test cases use medium packages which are defined within the very same package that contains the Resource directory (i.e., ExternalMedia itself).

In practice, only a finite number of actual package media can be defined in ExternalMedia. Any end user will eventually need to define his/her own media outside of the library (which he/she can use but not modify as an end user). If you do so, the problem is still there. Try these simple examples:

package TestExternalMediaDefinition
  package WaterIF95 "RefProp water model"
    extends ExternalMedia.Media.FluidPropMedium(
      mediumName = "Water", 
      libraryName = "FluidProp.RefProp", 
      substanceNames = {"H2O"});
  end WaterIF95;

  model Test1
    package Medium = WaterIF95;
    Medium.Density d = Medium.density_pT(100000.0, 300);
  end Test1;

  model Test2
    package Medium = 
      ExternalMedia.Media.FluidPropMedium(
        mediumName = "Water", 
        libraryName = "FluidProp.RefProp",
        substanceNames = {"H2O"});
    Medium.Density d = Medium.density_pT(100000.0, 300);
  end Test2;
end TestExternalMediaDefinition;

In both cases, when I compile in OMC I get

error: externalmedialib.h: No such file or directory

You need to make sure that the path of the package where the external function is defined is used for C-code generation, not the one of the package where the medium is eventually declared.

Change History (8)

comment:1 by Martin Sjölund, 11 years ago

If the function has annotation IncludeDirectory="modelica://ExternalMedia/Resources/Include"? I guess the specification doesn't say which default library name for the IncludeDirectory should be used if you inherit an external function in a different package...
What if you inherit from multiple functions? :D

comment:2 by Adrian Pop, 11 years ago

If you inherit from multiple functions I guess you need to add all of the include annotations present in the base classes.

comment:3 by Martin Sjölund, 11 years ago

Are annotations even inherited though? Graphical ones certainly are not...
Anyway, there can be only one IncludeDirectory...

comment:4 by Adrian Pop, 11 years ago

I guess the derivative and include/lib annotations need to be inherited.
When translating Absyn->SCode we could fetch those, resolve the uri and
add the annotation to SCode.CLASS.cmt. Then we could propagate these on
instantiation to DAE.FUNCTION.

comment:5 by Martin Sjölund, 11 years ago

Actually... You cannot extend a function with an external section so... This is just because the Media package where it is contained is moved to another location.
You could trap it in SCode. But note that there is no such annotation present by default. So it is more likely that you need to handle this elsewhere to work properly.
Possibly by doing a reverse lookup from Absyn.INFO filename to library name...

comment:6 by Martin Sjölund, 11 years ago

Added m:#1456

comment:7 by Francesco Casella, 11 years ago

I understand the matter could be a bit controversial. I will therefore not rely on the default (which is probably a silly thing to do anyway) and specify the full IncludeDirectory="modelica://ExternalMedia/Resources/Include in all the functions within ExternalMedia.

Of course will need this annotation to be inherited properly when I extend the class.

comment:8 by Francesco Casella, 11 years ago

Resolution: fixed
Status: newclosed

Once the IncludeDirectory and LibraryDirectory annotations are added to the external function in ExternalMedia, the problem is solved.

Note: See TracTickets for help on using tickets.