Table of Contents Previous Chapter 1 Object-Oriented Design Using SDL-92

1 Object-Oriented Design Using SDL-92

Welcome to SDL-92! This methodology handbook will take you into the new world of Object Oriented SDL. It will follow one case (a simple Access Control system) from the specification to the final SDL-92 design. A simple OOA analysis is performed and general mapping rules between OOA and SDL-92 are derived. The SDL-92 concepts are introduced step by step by developing different versions of the Access Control system. The first version will make use of the OO concepts block types and process types only. The final version will use more advanced OO concepts, such as inheritance (specialization), virtual types, library diagrams (packages), etc.

The AccessControl System

The AccessControl system is a system to control the access to a building. To enter the building, a user must have a registered card, and a personal code (four digits). The device used for entering the card and personal code consists of a card reader, a keypad and a display (see "Requirement Specifications - Hardware" on page 15).

This application is chosen because it is a good example of an embedded system, with features that make it very suitable to be specified using SDL-92, and the new object oriented extensions.

The main characteristics of the system are:

Figure\x11 1 : X Window Interface to the AccessControl system. 
-----
(fig)  
       
-----

Requirement Specifications - Hardware

The hardware devices consists of the following components:

Requirement Specification - Software Logic

The requirements are divided into a number of default functions and a set of additional functions. Furthermore, the requirements are grouped into user functions and supervisor functions.

Default Functions: User Functions

Default Functions: Supervisor Functions

General Requirements

Additional Functions: User Functions

Additional Functions: Supervisor Functions

A brief OOA Orientation

For the Object Oriented Analysis phase we have chosen to use the Coad/Yourdon OOA method.(1) For readers not familiar with this method, here follows a brief orientation concerning the most important concepts in the OOA analysis.

General

The OOA method supports common OO concepts like: inheritance, relationship diagrams, services (methods) and scenarios. The real-time behavior can be described by state event tables.

Working Order

  1. Identify nouns from the written requirement specification (candidates for classes).
  2. Identify classes and objects.
  3. Identify structures and object relations.
  4. Define class attributes.
  5. Define class services.
  6. If necessary, to maintain an overview, form groups of related classes.
  7. Describe scenarios.

Notations and OOA Diagrams

The most important symbol is the class symbol (see Figure 2).

Figure\x11 2 : Class Symbol in OOA. 
-----
(fig)  
       
-----
As seen in Figure 2, there are two different class symbols:

The three text fields in the class symbol are used for specifying:

Class Relations and Class Structures in OOA

The general/specialization concept is based on the inheritance concept. The notation can be read as "is a", meaning that Sub1 is inherited from Super1 (see Figure 3).

Figure\x11 3 : "is a"notation in OOA. 
-----
(fig)  
       
-----
The whole/part of-structure is a notation to show how classes/instances are related to each other. The numbers indicates how many instances there can be of each class. The numbers in the example indicates that the class Whole can have 1 or many (1, m) instances of class Part2, but class Part2 can only be related to one instance of the class Whole (see Figure 4).

Figure\x11 4 : "Whole/Part of"notation in OOA. 
-----
(fig)  
       
-----

Instance Connection

An instance connection is a third type of relation that can be shown in OOA. In this case it is more a relation between instances than between classes that is shown, e.g. if we have two classes namely:

we can use an instance connection to show that the owner and the vehicle are related (see Figure 5)

Figure\x11 5 : Instance Connections. 
-----
(fig)  
       
-----

Class Attributes

A class attribute is data for which every instance of the class will have the same value.

Class Services

A class service represents a partial behavior of the class and can be called by other classes. An important difference between a service and signals (in more signal oriented languages like SDL/SDL-92), is that a service can have both "in" and "out" parameters, and that these are not shown in the class diagrams. A service can call a service in another class. This is sometimes also referred to as messages (see Figure 6).

Figure\x11 6 : Calling Services from other Services. 
-----
(fig)  
       
