SlideShare una empresa de Scribd logo
1 de 42
No Magic World Symposium, Allen TX
Ed Seidewitz
Model Driven Solutions, Inc. ● http://www.modeldriven.com
ed-s@modeldriven.com ● @seidewitz
Copyright © 2018 Ed Seidewitz
Using the Alf Action Language
with Cameo Simulation Toolkit
Part 1 – Basics
Page 2
About me
Ed Seidewitz
Chief Technology Officier, Model Driven Solutions, Inc.
ed-s@modeldriven.com ● @seidewitz
• 30 years experience as a project manager,
architect, developer and modeler
• Involved with UML since version 0.8
• Developer of fUML and Alf Reference
Implementations and MagicDraw Alf Plugin
• Chair of the OMG fUML and Alf Revision Task
Forces; member of the UML Revision Task Force
Copyright © 2018 Ed Seidewitz
Page 3
Goals
Part 1 – Basics (Today)
• Learn the basics of the Alf action language for Executable UML.
• Use the Alf Plugin for MagicDraw.
• Practice using Alf with Cameo Simulation Toolkit.
Part 2 – Modeling (Wednesday)
• Model simulations using the Alf action language.
• Use Alf in class and state machine models in MagicDraw.
• Create and run simulations using Alf with Cameo Simulation
Toolkit.
Copyright © 2018 Ed Seidewitz
Page 4
Prerequisites (for Part 1)
• Participant
– Basic knowledge of class, activity and state machine modeling
using MagicDraw
– Some experience with model execution using Cameo Simulation
Toolkit
– General familiarity with programming/scripting (particularly in a
language like C++, Java, JavaScript, etc.)
• System (for hands-on exercises)
– MagicDraw 18.5
– Cameo Simulation Toolkit 18.5sp3
– Alf plugin 18.5
Install MagicDraw, CST and Alf Plugin on line or from USB stick
Copyright © 2018 Ed Seidewitz
Page 5
5
Installing the Alf plugin
Copyright © 2018 Ed Seidewitz
Plugin documentation is available at:
https://docs.nomagic.com/display/ALFP185/Alf+plugin
Under Plugins
(commercial),
download / install the
Alf plugin v18.5.
Select Help ► Resource/Plugin
Manager to open the Resource/
Plugin Manager window.
 A new version will be
