Exercise 1 - Package

1 Question

What is a Package?


1.1

A package is a restricted and enhanced class that is primarily used to manage name spaces and organize Modelica code. A package has the restrictions of only containing declarations of classes, including all kinds of restricted classes, and constants. Variable declarations are not allowed.


2 Creating a Package

Create a package that contains a division function (that divides two Real numbers) and a constant k = 5.




Create a class, containing a variable x. The variable gets its value from the division function inside the package, which divides 10 by 5.




Simulate the class x and obtain the value of x by writing val(x,time), as below (let's choose time = 0):



2.1



2.1.1 Simulation of MyPackage