-----

Describing Real-time Behavior

Each class runtime behavior can be described with a state machine. We have not used this concept. Instead we will use the process concept in SDL to describe the real-time behavior.

Scenarios

A scenario is a way of describing how the system should react to an external/internal stimuli. A scenario is always started with an external/internal stimuli triggering a service in one class; the subsequent sequence of service calls is then shown. A scenario can either be shown using special notations in the class diagram, or in a separate scenario diagram.

We have used the later notation because it is very similar to the MSC (Message Sequence Chart) concept supported by SDT (see Figure 7).

Figure\x11 7 : A Scenario Described using an MSC. 
-----
(fig)  
       
-----

The OOD Model

The OOA method is followed up with an OOD (Object Oriented Design) model. In this model other aspects of an application are covered, such as:

We have not used any of the OOD concepts. Instead, we have used the result from the OOA analysis as input to the SDL-92 design.

An OOA of the AccessControl System

Figure\x11 8 : The OOA model of the AccessControl system 
(Basic Version). ----- (fig) -----

The Basic Version

We have not used the inheritance concept in the basic version because there are only simple and self-contained classes here. What you can see in Figure 8 is the Whole/Part of and the instance connection relations between the classes and the attributes and services for the individual classes.

A Scenario - OpenDoor

The following MSC describes the scenario for "Opening a Door". It starts with the reading of a user card (see Figure 9).

Figure\x11 9 : Scenario OpenDoor. 
-----
(fig)  
       
       
-----
-----------------------------------------------------------------
Note:                                                              
The messages are OOA messages and cannot be mapped directly to     
SDL signals in the forthcoming SDL implementation. The SDL sig     
nal ValidateCode will be followed by a return signal (OK or NOK)   
from the RegisteredCard process.                                   
-----------------------------------------------------------------

The Enhanced Version

The following example is how an analysis of the additional functions "Display of Time" and "Setting of Time" can be performed. The addition of a clock function will mainly affect the class Controller (setting of time) and the class Display (display of current time). A new class Clock must also be introduced. The properties of this class handle the clock and update the current time (see Figure 10).

Figure\x11 10 : System AccessControl with Time. 
-----
(fig)  
       
-----

Mapping Rules OOA - SDL-92

There is no one-to-one mapping between OOA and SDL-92. As can be seen in the following table, there are OOA concepts that can be mapped to more than one SDL-92 concept. The selection is dependent on the context where it is used, e.g. a class containing mainly data and data-manipulation services is probably best mapped to an ADT.

-------------------------------------------------------------------
OOA                            SDL-92                                
-------------------------------------------------------------------
Class (no outer frame around   Process type (alternatively ADT).     
the object)                                                          
Class and object               Process type (alternatively ADT)      
                               and instances of this class in the    
                               system.                               
Attributes                     Process variables.                    
Services                       Signals.                              
                               NOTE! The SDL-92 signal con           
                               cept does not cover the whole ser     
                               vice concept: most services returns   
                               a value; a service can even contain   
                               states!                               
External input/output          Signals to the environment.           
Create                         Formal parameters and start transi    
                               tions in processes.                   
Connect (an implicit service)  Signalling between processes to be    
                               introduced to themselves.             
Access (an implicit service)   Can be implemented with               
                               Export/import-view/revealed for       
                               the reading of variables in other     
                               objects, or ordinary assignments if   
                               they are internal variables.          
Groups                         Block types/block set.                
Scenarios                      MSC diagrams.                         
Generalization/specialization  Inheritance using specialization.     
Whole/part of structure        Block types/block sets to some        
                               extent. Cardinality can be shown      
                               both for blocks and processes.        
Object relation                Cardinality can be shown both for     
                               blocks and processes.                 
Service charts                 Informal process descriptions to      
                               describe a service.                   
-------------------------------------------------------------------

An SDL-92 Specification of the AccessControl System

