Statecharts 1.- INTRODUCTION 1.- INTRODUCTION

Similar documents
Unified Modeling Language 2

STATE MACHINES. Figure 1: State Machines

Combined Modeling and Programming with State Machines

Section 8. The Basic Step Algorithm

States Transitions Connectors Esterel Studio

Finite State Machines and Statecharts

Exercise Unit 2: Modeling Paradigms - RT-UML. UML: The Unified Modeling Language. Statecharts. RT-UML in AnyLogic

Ingegneria del Software Corso di Laurea in Informatica per il Management

visualstate Reference Guide

Dynamic Modeling - Finite State Machines

Stateflow Best Practices By Michael Burke

Chapter 10. Object-Oriented Analysis and Modeling Using the UML. McGraw-Hill/Irwin

YOLOP Language Reference Manual

UNIT-4 Behavioral Diagrams

Software Development. Designing Software

STUDENT OUTLINE. Lesson 8: Structured Programming, Control Structures, if-else Statements, Pseudocode

NAME CHSM-Java Concurrent, Hierarchical, Finite State Machine specification language for Java

Meltem Özturan

Finite State Machine Modeling for Software Product Lines. Finite State Machines and Statecharts

CA314 Object Oriented Analysis & Design - 7. File name: CA314_Section_07_Ver01 Author: L Tuohey No. of pages: 16

State Machine Diagrams

Maciej Sobieraj. Lecture 1

NAME CHSM-C++ Concurrent, Hierarchical, Finite State Machine specification language for C++

UML REFERENCE SHEETS. 2013, 2014 Michael Marking; all rights reserved, including moral rights. Web site:

SCXML State Chart XML

Activities Radovan Cervenka

Object-Oriented Software Engineering Practical Software Development using UML and Java. Chapter 8: Modelling Interactions and Behaviour

Object oriented programming. Instructor: Masoud Asghari Web page: Ch: 3

12 Tutorial on UML. TIMe TIMe Electronic Textbook

16.1 Introduction... 2

EE414 Embedded Systems Ch 9. State Machines

What is a Class Diagram? A diagram that shows a set of classes, interfaces, and collaborations and their relationships

What is a Class Diagram? Class Diagram. Why do we need Class Diagram? Class - Notation. Class - Semantic 04/11/51

SCXML State Chart XML. Previously, in this course...

Activity Diagram Written Date : September 02, 2016

The STATEMATE Semantics of Statecharts

Practical UML - A Hands-On Introduction for Developers

1 Statecharts language and Statemate Magnum

UML- a Brief Look UML and the Process

In addition to the primary macro syntax, the system also supports several special macro types:

CS 370 REVIEW: UML Diagrams D R. M I C H A E L J. R E A L E F A L L

Enterprise Architect - UML Dictionary

Motivation State Machines

Practical UML : A Hands-On Introduction for Developers

Enterprise Architect. User Guide Series. UML Models. Author: Sparx Systems. Date: 30/06/2017. Version: 1.0 CREATED WITH

Software Service Engineering

CISC836: Models in Software Development: Methods, Techniques and Tools

Programming Languages Third Edition. Chapter 9 Control I Expressions and Statements

Embedded Systems. Problem 1: Getting started with STATEFLOW. Starting STATEFLOW

GBL Language Reference Manual

Basic Structural Modeling. Copyright Joey Paquet,

Introduction to Software Engineering. 6. Modeling Behaviour

JOURNAL OF OBJECT TECHNOLOGY

Łabiak G., Miczulski P. (IIE, UZ, Zielona Góra, Poland)

Petri Nets" Computer Science 520/620 Spring 2011 Prof. L. Osterweil" Software Models and Representations" Part 3" Some Semantics"

Computer Science 520/620 Spring 2011 Prof. L. Osterweil" Software Models and Representations" Part 3" Petri Nets"

The sequence of steps to be performed in order to solve a problem by the computer is known as an algorithm.

UNIT-II Introduction to UML

CHAD Language Reference Manual

System Analysis and Design. Statecharts

Spoke. Language Reference Manual* CS4118 PROGRAMMING LANGUAGES AND TRANSLATORS. William Yang Wang, Chia-che Tsai, Zhou Yu, Xin Chen 2010/11/03

UML 2.0 State Machines

Specifying Precise Use Cases with Use Case Charts

CISC-124. Casting. // this would fail because we can t assign a double value to an int // variable

Computer Science 520/620 Spring 2013 Prof. L. Osterweil" Use Cases" Software Models and Representations" Part 4" More, and Multiple Models"

Computer Science 520/620 Spring 2013 Prof. L. Osterweil" Software Models and Representations" Part 4" More, and Multiple Models" Use Cases"

