IBM
Contents Index Previous Next



Creating a Process Type from a Process


What You Will Learn

Changing into a Process Type

To facilitate the introduction of new features, we will start by generalizing the process Game, by changing it to a process type, that you later on will be in a position to specialize or redefine.

  1. Open the process Game and change the diagram type from process to process type, simply by selecting the diagram heading symbol and editing the text in it to say "Process Type Game".

Figure 149 : Changing the diagram type

  1. From the SDL Editor's File menu, save the diagram Process Type Game on a new file, e.g. new_game.spt using the Save As command. Edit the file name in the file selection dialog and click OK. (The existing *.spt files are copies of the complete system that comes with the examples in the SDL Suite.)
  2. Raise the Organizer window.

Figure 150 : Invalid reference as shown in the Organizer

You may notice that the reference symbol has been changed to -Process Type Game, and marked as having no reference in the parent diagram. Also, the old process Game is marked as unconnected. Do not bother about that for the moment - it will be replaced by an instantiation symbol, which will be explained later.
  1. Open the diagram block GameBlock. Change it so that the process reference Game is changed to an instantiation of the process type Game. The syntax is: "Game(0,1):Game" (You are allowed to add newlines to have the text fit into the symbol.)
    • Before you have started text editing, the text cursor is not flashing. Pressing <Delete> at this stage deletes the whole selected symbol. Once text editing has started, the text cursor is flashing and pressing <Delete> only deletes a character.
  2. As soon as you deselect the symbol, one text rectangle appears for each connection point to the signal routes. Name the connections points for instance G2 and G5:

Figure 151 : Naming the connection points

  1. Also add a process type reference symbol with the name Game. The block diagram should now look like this:

Figure 152 : The resulting block

  1. Save the block diagram on a new file, e.g. new_gameblock.sbk (use Save As as before).

Inserting Gates and Virtual Transitions

You will now finish the process type Game. You are recommended to do this by following the editing instructions described below. If you prefer, you can instead connect to the finished version of the diagram (see Connecting to the Finished Diagram), but you should in any case read through the text below.

Editing the Process Type Diagram

  1. Go back to the process type Game in the SDL Editor. The connection to the signal routes must be defined using gate symbols, named in accordance to the connection points you just defined.
  2. Gate symbols are to be connected to the frame symbol. If you want to connect gates to the left or top of the frame, you must first select the frame and drag it down and/or right.

Figure 153 : Adjusting the frame symbol

  1. For each of the gates G2 and G5, add a gate symbol and fill in the name and the signal list.
    • The gate symbol is the one who looks like an arrow. Remember that the Status Bar displays the type of a symbol when you point to or select it in the symbol menu.
    • To direct a gate to the frame, you must add a gate, then -Redirect it. (Gates can also be made bidirectional.)
    • You may use the New Window command to bring both the -Process Type Game and the Block GameBlock into view at the same time, then Copy and Paste the text between the diagrams.
    • You may also take advantage of the Signal Dictionary window, and Insert the signals from the block GameBlock (Up).
  2. Also make the start transition as well as the input of the signals Probe and Bump virtual by adding the text "VIRTUAL" before the name of the signal.
    • By doing this, you will later on be able to change the properties of the game in a smooth way.

The changes to the resulting diagram should now look something like this:

Figure 154 : The resulting process type Game

Connecting to the Finished Diagram

The finished Game process type diagram is also available as the file game.spt. If you instead of drawing the diagram wish to use this file, do as follows:

  1. In the SDL Editor, close the Game process type diagram.
  2. In the Organizer, select the diagram Process Type Game, and then select Connect from the Edit menu.
  3. Select the option To an existing file. Change the filename to game.spt, or select this file by using the folder button.
  4. Click Connect and check the new file connection in the Organizer.

The Organizer Structure

  1. Save everything. The resulting Organizer list should now resemble:

Figure 155 : Resulting Organizer view

Note the presence of an instantiation symbol, looking like a normal symbol, but with the generic "X:Y" (meaning -instance:type) notation in it. The instantiation symbol denotes that the type is actually instantiated somewhere in the diagram.
Instantiation symbols in the Organizer cannot be used for navigating into the system hierarchy with a double click, since they do not refer to diagrams. (You can use them from within the SDL Editor with the support from the Type Viewer tool, which you will practice on later in this tutorial).
  1. Terminate by analyzing the system. Correct any syntactic or semantic errors that are reported.

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