We will now introduce the new SDL-92 concepts step by step.

Version 1: Use of Block Types and Process Types

We have not used the group concept in OOA because the system is relatively small. But, in SDL, you have to use blocks as a container of processes.

We have identified three blocks: LocalPanel, Doors and RegisteredCard (see Figure 11).

Figure\x11 11 : System Diagram AccessControlOOA. 
-----
(fig)  
       
       
-----

Block Types and Process Types

A type definition can be placed anywhere in a system. We have chosen to place them on the system level so that they will have maximum visibility. This means that they can be instantiated anywhere, and also be used for specialization anywhere in the system.

Block Type LocalPanel

In the OOA analysis we found a number of classes and objects. In the mapping to SDL-92 we have to consider not only the classes, but also the relations between classes, e.g. the "whole/part of" relations found in the analysis. The structure LocalPanel: CardReader, Display and KeyPad is implemented as a block type LocalPanel containing the processes CardReader, Display, KeyPad and Controller (see Figure 12).

Figure\x11 12 : The Block Type LocalPanel. 
-----
(fig)  
       
       
-----

Process Type Controller

In the OOA analysis the class Controller was regarded as a class related to the class RegisteredCards. But seen from a signalling perspective, the Controller process will mainly be communicating with the panel processes KeyPad, CardReader and Display. This is the reason to put the process Controller (i.e. an instance of the process type Controller) inside the block type LocalPanel.

Block Type RegisteredCard and Process Type RegisteredCard

The block type RegisteredCard will only contain an instance of the process type RegisteredCard.

-----------------------------------------------------------------------
Note:                                                                    
It is perfectly legal in SDL to use the same name for a block type and   
a process type because they are of different Entity classes (see         
Figure 13).                                                              
-----------------------------------------------------------------------
Figure\x11 13 : The Block Type RegisteredCard. 
-----
(fig)  
       
       
-----

The Classes Card and Code

As previously mentioned there are classes that will mainly contain data and data manipulation services. The classes Card and Code are of this type and they are implemented as abstract data types. The data type CardDbType has a number of operators defined to validate a card and a code, and to register a new card and a new code. These operators are also implemented in-line, as "C" functions (see Figure 14).

Figure\x11 14 : Data Type CardType and CardDbType. 
-----
(fig)  
       
-----
An instance of the type CardDbType is declared in the process type RegisteredCard. The services ValidateCard, ValidateCode and RegisterCardAndCode for the class RegisteredCard are now implemented as operators for the data type CardDbType (see Figure 15).

Figure\x11 15 : Call of Operators inside the Process RegisteredCard. 
-----
(fig)  
       
-----

Block Type Doors and Process Types Door and DoorLock

A requirement for the AccessControl system is that it should be able to control up to 4 doors. In our SDL-92 design, this can be accomplished by creating a block set of the block type Doors. The Synonym NOOFDOORS is by default 1 but can be assigned any value between 1 and 4. Block type Doors consists of the processes Door and DoorLock. To follow the OOA analysis, the process Door will control how long a door should be opened (attribute DoorTimeOut) and the process DoorLock will open and close a door (services OpenDoor and CloseDoor).

Version 2: Use of 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. Using procedures is often the solution. In the first version procedures are frequently used and we shall now take a look at two of them, namely 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 (user cards or the supervisor's credit card). The function of this procedure is as follows:

Procedure ReadCode

This is a procedure to read four digits from the keyboard. The digits read will be stored in an array named 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 17).

Figure\x11 17 : Procedure ReadCode. 
-----
(fig)  
       
       
-----

Use of Remote Procedures and Value Returning Procedures in Version 2

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

  1. This is the most natural place for it, because this procedure is called whenever a card is to be registered.
  2. No signals have to be exchanged between process Controller and process RegisterCard to announce when to start and stop the registration procedure.
