![]() |
![]() |
![]() |
![]() |
![]() |
Using Packages and Block Types
What You Will Learn
- To create a package diagram
- To use a package in a system
- To refer to and instantiate a block type
- To define a process type as virtual
Package - a Reusable Component
Packages are used to make type definitions available in different systems, and to make components reusable. You will take advantage of the package concept by developing two versions of the DemonGame, one that has only the basic "Probe" feature, and one that also includes the "Jackpot" and "DoubleStake" features.
The idea here is to develop a package "BasicFeatures" that is used in the basic version and that is reusable to 100% in the advanced version.
Using packages to their full extent in this example requires not only the process Game to be transformed to a process type (as you have done in the previous exercises, when creating the JackpotGame, DoubleGame and SuperGame), but also to transform the process Main and the block GameBlock to reusable process type and block type, respectively.
You have probably noticed that the process type Main also requires to be extended for each feature that we add ("jackpot", "double", etc.), so it would be a good idea to make a reusable type of it. This has already been prepared for you, so your task will be to add the required "glue" to build the two packages.
- Start by copying the files gameblock.sbt and main.spt from the directory $-telelogic/sdt/examples/demongame/sdl92/packages (on UNIX), or C:\IBM\Rational\SDL_TTCN_Suite6.3\sdt\examples\demongame\sdl92\packages (in Windows) to the same directory you created earlier for this tutorial.
Creating a Package
- Select the Add New command from the Organizer's Edit menu. In the Add New dialog, specify document type as SDL Package, and document name as BasicFeatures.
- As you click OK, a new diagram structure is created in the Organizer with the package diagram as root diagram. (The Organizer supports managing multiple structures in the same system file.)
- The newly created package should contain the generic properties for the DemonGame; namely:
- With the SDL Editor, move the declaration of the signals from the system diagram to the package diagram. Also add the process type reference symbol Game and the block type reference symbol -BasicGameBlock to the package diagram. See below.
- Save the package diagram on a file, e.g. basicfeatures.sun
- With the Organizer, connect the block type BasicGameBlock to the recently copied file gameblock.sbt (the diagram is depicted in Figure 170).
- Note that the process type Main is declared as VIRTUAL. This is essential since we are going to add properties to Main, and need to address signals from the environment to Main, without changing its name to e.g. "SuperMain" (compare to how you did for the process type Game that was specialized into -JackpotGame, etc.). By defining a process type as VIRTUAL, we can later add properties without changing its name, using the keyword REDEFINED (you will practice that in a few moments, in Redefined Process Type Main).
- You should also connect the process type Main to the copied file main.spt (This may already have been done if you had Expand Substructure turned on in the Connect dialog in the previous step.)
Using a Package
To use a package, you add a USE statement to the package reference symbol (looking like a text symbol immediately outside the frame symbol).
- To create a version of the DemonGame that has the basic features, add a USE statement to the system diagram. Also remember to instantiate the block type -BasicGameBlock (which is contained in the package). See below.
- In the Organizer, Disconnect the old GameBlock from the system structure. The resulting Organizer view should now be something like this (the order of appearance of symbols may differ):
http://www.ibm.com/rational |
![]() |
![]() |
![]() |
![]() |