Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 5 SDL - Data 2007, rev. 08 SEG2101 Chapter 5.

Similar presentations


Presentation on theme: "Chapter 5 SDL - Data 2007, rev. 08 SEG2101 Chapter 5."— Presentation transcript:

1 Chapter 5 SDL - Data 2007, rev. 08 SEG2101 Chapter 5

2 Contents Data Simple data in SDL
Dynamic generation of process instances SDL symbol summary Example 2007, rev. 08 SEG2101 Chapter 5

3 5.1: What is Data? The bytes of a computer normally play two different roles. Some bytes are parts of the program, while others are manipulated by the programs.  control and data Data is usually used to represent spatial information whereas control is used for temporal information about behavior progress. Data exists over time. Abstract data types 2007, rev. 08 SEG2101 Chapter 5

4 5.2: Simple Data in SDL Cid (integer) Digit (integer)
DCL no_dig integer DCL cardid integer 2007, rev. 08 SEG2101 Chapter 5

5 Declaration of Variables
DCL is the keyword which precedes data declaration. A list of names follows DCL and the line is terminated by a sort name. The common predefined types: Boolean, Character, Charstring, Integer, Natural, and Real. 2007, rev. 08 SEG2101 Chapter 5

6 Variable Declaration & Manipulation
A process may locally use and manipulate data stored in variables. The variable may be initialized when it is created at interpretation time to a certain value. During a transition the process can use and manipulate its own local variables, using the task construct. 2007, rev. 08 SEG2101 Chapter 5

7 Task Symbol Used to set the values of data by assignments.
A task symbol may contain a list of assignments separated by commas. 2007, rev. 08 SEG2101 Chapter 5

8 Task Symbol (II) Variable occurrences on the right of an assignment operator means extracting the value from the variable. Operations are associated with types. Variables on the left of the assignment operator are modified to become the expression value of the right-hand side. 2007, rev. 08 SEG2101 Chapter 5

9 Input Signal with Data Values carried by input signals must be transferred to local variables There is no way to access the input signal again after it has been consumed. 2007, rev. 08 SEG2101 Chapter 5

10 Decision Symbol Used to choose between different alternative courses of action upon a question. 2007, rev. 08 SEG2101 Chapter 5

11 2007, rev. 08 SEG2101 Chapter 5

12 Output Signal with Data
Full expression can be in signal parameters, not only variables. 2007, rev. 08 SEG2101 Chapter 5

13 Process PanelControl 2007, rev. 08 SEG2101 Chapter 5

14 Process PanelControl (II)
A special initialization construct DCL trial_no Integer := 0; Output symbol where the destination is a process name 2007, rev. 08 SEG2101 Chapter 5

15 TIME, Duration, and TIMERS
2007, rev. 08 SEG2101 Chapter 5

16 TIME, Duration, and TIMER (II)
Time: data type NOW is a predefined variable Duration: data type TIMER: a special type of object with operations SETactive RESETinactive and sending a message when time period has elapsed 2007, rev. 08 SEG2101 Chapter 5

17 TIMER Automata 2007, rev. 08 SEG2101 Chapter 5

18 Process Identification (PId)
Each SDL process has a unique identifier, a value of data type PId. Special value NULL (no process) Predefined variables SELF: the process itself OFFSPRING: the most recent process created by SELF PARENT: SELF is OFFSPRING of PARENT SENDER: the process that sent the last signal received and processed by SELF 2007, rev. 08 SEG2101 Chapter 5

19 Use of PId Variables 2007, rev. 08 SEG2101 Chapter 5

20 Use of PId Variables (II)
2007, rev. 08 SEG2101 Chapter 5

21 Output Symbols 2007, rev. 08 SEG2101 Chapter 5

22 Save Symbol Save symbol assures that a set of signals will be bypassed until the process has entered a different state. Then the saved signals will be processed; they remain in the input queue in their original order. Example below: in all states but Idle, Code will be saved. Code signal will only be handled in the Idle state. 2007, rev. 08 SEG2101 Chapter 5