The procedure ReadCode must also be moved, because there will be a deadlock situation when the RegisterCard procedure calls the ReadCode procedure.

-------------------------------------------------------------------------
Note:                                                                      
When a process calls a remote procedure, it enters a new implicit          
state where it will wait for an (implicit) return signal indicating that   
the procedure call has been executed. Any new signals, including           
calls to remote procedures, will be saved. This can easily lead to         
deadlock situations!!!                                                     
-------------------------------------------------------------------------
The ReadCode procedure can be placed in the KeyPad process and FlashMessage (another procedure also called by the RegisterCard) can be placed in the Display process.

The Remote Procedure Concept in SDL-92

Normally a procedure can only be called from the declaring process (or procedure) but by declaring it as EXPORTED it can be called from any process or procedure in the system. The remote procedure concept is modelled with an exchange of signals.

The Save Concept

The service process (the process with the EXPORTED procedure) can only handle a remote procedure call when it is in a state. If it is essential that a process is not interrupted with a remote procedure call in certain states, it is possible to use the SAVE symbol to save the call and handle it in a later state. This will mean that you cannot be sure that a remote procedure call will be handled directly. The model for the calling process is also that a new implicit state is introduced for each remote procedure call. The process will remain in this state until the remote procedure call is handled and executed.

How to Declare an Exported Procedure

  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.
    Figure\x11 18 : Declaration of a Remote Procedure. 
    -----
    (fig)  
           
    -----
    

The Value Returning Procedure Concept in SDL-92

Any procedure can be called as a value returning procedure provided the last parameter is of IN/OUT type. The recommended way is to declare it as value returning if it is intended to be used as such. A call to a value returning procedure can be used directly in an expression, e.g. in an assignment. (see Figure 19).

Figure\x11 19 : Use of Value Returning Procedures. 
-----
(fig)  
       
       
-----
In version 2 we have declared the procedure ReadCode as a value returning procedure, and it will return ReadCodeResult. We want to return this result from the procedure RegisterCard also, so we save it in a variable. (See Figure 18 on page 40 and Figure 19.)

Global Procedures

A procedure can also be defined globally in SDL-92. The conceptual model is that a local copy of the procedure is created in each process where it is called.

A Global Procedure for Sending a Message with the Signal Display

It is mostly the process Controller that displays messages. But the procedure RegisterCard (in process RegisteredCard) and the process Door also send messages.

The process Controller acts as an intermediate conveyer of the signal Display to the process Display in version 1. It is tempting to declare a global procedure that can send any message on the signal Display, and to call this procedure from process Display, process Door and the procedure RegisterCard. Unfortunately, this will not work. The reason is the above mentioned model with the creation of an implicit local model of the procedure. Calling the procedure from, for example, the process Door will in fact result in sending the signal from the calling process. Besides obscuring the signal sending, nothing will be gained by this; the signal must still be declared on the outgoing channel, etc. An alternative is of course to declare the procedure as an EXPORTED procedure and call it as a Remote procedure, but the remote procedure concept should be used with moderation and definitely not in this case, with the sole purpose of hiding signal sending.

A Few Hints on When to Use the Different Procedure Concepts

Local Procedures

Remote and Value Returning Procedures

Global Procedures

Maintenance Aspects

Specialization: Adding/Redefining Properties

One of the major benefits of using an object oriented language is the possibility to, in a very simple and intuitive way, create new objects by adding new properties to existing objects, or to redefine properties of existing objects. This is what is commonly referred to as specialization.

In SDL-92, specialization of types can be accomplished in two ways:

As an example, we may have a special type of door equipped with an automatic door opener that opens the door as soon as it is unlocked. This can be modelled as a new block type SpecialDoor (Figure 20 on page 45) which is a subtype of the original block type Doors. In SpecialDoor we have added a new process DoorOpener, which opens the door upon receipt of the signal OpenDoor from DrLk (of type DoorLock), and keeps the door open until it receives the signal CloseDoor from DrLk.

