on open source tools for behavioral modeling and analysis ... · on open source tools for...

20
Budapest University of Technology and Economics Department of Measurement and Information Systems On Open Source Tools for Behavioral Modeling and Analysis with fUML and Alf Zoltán Micskei, Raimund-Andreas Konnerth, Benedek Horváth, Oszkár Semeráth, András Vörös, and Dániel Varró Open Source Software for Model Driven Engineering 2014 This work was partially supported by

Upload: others

Post on 26-Jun-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: On Open Source Tools for Behavioral Modeling and Analysis ... · On Open Source Tools for Behavioral Modeling and Analysis with fUML and Alf Zoltán Micskei, Raimund-Andreas Konnerth,

Budapest University of Technology and EconomicsDepartment of Measurement and Information Systems

On Open Source Tools forBehavioral Modeling and Analysis

with fUML and Alf

Zoltán Micskei, Raimund-Andreas Konnerth, Benedek Horváth, Oszkár Semeráth,

András Vörös, and Dániel Varró

Open Source Software for Model Driven Engineering 2014

This work was partially supported by

Page 2: On Open Source Tools for Behavioral Modeling and Analysis ... · On Open Source Tools for Behavioral Modeling and Analysis with fUML and Alf Zoltán Micskei, Raimund-Andreas Konnerth,

High-level

System Model

Model Based Analysis of Distributed SystemsSystem design

Mathematical

model

Model

generation

Mathematical analysis

List of

inconsistencies Analysis(e.g. model checker)

Fix problemReceive request

Calculate Rating

Send offer

Accept?

Receive answer

Send reply

Send rejection

Receiveupdate request

Update?YesNo

Yes No

Page 3: On Open Source Tools for Behavioral Modeling and Analysis ... · On Open Source Tools for Behavioral Modeling and Analysis with fUML and Alf Zoltán Micskei, Raimund-Andreas Konnerth,

OMG standard

Formal MethodsfUML AlfUML

Overview of the Approach

3

Activity Diagram Alf Model Timed AutomataState Machine

1. What open source tools are available for fUML and Alf?2. What level of support do they provide?3. What are their maturity level?4. What techniques are available for model generation?

Page 4: On Open Source Tools for Behavioral Modeling and Analysis ... · On Open Source Tools for Behavioral Modeling and Analysis with fUML and Alf Zoltán Micskei, Raimund-Andreas Konnerth,

Formal MethodsfUML AlfUML

UML Editor

Open Source Tooling Overview

4

Alf Editor Model Checker

fUML Reference Impl. AlfRef. Impl.

Papyrus Alf Editor

Moka

Moliz

UPPAAL

Activity Diagram Alf Model Timed AutomataState Machine

Page 5: On Open Source Tools for Behavioral Modeling and Analysis ... · On Open Source Tools for Behavioral Modeling and Analysis with fUML and Alf Zoltán Micskei, Raimund-Andreas Konnerth,

Running Example: Fibonacci Calculation

5

let tmp: Integer = 0;if (input == 1) {

return 1;} else if (input ==2) {

return 1;

}let i: Integer = 3;while (i <= input) {

tmp = var1 + var2;

var1 = var2;

var2 = tmp;i++;

}return tmp;

UML State Machine ALF UPPAAL

Page 6: On Open Source Tools for Behavioral Modeling and Analysis ... · On Open Source Tools for Behavioral Modeling and Analysis with fUML and Alf Zoltán Micskei, Raimund-Andreas Konnerth,

Lesson Learned

No list of tools: Even collecting the tools was considerable efforto Promote tools on OMG website

Few examples: Few example fUML models or Alf code available. o Version and tool incompatibility hinders

Reference implementations: o Help understand the specifications,

o Good starting point

Alf grammar: Complex structures to ensure unambiguity o Good for evaluation of expressions

o Not good for semantic information to help verification

Transformation: Mapping of state machines?

6

Page 7: On Open Source Tools for Behavioral Modeling and Analysis ... · On Open Source Tools for Behavioral Modeling and Analysis with fUML and Alf Zoltán Micskei, Raimund-Andreas Konnerth,