ENGR 1181 MATLAB 09: For Loops 2

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual

SOFTWARE ENGINEERING UML FUNDAMENTALS. Saulius Ragaišis.

Lecture Transcript While and Do While Statements in C++

Handout 9: Imperative Programs and State

Prof. Dr. Reinhard von Hanxleden. Christian-Albrechts Universität Kiel Department of Computer Science Real-Time Systems and Embedded Systems Group

The Warhol Language Reference Manual

STUDENT LESSON A12 Iterations

CGS 3066: Spring 2015 JavaScript Reference

Lecture Outline. COMP-421 Compiler Design. What is Lex? Lex Specification. ! Lexical Analyzer Lex. ! Lex Examples. Presented by Dr Ioanna Dionysiou

Pieter van den Hombergh. Fontys Hogeschool voor Techniek en Logistiek. September 9, 2016

Chapter 2: Introduction to C++

Object-Oriented and Classical Software Engineering

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

egrapher Language Reference Manual

JME Language Reference Manual

Chapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen

Simulation-Based Analysis of UML Statechart Diagrams: Methods and Case Studies 1

Introduction to C Programming

SECTION 1: INTRODUCTION. ENGR 112 Introduction to Engineering Computing

Decaf Language Reference

Lecture 16: Hierarchical State Machines II

The learning objectives of this chapter are the followings. At the end of this chapter, you shall

Relational Operators and if. Class 10

Thirty one Problems in the Semantics of UML 1.3 Dynamics

Java Bytecode (binary file)

Software Engineering. Page 1. Objectives. Object-Behavioural Modelling. Analysis = Process + Models. Case Study: Event Identification

Solved Question Paper June 2017

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Quick Reference Guide

Modeling Hybrid Systems with Petri Nets

Introduction. Purpose. Intended Audience. Conventions. Close

UML Diagrams MagicDraw UML Diagrams

Control Flow. COMS W1007 Introduction to Computer Science. Christopher Conway 3 June 2003

Transcription:

Statecharts INDEX 1.- Introduction 2.- When to use Statecharts 3.- Basic components 4.- Connectors and compound transitions Mª Ángeles Martínez Ibáñez University of Bergen Selected topics in programming theory 1 5.- Concurrent Statecharts 6.- Hierarchy of States 7.- Bibliography Selected topics in programming theory 2 1.- INTRODUCTION Definition: Statecharts are used to describe the behaviour of a system and describe all of the possible states of an object as events acting upon it. PowerLevel (Level) Stop Idle Start (Time) Stop (TimeRemaining) Start (time) Simple example Microwave StateChart- 1.- INTRODUCTION As it s seen, Statecharts are finite state machines extended with hierarchy and parallelism, allowing a complex system to be expressed in a more compact way. Statecharts describe how the functionality of a system relates to the state in which it exists at any one point in time, and how its state changes in response to events acting upon it. It relates things happening to an object to changes in the object. Selected topics in programming theory 3 Selected topics in programming theory 4

2.- When to use Statecharts Use statecharts for classes where it is necessary to understand the behaviour of the object through the entire system. Not all classes will require a statechart, and there aren t useful for describing the collaboration of all objects in a use case. Statecharts are other combined with other diagrams such as interaction diagrams and activity diagrams. Selected topics in programming theory 5 States: they re represented by rounded boxes and show the state of the object. The arrow between states indicates the transition. Selected topics in programming theory 6 All the diagrams begin with a start state and ends with a final state. It s not obligatory use exactly one of each type. We can have diagrams with one or more start state and with no final state. Is very common find system s behaviour which never ends. -> And-states: Have orthogonal components that are related by and. They re represented graphically as rounded rectangles (parent state) divided by dashed lines -> Or-states: This is, if the state of the high level is active, only one of the internal states will be active. Selected topics in programming theory 7 Selected topics in programming theory 8

Selected topics in programming theory 9 Selected topics in programming theory 10 Transition: they re represented by an arrow from one to other state. Self-Transition: that is a transition which goes back to the same state. Example Elevator- Selected topics in programming theory 11 Selected topics in programming theory 12

Default transition: specified by a small arrow emanating from a small solid circle. Selected topics in programming theory 13 Selected topics in programming theory 14 Triggers: Triggers are the dynamic elements in statecharts. Triggers cause state transitions or static reactions. Events, conditions or a combination of both can be triggers. Triggers represented graphically as directed graphs (arrows), connecting two states. -> Events: Events signify a precise instant in time; they are edge-sensitive, comparable to signals and interrupts. Events can be generated externally to the statechart (primitive events) or internally. Sources for internally generated events are actions, timeouts or sensors for detecting the status of states, activities, conditions and data items. Selected topics in programming theory 15 Selected topics in programming theory 16

