1 / 56

Data in SDL: Simple Data, Dynamic Generation, and Symbol Summary.

This chapter introduces the concept of data in SDL, including simple data types, variable declaration and manipulation, task symbols, input and output signals with data, decision symbols, process control, time and timers, process identification, dynamic process creation, and more.

steveharris
Download Presentation

Data in SDL: Simple Data, Dynamic Generation, and Symbol Summary.

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 5 SDL - Data SEG2101 Chapter 5

  2. Contents • Data • Simple data in SDL • Dynamic generation of process instances • SDL symbol summary • Example 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 SEG2101 Chapter 5

  4. 5.2: Simple Data in SDL Cid (integer) Digit (integer) DCL no_dig integer DCL cardid integer 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. 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. 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. 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. 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. SEG2101 Chapter 5

  10. Decision Symbol • Used to choose between different alternative courses of action upon a question. SEG2101 Chapter 5

  11. SEG2101 Chapter 5

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

  13. Process PanelControl 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 SEG2101 Chapter 5

  15. TIME, Duration, and TIMERS 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 SEG2101 Chapter 5

  17. TIMER Automata SEG2101 Chapter 5

  18. 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 Process Identification (PId) SEG2101 Chapter 5

  19. Use of PId Variables SEG2101 Chapter 5

  20. Use of PId Variables (II) SEG2101 Chapter 5

  21. Output Symbols 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. 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. SEG2101 Chapter 5

  24. Creation of Processes SEG2101 Chapter 5

  25. PROCESS CUControl Create Symbol SEG2101 Chapter 5

  26. Dynamic Process Creation 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). SEG2101 Chapter 5

  28. Daemongame System SEG2101 Chapter 5

  29. Block Structure of Daemongame SEG2101 Chapter 5

  30. Process and Dynamic Process Creation SEG2101 Chapter 5

  31. 5.6: SDL Symbol Summary SEG2101 Chapter 5

  32. SDL Symbol Summary (II) SEG2101 Chapter 5

  33. SDL Data: Part 2 • SDL data types • Abstract data types • Shared variables and enabling conditions 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 ‘/=’ SEG2101 Chapter 5

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

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

  37. Character • "<" : Character, Character -> Boolean; • "<=" : Character, Character -> Boolean; • ">" : Character, Character -> Boolean; • ">=" : Character, Character -> Boolean; • Num : Character -> Integer; • Chr : Integer -> Character; 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; SEG2101 Chapter 5

  39. Duration "+" : Duration, Duration -> Duration; "-" : Duration -> 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; SEG2101 Chapter 5

  40. Time "+" : Time, Duration -> Time; "+" : Duration, Time -> Time; "-" : Time, Duration -> Time; "-" : Time, Time -> Duration; "<" : Time, Time -> Boolean; "<=" : Time, Time -> Boolean; ">" : Time, Time -> Boolean; ">=" : Time, Time -> Boolean; 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; 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. SEG2101 Chapter 5

  43. Real "-" : Real -> Real; "+" : Real, Real -> Real; "-" : Real, Real -> Real; "*" : Real, Real -> Real; "/" : Real, Real -> Real; "<" : Real, Real -> Boolean; ">" : Real, Real -> Boolean; "<=" : Real, Real -> Boolean; ">=" : Real, Real -> Boolean; SEG2101 Chapter 5

  44. New Type Definition (example of abstract data type) SEG2101 Chapter 5

  45. Syntype Definition syntype example2 = integer constant 0:10; endsyntype; 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; SEG2101 Chapter 5

  47. Struct newtype Person struct Name Charstring; Address Charstring; PhoneNumber Charstring; endnewtype; 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; SEG2101 Chapter 5

  49. Array (III) 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; SEG2101 Chapter 5

More Related