23 5.5: Dynamic Generation of Process Instances
In SDL, a process may create other processes. The creation is shown by a dashed line from PARENT to OFFSPRING. Blocks cannot be generated dynamically. 2007, rev. 08 SEG2101 Chapter 5

24 Creation of Processes 2007, rev. 08 SEG2101 Chapter 5

25 PROCESS CUControl Create Symbol 2007, rev. 08 SEG2101 Chapter 5

26 Dynamic Process Creation
2007, rev. 08 SEG2101 Chapter 5

27 Stop Symbol Processes are created by their parent.
A processes terminates when it reaches a stop symbol. (Note: processes may not kill each other). 2007, rev. 08 SEG2101 Chapter 5

28 Daemongame System 2007, rev. 08 SEG2101 Chapter 5

29 Block Structure of Daemongame
2007, rev. 08 SEG2101 Chapter 5

30 Process and Dynamic Process Creation
2007, rev. 08 SEG2101 Chapter 5

31 5.6: SDL Symbol Summary 2007, rev. 08 SEG2101 Chapter 5

32 SDL Symbol Summary (II)
2007, rev. 08 SEG2101 Chapter 5

33 SDL Data: Part 2 SDL data types Abstract data types
Shared variables and enabling conditions 2007, rev. 08 SEG2101 Chapter 5

34 Operators Data types in SDL are
Predefined types, such as Integer, etc. Programmer-defined types: They are defined using keywords Newtype or syntype. Examples are: Subranges of Integer Enumerations Arrays Record types (called structure in C, like objects with attributes) Abstract data types (not much used) For every data type defined in SDL, the following operators are always defined: Assignment ‘:=’ Test for equality ‘=’ Test for non-equality ‘/=’ 2007, rev. 08 SEG2101 Chapter 5

35 Infix and Prefix Operators
“+” : Integer,Integer -> Integer; num : Character -> Integer; I := I+1; N := num(‘X’); I := “+”(I,1); 2007, rev. 08 SEG2101 Chapter 5

36 Boolean "NOT" : Boolean -> Boolean
"AND" : Boolean, Boolean -> Boolean "OR" : Boolean, Boolean -> Boolean "XOR" : Boolean, Boolean -> Boolean "=>" : Boolean, Boolean -> Boolean 2007, rev. 08 SEG2101 Chapter 5

37 Character "<" : Character, Character -> Boolean;
Num : Character -> Integer; Chr : Integer -> Character; 2007, rev. 08 SEG2101 Chapter 5

38 Charstring MkString : Character -> Charstring;
Length : Charstring -> Integer; First : Charstring -> Character; Last : Charstring -> Character; "//" : Charstring, Charstring -> Charstring; SubString : Charstring, Integer, Integer -> Charstring; 2007, rev. 08 SEG2101 Chapter 5

39 Duration "+" : Duration, Duration -> Duration;
"*" : Duration, Real -> Duration; "*" : Real, Duration -> Duration; "/" : Duration, Real -> Duration; ">" : Duration, Duration -> Boolean; "<" : Duration, Duration -> Boolean; ">=" : Duration, Duration -> Boolean; "<=" : Duration, Duration -> Boolean; 2007, rev. 08 SEG2101 Chapter 5

40 Time "+" : Time, Duration -> Time; "+" : Duration, Time -> Time;
"<" : Time, Time -> Boolean; "<=" : Time, Time -> Boolean; ">" : Time, Time -> Boolean; ">=" : Time, Time -> Boolean; 2007, rev. 08 SEG2101 Chapter 5

