SDL Data - PowerPoint PPT Presentation

1 / 56
About This Presentation
Title:

SDL Data

Description:

A list of names follows DCL and the line is terminated by a sort name. ... generator takes two generator parameters, the component sort and the name of ... – PowerPoint PPT presentation

Number of Views:49
Avg rating:3.0/5.0
Slides: 57
Provided by: jyz3
Category:
Tags: sdl | data | generator | name

less

Transcript and Presenter's Notes

Title: SDL Data


1
Chapter 5
  • SDL - Data

2
Contents
  • Data
  • Simple data in SDL
  • Dynamic generation of process instances
  • SDL symbol summary
  • Example

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

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

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.

7
Task Symbol
  • Used to set the values of data by assignments.
  • A task symbol may contain a list of assignments
    separated by commas.

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.

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.

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

11
(No Transcript)
12
Output Signal with Data
  • Full expression can be in signal parameters, not
    only variables.

13
Process PanelControl
14
Process PanelControl (II)
  • A special initialization construct
  • DCL trial_no Integer 0
  • Output symbol where the destination is a process
    name

15
TIME, Duration, and TIMERS
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

17
TIMER Automata
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

19
Use of PId Variables
20
Use of PId Variables (II)
21
Output Symbols
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.

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.

24
Creation of Processes
25
PROCESS CUControl
Create Symbol
26
Dynamic Process Creation
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).

28
Daemongame System
29
Block Structure of Daemongame
30
Process and Dynamic Process Creation
31
5.6 SDL Symbol Summary
32
SDL Symbol Summary (II)
33
SDL Data Part 2
  • SDL data types
  • Abstract data types
  • Shared variables and enabling conditions

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 /

35
Infix and Prefix Operators
  • Integer,Integer -gt Integer
  • num Character -gt Integer
  • I I1
  • N num(X)
  • I (I,1)

36
Boolean
  • "NOT" Boolean -gt Boolean
  • "AND" Boolean, Boolean -gt Boolean
  • "OR" Boolean, Boolean -gt Boolean
  • "XOR" Boolean, Boolean -gt Boolean
  • "gt" Boolean, Boolean -gt Boolean

37
Character
  • "lt" Character, Character -gt Boolean
  • "lt" Character, Character -gt Boolean
  • "gt" Character, Character -gt Boolean
  • "gt" Character, Character -gt Boolean
  • Num Character -gt Integer
  • Chr Integer -gt Character

38
Charstring
  • MkString Character -gt Charstring
  • Length Charstring -gt Integer
  • First Charstring -gt Character
  • Last Charstring -gt Character
  • "//" Charstring, Charstring -gt Charstring
  • SubString Charstring, Integer, Integer
  • -gt Charstring

39
Duration
  • "" Duration, Duration -gt Duration
  • "-" Duration -gt Duration
  • "-" Duration, Duration -gt Duration
  • "" Duration, Real -gt Duration
  • "" Real, Duration -gt Duration
  • "/" Duration, Real -gt Duration
  • "gt" Duration, Duration -gt Boolean
  • "lt" Duration, Duration -gt Boolean
  • "gt" Duration, Duration -gt Boolean
  • "lt" Duration, Duration -gt Boolean

40
Time
  • "" Time, Duration -gt Time
  • "" Duration, Time -gt Time
  • "-" Time, Duration -gt Time
  • "-" Time, Time -gt Duration
  • "lt" Time, Time -gt Boolean
  • "lt" Time, Time -gt Boolean
  • "gt" Time, Time -gt Boolean
  • "gt" Time, Time -gt Boolean

41
Integer, Natural
  • "-" Integer -gt Integer
  • "" Integer, Integer -gt Integer
  • "-" Integer, Integer -gt Integer
  • "" Integer, Integer -gt Integer
  • "/" Integer, Integer -gt Integer
  • "mod" Integer, Integer -gt Integer
  • "rem" Integer, Integer -gt Integer
  • "lt" Integer, Integer -gt Boolean
  • "gt" Integer, Integer -gt Boolean
  • "lt" Integer, Integer -gt Boolean
  • "gt" Integer, Integer -gt Boolean
  • Float Integer -gt Real
  • Fix Real -gt Integer

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.

43
Real
  • "-" Real -gt Real
  • "" Real, Real -gt Real
  • "-" Real, Real -gt Real
  • "" Real, Real -gt Real
  • "/" Real, Real -gt Real
  • "lt" Real, Real -gt Boolean
  • "gt" Real, Real -gt Boolean
  • "lt" Real, Real -gt Boolean
  • "gt" Real, Real -gt Boolean

44
New Type Definition (example of abstract data
type)
45
Syntype Definition
  • syntype example2 integer
  • constant 010
  • endsyntype

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

47
Struct
  • newtype Person struct
  • Name Charstring
  • Address Charstring
  • PhoneNumber Charstring
  • endnewtype

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

49
Array (II)
  • GENERATOR Array
  • (TYPE Index,TYPE Itemsort)
  • OPERATORS
  • Make! Itemsort?Array
  • Modify! Array,Index,Itemsort?Array
  • Extract! Array,Index?Itemsort
  • AXIOMS
  • ...
  • ENDGENERATOR Array

50
Array (III)
51
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

52
String (II)
  • MkString Itemsort -gt String
  • Length String -gt Integer
  • First String -gt Itemsort
  • Last String -gt Itemsort
  • "//" String, String -gt String
  • SubString String, Integer, Integer
  • -gt String

53
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 031
  • endsyntype
  • newtype P1 Powerset(SmallInteger)
  • endnewtype

54
Powerset (II)
  • "IN" Itemsort, Powerset -gt Boolean
  • Incl Itemsort, Powerset -gt Powerset
  • Del Itemsort, Powerset -gt Powerset
  • Length Powerset -gt Integer
  • Take Powerset -gt Itemsort
  • Take Powerset, Integer -gt Itemsort
  • "lt" Powerset, Powerset -gt Boolean
  • "gt" Powerset, Powerset -gt Boolean
  • "lt" Powerset, Powerset -gt Boolean
  • "gt" Powerset, Powerset -gt Boolean
  • "AND" Powerset, Powerset -gt Powerset
  • "OR" Powerset, Powerset -gt Powerset

55
Imported and Exported Value
  • The exported declaration and the imported
    specification must both be equal to the remote
    variable specification.

56
Shared Variables
57
Shared Variables (II)
Write a Comment
User Comments (0)
About PowerShow.com