xtUML and BridgePoint®

Transcription

xtUML and BridgePoint®
xtUML and BridgePoint®
Staffan Kjellberg
Product Manager
SLE, SMA
Outline
Why does BridgePoint look the way it does?
BridgePoint tool suite
Case study – Sumo Robot
− Deep dive
Action Language OAL
Execution Rules
Q&A
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
2
Background
Why does BridgePoint look the way it does?
Because of industry needs…
…and the open market.
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
4
Why does BridgePoint look the way it does?
1.
2.
3.
4.
Added complexity
Maturity
Intended audience
Historical reasons
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
5
1. Added complexity
Diagrams are two
dimensional…
vs.
…as opposed to code
which is linear in its nature
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
6
2. Maturity
Price Performance
System Complexity
High Level
Language
xtUML Models
Compiler
Model
Compiler
Machine
Code
Assembly
High Level
Language
1980s
1990s
2000s
Assembly
Assembler
Increased
Productivity
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
7
Crossing the chasm
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
8
3. Intended audience
Tools are designed for the industry
The tools are there to get the job done
Write once read many
Or,...
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
9
4. Historical reasons
xtUML and MDA
evolved from
Shlaer/Mellor
OOA/RD (1988)
BridgePoint
• created in 1992
• now in its second generation
• completely rebuilt on Eclipse
• built using itself
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
10
10
The Tool
Framework
Eclipse framework
−Uses Eclipse paradigm for consistency with other tools
Collection of Plug-ins, packaged as Eclipse
extension
−Each release easily drops into existing Eclipse installation
Extension points
−Integrate with your own tools
or those of other vendors
−Extend the capabilities of BP
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
12
12
Eclipse continued
Workspace – a collection of projects
Projects – has certain natures and contain resources
Resources – files and folders in a project
Views – provides different view
Editors – tools that operate on resources
Perspectives – a collection of views and editors
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
13
13
Workspace
Work area for any set of projects
Usually some directory in the file system
The workspace is specified when Eclipse starts
BridgePoint Model
BridgePoint Model
C++ Code
Experimental Models
Documentation
Documentation
Legacy Code
Legacy Code
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
14
14
Projects, Resources, Views & Editors
View
Editor
Project
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
15
15
Perspective
Each Eclipse session contains one or more
perspectives
Each perspective provides a set of functionality
aimed at accomplishing a specific type of task or that
works with specific types of resources
−For example, the C/C++ perspective combines views that you
would commonly use while editing C/C++ source files
You might need switch perspectives frequently as
you perform different tasks
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
16
16
BridgePoint Perspectives
Tool
Perspective
Model Builder
(UML)
xtUML Modeling
Model Verifier
(x)
xtUML Debugging
Model Compiler
(t)
EDGE Projects
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
17
17
Eclipse terminology - continued
Run configurations
−A reusable configuration of an executable unit
−Holds arguments, environment variables etc. that is passed to
the execution
Debug configurations
−Similar to a Run configuration but will launch the executable in
debug mode
−Verifier session are always launched in debug mode
Manage the life cycle of Run/Debug configurations
using the Debug view
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
18
18
BridgePoint Model Export / Import
Exports only models – no other
project artifacts
Allows portions of the model to
be exported
Model are imported to existing
BridgePoint projects
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
19
19
Generic Eclipse Export / Import
Exports imports entire projects with all artifacts
Non-intuitive flow:
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
20
20
Executable Models
Raising the level of abstraction
xtUML
Executable & Translatable UML
C++
SmallTalk
Java
Python
C
Assembler
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
22
22
xtUML – Executable and Translatable UML
Unified Modeling Language
− Industry standard notation
− Family of languages
“Executable UML”
− Defines a method, including:
• Semantics of diagrams
• Relationship between diagrams
• Action language
• Execution rules
• Order of construction
• Path to implementation
Copyright © 2005 Mentor Graphics Corp. All rights reserved
23
© Copyright 2003-2009. Mentor
Graphics
xtUML
- EDATFCorp.
2009 All Rights Reserved.
23
23
23
xtUML Design flow
Component Diagram
•Decompose the application
•Define Interfaces
Class Diagram
•Abstractions, associations
•Operations
State Diagram
• Functional lifecycle
• Event handling
Action Specification
•Processing
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
24
24
Case study I – Sumo Robots
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
25
25
Component View
Non xtUML -Modeled
Components
Interfaces
on Ports
Interface
Definition
Models
wired
Provided Interface
graphically
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
26
26
Action Language, OAL
Types of Actions
create, delete instances
read, write attributes
read parameter values
relate, unrelate instances
invoke operations, set parameter values
send events, set parameter values
find instances
computation
create, read, write local variables
control: iterate, loop, decision
Do we need anything else?
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
28
28
Homes for Actions
States
Transitions
Operations
−Instance-based
−Class-based
Ports
Mathematicallyderived attributes
Bridge Operations
Functions
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
29
29
Arithmetic
Boolean
Logical
Operators
−+ - * / %
− Unary -
− and or
− Unary not
− == !=
− < <= >
>=
Assignment
Instance Handles
− assign x = 1;
− Assign keyword optional
− == !=
− empty not_empty
− cardinality
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
30
30
Implicit Typing
Data Types
− All data items are implicitly typed by the value assigned to them on their first use
within an action.
Simple Data Types
System Data Types
Reference Types
− Integer
− Real
− String
− Boolean
− Date
− Timestamp
− Unique ID
− Timer Handle
− Instance Handle
− Instance Handle Set
− Event Instance
− Component Handle
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
31
31
Expressions
a = 3 ;
/* integer typed local variable */
assign x = 3.14 ;
/* floating point value (real) */
y = 11.0 ;
/* another real */
done = false;
// boolean typed local variable
z = x + y * x;
/* Operator Precedence */
b = a % 2;
/* remainder operator */
s1 = “Hello”;
/* String Variable – dynamic size */
s2 = “World!”;
//
C++ Comments also allowed
s3 = s1 + “ “ + s2; // String Concatenation
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
32
32
IF Statement
No semicolon after the IF statement
As many ELIF clauses as desired
Nested IF statements allowed, END IF; terminates statement.
if (serialNumber > 1000)
// do something
elif (serialNumber > 2000)
// do something
if (empty firstPoint)
else
// or something
// this is the first trackPoint in the log
end if;
relate self to trackPoint across R1.'has first';
relate self to trackPoint across R3.'has last';
else
unrelate self from lastPoint across R3.'has last';
relate self to trackPoint across R3.'has last';
relate lastPoint to trackPoint across R2.'follows';
end if;
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
33
33
Loops
WHILE and FOR EACH. Use WHILE to implement a FOR loop.
Can be nested.
Defines a local scope.
for each mobile in mobiles
// do something
end for;
i = 0;
while (i < 4)
// do something
i = i + 1;
end while;
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
34
34
Create / delete statement
Syntax:
create object instance <instance handle> of <keyletter>;
create object instance of <keyletter>;
delete object instance <instance handle>;
create object instance trackPoint of TrackPoint;
delete object instance trackPoint;
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
35
35
Relate / unrelate statement
OAL is used to manage relationships
between specific instances of classes.
relate mobile to call across R1;
Local instance
reference variable
Association label
unrelate mobile from call across R1;
Local instance reference variable
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
36
36
Select one / many … related by …
Select one requires the use of the related by clause
select one timer related by self->WorkoutTimer[R4];
select one timer related by self->WorkoutTimer[R4];
Local instance
reference variable
Key letters Association
label
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
37
37
Events
generate MO_O8:cooking_period(period: 60) to oven;
Event name
Event parameters
Destination
// Receiving Event – rcvd_evt is a keyword.
self.remaining_cooking_time = rcvd_evt.period;
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
38
38
Delayed event
create event instance event of MO_O8(period: 60) to oven;
handle = TIM::timer_start(event_inst: event, microseconds: 1000000);
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
39
39
Execution Rules
State Models
Capture lifecycles in state models
−Instance-based vs. Class-based
Actions take finite time
Transitions are considered instantaneous
All state machines execute concurrently
Instance creation
−No actions executed
−Lowest numbered state
Final state
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
41
41
State Dispatch
Event delivery causes one of:
−Transition
−Ignore
−Error (“Can’t Happen”)
Transition:
−Execute actions on transition
−Execute actions within state
−Change current state
Ignore:
−Event is discarded, no state change, no
actions
Error:
−System-level (as opposed to modeled)
recovery invoked
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
42
42
Event Delivery
Events are reliable
Events do not interrupt executing actions
Order is preserved among sender/receiver pair
Self-directed events are delivered before others
Delayed events specify minimum delay
−Time EE provides timer operations and real-time clock
Currently:
−No guards
−No re-queuing
−No peeking or selecting among multiple events
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
43
43
Summary
These rules represent a 'contract'
between the world of analysis and the
world of implementation
The architecture undertakes to
implement dynamic behavior according
to the agreed semantics.
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
44
44
Case study I – continued
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
45
45
Thank You
For more information on
System Modeling and
Model Driven Development,
visit
www.mentor.com/sm
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
46
46
Components
UML 2.0 Component Definition
A modular part of a system design that hides its
implementation behind a set of external interfaces
Within a system, components satisfying the same set
of interfaces may be substituted freely
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
48
48
Component Packages
Packages are a diagrammatic way to group modeling
elements together and manage their hierarchy.
Components are defined in packages.
Packages can be nested.
Component packages may contain other component
packages and/or interface packages.
Interfaces also are organized in packages.
This allows a level of organizational association
between components and their interfaces.
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
49
49
Interfaces
An interface is a declaration of a collection of
synchronous and asynchronous messages
Managed separately from components
Components implement Interfaces
The separation also allows more than one component
to implement (require or provide) any particular
interface.
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
50
50
Interface Editor
Name
Synchronous
messages
−Operations
−Can carry return values
Asynchronous
message
−Signals
−No return value
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
51
51
Provided vs. Required
Provided Interface
−“The Ball”
− Allows a component to provide
services
to other components
Provided
Required Interface
− “The Cup”
−Allows a component to demand
Required
services from another component
Ports provide a name.
−Necessary if an interface is multiply
used.
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
52
52
Formal Interfaces
When an interface is added it is
not named or formalized.
Name interface for clarity
Formalize to interfaces declared
in interface packages.
Interfaces must be
formalized to pass
messages.
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
53
53
Termination of Interface Messages
Signal (async message) between two connected
components:
− Class based state machine (mapped event), or
− Receiving port
Signal sent from single component
− Sending port
Operation (sync message) between two connected
components:
− Receiving port
Operation invoked from single component:
− Sending port
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
54
54
Component Views
Non xtUML -Modeled
Components
Interfaces
on
Ports
Interface
Definition
Models
wired
Provided Interface
graphically
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
55
55
Nesting Components
Internal interfaces
Delegation
−Provided and required
interfaces to Parent
Component
Leaf components:
−xtUML models
• Class,
• State Machine
• Actions
−Legacy code
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
56
56
Component Definitions
The internals of a component defines its behavior
The behavior is expressed as
1. Class models, or
2. Other nested components
Behavior can not be defined as a combination of
class models and nested components
Components with class models is therefore always
leaves in the component hierarchy
Or..
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
57
57
Component References
A component reference is a pointer to a component definition
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
58
58
Component References (vs. Definitions)
Placeholder for a
component.
Allows for multiple
implementations to be
swapped conveniently.
Multiple configurations with
different components in
Verifier.
Purple Glyph
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
59
59
Getting Started
Divide and conquer
−Any boundary
−Hierarchically nesting
Define interfaces
−Operations and signals
Connect components
Copyright © 2005 Mentor Graphics Corp. All rights reserved
© Copyright 2003-2009. Mentor Graphics Corp. All Rights Reserved.
60
60