The package diagram is used to display the way a model is organized in the form of a package containment hierarchy. A package diagram may also show the model elements that packages contain and the dependencies between packages and their contained model elements.
In project development, the model elements may quickly reach a large number that makes it necessary to somehow structure them, even for small development projects. Similar to how a group of files in folders and directories on the hard disk, packages take care of the model structure. The package diagram shows the packages and their relationships.
A package diagram is typically used for the following ways:
- large scale systems to picture dependencies between major elements in the system
- Package diagrams represent a compile-time grouping mechanism.
- Package diagrams also provide a namespace for model elements
The package diagram, labeled pkg, is used to organize the model elements contained in the model. In this diagram, the System Model appears in the diagram header and contains packages for Requirements, Behavior, Structure, and Parametrics. Each of these packages, in turn, contains model elements that are presented on the requirement diagram, activity diagram, block definition diagram, internal block diagram, and parametric diagram, respectively. Note that model elements for both the block definition diagram and internal block diagram are contained in the Structure package.
There are three major relationships model the dependency between packages:
Containment: Contain packageable elements and other packages
Package import: Import all elements from another package to the namespace
Element import: Import one element from another package to the namespace
Package vs Block
A Package is a generic grouping mechanism for organizing various model elements and related diagrams within a unique namespace. A SysML Package is capable of containing any arbitrary SysML model element, including (but not limited to) Blocks.
- A SysML Block is the basic structural element used within a SysML model and is used analogously to how UML Classes are used to structure a UML object model.
- Consequently, while a SysML Package may contain (provide a unique namespace for) Blocks and other SysML model elements, a SysML Block cannot own (be composed of) or contain SysML Packages or SysML diagrams.
Package Diagram Example – HSUV
The package diagram below shows the structure of the model used to evaluate the sample problem. Model elements are contained in packages, and relationships between packages (or specific model elements) are shown on this diagram. The relationship between the views (OperationalView and PerformanceView) and the rest of the user model are explicitly expressed using the «import» relationship.
Note that the «view» models contain no model elements of their own and that changes to the model in other packages are automatically updated in the Operational and Performance Views.
Relating HSUV Model with Top-Level Package Diagram
As shown in the top-level package diagram, the HSUVModel is a package that represents the user model. The SysML Profile must be applied to this package to include stereotypes from the profile. The HSUVModel may also require model libraries, such as the SI Units Types model library. The model libraries must be imported into the user model as indicated.