Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Custom packages: Failed to insert class ... within ...

Custom packages: Failed to insert class ... within ...

Hi.
I like to structure my Modelica classes hierarchically and in separate files.
So I created a new folder "C:\WSNmodel\" which contains:
package.mo:

Code:

within ;

package WSNmodel
  "Wireless Sensor Node root package";
extends Modelica.Icons.Package; 
end WSNmodel;

and
SolarCellTest.mo:

Code:

within WSNmodel;

model SolarCellTest
...
equation
...
end SolarCellTest;

(This is the very first step and additional subfolders with their package.mo will follow in the future)

When I open SolarCellTest.mo it says:

Code:

[:0:0-0:0] Error: Failed to insert class SolarCellTest within WSNmodel;

the available classes were:
  Modelica.SIunits.ComplexPower
  Modelica.SIunits.ComplexAdmittance
  Modelica.SIunits.ComplexImpedance
  Modelica.SIunits.ComplexReluctance
  Modelica.SIunits.ComplexMagneticFlux
  Modelica.SIunits.ComplexMagneticFluxDensity
  Modelica.SIunits.ComplexMagnetomotiveForce
  Modelica.SIunits.ComplexMagneticPotentialDifference
  Modelica.SIunits.ComplexMagneticPotential
  Modelica.SIunits.ComplexMagneticFieldStrength
  Modelica.SIunits.ComplexElectricFlux
  Modelica.SIunits.ComplexElectricFluxDensity
...  [all MSL classes]

I already added the path "C:\WSNmodel\" to MODELICAPATH
and in OMEdit in Tools->Options->Libs->Custom.

When I try it with Wolfram SystemModeler it says:

Code:

No top level Modelica classes found in the file SolarCellTest.mo

Another issue is, when I open package.mo it says:

Code:

No viable alternative near token: ;

What is going on here???
Thanks!

Re: Custom packages: Failed to insert class ... within ...

Remove the ; after the class comment.

Re: Custom packages: Failed to insert class ... within ...

Hi sjoelund.se!

Thanks for your quick response!
What do you mean with "class comment"?

I tried to remove the ";" on different positions - other error occure like:
Error: No viable alternative near token: WSNmodel
or
Error: Parser error: Unexpected token near:  (<EOF>)

In all examples I have studied, the ";" is written as I did it.
So it seems, that there is another issue.

Best Regards
Jan

Re: Custom packages: Failed to insert class ... within ...

Code:

within ;


package WSNmodel

  "Wireless Sensor Node root package" /* No semicolon is allowed here! */

extends Modelica.Icons.Package; 

end WSNmodel;

Re: Custom packages: Failed to insert class ... within ...

Hi sjoelund.se.
Yes! It is working now. I was very blind :-)
Thanks!

There are 0 guests and 0 other users also viewing this topic
You are here: