66
1 Statecharts - Tool João Pimentel

Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

1

Statecharts - Tool

João Pimentel

Page 2: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

2

Agenda

Introduction

Installing

Modeling

Simulation

Practice

Page 3: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

3

Yakindu Statecharts Tool

“The free to use, open source toolkit YAKINDU Statechart Tools

(SCT) provides an integrated modeling environment for the

specification and development of reactive, event-driven systems

based on the concept of statecharts.”

at http://statecharts.org

Page 4: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

4

Features

Modeling

Syntax checking

Simulation

Integration with Java code

Code generation

• Java

• C

• C++

Page 5: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

5

Download

Page 6: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

6

Online resources - documentation

Page 7: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

7

Online resources - forum

Page 8: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

8

Yakindu –

installing & Running

Page 9: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

9

Installing

If you get the “Full Eclipse” version, all you need to

do is to extract the downloaded file

Page 10: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

10

Running (1/3)

And then just run the Eclipse execution file from the

folder you’ve just extracted

Page 11: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

11

Running (2/3)

During startup you’ll be prompted with the usual

“Select a worspace” window

You can choose any folder to store yourprojects’ files, then press “OK”

Page 12: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

12

Running (3/3)

You are then greeted with the regular Eclipse

welcome window

Page 13: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

13

Creating a new project

Page 14: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

14

Creating a new project (1/4)

File/New/Java Project

Page 15: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

15

Creating a new project (2/4)

Page 16: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

16

Creating a new project (3/4)

Close the “Welcome” window, if still open

Page 17: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

17

Creating a new project (4/4)

Page 18: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

18

Creating a new statechart

Page 19: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

19

Creating a new statechart (1/5)

Page 20: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

20

Creating a new statechart (2/5)

Yakindu/Statechart Model

Page 21: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

21

Creating a new statechart (3/5)

1) Write a name for your statechart, with the “.sct” extension

Page 22: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

22

Creating a new statechart (4/5)

Page 23: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

23

Creating a new statechart (5/5)

Page 24: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

24

Getting to know the environment

Page 25: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

25

Project Explorer

Browse your project’s files

Page 26: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

26

Outline

Zoomed out view of your statechart

Page 27: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

27

Problems/Properties

Problems: warnings and errors in your current project

Properties: properties of the selected element

Page 28: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

28

Problems

Page 29: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

29

Main Panel (1/4)

The actual modeling

Page 30: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

30

Main Panel (2/4)

Text area for declarations

Page 31: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

31

Main Panel (3/4)

The actual statechart

Page 32: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

32

Main Panel (3/4)

Palette of modeling elements

Page 33: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

33

Perspective

Page 34: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

34

Inserting elements

Page 35: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

35

Pallete

Page 36: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

36

Inserting elements

To insert an element, select the element in the Palette (1)

and then draw it in the statechart (2)

Page 37: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

37

Inserting transitions (1/2)

To insert a transition, select “Transition” in the Palette (1)

and then drag (2) and drop (3) from the origin state to the

target state...

Page 38: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

38

Inserting transitions (2/2)

... and lastly you can detail the transition: event

(condition) / action

Page 39: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

39

Inserting super-states (1/2)

Super-states are called “Composite States” – it can be

added in the same way as regular states

Page 40: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

40

Inserting super-states (2/2)

If you need to turn a state into a super-state, you just need

to add a “Region” to that state

Page 41: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

41

Inserting orthogonal states (1/3)

To insert an orthogonal state, select “Orthogonal State” in

the pallete (drop-down menu of “Composite State”), then

just insert it as a regular state

Page 42: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

42

Inserting orthogonal states (2/3)

The orthogonal state starts with 2 sub-states. To add more,

insert a region

Page 43: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

43

Editing elements

Page 44: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

44

Editing elements (1/2)

Option 1) Double-click the element; write; press Enter.

Page 45: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

45

Editing elements (2/2)

Option 2) Click the element (1); go to the Properties panel

(2); edit.

Page 46: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

46

Simulation

Page 47: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

47

Running a simulation (1/3)

Create a statechart

Page 48: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

48

Running a simulation (2/3)

In the Run menu (1), select “Run As” (2), “Statechart

Simulation (3)

Page 49: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

49

Running a simulation (3/3)

The tool will change to the “SC Simulation” perspective

Active states are highlighted in red (1)

Page 50: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

50

Practice 1

Create this statechart and simulate its execution

Page 51: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

51

Events

Page 52: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

52

After

Syntax: after time unit

Unit:

• s – seconds

• ms – milliseconds

• us – microseconds

• ns – nanoseconds

• empty – implies seconds

Page 53: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

53

Custom Events

You can write any event in your transitions (1)

• But you need to declare the events (2)

Page 54: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

54

Defining events (general)

You can define general events

interface:in event pressCapsLocksin event pressEnterin event ...

Page 55: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

55

Defining events (scoped)

Or you can define scoped events

interface Keyboard:in event pressCapsLocksin event pressEnterin event ...

Page 56: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

56

Events in a simulation

During simulation, the declared events appear in a list of events, which can be

clicked to simulate the occurrence of that event

Page 57: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

57

Variables and Actions

Page 58: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

58

Variables (declaring 1/2)

internal:

var varName:varType = startingValue

Ex: var count:integer = 0

Page 59: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

59

Variables (declaring 2/2)

Possible types:

• integer

• real

• boolean

• string

Page 60: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

60

Variables (modifying)

Variable can be modified by actions

Page 61: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

61

Actions

Transition

• event [condition] / action

State

• entry / action

• exit / action

Page 62: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

62

Variables (conditions)

Variables can also be used to define conditions

• event [condition] / action

Page 63: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

63

Variables (simulation)

During simulation, the current value of variables is also

displayed in the “Simulation View”

Page 64: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

64

Variables and Actions

Page 65: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

65

Practice 2Create this statechart and simulate its execution

Page 66: Statecharts - Tool - UFPEin1020/docs/aulas/Statecharts...3 Yakindu Statecharts Tool “The free to use, open source toolkit YAKINDU Statechart Tools(SCT) provides an integrated modeling

66

Practice 3

Create the statechart for a traffic light, and simulate its

execution