Figure\x11 20 : The Block Type SpecialDoor. 
-----
(fig)  
       
-----
The keyword INHERITS defines the new type SpecialDoor as a subtype of Doors. Except for that the process DoorOpener and the signal route DrLkDrOp are added, the contents of SpecialDoor are the same as the contents of Doors. The process DrLk is dashed in order to indicate that it refers to the DrLk defined in Doors.

Behavior (i.e. transitions) can be added to a process type using the same principle. For example, the process type TimeDisplay (Figure 21) is a subtype of Display with the addition of a new transition. The gates A and B are dashed in order to indicate that they refer to the gate definitions in the process type Display, with the addition of the signal DisplayTime.

Figure\x11 21 : The Process Type TimeDisplay. 
-----
(fig)  
       
-----
In some cases it may be necessary not only to add properties, but also to redefine properties of a supertype. In Figure 20, the process type DoorLock has to be redefined in order to send the signals OpenDoor and CloseDoor respectively to the new process DoorOpener. Therefore, the corresponding transitions of DoorLock have to be defined as virtual transitions, as depicted in Figure 22.

Figure\x11 22 : The Process Type DoorLock with Virtual Transitions. 
-----
(fig)  
       
-----
Then, in the definition of the new block type SpecialDoor, the corresponding transitions of the process type DoorLock are redefined as shown in Figure 23.

Figure\x11 23 : The Redefined Process Type DoorLock. 
-----
(fig)  
       
-----
In addition to virtual transitions, it is also possible to specify start transitions, saves, continuous signals, spontaneous transitions, priority inputs, remote procedure inputs and remote procedure saves as virtual. Furthermore, a virtual save can be redefined into an input transition.

Example: Adding a Clock to the AccessControl System

The AccessControl system described in the previous sections can be extended to contain a clock which holds the current time. The time is displayed on the display in the format "HH:MM", and the time can be set from the panel by first entering a "#" followed by the time in the format "HHMM".

After an analysis of the problem, e.g. using OOA as described earlier, it is decided that the clock functionality is easiest realized by adding a clock to the local panel. Each minute the clock sends the current time to the controller, which displays the time on the display. Furthermore, the controller is extended to cope with the setting of the time from the key pad.

In order to apply the SDL-92 concepts of specialization to this problem, the original access control specification has to be slightly modified. Since an access control system containing a clock can be regarded as a specialization of the original access control specification, it must be possible to inherit the properties of the original access control system when defining the new system. Therefore, it is necessary that the original AccessControl system is defined as a system type (named BaseAccessControl), as depicted in Figure 24.

Figure\x11 24 : The System Type BaseAccessControl. 
-----
(fig)  
       
-----
Since the specialization of BaseAccessControl requires changes to the block type LocalPanel, it is defined as virtual. For the same reason, the process types used in the block type LocalPanel (i.e. CardReader, Display, KeyPad and Controller) are all defined as virtual. Finally, for reasons of clarity, the definitions of process types that previously where made on the system level are now made in the block types where they are used.

Now, a definition of the access control system containing a clock (named TimeAccessControl) can be based on the system type BaseAccessControl, as depicted in Figure 25.

Figure\x11 25 : The System Type TimeAccessControl. 
-----
(fig)  
       
-----
The system type TimeAccessControl inherits BaseAccessControl with the addition of a new signal DisplayTime, which is sent from the block Lp (of type LocalPanel) to the environment. Furthermore, the block type LocalPanel is redefined in TimeAccessControl; as depicted in Figure 26.

Figure\x11 26 : The Redefined Block Type LocalPanel. 
-----
(fig)  
       
-----
LocalPanel is redefined to contain a process Clock which sends the signal DisplayTime to Cl (of type Controller) and receives the signal SetTime from Cl. Furthermore, Cl is extended to send the signal DisplayTime to Dl (of type Display), which in turn sends it on to the environment via gate C.