Events may also be a compound set of other events and conditions. Events are represented as a alphanumeric labels on transition lines or in the On field in state definitions. Selected topics in programming theory 17 Selected topics in programming theory 18 The negation of an event using the not operation must be approached with caution. This negation means that the specified event did not occur. Event expressions are evaluated according to the conventional precedence rules of logical operations, and parentheses can be used. E5 E1 or E2 or E3 or E4 Example -Negating an event- Selected topics in programming theory 19 Selected topics in programming theory 20

The any operator is used to detect the fact that some unspecified component of an event array has occurred. The all operator captures the simultaneous occurrence of all events in the array. -> Conditions: Conditions are boolean expressions, valued TRUE or FALSE, that signify a time span during which the condition holds. Conditions can be edge or levelsensitive. Conditions may be primitive elements or compound elements that express a set of boolean operations such as AND and OR. Selected topics in programming theory 21 Selected topics in programming theory 22 Conditions are represented as alphanumeric labels on transition lines, enclosed in brackets in the form event[condition], or in the Trigger field in state definitions. exp1 = exp2, exp1 > exp2, exp1 <= exp2, exp1 # exp2 exp1 < exp2 exp1 >= exp2 Comparison conditions Selected topics in programming theory 23 Selected topics in programming theory 24

-> Data-item expressions: A data-item is a unit of information that may assume values of various types and structures. They re similar to the data elements in conventional programming languages: variables, constants, and so on. They maintain their values until they re explicitly changed and assigned new values. Knowing this, data-item expressions can be used in assignment actions, and can be of different types: numeric (integer, real, bit, bitarray), strings, and structured. With numeric expressions It s allow to use user functions (functions that are not predefined) Selected topics in programming theory 25 Selected topics in programming theory 26 Actions: Actions are instantaneous operations and are performed as a result of some trigger. Changing the value of a condition or data-item and invocations of activities are examples of actions. An action can also be a sequence of actions that occur simultaneously regardless of the sequence of their appearance. Selected topics in programming theory 27 Selected topics in programming theory 28

Logical conditional actions may be expressed based on conditions or on the occurrence of events. Actions are represented as alphanumeric labels on the transition lines, separated by a slash in the form event[condition]/action, or in the Action field in state definitions. When an action is a sequence of actions, the actions that make it up are separated by semicolons. Selected topics in programming theory 29 Selected topics in programming theory 30 If we re working with textual language, this allows various types of actions classified as follows: Basic actions that manipulate elements. Conditional and iterative actions. -> Element manipulation: It causing changes that can be checked and triggering other happenings in the system. The elements which are manipulated by most basic actions are: events, conditions and data-items. Selected topics in programming theory 31 Selected topics in programming theory 32

Event manipulation: is just sending the event. This is perfomed by the action that is simply the name of the event. Condition manipulation: special actions can cause a condition to become true or false. We can find many abbreviations for this. A condition has two associated events: tr(c) changes from false to true. fs(c) changes from true to false An action has this events: tr!(c) set the truth value of condition C to true fs!(c) it corresponds with the action make_false(c), and, obviously, set it to false. Selected topics in programming theory 33 Selected topics in programming theory 34 It s usual to think that, tr(c) always occur when tr!(c) is executed, but this isn t correct. The events occur only when the truth value of C changes value, but the actions can be executed without changing the truth value if ti was the desired one to start with. Data-items manipulation: all types of dataitems can be involved in assignments. The right-handside expression of the assignment must be type consistent with the assigned data-item on the left-hand side. Both sides must be either numeric or string. Selected topics in programming theory 35 Selected topics in programming theory 36

-> Compound actions and context variables: It s possible to perform more than one action when a transition is taken. If we want to do this, we ve to write it by separating the component actions by a semicolon. The conditional action is other kind of compound action, in thich the actual action carried out depends on a condition or an event. We can find two cases: Condition Event expression if C then A else B end if when E then A else B end when Actions Selected topics in programming theory 37 Selected topics in programming theory 38 -> Iterative actions: They have been declarated to help manipulate arrays. for I in N1 to N2 loop A end loop The action break, will skip the rest of loop s iterations, and the action that follows the loop construct will be the next one to execute. The while loop iterates until some condition becomes false. We can use the break action here too, to jump out of the loop without completing the iteration. Selected topics in programming theory 39 Selected topics in programming theory 40

