Table of Contents Previous Chapter 4 Tutorial: An SDL-92 Example
This version uses remote procedures, value returning procedures and global procedures.
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.
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)
-----
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)
-----
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:
- This is the most natural place for it, because this procedure is called whenever a card is to be registered.
- No signals have to exchanged between process Controller and process RegisterCard to announce when to start and stop the registration scheme.
Due to the SDL-92 model of remote procedures the move of the RegisterCard procedure will enforce some other changes in the design:
- The procedure ReadCode (now in process Controller) must me moved, otherwise a deadlock situation will occur when RegisterCard calls this procedure. We will move it to the process KeyPad.
- The signal Display, sent from procedure RegisterCard to Controller, must be sent directly to the Display process. This is also a result of the remote procedure model (Controller will enter an implicit state after the call of the remote procedure where all signals will be saved except the return signal).
- The process FlashMessage must also be moved for the same reason as for the ReadCode. This procedure will be placed in the Display process.
Both the RegisterCard, the ReadCode and the FlashMessage procedure must allow remote procedure calls since they are now defined in different processes.
- Declare it as EXPORTED in the procedure heading
- Make an Import Procedure Specification in each process/procedure that wants to call the remote procedure.
- 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)
-----
- Now, open the system file AccessControlOOAVer2.sdt
- 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.
- Bring up the page InteractionPage of the system diagram in an SDL Editor.
- 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)
-----
- 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)
-----
- 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.
As mentioned before the signal Display from the procedure RegisterCard must be sent directly to Process Display.
- 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)
-----
- Open the page InitSys of the process type Controller.
- Make an Import Procedure Specification of the procedure RegisterCard, ReadCode and FlashMessage, see Figure 176.
Figure\x11 176 : An Imported Procedure Specification.
-----
(fig)
-----
- You should also remove the reference symbol for the procedure RegisterCard, ReadCode and FlashMessage.
- 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)
-----
This procedure should be moved to the process Display and it must also be declared as EXPORTED.
- Open the process type Display and place a procedure reference symbol and name it FlashMessage.
- Connect the symbol to the file flashmessage.spd.
- 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)
-----
- You must also change the VIA clause from VIA E to VIA B.
- 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).
- 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)
-----
- This procedure is also using a Timer:KeyTimer. Declare this timer in the KeyPad process.
- You must also change the in signal from ReadCode to Keystroke. See Figure 180.
Figure\x11 180 : Changes in Process KeyPad.
-----
(fig)
-----
- Make an Import Procedure Declaration for the two procedures: FlashMessage and ReadCode.
- 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)
-----
- Declare the procedure as EXPORTED.
- Remove signals Registered, NotRegistered and add signal Display in the gate A.
- Now, go to the Page RegisterMode of the process type.
- 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.
- 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)
-----
The procedure ReadCode is now a value returning procedure.
- The first thing you should do is to remove the Call procedure Symbol and call the procedure directly in the decision symbol.
- Sending of the signals StopValidate and RegisterCardAndCode is replaced with assigning the "flags".
- 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)
-----
- If you have carried out the instructions exactly, you should now be able to analyze and generate a simulator without any errors.
- 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.
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