Technologies for M2M

Page 8: On Open Source Tools for Behavioral Modeling and Analysis ... · On Open Source Tools for Behavioral Modeling and Analysis with fUML and Alf Zoltán Micskei, Raimund-Andreas Konnerth,

Java over EMF API

8

Concrete Syntax

Abstract Syntax

while (i <= input){i++;

}

:WhileStatement

:Block

:Increment

:VariableRefname = "i"

:ConditionTest

conditionblock

:Relationop="<="

:VarRefname = "i"

:VarRefname = "input"

:Location

:Edge :Edge

:Guardexp="!(i<=input)"

:Location

:Edge :Edge

trg src

src trg

:Guardexp="!(i<=input)"

:Updateexp="i++"

srctrg

Page 9: On Open Source Tools for Behavioral Modeling and Analysis ... · On Open Source Tools for Behavioral Modeling and Analysis with fUML and Alf Zoltán Micskei, Raimund-Andreas Konnerth,

Java over EMF API

Defined by Java code

1. Traversal by code

2. Manual model building

3. No traceability

- High Maintenance

- Low Reusability

+ Easy to start

9

Concrete Syntax

Abstract Syntax

while (i <= input){i++;

}

:WhileStatement

:Block

:Increment

:VariableRefname = "i"

:ConditionTest

conditionblock

:Relationop="<="

:VarRefname = "i"

:VarRefname = "input"

:Location

:Edge :Edge

:Guardexp="!(i<=input)"

:Location

:Edge :Edge

trg src

src trg

:Guardexp="!(i<=input)"

:Updateexp="i++"

srctrg

Transformation codeLocation transform(WhileStatement w) {

for(Statement s: w.block.statements) {/* map the inner states */}

for(Location l : locations) {/* Link the locations to a circle */}

// Map the condition// Set the guards of the outgoing edges

}

w.block.increment.variableRef.name 1

l = factory.createLocation(); 2

e.setSource(locationMap.get(

edgeMap.get(w.condition)));3

for(state:block)

instanceofA,B,CState

1

Factory.create

setTarget()

2

Page 10: On Open Source Tools for Behavioral Modeling and Analysis ... · On Open Source Tools for Behavioral Modeling and Analysis with fUML and Alf Zoltán Micskei, Raimund-Andreas Konnerth,

M2M Languages

• Example: ATL

• Alternatives:

o Epsilon

o QVT

o Xtend

o …

10

Concrete Syntax

Abstract Syntax

while (i <= input){i++;

}

:WhileStatement

:Block

:Increment

:VariableRefname = "i"

:ConditionTest

conditionblock

:Relationop="<="

:VarRefname = "i"

:VarRefname = "input"

:Location

:Edge :Edge

:Guardexp="!(i<=input)"

:Location

:Edge :Edge

trg src

src trg

:Guardexp="!(i<=input)"

:Updateexp="i++"

srctrg

ATL Codemodule Alf2UPPAAL; create OUT : Machine from IN : Block {

rule Condition2Guard {from s: Alf!Conditionto positiveGuard: UPPAAL!Guard( location <- /*...*/

expression <- /*...*/)negativeGuard: UPPAAL!Guard( location <- /*...*/

expression <- /*...*/)}}

rule State2Location {from s: Alf!Stateto l: UPPAAL!Location}

rule Transition2Edge {from s1: Alf!State,

s2: Alf!State ( /* next state */ )to e: UPPAAL!Edge( src <- /*...*/

trg <- /*...*/ )}

Page 11: On Open Source Tools for Behavioral Modeling and Analysis ... · On Open Source Tools for Behavioral Modeling and Analysis with fUML and Alf Zoltán Micskei, Raimund-Andreas Konnerth,

Declarative Queries + MT languages

Defined by Queries + Templates

1. Traversal Queries

2. Building by Templates

3. (Match, Result) traces

11

Concrete Syntax

Abstract Syntax

while (i <= input){i++;

}

:WhileStatement

:Block

:Increment

:VariableRefname = "i"

:ConditionTest

conditionblock

:Relationop="<="

:VarRefname = "i"

:VarRefname = "input"

:Location

:Edge :Edge

:Guardexp="!(i<=input)"

:Location

:Edge :Edge

trg src

src trg

:Guardexp="!(i<=input)"

:Updateexp="i++"

srctrg

Queriespattern While(W,Condition,States){

WhileStatement.condition(W,Condition);

WhileStatement.block(W,Block);}

pattern Relation(R,Op1,Op2){Relation.left(R,Op1);Relation.right(R,Op1);Relation.op(R,"<=");}

def dispatch transform(WhileStatement w) {val innerStates=WhilePattern.getStates(w).map[createState]val condition=WhilePattern.getCondition(w)/* link the edges */ }

def dispatch transform(Relation condition) {val m=RelationPattern.getMatch(condition)createGuard()=>[exp='''«m.op1.name» <= «m.op2.name»''']}

Templates

Whilematch

Relationmatch

Whiletemplate

Relationtemplate

http://eclipse.org/incquery

Page 12: On Open Source Tools for Behavioral Modeling and Analysis ... · On Open Source Tools for Behavioral Modeling and Analysis with fUML and Alf Zoltán Micskei, Raimund-Andreas Konnerth,

Query-based Features

12

Declarative build by Queries

1. Queries

2. Declarative model buildObject, References, Attributes

3. Implicit, referrable traces"Guard Image of while"

Concrete Syntax

Abstract Syntax

while (i <= input){i++;

}

:WhileStatement

:Block

:Increment

:VariableRefname = "i"

:ConditionTest

conditionblock

:Relationop="<="

:VarRefname = "i"

:VarRefname = "input"

:Location

:Edge :Edge

:Guardexp="!(i<=input)"

:Location

:Edge :Edge

trg src

src trg

:Guardexp="!(i<=input)"

:Updateexp="i++"

srctrg

Query Based Features@QueryBasedObject(Location)pattern Statement(S)

@QueryBasedObject(Edge)@QueryBasedFeature(src, Edge, From)@QueryBasedFeature(trg, Edge, To)pattern nextState(From,To)

@QueryBasedObject(Guard)@QueryBasedFeature(exp, "($Expression$)")@TraceLookup(Incoming, Edge) @QueryBasedFeature(guard, Edge, Guard)pattern PositiveWhileCondition(Incoming, Condition, Expression)

@QueryBasedObject(Guard)@QueryBasedFeature(exp, "! ($Expression$)")@TraceLookup(Outgoing, Edge) @QueryBasedFeature(guard, Edge, Guard)pattern NegativeWhileCondition(Outgoing, Condition, Expression)

http://eclipse.org/incquery

Page 13: On Open Source Tools for Behavioral Modeling and Analysis ... · On Open Source Tools for Behavioral Modeling and Analysis with fUML and Alf Zoltán Micskei, Raimund-Andreas Konnerth,

Technologies for M2T

Page 14: On Open Source Tools for Behavioral Modeling and Analysis ... · On Open Source Tools for Behavioral Modeling and Analysis with fUML and Alf Zoltán Micskei, Raimund-Andreas Konnerth,

"<location name=\"Location_"+ i +"\"/>"

Native Java over EMF API

Defined by Java code

1. Traversal by code

2. Manual text building

3. No traceability

- High Maintenance

- Low Reusability

+ Easy to start

14

Concrete Syntax

Abstract Syntax

while (i <= input){i++;

}

:WhileStatement

:Block

:Increment

:VariableRefname = "i"

:ConditionTest

conditionblock

:Relationop="<="

:VarRefname = "i"

:VarRefname = "input"

:Location

:Edge :Edge

:Guardexp="!(i<=input)"

:Location

:Edge :Edge

trg src

src trg

:Guardexp="!(i<=input)"

:Updateexp="i++"

srctrg

Transformation codeLocation transform(WhileStatement w) {

for(Statement s: w.block.statements) {/* map the inner states */}

for(Location l : locations) {/* Link the locations to a circle */}

// Map the condition// Set the guards of the outgoing edges

}

2