Activities: Activities are operations that are performed in a non-zero amount of time. Activities can be controlled (started or stopped) through actions, and their status can be monitored. Activities are not represented graphically in statecharts. They may appear as part of other element definitions. Selected topics in programming theory 41 Selected topics in programming theory 42 4. CONNECTORS AND COMPOUND 4. CONNECTORS AND COMPOUND Connectors and Compound Transitions: they are used to help economize in arrows to clafiry the specification. -> Condition connectors: Also called C-connectors. They are represented graphically as circles containing the letter C. If distinct conditions apply to the outbound transition arrows, they must be exclusive in order to prevent nondeterminism. S1 E [C1] C [C2] S2 S3 Selected topics in programming theory 43 Selected topics in programming theory 44

4. CONNECTORS AND COMPOUND -> Swtich connectors: Also called S-connectors. They are usually used with events rather than conditions, but the purpose is the same one that with the C-connector. 4. CONNECTORS AND COMPOUND -> Junction connectors: Transition arrows can be joined using this kind of connectors. We can find events which causes exit from two states and, in the other hand, the case in which two events lead out of a state into two separate states. Selected topics in programming theory 45 Selected topics in programming theory 46 4. CONNECTORS AND COMPOUND -> Diagram connectors: They are used for eliminating lengthy arrows from the chart in favor of marking two points in the chart and indicating that the arrow flows from one point to the other. Is useful for do symbolic reference to another occurrence of the same symbol in another diagram, allowing for connections among separate diagrams. 4. CONNECTORS AND COMPOUND -> History connector: Also called H-connector. It s feature is to enter the state most recently visited within the group of states (this is obtained by the history entrances ). If we want to extend a history entrance down to all levels, the H-connector can appear with an asterisk attached (this is a deep history connector). Selected topics in programming theory 47 Selected topics in programming theory 48

4. CONNECTORS AND COMPOUND 4. CONNECTORS AND COMPOUND Example if the system was last in operating.fast, then that would be the state entered despite the fact that slow is the initial state.- Example statechart with history connector for account- Selected topics in programming theory 49 Selected topics in programming theory 50 4. CONNECTORS AND COMPOUND Fork: We may view this as another kind of compound transition. This transition splits the execution flow into two or more parallel activities. -Example UML Notation- -Example Join&Fork- Selected topics in programming theory 51 Selected topics in programming theory 52

5. CONCURRENT STATECHARTS 5. CONCURRENT STATECHARTS When we talk about that, statecharts support concurrent, we refer that in the same statechart, it can be more than one state executing simultaneously. When the order leaves the concurrent states, it s in only a single state. Concurrent state diagrams are useful when a given object has sets of independent behaviors. But they are not very advisable. Selected topics in programming theory 53 Selected topics in programming theory 54 6. HIERARCHY OF STATES 6. HIERARCHY OF STATES The reason to use this is because the highly complex behavior cannot be easily described by simple diagrams. S F E Statechart can finish being a chaotic succession of states and transitions. G/A E/B U The use of a hierarchic scheme offers a solution to this problem. T F G/A A simple state-transition diagram without hierarchy Selected topics in programming theory 55 Selected topics in programming theory 56

6. HIERARCHY OF STATES SUMMARY V G/A S T E/B F E U G/A Clustering of states of the V las example. The semantic is to be in V is to be, exclusively, in either of its substates, S or T. This is the classical exclusive-or applied to states. V is called an or-state, and it s parent of the two sibling states S and T. Statechart diagrams is a graph that represents a behavior s state machine. A state is a condition during the life of an object or an interaction during which it satisfies some condition, performs some action, or waits for some event. Selected topics in programming theory 57 Selected topics in programming theory 58 SUMMARY An event is an occurrence that may trigger a state transition. A transition is a relationship between two states indicating that an object in the first state will enter the second state and perform specific actions when a specified event occurs provided that certain specified conditions are satisfied. SUMMARY The trigger for a transition is the occurrence of the event labeling the transition. If an event doesn t trigger any transition, it s discarded. A condition is an expression which decides whether a state transition actually occurs. An action are associated with transitions and are considered to be processes that occur quickly and aren t interruptible. Selected topics in programming theory 59 Selected topics in programming theory 60

SUMMARY Activities are associated with states and can take longer. An activity may be interrupted by some event. [FS98] [HM98] 7.- Bibliography M. Flower, K. Scott: UML Distilled. Second Edition. A Brief Guide to the Standard Object Modeling Language, Addison Wesly Professional. D. Harel, M. Politi Modeling Reactive Systems with Statecharts. The statemate approach, McGraw-Hill, New York, United states [Op97] http://www.opengroup.org/ [In02] http://www.informatik.uni-freiburg.de/ [De02] http://dependable.kaist.ac.kr/ Selected topics in programming theory 61 Selected topics in programming theory 62 7.- Bibliography [Iv04] [Cs] [Cs] http://www.iv.cs.tu-berlin.de http://www.cs.uiowa.edu/ http://www.cs.sjsu.edu/ Selected topics in programming theory 63