The redefinition of Display is straightforward. As depicted in Figure 27, a new transition for the signal DisplayTime is added.

Figure\x11 27 : The Redefined Process Type Display. 
-----
(fig)  
       
       
-----
The redefinition of Controller (Figure 28 on page 53) involves two issues: the addition of functionality to treat the signal DisplayTime, and the addition of functionality to read a new time from the KeyPad and correspondingly set the clock.

Figure\x11 28 : The Redefined Process Type Controller. 
-----
(fig)  
       
       
-----
To cope with the signal DisplayTime, a transition is added to every state that, upon receipt of DisplayTime, sends it on to the process Dl (via gate E). Furthermore, a transition for the signal ReadCode is also added to state Idle in order to realize the setting of the clock. If the key pressed on the key pad is "#" then the new time is read (in the procedure ReadTime). If the new time was read successfully, then the signal SetTime is sent to the process Clock.

Finally, the process Clock is defined as depicted in Figure 29.

Figure\x11 29 : The Process Clock. 
-----
(fig)  
       
-----
The variable CurrentTime of type Time, holds the current time in minutes. Every minute (duration 60), a timer expires which causes the variable CurrentTime to be incremented by 1, and the signal DisplayTime to be sent to process Cl. Receipt of the signal SetTime causes the variable CurrentTime to be updated with the new value. Since the time outside process Clock (i.e. the parameter of the signals DisplayTime and SetTime) is represented as a charstring, there is a need for functions converting Time to Charstring and vice versa. These functions can be defined in the following way:

NEWTYPE TimeOperators
  LITERALS Dummy;
  OPERATORS
    TimeToString : Time -> Charstring;
      /* Converts time to Charstring. The result
         is on the form 'HH:MM' */
      /*#OP (B) */
    StringToTime : Charstring -> Time;
      /* Converts Time to Charstring. Assumes that
         the Charstring is on the form 'HHMM'. */
      /*#OP (B) */
/*#ADT (B)
#BODY
SDL_Charstring #(TimeToString)(T)
SDL_Time T;
{
  SDL_Charstring result:=NULL;
  int Hours, Minutes;
  char tmp1[4], tmp2[4];
  Hours = (T.s/60/60)%24;
  Minutes = (T.s/60)%60;
  tmp1[0]='V';
  tmp2[0]='V';
  sprintf(&(tmp1[1]),"%2ld",Hours);
  sprintf(&(tmp2[1]), "%2ld",Minutes);
  xAss_SDL_Charstring(&result,tmp1,XASS);
xAss_SDL_Charstring(&result,xConcat_SDL_Charstring
(result,xMkString_SDL_Charstring(`:')));
xAss_SDL_Charstring(&result,xConcat_SDL_Charstring
(result,tmp2));
  result[0]='V';
  if(Hours<10)
    result[1]='0';
  if(Minutes<10)
    result[4]='0';
  return result;
}
SDL_Time #(StringToTime)(C)
SDL_Charstring C;
{
  SDL_Time T;
  SDL_Charstring tmpstr;
  tmpstr=xSubString_SDL_Charstring(C,1,2);
  T.s = atoi(++tmpstr)*60*60;
  tmpstr=xSubString_SDL_Charstring(C,3,2);
  T.s = T.s + atoi(++tmpstr)*60;
  return T;
}
*/
ENDNEWTYPE;
This page intentionally left blank 


Footnotes

(1)
Coad, P and E.Yourdon, Object-Oriented Analysis, Yourdon press, Prentice Hall, Englewood Cliffs, NJ, 1990.
(2)
SDL-92 differs from most other object oriented languages in the sense that SDL-92 offers possibilities to specialize behavior specifications. In most other languages this is accomplished by redefining virtual methods in subclasses; in SDL-92 this is easily accomplished by adding new transitions to a process type.
 
Table of Contents Next Chapter