41 Integer, Natural "-" : Integer -> Integer;
"+" : Integer, Integer -> Integer; "-" : Integer, Integer -> Integer; "*" : Integer, Integer -> Integer; "/" : Integer, Integer -> Integer; "mod" : Integer, Integer -> Integer; "rem" : Integer, Integer -> Integer; "<" : Integer, Integer -> Boolean; ">" : Integer, Integer -> Boolean; "<=" : Integer, Integer -> Boolean; ">=" : Integer, Integer -> Boolean; Float : Integer -> Real; Fix : Real -> Integer; 2007, rev. 08 SEG2101 Chapter 5

42 PId The type PId is used as a reference to process instances.
PId has only one literal, Null. All other values are obtained from the SDL predefined variables Self, Sender, Parent, and Offspring. 2007, rev. 08 SEG2101 Chapter 5

43 Real "-" : Real -> Real; "+" : Real, Real -> Real;
"<" : Real, Real -> Boolean; ">" : Real, Real -> Boolean; "<=" : Real, Real -> Boolean; ">=" : Real, Real -> Boolean; 2007, rev. 08 SEG2101 Chapter 5

44 New Type Definition (example of abstract data type)
2007, rev. 08 SEG2101 Chapter 5

45 Syntype Definition syntype example2 = integer endsyntype;
constant 0:10; endsyntype; 2007, rev. 08 SEG2101 Chapter 5

46 Enumeration An enumeration sort is a sort containing only the values enumerated in the sort. newtype KeyPosition literals Off, Stand_by, Service_mode endnewtype; 2007, rev. 08 SEG2101 Chapter 5

47 Struct newtype Person struct endnewtype; Name Charstring;
Address Charstring; PhoneNumber Charstring; endnewtype; 2007, rev. 08 SEG2101 Chapter 5

48 Array The predefined generator Array takes two generator parameters, an index sort and a component sort. There are no restrictions in SDL on the index and component sort. newtype A1 Array(Character, Integer) endnewtype; 2007, rev. 08 SEG2101 Chapter 5

49 Array (III) 2007, rev. 08 SEG2101 Chapter 5

50 String The String generator takes two generator parameters, the component sort and the name of an empty string value. A value of a String type is a sequence of component sort values. There is no restriction on the length of the sequence. newtype S1 String(Integer, Empty) endnewtype; 2007, rev. 08 SEG2101 Chapter 5

51 String (II) MkString : Itemsort -> String
Length : String -> Integer First : String -> Itemsort Last : String -> Itemsort "//" : String, String -> String SubString : String, Integer, Integer -> String 2007, rev. 08 SEG2101 Chapter 5

52 Powerset The Powerset generator takes one generator parameter, the item sort, and implements a powerset over that sort. A Powerset value can be seen as: for each possible value of the item sort it indicates whether that value is member of the Powerset or not. syntype SmallInteger = Integer constants 0:31 endsyntype; newtype P1 Powerset(SmallInteger) endnewtype; 2007, rev. 08 SEG2101 Chapter 5

53 Powerset (II) "IN" : Itemsort, Powerset -> Boolean
Incl : Itemsort, Powerset -> Powerset Del : Itemsort, Powerset -> Powerset Length : Powerset -> Integer Take : Powerset -> Itemsort Take : Powerset, Integer -> Itemsort "<" : Powerset, Powerset -> Boolean ">" : Powerset, Powerset -> Boolean "<=" : Powerset, Powerset -> Boolean ">=" : Powerset, Powerset -> Boolean "AND" : Powerset, Powerset -> Powerset "OR" : Powerset, Powerset -> Powerset 2007, rev. 08 SEG2101 Chapter 5

54 Imported and Exported Value
The exported declaration and the imported specification must both be equal to the remote variable specification. 2007, rev. 08 SEG2101 Chapter 5

55 Shared Variables 2007, rev. 08 SEG2101 Chapter 5

56 Shared Variables (II) 2007, rev. 08 SEG2101 Chapter 5


Download ppt "Chapter 5 SDL - Data 2007, rev. 08 SEG2101 Chapter 5."

Similar presentations


Ads by Google