IBM
Contents Index Previous Next



Using Packages and Block Types


What You Will Learn

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.

  1. 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.
    • All diagrams in the remaining exercises are available in the above directory. You may choose to copy them if you do not want to draw all diagrams, and then connect the created diagram symbols in the Organizer to the corresponding files.

Creating a Package

To create a package:

  1. 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.

Figure 168 : Adding a new package Basic Features

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:
  • The declaration of the signal interface between the "basic" -DemonGame and the environment, as well as a process type Main that supports the signal interface.
  • The definition of the process type Game with the basic functionality.
  • A block type that contains the process types.
  1. 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.

Figure 169 : The package BasicFeatures

  1. Save the package diagram on a file, e.g. basicfeatures.sun
  2. 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).

Figure 170 : The block type BasicGameBlock

  1. 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).

  1. 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.

Figure 171 : USE of packages

  1. 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):

Figure 172 : System BasicDemonGame using package BasicFeatures

  1. Terminate the exercise by analyzing the resulting system.

Note:

You may analyze the package (by selecting the package symbol in the Organizer as input to the Analyzer before ordering the Analyze command), in which case a partial semantic analysis will be done on the package. (The Analyzer will not check the consistency between the package and the system that uses it.)

A complete semantic analysis requires the system diagram to be selected before ordering Analyze.


http://www.ibm.com/rational
Contents Index Previous Next