Table of Contents Previous Chapter 4 Tutorial: An SDL-92 Example

4 Tutorial: An SDL-92 Example

Version 2

This version uses remote procedures, value returning procedures and global procedures.

General

A general rule when designing an SDL process is to keep the transitions as short as possible. Use of procedures is then often the solution. In the first version procedures are frequently used and we shall take a look at two of them: RegisterCard and ReadCode. Both are declared and called by the Controller process.

Procedure RegisterCard

This procedure is called when a new card should be registered (an user card or the supervisor's Master Card) (see Figure 170)

Figure\x11 170 : The Procedure RegisterCard. 
-----
(fig)  
       
-----

Procedure ReadCode

This is a procedure to read four digits from the keyboard. The digits will be stored in an array CodeData. If four digits are successfully received the ReadCodeResult is assigned "Successful" and a return to the calling process or procedure will take place.

This procedure is called both by the procedure RegisterCard and by the process Controller in the sequence of validating card and code (see Figure 171)

Figure\x11 171 : The Procedure ReadCode. 
-----
(fig)  
       
-----

Use of Remote Procedures and Value Returning Procedures

The idea in version 2 is to move the procedure RegisterCard from the process Controller to process RegisterCard. There are two reasons for doing this:

Additional Changes

Due to the SDL-92 model of remote procedures the move of the RegisterCard procedure will enforce some other changes in the design:

Both the RegisterCard, the ReadCode and the FlashMessage procedure must allow remote procedure calls since they are now defined in different processes.

How to Make a Procedure Available for Remote Procedure Calls

  1. Declare it as EXPORTED in the procedure heading
  2. Make an Import Procedure Specification in each process/procedure that wants to call the remote procedure.
  3. Introduce the name and signature (FPAR) of Exported and Imported procedures by making a Remote Procedure Definition, preferably in the system diagram, see Figure 172.
    Figure\x11 172 : Declaration of an exported procedure. 
    -----
    (fig)  
           
    -----
    

The System File

  1. Now, open the system file AccessControlOOAVer2.sdt
  2. Set the Source Directory, save and close the system file and open it again.
    The SDL system connected to this system file is the same as in the first version. All the diagrams that will be changed in version 2 are copies of the diagrams in version 1, so you can at any time go back to version 1 by opening up the system file for this version.

Changes in the System Diagram

  1. Bring up the page InteractionPage of the system diagram in an SDL Editor.
  2. You should now introduce the names and signatures of all EXPORTED procedures we will use in version 2, see Figure 173.
    Figure\x11 173 : Names and Signatures of Exported Procedures. 
    -----
    (fig)  
           
    -----
    
  3. You should also remove the signals Registered, NotRegistered and RegisterCardAndCode and add the signal Display on the channel from block RegisteredCard to block LocalPanel, see Figure 174.
    Figure\x11 174 : Having Removed and Added some Signals. 
    -----
    (fig)  
           
    -----
    
  4. The signal Display must also be added on the signal route and gate in the Block Type RegisteredCard. When you are editing the signallist you can also remove the signals Registered and NotRegistered.

Changes in the Block type LocalPanel

As mentioned before the signal Display from the procedure RegisterCard must be sent directly to Process Display.

  1. Add a signal route going from env to process Display. Name the gate B and add the signal Display on the signal route and gate, see Figure 175.
    Figure\x11 175 : New Gate Connection and Signal Route. 
    -----
    (fig)  
           
    -----
    

Changes in Process Type Controller

  1. Open the page InitSys of the process type Controller.
  2. Make an Import Procedure Specification of the procedure RegisterCard, ReadCode and FlashMessage, see Figure 176.
    Figure\x11 176 : An Imported Procedure Specification. 
    -----
    (fig)  
           
    -----
    
  3. You should also remove the reference symbol for the procedure RegisterCard, ReadCode and FlashMessage.
  4. The call for the remote procedure RegisterCard will be the same as if it was a local procedure, so nothing has to be changed on the page RegisterCard, see Figure 177.
    Figure\x11 177 : Calling the Procedure RegisterCard. 
    -----
    (fig)  
           
    -----
    

Changes in Procedure FlashMessage

This procedure should be moved to the process Display and it must also be declared as EXPORTED.

  1. Open the process type Display and place a procedure reference symbol and name it FlashMessage.
  2. Connect the symbol to the file flashmessage.spd.
  3. Open the procedure and type in EXPORTED before the keyword procedure in the diagram heading (the name field is editable), see Figure 178.
    Figure\x11 178 : Exporting the Procedure FlashMessage. 
    -----
    (fig)  
           
    -----
    
  4. You must also change the VIA clause from VIA E to VIA B.
  5. The FlashMessage procedure uses a Timer: DisplayTimer. This timer must now be declared in the Display process (a procedure is not allowed to declare timers in SDL).

Changes in Procedure ReadCode

  1. Place a procedure reference symbol in the process KeyPad and connect it to the existing file readcode2.spd Declare this procedure as an EXPORTED value returning procedure, see Figure 179.
    Figure\x11 179 : Exporting the Procedure ReadCode. 
    -----
    (fig)  
           
    -----
    
  2. This procedure is also using a Timer:KeyTimer. Declare this timer in the KeyPad process.
  3. You must also change the in signal from ReadCode to Keystroke. See Figure 180.
    Figure\x11 180 : Changes in Process KeyPad. 
    -----
    (fig)  
           
    -----
    

Changes in Process Type RegisteredCard

  1. Make an Import Procedure Declaration for the two procedures: FlashMessage and ReadCode.
  2. Place a procedure reference symbol for the procedure RegisterCard. Connect it to the existing file registercard.spd, see Figure 181.
    Figure\x11 181 : Importing the Procedure Type RegisteredCard. 
    -----
    (fig)  
           
    -----
    
  3. Declare the procedure as EXPORTED.
  4. Remove signals Registered, NotRegistered and add signal Display in the gate A.
  5. Now, go to the Page RegisterMode of the process type.
  6. The signals RegisterCardAndCode and StopValidate are replaced by two internal flags: RegisterCardAndCodeFlag and StopValidateFlag. Declare these two "flags" as boolean variables. You find the DCL clause on the first Page ValidateCard.
  7. The rest of the code on this page is moved to the procedure RegisterCard, see Figure 182.
    Figure\x11 182 : The Code Moved to Process RegisteredCard. 
    -----
    (fig)  
           
    -----
    

Changes in Procedure RegisterCard

The procedure ReadCode is now a value returning procedure.

  1. The first thing you should do is to remove the Call procedure Symbol and call the procedure directly in the decision symbol.
  2. Sending of the signals StopValidate and RegisterCardAndCode is replaced with assigning the "flags".
  3. The code removed from the process type RegisteredCard is inserted here in the procedure after the task symbol with the text: RegisterCardAndCode:=true, see Figure 183.
    ------------------------------------------------------------------
    Note:                                                               
    Please note that you must change the gate names in the VIA clause   
    from E to A.                                                        
    ------------------------------------------------------------------
    
    Figure\x11 183 : The Resulting Procedure RegisteredCard. 
    -----
    (fig)  
           
    -----
    

Analyzing and Simulating Version 2

  1. If you have carried out the instructions exactly, you should now be able to analyze and generate a simulator without any errors.
  2. Simulate this version in the same way as you did with version 1, see "Simulating the AccessControl system with an X Windows User Interface" on page 246.

Analyzing and Simulating a Prepared AccessControl Version 2

If you run into any errors that you cannot correct you can go down to directory VERS2COMPLETE and open the system file AccessControlOOAVer2Compl.sdt.

This system file will contain a correct version of the AccessControlOOA Version 2 system and you can directly generate a simulator from it.

 
Table of Contents Next Chapter