visual state machine

Upload: thang

Post on 05-Apr-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/31/2019 Visual State machine

    1/71

    Prsentation afIAR visualSTATE

    Lars Kornbek

    [email protected]

  • 7/31/2019 Visual State machine

    2/71

    Agenda

    Lidt historie samt firma prsentation

    visualSTATE

    Grundlggende visualSTATE opbygning Designeren og UML

    Formel verifikation

    Test / Validering samt prototyping

    Kodegenerering og RealLink Dokumentation

    Kunderne og deres applikationer

    Nste visualSTATE release

    Demo af visualSTATE

  • 7/31/2019 Visual State machine

    3/71

    Lidt historie samt firma

    prsentation

  • 7/31/2019 Visual State machine

    4/71

    visualSTATE and IAR A/S History

    1985 1987 1989 1991 1993 1995 1997 1999 2001

    University

    B&O R&D

    B&O Technology

    Beologic A/S

    Baan

    IAR

    Today

  • 7/31/2019 Visual State machine

    5/71

    IAR Systems World wide

    San Francisco

    San Jos

    Boston

    Munich

    London

    Uppsala

    Jonkoping

    Aarhus

    Tokyo

    Sales

    App. Dev. Services

    R&D

    App. Dev. Services

    R&D

    Sales Sales

    App. Dev. Services

    Sales

    R&D

  • 7/31/2019 Visual State machine

    6/71

    VisionTo radically improve the software

    development process for embedded

    application development. We are creatingnew leading edge embedded solutions that

    drastically shorten the entire development

    process while still achieving more efficientresults.

    FromFrom ideaidea toto targettarget !!

  • 7/31/2019 Visual State machine

    7/71

    visualSTATE

    programming tool for Design, Prototyping, CodeGeneration, Test & Documentation

  • 7/31/2019 Visual State machine

    8/71

    Different ArchitecturesDifferent Architectures.. OneOne Solution.Solution.The IAR Solut ion is now available for more than 30 chip

    architectures!

    8-bit 16-bit

    32-bit

    Intel

    Atmel

    MotorolaNEC

    National

    Semiconductor

    Hitachi

    ToshibaZilog

    Sharp

    Samsung

    Texas Instruments

    OKI

    ITT

    Microchip Technologies

    Mitsubishi

    DSP

    Embedded Workbenchdevelopment toolkit based on C/C++ compilers

  • 7/31/2019 Visual State machine

    9/71

    The IAR Embedded Workbench

    A complete development suite for embedded development:

    Project management functionality

    Editors for source code and binary files

    ANSI C & Embedded C++ compilers

    Assembler

    Linker & librarian

    Debugger (Simulator, Emulator & ROM-monitor)

  • 7/31/2019 Visual State machine

    10/71

    IAR MakeAppautomatic code generators for device drivers

  • 7/31/2019 Visual State machine

    11/71

    BlueTooth

    StarterKitMakeApp for BlueTooth

    PreQual

  • 7/31/2019 Visual State machine

    12/71

    Other Products / Services

    Consultant services

    Project startup Project preview

    project development

    Training Product training

    Technology training (C++, EC++, UML, BT, etc)

    Technical Support Services

    Application development Services

  • 7/31/2019 Visual State machine

    13/71

    Hvad er vigtigt for embeddede

    systemer?

  • 7/31/2019 Visual State machine

    14/71

    Krav til embeddede systemer

    Tidskrav

    Eksekverings-tid / Real-time Deterministisk

    Ressource forbrug / Kodestrrelse

    RAM

    ROM

    Kvalitet / plidelighed

  • 7/31/2019 Visual State machine

    15/71

    Grundlggende visualSTATE

    opbygning

  • 7/31/2019 Visual State machine

    16/71

    High-levelAnalysis &Design Tool

    strictly formal

    Analysis

    Design

    Verification

    Coding

    Integration

    UMLSDL

    SAInformal analysis

    Incomplete design

    Manual

    coding

    Trial & Error

    Traditional Development IAR baseddevelopment

    Typical CASE-tool baseddevelopment

    Informalmethod

    Manual

    coding Manual coding

    IARIAR

    visualSTATE

    MakeApp

    Embedded

    Workbench

    From idea to target

    FromDesign ToFinal Tested Code in anEasy Way

  • 7/31/2019 Visual State machine

    17/71

    IAR visualSTATE notations

    State machines designed in IAR visualSTATE can be designed using two

    notations :

    S/E notation based on the Mealy notation

    UML notation for Statecharts

    Hierarchy

    Concurrency

    Memory in state machines

    S1

    S2

    S3

    E1 / A2A3

    E1!S4/A2A3

    E1 / A1

    SE_RESET

  • 7/31/2019 Visual State machine

    18/71

    Hvad er en tilstandsmaskine ?

    En maskine/system med en tilstands-orienteret dynamisk opfrsel

    Et dynamisk system, der reagerer p pvirkninger afhngig af tid

    og tilstand

    Et tilstandsdiagram beskriver

    Livs-forlbet af et system

    Hvordan systemet reagerer p pvirkninger i alle situationer

    Eksempler

    Mobiltelefoner

    Automater (kaffe, slik, cigaretter, Dankort, ...)

    Operatr-paneler

    Symaskiner

    Reguleringer (varme, lys, fugtighed, ...)

  • 7/31/2019 Visual State machine

    19/71

    De centrale elementer i tilstandsmaskiner er :

    Events

    States

    Actions

    Events

    Hndelser, der pvirker tilstandsmaskinen

    Har i princippet ingen tidsmssig udstrkning

    (forekommer momentant og asynkront)

    States

    Beskriver systemets tilstand mellem to events

    Har tidsmssig udstrkning

    Actions

    Beskriver systemets pvirkning p omgivelserne

    Har i princippet ingen tidsmssig udstrkning (udfres

    momentant og uden afbrydelser)

  • 7/31/2019 Visual State machine

    20/71

    TraditionelTraditionel implementationimplementation af tilstandsmaskineraf tilstandsmaskiner

    Manuel kodning med switch-case

    Manuel kodning med tabeller

    Manuel kodning med tilstandsklasser

    Arv og polymorfe operationer (C++/Java)

    switch ( current_state ) {

    case ALARM :

    if ( event == ALARM_KVITTERING ) {

    StopAlarm();

    current_state = INGEN_ALARM;

    }

    break;

    case ...

    :

    }

    Hvordan hndterer viHvordan hndterer vihierarki,hierarki,

    concurrencyconcurrency

    ogog

    synkroniseringersynkroniseringerved manuel kodningved manuel kodning

    ??

  • 7/31/2019 Visual State machine

    21/71

    Rule notation

    CSV = current state vector

    NSV = next state vector

    AV = action vector

    Each state machine is always in one and only one

    state

    State changes (transitions) are triggered by one and

    only one event

    event CSV : NSV AV

  • 7/31/2019 Visual State machine

    22/71

    visualSTATE

    Fundamentals

    visualSTATEenigne

    Device Driver

    convert inputsto events

    Real Life

    x=port(0); port(1) = 1;

    Real Life

    Device Driver

    convert actionsto outputs

    Events Action functions

    Event Queue

  • 7/31/2019 Visual State machine

    23/71

    Mathematical proof of correct code through binary arrayswith unique interpretation

    Kernel functionality verified in millions of applications

    since 1987

    Modeling

    Well definedset of mathematical

    operations

    Run-time

    Technological concept

    State analysis

    Patented

    Patented

  • 7/31/2019 Visual State machine

    24/71

    Hvad kan visualSTATE?

    Fejl hvis Event1 og state1 og state2

    A

    C

    B

    D

    Event1() /

    Event2() /

    Event5() /

    Event6() /Event3() /

    Event4() /

    Design vha.grafisk

    programmering

    Prototype pbaggrund af

    designA

    C

    B

    D

    Event1() /

    Event2() /

    Event5() /

    Event6() /Event3() /

    Event4() /

    Event1Event3Event7Event4

    ...

    Manuel

    test

    Automatisktest

    Kodegenerering Dokumentation

    A

    C

    B

    D

    Event1() /

    Event2() /

    Event5() /

    Event6() /Event3() /

    Event4() /

    {if (SEM.CSV [4] == 0x05)SEM.WSV [3] = 0x0F;

    ....

    }

    A

    C

    B

    D

    Event1() /

    Event2() /

    Event5() /

    Event6() /Event3() /

    Event4() /

    This TV set has been

    developed for a

    Motorola platform...

  • 7/31/2019 Visual State machine

    25/71

    Designer / UML

  • 7/31/2019 Visual State machine

    26/71

    Hvad er UML

    UML, Unified Modeling Language

    UML er en metode / notation der prver at samlenogle af de forskellige objekt orienterede

    metoder.

    OMG godkendte UML som standard i 1997.

    3 modeller

    Kravmodeller (USE-case diagram og sekvensdiagram)

    Strukturer (klassediagrammer)

    Opfrsel (tilstandsdiagrammer)

  • 7/31/2019 Visual State machine

    27/71

    Hvorfor UML

    Veldefineret objekt model

    Uafhngig af implementerings sprog Mulighed for genbrug

    Samme platform uafhngig af type applikation

    Bred vifte af vrktjer

    Bred vifte af litteratur, trning og

    konsulentydelser Efterhnden udbredt p undervisnings

    institutioner

  • 7/31/2019 Visual State machine

    28/71

    Designing a stereo...

    Either the tape recorder orthe radio orthe CD

    player is active...

  • 7/31/2019 Visual State machine

    29/71

    Events are added...

    Transition

    Event

  • 7/31/2019 Visual State machine

    30/71

    A new hierarchical level is introduced

    Substate

    Super

    state

    The states STOPPED, PLAYING and RECORDING

    are only active when state TAPE is active

  • 7/31/2019 Visual State machine

    31/71

    Concurrency is introduced

    State PLAYING orstate STOPPED

    and

    state CD orstate NO_CD are active

    Composite

    state

    Concurrent

    substate

  • 7/31/2019 Visual State machine

    32/71

    Actions are added

    Action

  • 7/31/2019 Visual State machine

    33/71

    Entry and Exit actions

    Entry action

    Exit action

    Entry actions are activated each time a state in entered

    Exit actions are activated each time a state is left

  • 7/31/2019 Visual State machine

    34/71

    Initial statesInitial

    state

    Initial states are used to initialize the statecharts and as default

    states in superstates

  • 7/31/2019 Visual State machine

    35/71

    History states

    Historystate

    History states are used to apply memory to the statecharts

  • 7/31/2019 Visual State machine

    36/71

    Variables

    Variable

  • 7/31/2019 Visual State machine

    37/71

    Signals

    Signal

    Signals can be used to send a message to another state

    machine

  • 7/31/2019 Visual State machine

    38/71

    Internal transitions

    Internal

    transition

    An internal transition does not cause any state change

  • 7/31/2019 Visual State machine

    39/71

    InIn thethe realreal worldworld......

    Events could be interrupts, a button press,

    timeouts, reset...

    States represents whatever the product is doing

    right now...

    Actions could control valves, displays, a CAN

    bus...

    Variables could be used to representtemperatures, counters, flags...

    Summary - UML and visualSTATE Rules :

  • 7/31/2019 Visual State machine

    40/71

    Each state machine is always in one and

    only one state

    State changes (transitions) are triggeredby one and only one

    event / event group / signal

    Upon receipt of a trigger, all statecombinations are frozen until all

    transitions have been handled,and all variables are double buffered (if

    necessary)

    Summary UML and visualSTATE, Rules :

    S UML d i lSTATE T iti

  • 7/31/2019 Visual State machine

    41/71

    Summary - UML and visualSTATE, Transition :

    A B

    EV(p) S1 [(x < 7) || (y > 10)]

    [z = MAX] A2(x, y) S4 ^SIG

    /

    Condition side

    Action side

    Trigger State

    condition

    Guard

    expression

    Assignment Action

    function

    Forcestate

    Signal

  • 7/31/2019 Visual State machine

    42/71

    Design / metodeDesign / metodeDe 6 trin :

    1. Identificr events og actions

    2. Identificr states

    3. Gruppr efter hierarki

    4. Gruppr efter concurrency

    5. Tilfj transitioner

    6. Tilfj synkroniseringer

  • 7/31/2019 Visual State machine

    43/71

    Trin 1 : Identificr events og actions

    Events er omgivelsernes pvirkning p

    systemet

    = input til tilstandsmaskinen

    Events er eksterne hndelser

    Signalerer interne hndelser frasystemet selv

    Actions er systemets pvirkning p

    omgivelserne= output fra tilstandsmaskinen

    Actions er systemets reaktion p de

    eksterne pvirkninger

    T i 2 Id ifi

  • 7/31/2019 Visual State machine

    44/71

    Trin 2 : Identificr states

    States identificeres udfra kravspecifikation samtviden om problem-domnet.

    Dren kan vre ben eller lukket

    Dren kan vre lst eller ulst

    Switchen kan vre i en af de tre positioner

    Lyset kan tndt eller slukket

    T i 3 G ft hi ki

  • 7/31/2019 Visual State machine

    45/71

    Trin 3 : Gruppr efter hierarki

    Undersg hvilke states, der i sig selv har dynamisk

    opfrsel, samt om visse tilstande kun vil optrde i

    bestemte situationer

    Med denne gruppering modelleres, at dren ikke kan

    vre ben eller lukket, nr den er lst.

    Modellen indkapsler muligheden for at bne en dr

    kun muligt, nr dren er ulst

    T i 4 G ft

  • 7/31/2019 Visual State machine

    46/71

    Trin 4 : Gruppr efter concurrency

    Undersg hvilke tilstande, der kan vre aktive p samme tid

    Opdel i flere parallelle aktive tilstandsmaskiner

    Det skal vre muligt at bne, lukke og lse dren

    samtidigt med at switchen ndres og

    samtidigt med at lyset skifter

    Trin 5 : Tilfj transitioner

  • 7/31/2019 Visual State machine

    47/71

    Trin 5 : Tilfj transitioner

    Identificr hvilke tilstandsskift og udfrelse af actions, der skal foreg, nr events forekommer

    Beskriv scenarier (sekvenser af pvirkninger) og tilfj transitioner, der understtter disse

    Bemrk, at der er indfrt yderligere hierarki

    af design hensyn

    n transition til hver switch-position

    Trin 6 : Tilfj synkroniseringer

  • 7/31/2019 Visual State machine

    48/71

    Trin 6 : Tilfj synkroniseringer

    Identificr hvilke transitioner, der er betingede og tilfj evt. yderligere transitioner

    Identificr hvilke transitioner, der har brug for at sende interne beskeder

    Nr dren bnes mens switchen er i sensitive,

    s skal lyset tndes....

    .... etc.

  • 7/31/2019 Visual State machine

    49/71

    IAR visualSTATE Designer

    Graphical overview

    of system behavior

    Hierarchical state

    systems Multiple and inter-

    related state

    machines

    Parallel threads ofcontrol

    UML Statecharts

    State Transition

    Diagrams

  • 7/31/2019 Visual State machine

    50/71

    Formel verifikation

    IAR visualSTATE Testing

  • 7/31/2019 Visual State machine

    51/71

    Interrelationships

    between state-machines arechecked

    All combinations

    are checked

    S11

    S13

    S12

    KEY1

    KEY1

    S14

    KEY2[S21 && S22]

    S21

    S22

    IAR visualSTATE Testing

    Dynamic Formal Verification

    KEY3

    ConflictingTransition

    Dead end

    UnreachableTransition

    Verificator settings

  • 7/31/2019 Visual State machine

    52/71

    Verificator settings

    Exhaustive computation

    7 different checks

    Use of elements

    Reachable transitions

    Conflicting transitions

    Activation of elements

    State dead end Local dead end

    System dead end

    Forward / Backward mode

    Backward = no dead-end check

  • 7/31/2019 Visual State machine

    53/71

    Test / Validering samtprototyping

    IAR i lSTATE T ti

  • 7/31/2019 Visual State machine

    54/71

    Simulation

    Sending events

    Monitoring

    Current States

    Active events Guards

    Triggered actions

    Timers

    Variables

    Signals

    AA AB

    AD AC

    E1() /

    E2() /

    E3() /

    E4() /E3() /

    IAR visualSTATE Testing

    Manual validation

    IAR visualSTATE Testing

  • 7/31/2019 Visual State machine

    55/71

    Record test sequences Static analysis, use of

    Events

    Actions

    Signals Internal & External-

    variables

    Dynamic analysis

    Test coverage analysis

    Non-activated elements

    Most frequently used

    IAR visualSTATE Testing

    Log & Animation

  • 7/31/2019 Visual State machine

    56/71

    Prototyping

    Why prototyping

  • 7/31/2019 Visual State machine

    57/71

    You can build a model that looks and behave likeyour final product

    You can get feedback from marketing, sales and

    customers and therefore make corrections in amuch earlier state in your development process

    and therefore save money.

    It will help you increase the awareness andknowledge of your product before it is launched

    With visualSTATE your final product will

    behave in a way 100% identical to that of your

    prototype.

    y p yp g

  • 7/31/2019 Visual State machine

    58/71

    Prototyping with Altia FacePlate

    Altia integration to visualSTATE

  • 7/31/2019 Visual State machine

    59/71

    g

    Other Prototype possibilities

  • 7/31/2019 Visual State machine

    60/71

    y

    Visual C / C++

    App note 10743: Prototyping in Visual C++ with IARvisualSTATE

    Borland C++ builder

    IAR DK can provide you with an example. Visual Basic

    App note 45079: Prototyping in Visual Basic with

    visualSTATE expert DLL.

    Delphi

    App note 45079: Prototyping in Visual Basic with

    visualSTATE expert DLL.

  • 7/31/2019 Visual State machine

    61/71

    Kodegenerering og RealLink

    IAR visualSTATE Code generation

  • 7/31/2019 Visual State machine

    62/71

    IAR visualSTATE Code generation

    Features Automatic Code Generation based on the design

    Generation of very compact code for 8/16/32-bitmicroprocessors

    integrates with any ANSI-C Compiler

    Integrates with any RTOS

    Advantages SW-consistency between design and actual code

    is guaranteed

    Avoid manual coding, spaghetti coding and

    reverse engineering

    Flexible realization in any target

  • 7/31/2019 Visual State machine

    63/71

    Design + Test+ Prototyping

    Automaticcode-generation

    Real-Link Hardware

    ^ RTOSDevice Drivers

    v

    API*

    Application CompleteTargetA

    pplication

    8-/16-/32-bit*) Foot print: 600 bytes to 2K

    Model

    Connectivity via Real-Link

  • 7/31/2019 Visual State machine

    64/71

    Host

    Wire

    Target

    *) Foot print: ~1K (RS232 interface)

    Real-Link Agent*Real-Link Server

    TCP/IP Direct

    Validator

    Application

    Model

  • 7/31/2019 Visual State machine

    65/71

    Documentation

    IAR visualSTATE Documentation

  • 7/31/2019 Visual State machine

    66/71

    Features Automatic generation of

    design/test/code

    documentation

    Customized generation of

    documents

    Advantages 100% consistent with current

    implementation

    Customized

    documentation/manual

    Up-to-date documentation

    Our customers

  • 7/31/2019 Visual State machine

    67/71

    One genericOne generic

    productproduct

    for a varietyfor a variety

    of industriesof industries

    Automotive

    Telecom

    Medical

    Electronics

    Aerospace & Defense

    Financial

    Industrial machinery

    Industrial instruments

    Consulting & Education

    Multimedia & Entertainment

    Case Stories

  • 7/31/2019 Visual State machine

    68/71

    Husqvarna Viking, MMI for sewing machine

    Grundfos Group, Pumps Bang & Olufsen, TV, video and stereo

    Danfoss A/S, MMI for flow meters

    P.I.V. Eldutronik, frequency controller

    Spark Holland, laboratory equipment

    Wittenborg A/S, Vending machines

    http://www.iar.com/Products/vS/References

    Other Customers

  • 7/31/2019 Visual State machine

    69/71

    Canon Inc.

    LG Electronics

    Digianswer A/S

    DE-VI A/S

    DEIF A/S

    Migatronic A/S

    FBI laboratory

    KONE Corporation

    Lego Systems A/S

    Novo Nordisk A/S

    Scanvgt International A/S

    Siemens Elema AB

    Siemens AG

    Terma Elektronic A/S

    Next visualSTATE release

  • 7/31/2019 Visual State machine

    70/71

    Hierarchical Coder

    C++ wrapper

    Verification of guard and assignments

    Trace generation w/ Validator integration

    New UML modeling constructs

    Team work (+VCS)

    New Navigator

    Graphical breakpoints and transitions

    General bug fixing, performance and stabilityimprovements

    Future: More UML support ???

    Questions

  • 7/31/2019 Visual State machine

    71/71