Page 15: On Open Source Tools for Behavioral Modeling and Analysis ... · On Open Source Tools for Behavioral Modeling and Analysis with fUML and Alf Zoltán Micskei, Raimund-Andreas Konnerth,

„M2T”: Queries + AST generation

15

Direct code generation Simple structure

Low complexity

Fast development

Linear output generation(single pass)

⁻ Problematic formatting

⁻ Problematic M2C synchronization

AST generation Represents the program

structure (PSM)

⁻ Can be very complex

⁻ Slower development

⁻ Distributed generation process

Support for M2C synchronization

Incremental code generation

”pretty formatting”

E.g., Eclipse JDT

Model Template Code Model Template Model Grammar Code

Page 16: On Open Source Tools for Behavioral Modeling and Analysis ... · On Open Source Tools for Behavioral Modeling and Analysis with fUML and Alf Zoltán Micskei, Raimund-Andreas Konnerth,

Chaining Transformations alongViews

Page 17: On Open Source Tools for Behavioral Modeling and Analysis ... · On Open Source Tools for Behavioral Modeling and Analysis with fUML and Alf Zoltán Micskei, Raimund-Andreas Konnerth,

Outlook: An Avionics Project

Avionics R&D project

o Model-driven toolchain

o Allocate SWs onto HWs

o Platform: ARINC 653

FunctionalArchitecture

Platform description

Componentdatabase

Allocation

IntegratedSystem Model

Page 18: On Open Source Tools for Behavioral Modeling and Analysis ... · On Open Source Tools for Behavioral Modeling and Analysis with fUML and Alf Zoltán Micskei, Raimund-Andreas Konnerth,

Outlook: An Avionics Project

Avionics R&D project

o Model-driven toolchain

o Allocate SWs onto platform

Simplified Example

18

PilotControl

SubS1

Navigation

FMS

SubS2

EMS

tag: func

tag: func

tag: func

tag: func

InPort/OutPort

Simulink

Id

Id Other SubSystem without tag

Function SubSystem with "func" tag)

Port Blocks

FAM_PilotControl: Function

FAM_Navigation: Function

FAM_FMS : Function

FAM_EMS : Function

nav2ems:InformationLink

provider

consumer

subFunctions

provider

consumer

EMS: Engine Management System FMS: Flight Management System

nav2fms:InformationLink

FAM

id:Function id:InformationLink

View

Maintanence• Incrementally• Immediately

Maintenance:• Incrementally• Immediately

Page 19: On Open Source Tools for Behavioral Modeling and Analysis ... · On Open Source Tools for Behavioral Modeling and Analysis with fUML and Alf Zoltán Micskei, Raimund-Andreas Konnerth,

Summary of Behavior Modeling ToolsTool Version Modified Platform Goal

fUM

L

fUML Ref. Impl. 1.1.0 2013-06 Java / console Interpreter

Moka 1.0.0 2014-06 Eclipse Execution engine

Moliz 1.0 2014-06 Eclipse Execution engine

Alf Alf Ref. Impl. 0.4.0 2014-05 Java / console Interpreter

Papyrus Alf Editor - 2014-07 Eclipse Editor

UPPAAL 4.0 2010-09 Application Model Checker

19

Maturity• Proven: Eclipse platform, UPPAAL• Early prototype: fUML engines (Moka, Moliz)• Alpha: Alf editor in Papyrus is still in active development

Page 20: On Open Source Tools for Behavioral Modeling and Analysis ... · On Open Source Tools for Behavioral Modeling and Analysis with fUML and Alf Zoltán Micskei, Raimund-Andreas Konnerth,

Summary of Transformation Tools

20

Tool Version Modified Platform Goal

Tran

sfo

rmat

ion EMF 2.10.0 2013-05 Eclipse Metamodelling tool

ATL 3.5 2013-13 Eclipse M2M transformation

XTend 2.7 2014-09 Eclipse Template Language

IncQuery 0.8 2014-07 Eclipse Query engine

Query Based Feat. Eclipse M2M transformation

Maturity• Proven: Eclipse platform and core services (e.g. EMF, Xtend), ATL• Stable: EMF-IncQuery (note: local developer support)