available for the 19.0
release.
Or click here to install
from USB stick.
Page 6
Background
Copyright © 2018 Ed Seidewitz
Page 7
Executable UML
Executable UML is a (growing) subset of standard UML that can be
used to define, in an executable, operational style, the structural and
behavioral semantics of systems.
• Foundational UML (structural and activity models)
– http://www.omg.org/spec/FUML
• Precise Semantics of UML Composite Structure (PSCS)
– http://www.omg.org/spec/PSCS
• Precise Semantics of UML State Machines (PSSM)
– http://www.omg.org/spec/PSSM
Copyright © 2018 Ed Seidewitz
• Action Language for Foundational UML (Alf)
– http://www.omg.org/spec/ALF
A textual surface representation for UML modeling elements with the
primary purpose of acting as the surface notation for specifying executable
(fUML) behaviors within an overall graphical UML model.
Alf Plugin
Page 8
Why an action language?
• Graphical notations are good for…
Copyright © 2018 Ed Seidewitz
Structural models
High-level behavioral models
Page 9
Why an action language?
• …but not so good for detailed behavior
Copyright © 2018 Ed Seidewitz
Full executability requires complete
specification of behavior and
computation. This is often much more
easy to specify using a textual notation.
Page 10
Why not just use a scripting language?
• Scripting language:
No standard syntactic or semantic integration with UML
• Alf:
Full, standardized syntactic and semantic integration with UML
Copyright © 2018 Ed Seidewitz
this.lineItems->remove(item)
this.totalAmount = Subtract(this.totalAmount, item.amount)
ALH.removeValue(self, "lineItems", item);
arguments = ALH.createList();
arguments.add(ALH.getValue(self, "totalAmount"));
arguments.add(ALH.getValue(item, "amount”));
ALH.setValue(self, "totalAmount",
ALH.callBehavior("Subtract", arguments));
Example using the MagicDraw-
specific Action Language
Helper API for JavaScript.
Page 11
The basic idea: Alf maps to fUML
Copyright © 2018 Ed Seidewitz
activity DoSomething(in input: Integer, out output Integer): Integer {
output = A(input);
return B();
}
Alf behavioral notation
maps to fUML activity
models.
The semantics of the Alf notation is
defined by its mapping to fUML
Page 12
Hands On
Hello World
Copyright © 2018 Ed Seidewitz
Page 13
Create an Alf project
Copyright © 2018 Ed Seidewitz
In the Alf folder,
select the Alf
template.
 The Alf template automatically
loads the Alf Library model and
sets Alf as the default language
for opaque behaviors, actions
and expressions.
Under Other,
select Project
from Template.
Select File ► New Project to
open the project creation window.
Create a Hello
World project.
Page 14
Create the Hello World activity
Copyright © 2018 Ed Seidewitz
Create a
new Activity.
Enter the Alf code in
the Alf editor window.
When the code is
correct, click Save.
 If the Alf editor window
is closed, you can open
it using Window ► Alf.
Page 15
Executing the activity
Copyright © 2018 Ed Seidewitz
Right click on the
Activity and select
Simulation ► Run.
Set Animation Speed
to the highest level…
…and click
here to run.
Output appears in
the console pane.
Page 16
Basic Concepts
Copyright © 2018 Ed Seidewitz
Page 17
Assignment as data flow
Copyright © 2018 Ed Seidewitz
a = +1;
b = -a;
a = A(a) + B(b);
Local names map to
forked object flows.
Subexpressions are
evaluated concurrently.
A re-assigned local
name actually maps
to a new flow.
 The literal “1” has type
Natural. The expression
“+1” has type Integer. The
expression “A(a) + B(b)” has
type Integer, which is not
compatible with Natural.
The local name a implicitly
gets the type Integer.
Statements map to structured
activity nodes with control flows
to enforce sequential execution.
a = 1;
a = A(a); ✗
type conformance
Page 18
Using Alf for behaviors
Copyright © 2018 Ed Seidewitz
lineItem = new LineItem(product, quantity);
this.lineItems->add(lineItem);
this.totalAmount = this.totalAmount + lineItem.amount;
Method of an operation
this.lineItems = checkOut.items;
Customer_Order.createLink(checkOut.customer, this);
this.datePlace = CurrentDate();
this.totalAmount = lineItems.amount->reduce '+';
this.SubmitCharge(checkOut.card);
Behavior on a state machine
battFrac = battCond / this.maxBattLevel;
gThrottle = Max(accelPos * (1-battFrac), this.maxGThrottle);
eThrottle = Max(accelPos * battFrac, this.maxEThrottle);
Body of an action
Page 19
Using Alf for expressions
Copyright © 2018 Ed Seidewitz
Activity Edge Guards
State Machine Transition Guards
Page 20
Hands On
Stopwatch
Copyright © 2018 Ed Seidewitz
Page 21
Open the StopWatch sample project
Copyright © 2018 Ed Seidewitz
…
Click Samples on
the Welcome Screen
Under Simulation,
choose the StopWatch
sample project.
 Select File ► Save Project As…
to save a local copy of the project
before continuing.
Page 22
Setup the project for Alf
Copyright © 2018 Ed Seidewitz
Remove the existing
Project Usage for
fUML_Library.
 This part will not be
necessary in v19.0.
Select Tools ► Alf ►
Load Library to load
the Alf Library.
Page 23
Open the StopWatch state machine
Copyright © 2018 Ed Seidewitz
Page 24
Replace the ready state behavior
Copyright © 2018 Ed Seidewitz
Open the Specification
window for the ready
state.
Under Entry, change
the Behavior Type to
Opaque Behavior.
 Be sure to select the ready
state as a whole, not just the
line for the entry behavior.
Page 25
Replace the reset timer activity
with Alf code
Copyright © 2018 Ed Seidewitz
 Be sure to click on the text
for the entry behavior, not
the entire state.
Click on the
entry behavior…
replaced by
 The use of the prefix this
is required to access an
attribute value in Alf.
…and enter the
code into the Alf
editor window.
Page 26
Show the Alf code on the state machine
diagram
Copyright © 2018 Ed Seidewitz
Open the Symbol
Properties window for
the ready state.
Set the Opaque
Behavior Display Mode
property to Body.
Page 27
Coming in v19.0!
Copyright © 2018 Ed Seidewitz
Syntax-aware editing
of Alf code in opaque
body editors.
Page 28
Replace the Increase time activity with Alf
code
Copyright © 2018 Ed Seidewitz
replaced by
 The ++ operator
increments its argument.
Page 29
Executing the StopWatch model
Copyright © 2018 Ed Seidewitz
Right click on the
StopWatch class and select
Simulation ► Run.
Start the simulation, then
trigger the start signal.
Output is displayed
in the console tab.
The current state
machine configuration
is animated.
Page 30
Sequences
Copyright © 2018 Ed Seidewitz
Page 31
Sequences
Copyright © 2018 Ed Seidewitz
activity GetReadings(in sensors: Sensor[*]): Integer[*] {
readings = sensors->collect sensor (sensor.reading);
return readings;
}
The input parameter has
an unordered set of
values (by default).
Object flows always carry
ordered sequences of
values.
Values are handled one
by one within the
expansion region.
The read actions
happen concurrently.
The result is a sequence
ordered respective to the
input sequence.
The return parameter
gets an unordered set
of values (by default).
 The Alf on the left could be
written more simply as:
return sensors.reading;
The local name reading
implicitly gets the type Integer
and the multiplicity [0..*].
 Arbitrary sequences cannot
be assigned to local names
with multiplicity [0..1].
reading = -1;
readings = reading;
reading = readings;
Implicitly gets the multiplicity [0..1]
A single value is really just a
sequence of length 1.
✗ multiplicity conformance
Page 32
Null as the empty sequence
Copyright © 2018 Ed Seidewitz
A LiteralNull is intended to be used to explicitly model the lack of a value.
In the context of a MultiplicityElement with a multiplicity lower bound of 0,
this corresponds to the empty set (i.e., a set of no values). It is equivalent
to specifying no values for the Element.
null = any [ ] { }
From the UML 2.5 specification (clause 8.2.3):
The Alf interpretation: null is the (untyped) empty sequence
sensors = null;
sensors.readings;
WriteLine(null);
WriteLine(name ?? "no name");
“null” can be assigned to any target with
a multiplicity lower bound of 0.
This is not an error. It is equivalent to
sensors->collect sensor (sensor.reading);
which evaluates to “null”.
 An argument for
a parameter of
multiplicity 1..1
cannot be null.
✗
multiplicity conformance
A null-coalescing expression can be used
to provide a non-null “default value”.
Page 33
Hands On
Reversing a Sequence
Copyright © 2018 Ed Seidewitz
Page 34
Create the Reverse project
Copyright © 2018 Ed Seidewitz
Create a new project
using the Alf
template, as before.
Page 35
Create the Reverse activity diagram
Copyright © 2018 Ed Seidewitz
Create a new
Activity Diagram.
Page 36
Add activity parameter nodes
Copyright © 2018 Ed Seidewitz
Leave the parameters
untyped.
Page 37
Add Alf code in opaque actions
Copyright © 2018 Ed Seidewitz
Click on the opaque
action to enter code in
the Alf editor window.
The CompiledRepresentation
stereotype records the executable
activity compiled from the code.
Click on the opaque action and
select Symbol Properties to turn
off stereotype display.
Click here to make this the default.
Select Expert mode,
if necessary.
 If you are using SysML, be careful
to us the UML Boolean type, not
the SysML Boolean type.
Page 38
Fill in the activity model
Copyright © 2018 Ed Seidewitz
Using an expression here is a
shorthand for the statement
result = seq->isEmpty();
Alf in an Opaque Action
can access pins as
local names.
 Guards must be entered
as Literal Specifications.
Page 39
Coming in v19.0!
Copyright © 2018 Ed Seidewitz
Alf activity edge
guards using
decision input
values.
Page 40
Write a TestReverse activity
Copyright © 2018 Ed Seidewitz
Iterative for loop
Sequence construction
expression
Cast expression Null-coalescing expression
 The cast expression is required because the result of
Reverse is untyped. The null-coalescing expression
is required because a cast can result in null.
Page 41
Testing the Reverse activity
Copyright © 2018 Ed Seidewitz
Right click on
TestReverse and select
Simulation ► Run.
Click here to execute.
Make sure the slider is
all the way to the right!
This is the expected result.
Page 42
Bonus: Writing Reverse entirely in Alf
Copyright © 2018 Ed Seidewitz
activity RecursiveReverse(in seq : any[*] sequence) : any[*] sequence {
return seq->isEmpty()? null:
seq->excludeAt(1)->RecursiveReverse()->including(seq[1]);
}
activity IterativeReverse(in seq : any[*] sequence) : any[*] sequence {
result = null;
n = seq->size();
for (i in 0..n-1) {
result->add(seq[n-i]);
}
return result;
}
The arrow notation (sequence operation
expression) can be used with any behavior
that has a sequence as its first parameter.
Conditional-test expression
Remember that null is the
empty sequence.
add is an “in place”
collection function.

Más contenido relacionado

La actualidad más candente

La actualidad más candente (8)

Design pattern
Design patternDesign pattern
Design pattern
 
Project Status Report Timeline Of Product Status
Project Status Report Timeline Of Product StatusProject Status Report Timeline Of Product Status
Project Status Report Timeline Of Product Status
 
How to Write & Run a Test Case in Selenium | Selenium Tutorial | Selenium Tra...
How to Write & Run a Test Case in Selenium | Selenium Tutorial | Selenium Tra...How to Write & Run a Test Case in Selenium | Selenium Tutorial | Selenium Tra...
How to Write & Run a Test Case in Selenium | Selenium Tutorial | Selenium Tra...
 
BIM new.pptx
BIM new.pptxBIM new.pptx
BIM new.pptx
 
Siebel Open UI Debugging (Siebel Open UI Training, Part 7)
Siebel Open UI Debugging (Siebel Open UI Training, Part 7)Siebel Open UI Debugging (Siebel Open UI Training, Part 7)
Siebel Open UI Debugging (Siebel Open UI Training, Part 7)
 
BIM and FM
BIM and FMBIM and FM
BIM and FM
 
KPI Dashboard Powerpoint Ideas
KPI Dashboard Powerpoint IdeasKPI Dashboard Powerpoint Ideas
KPI Dashboard Powerpoint Ideas
 
Katalon Studio - Successful Test Automation for both Testers and Developers
Katalon Studio - Successful Test Automation for both Testers and DevelopersKatalon Studio - Successful Test Automation for both Testers and Developers
Katalon Studio - Successful Test Automation for both Testers and Developers
 

Similar a Using Alf with Cameo Simulation Toolkit - Part 1: Basics

SAP B1 integration framework scenario creation
SAP B1 integration framework scenario creationSAP B1 integration framework scenario creation
SAP B1 integration framework scenario creation
MistinDust
 
SiriusCon 2015 - Breathe Life into Your Designer!
SiriusCon 2015 - Breathe Life into Your Designer!SiriusCon 2015 - Breathe Life into Your Designer!
SiriusCon 2015 - Breathe Life into Your Designer!
melbats
 
xapp744-HIL-Zynq-7000
xapp744-HIL-Zynq-7000xapp744-HIL-Zynq-7000
xapp744-HIL-Zynq-7000
Umang Parekh
 

Similar a Using Alf with Cameo Simulation Toolkit - Part 1: Basics (20)

Using Alf with Cameo Simulation Toolkit - Part 2: Modeling
Using Alf with Cameo Simulation Toolkit - Part 2: ModelingUsing Alf with Cameo Simulation Toolkit - Part 2: Modeling
Using Alf with Cameo Simulation Toolkit - Part 2: Modeling
 
Hands On With the Alf Action Language: Making Executable Modeling Even Easier
Hands On With the Alf Action Language: Making Executable Modeling Even EasierHands On With the Alf Action Language: Making Executable Modeling Even Easier
Hands On With the Alf Action Language: Making Executable Modeling Even Easier
 
Standards-Based Executable UML: Today's Reality and Tomorrow's Promise
Standards-Based Executable UML: Today's Reality and Tomorrow's PromiseStandards-Based Executable UML: Today's Reality and Tomorrow's Promise
Standards-Based Executable UML: Today's Reality and Tomorrow's Promise
 
Elm Detroit 9/7/17 - Planting Seeds with Elm
Elm Detroit 9/7/17 - Planting Seeds with ElmElm Detroit 9/7/17 - Planting Seeds with Elm
Elm Detroit 9/7/17 - Planting Seeds with Elm
 
Unit 7 Java
Unit 7 JavaUnit 7 Java
Unit 7 Java
 
Vb introduction.
Vb introduction.Vb introduction.
Vb introduction.
 
SAP B1 integration framework scenario creation
SAP B1 integration framework scenario creationSAP B1 integration framework scenario creation
SAP B1 integration framework scenario creation
 
Simulation using model sim
Simulation using model simSimulation using model sim
Simulation using model sim
 
Sprouting into the world of Elm
Sprouting into the world of ElmSprouting into the world of Elm
Sprouting into the world of Elm
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)
 
Hacking the Kinect with GAFFTA Day 1
Hacking the Kinect with GAFFTA Day 1Hacking the Kinect with GAFFTA Day 1
Hacking the Kinect with GAFFTA Day 1
 
Java Applets
Java AppletsJava Applets
Java Applets
 
How to develop a Graphical User Interface (GUI) in Scilab
How to develop a Graphical User Interface (GUI) in ScilabHow to develop a Graphical User Interface (GUI) in Scilab
How to develop a Graphical User Interface (GUI) in Scilab
 
Lhy tutorial gui(1)
Lhy tutorial gui(1)Lhy tutorial gui(1)
Lhy tutorial gui(1)
 
SiriusCon 2015 - Breathe Life into Your Designer!
SiriusCon 2015 - Breathe Life into Your Designer!SiriusCon 2015 - Breathe Life into Your Designer!
SiriusCon 2015 - Breathe Life into Your Designer!
 
Android 3.1 - Portland Code Camp 2011
Android 3.1 - Portland Code Camp 2011Android 3.1 - Portland Code Camp 2011
Android 3.1 - Portland Code Camp 2011
 
Symbian OS - Memory Management
Symbian OS - Memory ManagementSymbian OS - Memory Management
Symbian OS - Memory Management
 
xapp744-HIL-Zynq-7000
xapp744-HIL-Zynq-7000xapp744-HIL-Zynq-7000
xapp744-HIL-Zynq-7000
 
The OptimJ Manual
The OptimJ ManualThe OptimJ Manual
The OptimJ Manual
 
ltspice basic practice.pptx
ltspice basic practice.pptxltspice basic practice.pptx
ltspice basic practice.pptx
 

Más de Ed Seidewitz

Executable UML Roadmap (as of September 2014)
Executable UML Roadmap (as of September 2014)Executable UML Roadmap (as of September 2014)
Executable UML Roadmap (as of September 2014)
Ed Seidewitz
 
Essence: A Common Ground for Flexible Methods
Essence: A Common Ground for Flexible MethodsEssence: A Common Ground for Flexible Methods
Essence: A Common Ground for Flexible Methods
Ed Seidewitz
 
Succeeding with Agile in the Federal Government: A Coach's Perspective
Succeeding with Agile in the Federal Government: A Coach's PerspectiveSucceeding with Agile in the Federal Government: A Coach's Perspective
Succeeding with Agile in the Federal Government: A Coach's Perspective
Ed Seidewitz
 
Models, Programs and Executable UML
Models, Programs and Executable UMLModels, Programs and Executable UML
Models, Programs and Executable UML
Ed Seidewitz
 
Architecting Your Enterprise
Architecting Your EnterpriseArchitecting Your Enterprise
Architecting Your Enterprise
Ed Seidewitz
 

Más de Ed Seidewitz (19)

SysML v2 - What's the big deal, anyway?
SysML v2 - What's the big deal, anyway?SysML v2 - What's the big deal, anyway?
SysML v2 - What's the big deal, anyway?
 
Introduction to the OMG Systems Modeling Language (SysML), Version 2
Introduction to the OMG Systems Modeling Language (SysML), Version 2Introduction to the OMG Systems Modeling Language (SysML), Version 2
Introduction to the OMG Systems Modeling Language (SysML), Version 2
 
The Very Model of a Modern Metamodeler
The Very Model of a Modern MetamodelerThe Very Model of a Modern Metamodeler
The Very Model of a Modern Metamodeler
 
SysML v2 and the Next Generation of Modeling Languages
SysML v2 and the Next Generation of Modeling LanguagesSysML v2 and the Next Generation of Modeling Languages
SysML v2 and the Next Generation of Modeling Languages
 
SysML v2 and MBSE: The next ten years
SysML v2 and MBSE: The next ten yearsSysML v2 and MBSE: The next ten years
SysML v2 and MBSE: The next ten years
 
Precise Semantics Standards at OMG: Executing on the Vision
Precise Semantics Standards at OMG: Executing on the VisionPrecise Semantics Standards at OMG: Executing on the Vision
Precise Semantics Standards at OMG: Executing on the Vision
 
Model Driven Architecture without Automation
Model Driven Architecture without AutomationModel Driven Architecture without Automation
Model Driven Architecture without Automation
 
UML: This Time We Mean It!
UML: This Time We Mean It!UML: This Time We Mean It!
UML: This Time We Mean It!
 
A Unified View of Modeling and Programming
A Unified View of Modeling and ProgrammingA Unified View of Modeling and Programming
A Unified View of Modeling and Programming
 
UML as a Programming Language
UML as a Programming LanguageUML as a Programming Language
UML as a Programming Language
 
Executable UML Roadmap (as of September 2014)
Executable UML Roadmap (as of September 2014)Executable UML Roadmap (as of September 2014)
Executable UML Roadmap (as of September 2014)
 
Essence: A Common Ground for Flexible Methods
Essence: A Common Ground for Flexible MethodsEssence: A Common Ground for Flexible Methods
Essence: A Common Ground for Flexible Methods
 
UML: Once More with Meaning
UML: Once More with MeaningUML: Once More with Meaning
UML: Once More with Meaning
 
Succeeding with Agile in the Federal Government: A Coach's Perspective
Succeeding with Agile in the Federal Government: A Coach's PerspectiveSucceeding with Agile in the Federal Government: A Coach's Perspective
Succeeding with Agile in the Federal Government: A Coach's Perspective
 
UML 2.5: Specification Simplification
UML 2.5: Specification SimplificationUML 2.5: Specification Simplification
UML 2.5: Specification Simplification
 
Models, Programs and Executable UML
Models, Programs and Executable UMLModels, Programs and Executable UML
Models, Programs and Executable UML
 
Architecting Your Enterprise
Architecting Your EnterpriseArchitecting Your Enterprise
Architecting Your Enterprise
 
Programming in UML: Why and How
Programming in UML: Why and HowProgramming in UML: Why and How
Programming in UML: Why and How
 
Executable UML and SysML Workshop
Executable UML and SysML WorkshopExecutable UML and SysML Workshop
Executable UML and SysML Workshop
 

Último

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 

Último (20)

%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 

Using Alf with Cameo Simulation Toolkit - Part 1: Basics

  • 1. No Magic World Symposium, Allen TX Ed Seidewitz Model Driven Solutions, Inc. ● http://www.modeldriven.com ed-s@modeldriven.com ● @seidewitz Copyright © 2018 Ed Seidewitz Using the Alf Action Language with Cameo Simulation Toolkit Part 1 – Basics
  • 2. Page 2 About me Ed Seidewitz Chief Technology Officier, Model Driven Solutions, Inc. ed-s@modeldriven.com ● @seidewitz • 30 years experience as a project manager, architect, developer and modeler • Involved with UML since version 0.8 • Developer of fUML and Alf Reference Implementations and MagicDraw Alf Plugin • Chair of the OMG fUML and Alf Revision Task Forces; member of the UML Revision Task Force Copyright © 2018 Ed Seidewitz
  • 3. Page 3 Goals Part 1 – Basics (Today) • Learn the basics of the Alf action language for Executable UML. • Use the Alf Plugin for MagicDraw. • Practice using Alf with Cameo Simulation Toolkit. Part 2 – Modeling (Wednesday) • Model simulations using the Alf action language. • Use Alf in class and state machine models in MagicDraw. • Create and run simulations using Alf with Cameo Simulation Toolkit. Copyright © 2018 Ed Seidewitz
  • 4. Page 4 Prerequisites (for Part 1) • Participant – Basic knowledge of class, activity and state machine modeling using MagicDraw – Some experience with model execution using Cameo Simulation Toolkit – General familiarity with programming/scripting (particularly in a language like C++, Java, JavaScript, etc.) • System (for hands-on exercises) – MagicDraw 18.5 – Cameo Simulation Toolkit 18.5sp3 – Alf plugin 18.5 Install MagicDraw, CST and Alf Plugin on line or from USB stick Copyright © 2018 Ed Seidewitz
  • 5. Page 5 5 Installing the Alf plugin Copyright © 2018 Ed Seidewitz Plugin documentation is available at: https://docs.nomagic.com/display/ALFP185/Alf+plugin Under Plugins (commercial), download / install the Alf plugin v18.5. Select Help ► Resource/Plugin Manager to open the Resource/ Plugin Manager window.  A new version will be available for the 19.0 release. Or click here to install from USB stick.
  • 6. Page 6 Background Copyright © 2018 Ed Seidewitz
  • 7. Page 7 Executable UML Executable UML is a (growing) subset of standard UML that can be used to define, in an executable, operational style, the structural and behavioral semantics of systems. • Foundational UML (structural and activity models) – http://www.omg.org/spec/FUML • Precise Semantics of UML Composite Structure (PSCS) – http://www.omg.org/spec/PSCS • Precise Semantics of UML State Machines (PSSM) – http://www.omg.org/spec/PSSM Copyright © 2018 Ed Seidewitz • Action Language for Foundational UML (Alf) – http://www.omg.org/spec/ALF A textual surface representation for UML modeling elements with the primary purpose of acting as the surface notation for specifying executable (fUML) behaviors within an overall graphical UML model. Alf Plugin
  • 8. Page 8 Why an action language? • Graphical notations are good for… Copyright © 2018 Ed Seidewitz Structural models High-level behavioral models
  • 9. Page 9 Why an action language? • …but not so good for detailed behavior Copyright © 2018 Ed Seidewitz Full executability requires complete specification of behavior and computation. This is often much more easy to specify using a textual notation.
  • 10. Page 10 Why not just use a scripting language? • Scripting language: No standard syntactic or semantic integration with UML • Alf: Full, standardized syntactic and semantic integration with UML Copyright © 2018 Ed Seidewitz this.lineItems->remove(item) this.totalAmount = Subtract(this.totalAmount, item.amount) ALH.removeValue(self, "lineItems", item); arguments = ALH.createList(); arguments.add(ALH.getValue(self, "totalAmount")); arguments.add(ALH.getValue(item, "amount”)); ALH.setValue(self, "totalAmount", ALH.callBehavior("Subtract", arguments)); Example using the MagicDraw- specific Action Language Helper API for JavaScript.
  • 11. Page 11 The basic idea: Alf maps to fUML Copyright © 2018 Ed Seidewitz activity DoSomething(in input: Integer, out output Integer): Integer { output = A(input); return B(); } Alf behavioral notation maps to fUML activity models. The semantics of the Alf notation is defined by its mapping to fUML
  • 12. Page 12 Hands On Hello World Copyright © 2018 Ed Seidewitz
  • 13. Page 13 Create an Alf project Copyright © 2018 Ed Seidewitz In the Alf folder, select the Alf template.  The Alf template automatically loads the Alf Library model and sets Alf as the default language for opaque behaviors, actions and expressions. Under Other, select Project from Template. Select File ► New Project to open the project creation window. Create a Hello World project.
  • 14. Page 14 Create the Hello World activity Copyright © 2018 Ed Seidewitz Create a new Activity. Enter the Alf code in the Alf editor window. When the code is correct, click Save.  If the Alf editor window is closed, you can open it using Window ► Alf.
  • 15. Page 15 Executing the activity Copyright © 2018 Ed Seidewitz Right click on the Activity and select Simulation ► Run. Set Animation Speed to the highest level… …and click here to run. Output appears in the console pane.
  • 16. Page 16 Basic Concepts Copyright © 2018 Ed Seidewitz
  • 17. Page 17 Assignment as data flow Copyright © 2018 Ed Seidewitz a = +1; b = -a; a = A(a) + B(b); Local names map to forked object flows. Subexpressions are evaluated concurrently. A re-assigned local name actually maps to a new flow.  The literal “1” has type Natural. The expression “+1” has type Integer. The expression “A(a) + B(b)” has type Integer, which is not compatible with Natural. The local name a implicitly gets the type Integer. Statements map to structured activity nodes with control flows to enforce sequential execution. a = 1; a = A(a); ✗ type conformance
  • 18. Page 18 Using Alf for behaviors Copyright © 2018 Ed Seidewitz lineItem = new LineItem(product, quantity); this.lineItems->add(lineItem); this.totalAmount = this.totalAmount + lineItem.amount; Method of an operation this.lineItems = checkOut.items; Customer_Order.createLink(checkOut.customer, this); this.datePlace = CurrentDate(); this.totalAmount = lineItems.amount->reduce '+'; this.SubmitCharge(checkOut.card); Behavior on a state machine battFrac = battCond / this.maxBattLevel; gThrottle = Max(accelPos * (1-battFrac), this.maxGThrottle); eThrottle = Max(accelPos * battFrac, this.maxEThrottle); Body of an action
  • 19. Page 19 Using Alf for expressions Copyright © 2018 Ed Seidewitz Activity Edge Guards State Machine Transition Guards
  • 20. Page 20 Hands On Stopwatch Copyright © 2018 Ed Seidewitz
  • 21. Page 21 Open the StopWatch sample project Copyright © 2018 Ed Seidewitz … Click Samples on the Welcome Screen Under Simulation, choose the StopWatch sample project.  Select File ► Save Project As… to save a local copy of the project before continuing.
  • 22. Page 22 Setup the project for Alf Copyright © 2018 Ed Seidewitz Remove the existing Project Usage for fUML_Library.  This part will not be necessary in v19.0. Select Tools ► Alf ► Load Library to load the Alf Library.
  • 23. Page 23 Open the StopWatch state machine Copyright © 2018 Ed Seidewitz
  • 24. Page 24 Replace the ready state behavior Copyright © 2018 Ed Seidewitz Open the Specification window for the ready state. Under Entry, change the Behavior Type to Opaque Behavior.  Be sure to select the ready state as a whole, not just the line for the entry behavior.
  • 25. Page 25 Replace the reset timer activity with Alf code Copyright © 2018 Ed Seidewitz  Be sure to click on the text for the entry behavior, not the entire state. Click on the entry behavior… replaced by  The use of the prefix this is required to access an attribute value in Alf. …and enter the code into the Alf editor window.
  • 26. Page 26 Show the Alf code on the state machine diagram Copyright © 2018 Ed Seidewitz Open the Symbol Properties window for the ready state. Set the Opaque Behavior Display Mode property to Body.
  • 27. Page 27 Coming in v19.0! Copyright © 2018 Ed Seidewitz Syntax-aware editing of Alf code in opaque body editors.
  • 28. Page 28 Replace the Increase time activity with Alf code Copyright © 2018 Ed Seidewitz replaced by  The ++ operator increments its argument.
  • 29. Page 29 Executing the StopWatch model Copyright © 2018 Ed Seidewitz Right click on the StopWatch class and select Simulation ► Run. Start the simulation, then trigger the start signal. Output is displayed in the console tab. The current state machine configuration is animated.
  • 30. Page 30 Sequences Copyright © 2018 Ed Seidewitz
  • 31. Page 31 Sequences Copyright © 2018 Ed Seidewitz activity GetReadings(in sensors: Sensor[*]): Integer[*] { readings = sensors->collect sensor (sensor.reading); return readings; } The input parameter has an unordered set of values (by default). Object flows always carry ordered sequences of values. Values are handled one by one within the expansion region. The read actions happen concurrently. The result is a sequence ordered respective to the input sequence. The return parameter gets an unordered set of values (by default).  The Alf on the left could be written more simply as: return sensors.reading; The local name reading implicitly gets the type Integer and the multiplicity [0..*].  Arbitrary sequences cannot be assigned to local names with multiplicity [0..1]. reading = -1; readings = reading; reading = readings; Implicitly gets the multiplicity [0..1] A single value is really just a sequence of length 1. ✗ multiplicity conformance
  • 32. Page 32 Null as the empty sequence Copyright © 2018 Ed Seidewitz A LiteralNull is intended to be used to explicitly model the lack of a value. In the context of a MultiplicityElement with a multiplicity lower bound of 0, this corresponds to the empty set (i.e., a set of no values). It is equivalent to specifying no values for the Element. null = any [ ] { } From the UML 2.5 specification (clause 8.2.3): The Alf interpretation: null is the (untyped) empty sequence sensors = null; sensors.readings; WriteLine(null); WriteLine(name ?? "no name"); “null” can be assigned to any target with a multiplicity lower bound of 0. This is not an error. It is equivalent to sensors->collect sensor (sensor.reading); which evaluates to “null”.  An argument for a parameter of multiplicity 1..1 cannot be null. ✗ multiplicity conformance A null-coalescing expression can be used to provide a non-null “default value”.
  • 33. Page 33 Hands On Reversing a Sequence Copyright © 2018 Ed Seidewitz
  • 34. Page 34 Create the Reverse project Copyright © 2018 Ed Seidewitz Create a new project using the Alf template, as before.
  • 35. Page 35 Create the Reverse activity diagram Copyright © 2018 Ed Seidewitz Create a new Activity Diagram.
  • 36. Page 36 Add activity parameter nodes Copyright © 2018 Ed Seidewitz Leave the parameters untyped.
  • 37. Page 37 Add Alf code in opaque actions Copyright © 2018 Ed Seidewitz Click on the opaque action to enter code in the Alf editor window. The CompiledRepresentation stereotype records the executable activity compiled from the code. Click on the opaque action and select Symbol Properties to turn off stereotype display. Click here to make this the default. Select Expert mode, if necessary.  If you are using SysML, be careful to us the UML Boolean type, not the SysML Boolean type.
  • 38. Page 38 Fill in the activity model Copyright © 2018 Ed Seidewitz Using an expression here is a shorthand for the statement result = seq->isEmpty(); Alf in an Opaque Action can access pins as local names.  Guards must be entered as Literal Specifications.
  • 39. Page 39 Coming in v19.0! Copyright © 2018 Ed Seidewitz Alf activity edge guards using decision input values.
  • 40. Page 40 Write a TestReverse activity Copyright © 2018 Ed Seidewitz Iterative for loop Sequence construction expression Cast expression Null-coalescing expression  The cast expression is required because the result of Reverse is untyped. The null-coalescing expression is required because a cast can result in null.
  • 41. Page 41 Testing the Reverse activity Copyright © 2018 Ed Seidewitz Right click on TestReverse and select Simulation ► Run. Click here to execute. Make sure the slider is all the way to the right! This is the expected result.
  • 42. Page 42 Bonus: Writing Reverse entirely in Alf Copyright © 2018 Ed Seidewitz activity RecursiveReverse(in seq : any[*] sequence) : any[*] sequence { return seq->isEmpty()? null: seq->excludeAt(1)->RecursiveReverse()->including(seq[1]); } activity IterativeReverse(in seq : any[*] sequence) : any[*] sequence { result = null; n = seq->size(); for (i in 0..n-1) { result->add(seq[n-i]); } return result; } The arrow notation (sequence operation expression) can be used with any behavior that has a sequence as its first parameter. Conditional-test expression Remember that null is the empty sequence. add is an “in place” collection function.

Notas del editor

  1. 5