Cameo Simulation Toolkit UserGuide
Cameo Simulation Toolkit UserGuide
Cameo Simulation Toolkit UserGuide
Refresh2
User Guide
Why Simulation? 9
Business Benefits 9
Installation and licensing 10
System requirements 10
Modeling Tools* 10
FLEXnet License Server 12
Basic concepts 12
Plugin installation 13
Plugin licensing 15
Uninstalling plugins and deactivating licenses 16
Updating plugins 16
User Guide 16
Getting started 17
Introduction to Cameo Simulation Toolkit 17
Key features 18
Simulation project template 19
Model simulation 21
Elements simulation 22
Simulating a Simulation Configuration 42
Subset property 44
Simulation Configuration and UI modeling 46
Project options 47
SimulationConfig stereotype 49
Simulation log 59
Simulation time and simulation clock 61
Automatic start of active objects 69
UI modeling diagram simulation 70
ImageSwitcher and ActiveImage 75
Tutorial 570
Stopwatch model sample 570
Stopwatch structure 571
Stopwatch Behavior 571
Creating an executable stopwatch model 571
Executing the stopwatch model 612
Creating User Interface mockups for the stopwatch model 635
Using simulation command line and showing test results through
Jenkins 644
Preparing a simulation project and Configs in MagicDraw 645
Running a project through simulate command line 646
Creating a JUnit test case and configuration file 647
Configuring Jenkins for the Automated testing 647
Simulate command arguments and parameters 649
Simulate command arguments with projects in Teamwork Cloud 652
Property file sample: Project-Config1.properties 653
JUnit test sample: TestSimulationCommandLine.java 654
Ant configuration file sample: run_junit.xml 656
Analysis pattern 657
Rollup Pattern simulation 657
Monte Carlo simulation 660
Trade study analysis 666
Integrating widgets for simulation 677
The jQuery Knob widget. 678
Why Simulation?
The purpose of a simulation is to gain system understanding without manipulating the real system,
either because it is not yet defined or available, or because it cannot be exercised directly due to cost,
time, resources or risk constraints. Simulation is typically performed on a model of the system.
With the Cameo Simulation Toolkit, users can test how the system reacts to user interaction or
predefined testing data and execution scenarios.
Business Benefits
Users will find that one of the key business benefits of the Cameo Simulation Toolkit is cost efficiency.
Employing Cameo Simulation Toolkit will assist enterprises in significantly reducing project costs,
allowing users to identify design errors before the actual production of components.
1 https://docs.nomagic.com/display/CST2021xR1/Cameo+Simulation+Toolkit+Documentation
2 https://docs.nomagic.com/display/CST2021x/Cameo+Simulation+Toolkit+Documentation
3 https://docs.nomagic.com/display/CST190SP4/Cameo+Simulation+Toolkit+Documentation
4 https://docs.nomagic.com/display/CST190SP3/Cameo+Simulation+Toolkit+Documentation
5 https://docs.nomagic.com/display/CST190SP2/Cameo+Simulation+Toolkit+Documentation
6 https://docs.nomagic.com/display/CST190SP1/Cameo+Simulation+Toolkit+Documentation
7 https://docs.nomagic.com/display/CST190/Cameo+Simulation+Toolkit+Documentation
In this section, you will learn about the system requirements, basic concepts, installation and licensing
procedures, and how to uninstall and update the plugin.
For more information, see No Magic product installation and licensing(see page 10).
Related pages
System requirements
Modeling Tools*
Resource Recommended
RAM 16GB
1
the project elements count is different due to the profiling data storing metamodel
optimized in 2021x (decrease by 40-80% in SysML and UAF projects).
2
these memory requirements are indicative and may vary by project specifics.
The operations that require more memory (1, 2, and 3.5 million of 2021x project elements
respectively):
Disk space The recommended disk space for installation and configuration files is 3GB or more
depending on used plugins, project type (local or server), and project size. In addition to
this, large server projects require extra disk space for configuration files:
Note: Element History and Content History features usage requires significantly more disk
space due to intensive caching at the client-side.
Depending on the feature usage scenario (e.g., retrieving content history from old/distant
project versions multiple times), the disk space might increase by up to 100GB.
* Magic Software Architect, Magic Cyber Systems Engineer, Magic Systems of Systems Architect,
MagicDraw, Cameo Systems Modeler, Cameo Enterprise Architecture
Earlier versions
Windows XP and earlier versions are not supported.
Mac OS 10.6 Snow Leopard and earlier versions are not supported.
Basic concepts
On this page
8 https://docs.nomagic.com/display/NMDOC/Java+version+support
9 https://docs.nomagic.com/display/NMDOC/Downloading+installation+files
The maximum license borrowing period is 2 months. If you would like to limit the
maximum borrowing period, please contact your sales representative.
The files where your defined settings and environment options are stored.
Configuration When upgrading your software, you can choose one of the following:
files
• If you want to import the environment options from an earlier modeling
tool or server version, select the location and click Import.
• If you are installing the software for the first time and/or do not want to
use earlier environment options, click Use Default.
The floating license allows you to install and use the same license on multiple
machines. The FlexNet license server is used to manage floating licenses.
Floating license
A combination of 12 numbers and letters (also known as the MAC Address or Physical
Address), which identifies the network card of a machine. It is used to tie the license
Host ID/Target ID to a particular machine.
Seat (Nodelock). The license of a modeling tool dedicated to one working place.
License type Floating (Shareable). Allows you to install and use the same license of a modeling
tool on multiple machines.
Please note, the license type of a modeling tool and a plugin used by this
tool must be the same.
Plugin installation
• Install a plugin bundle (.rdzip) that comes with a modeling tool directly via the Resource/Plugin
Manager dialog.
• Install an individually purchased archived plugin file (.zip) via the Resource/Plugin
Manager dialog.
• Install a plugin manually
• Obtain and install a plugin from a web server
You can extract the .rdzip file and then add selected plugins individually(see page 14).
To install an individual plugin from an archive file (.zip) via the Resource/Plugin Manager dialog
1. Extract an archived plugin file (.zip) file to the same directory where your modeling tool is
installed.
2. Start the modeling tool. The plugin is applied to your modeling tool.
You can also obtain the needed resources from a web server if you do not have the .rdzip file but have
been provided with an URL by your license manager.
To specify the server where the resources and their descriptor file are located
4. Click OK.
The resources from the selected location are listed in the Resource/Plugin Manager.
Getting help
If you run into any installation related problems, try the following:
checking the FAQ section11 for known problems
checking the No Magic Community forum12
contacting customer support13
14
Related pages
18
Plugin licensing
10 https://docs.nomagic.com/display/MD2021x/Resource+Manager
11 http://www.nomagic.com/support/faq.html
12 https://community.nomagic.com/
13 https://docs.nomagic.com/display/NMDOC/Support
14 https://docs.nomagic.com/display/NMDOC/Installing+plugins
15 https://docs.nomagic.com/display/NMDOC/Modeling+tools+and+plugins+licensing
16 https://docs.nomagic.com/display/NMDOC/FlexNet+license+server+installation+and+licensing
17 https://docs.nomagic.com/display/NMDOC/Installation+and+licensing
18 https://docs.nomagic.com/display/NMDOC/Installing+plugins
On this page
Updating plugins
On this page
User Guide
Welcome! This user guide will walk you through the basics of using Cameo Simulation Toolkit.
Use the search box to find a specific topic or select one from the list below:
Getting started
Cameo Simulation Toolkit is a MagicDraw plugin, which provides a unique set of tools supporting the
standardized construction, verification, and simulation of computational complete models based on a
foundational subset of the UML. It also enables Activity, State Machine and parametric simulation
(execution), animation, and debugging in UML and SysML models, including profiles, samples, and key
features(see page 18).
No Magic is the first in the industry to provide customers with an easy-to-use, standard-based
executable UML solution that integrates the semantics of different UML behaviors. The purpose of this
Getting Started section is to provide you with an overview of the plugin and a brief explanation of how
exactly this plugin works.
Related pages
Cameo Simulation Toolkit contains the Simulation Framework plugin that provides the basic GUI to
manage the runtime of any kind of executable models and integrations with any simulation engines.
• Simulation Window
• Toolbars and Debugger pane: to control simulation or a model simulation.
• Simulation Console: to simulate log outputs and command lines for active engines.
• Sessions pane: to select particular sessions of simulation.
• Variables pane: to monitor the runtime values of each simulation session.
• Breakpoints pane
• Trigger options
• Pluggable Simulation Engines
• Animation simulation
• Model debugger
• Pluggable Events and Data Sources
• Pluggable Mockup Panels
• Model-driven Simulation Configurations
• Pluggable Parametric Evaluator and Action Languages
For the version compatibility of the plugin and modeling tools, please refer to the compatibility of
Cameo Simulation Toolkit plugin19 page.
After installing MagicDraw and the Cameo Simulation Toolkit plugin, you can find samples of Cameo
Simulation Toolkit projects in the Samples directory under the Simulation section on the Welcome
page (go to Help from the main menu > Show Welcome Screen).
You can also find the offline user manual by going to Help on the main menu > Other Documentation
> Cameo Simulation Toolkit User Guide.
Related pages
Key features
Cameo Simulation Toolkit is capable of running your UML or SysML models. The key features of Cameo
Simulation Toolkit are as follows
19 https://www.nomagic.com/support/compatibility#Cameo%20Simulation%20Toolkit%20plugin
Related page
Simulation Project is a useful template that consists of fundamental diagrams and elements basically
required for the user to work on a simulation project. The template significantly reduces time spent on
working on the preparation of making simulation from scratch. The template is available in
the Simulation project category in the New Project dialog.
To open a template
20 https://docs.nomagic.com/display/SYSMLP2021xR2/SysML+Parametric+Diagram
Related pages
• Class diagram21
• Package diagram22
• State Machine diagram23
• Simulation Configuration and UI modeling(see page 46)
Model simulation
On this page
21 https://docs.nomagic.com/display/MD2021xR2/Class+diagram
22 https://docs.nomagic.com/display/MD2021xR2/Package+diagram
23 https://docs.nomagic.com/display/MD2021xR2/State+Machine+diagram
The following table shows a list of simulation engines and their supported elements that come with
Cameo Simulation Toolkit
Activity • Activities.
engine • Activity diagrams.
• Classes whose classifier behavior is an Activity.
• InstanceSpecifications of a class whose classifier behavior is an Activity.
Interaction • Interactions.
engine • Sequence diagrams.
• Classes whose classifier behavior is an Interaction.
• InstanceSpecification of a Class whose classifier behavior is an Interaction.
Parametric • Blocks that contain properties that are bound to other properties (or constraint
engine parameters) with connected binding connectors.
• SysML Parametric diagrams.
• InstanceSpecifications of a Block containing properties that are bound to other
properties (or constraint parameters) with connected binding connectors.
• Run the elements that are supported by the engines.(see page 22)
• Create a Simulation Configuration(see page 42) including setting a target element to be simulated
by the Simulation Configuration and run the model from the Simulation Configuration.
Related pages
Elements simulation
You can run a model simulation through the shortcut menu and the diagram toolbar.
Behavior
On this page
You can simulate a Behavior (Activity, State-Machine, or Interaction) either with or without its context
Classifier by simply right-clicking the Behavior in the browser or on a diagram and select
either Simulation > Run or Simulation > Run with Context. Here, the classifier is the context of the
Behavior.
You can also set the Behavior as a target of Simulation Configuration (See Simulating a Simulation
Configuration(see page 42) for more details) as follows
• Open the diagram and click Start on the Simulation window toolbar
• Right-click the diagram and select Simulation > Run.
The simulation of the Behavior, which is the context of the diagram, will run.
Activity
Whenever you run an Activity, Cameo Simulation Toolkit will create a new session for the Activity
simulation. If you run the Activity with its context, it will create another session under the session of the
context object in the Sessions pane. If you click it, the object of the Activity will appear in
the Variables pane. If there is an Activity diagram whose context is the simulating Activity, animation
Note
When you use a read self action in an Activity, normally it returns an object, which is the
context of the Activity. However, if the context object does not exist, it will return an Activity
execution, which is the Activity's object.
State Machine
Similar to the Activity simulation, when you run a State Machine, Cameo Simulation Toolkit will create a
new session for a State Machine simulation. If there is a State Machine diagram that represents the
State Machine, animation effect on the diagram will begin playing at the start of non-silent mode
simulation.
Related pages
Interaction
If you run an Interaction, Cameo Simulation Toolkit will simulate it and play animation effect on a
Sequence diagram, which represents the Interaction.
Related pages
Class
On this page
24 https://docs.nomagic.com/download/attachments/82761686/Calculator.mdzip?
api=v2&modificationDate=1510908736612&version=1
25 https://docs.nomagic.com/download/attachments/82761658/Figure_0007.png?
api=v2&modificationDate=1496891973503&version=1
Note
• The initialization through an instance replaces the default value in the Array of the Block.
• Any missing values in Array slots are replaced by default values from the Array of the
Block.
Note
If there are multiple implementation Classes, Simulation Toolkit will randomly choose one.
Diagram
You can use the shortcut menu or the diagram toolbar to simulate a diagram. Cameo Simulation Toolkit
will simulate the element, which is the context of the selected diagram, the same way it simulates a
Behavior or a Class depending on the element which is the context of diagram. You can also specify the
diagram as a target of a Simulation Configuration (see Simulating a Simulation Configuration(see page
42) for more details).
• Right-click a diagram and select either Simulation > Run or Simulation > Run with Context (if
the context of the diagram is a Behavior).
26 https://docs.nomagic.com/download/attachments/17678500/Figure_0007.png?
api=v2&modificationDate=1496891973503&version=1
Instance Specification
You can also run an InstanceSpecification. Cameo Simulation Toolkit will initialize an object from the
Classifier of the Instance Specification. The structure values of the object will be loaded from the slot of
the Instance Specification rather than from the default value of the properties of the Classifier.
• Right-click an Instance Specification and select either Simulation > Run or Simulation > Run
with Context if the classifier of the Instance Specification is a Behavior. You can also specify an
Instance Specification as a target of Simulation Configuration.
If the Behavior, the Classifier of the Instance Specification, has a SysML Adjunct property whose primary
is a parameter of the Behavior (See Adjunct Property(see page 482)), Cameo Simulation Toolkit will set the
value of the parameter with the value of the Adjunct property. Therefore, you can use a slot value of
the Adjunct property to set the initial value of the parameter.
Table
On this page
Cameo Simulation Toolkit provides the means to simulate a set of elements iteratively using a Generic
Table or an Instance Table. Each element in the table will be simulated one-by-one from the first to the
last row.
Note
For a model that has Behaviors (Classifier Behavior and/or Part Property with Behaviors), see
the autoStart tag in SimulationConfig(see page 49).
SimulationConfigs listed in the Simulation toolbar of the Instance table allow running an instance with full
setup, e.g., clock, plots, or UI.
Cameo Simulation Toolkit provides a Simulation Configuration. It is an element that you can use to run
an element with options that you can customize. You can see the details of such options in the next
chapter. You can run a Simulation Configuration through either the context menu or the main toolbar.
• In the main toolbar, click the Terminate button next to the Simulation Configuration name.
Related page
Subset property
Cameo Simulation Toolkit supports and includes Subset properties in a simulation. It initializes subsets
at the beginning of simulation and also updates their values during simulation. The following figure
demonstrates a model with subsets
You can update or add a value in the subsetting or subsetted properties. Removing or changing a value
in the set of values of a subsetting property will cause the value to disappear or will cause a change in
Sample model
The model used in the figures on this page is the SpacecraftMassRollup sample model that comes
with your modeling tool.
• Download SpacecraftMassRollup.mdzip27.
• Find it in the modeling tool <modeling tool installation
directory>\samples\simulation\SpacecraftMassRollup.mdzip.
27 https://docs.nomagic.com/download/attachments/82761697/SpacecraftMassRollup.mdzip?
api=v2&modificationDate=1505276195300&version=1
Project options
You can customize a simulation project, e.g., animation, simulation framework, and simulation engines
through project options. When you save the project, those project options will also be saved. In
addition, you can restore those options to default values with the Reset to Defaults button.
Note
The Options > Project command will be available only if one or more projects are open.
SimulationConfig stereotype
On this page
1. Right-click a Package in the Containment tree in a simulation project and select Create Diagram
> Simulation Configuration Diagram, which is the SimulationProfile stereotype applied.
2. Right-click the SimulationProfile [SimulationProfile.mdzip] stereotype in the Containment tree and
select Config > SimulationConfig [Class] and drag the Class to the diagram pane.
UI A user interface for configuration mockups that will start with a model simulation.
silent If the value is true, simulation will run without animation or idle time.
Note
You can drag any element that can be simulated to a Simulation Configuration to
set executionTarget for the dragged element.
excludedElement A list of elements which will be excluded and not instantiated if not ready to be used or not
needed, e.g., Class, Package, Use Case, Actor, Behavior, Connector, Port, and State. See
also in Instantiation scope with excluded elements(see page 57).
Note
The following elements will not be saved
• InstanceTable without the Classifier set.
• Nested instances inside slots.
• If the resultLocation is not specified, the simulation results will not be saved
even though the simulationTarget is the InstanceSpecification37.
enginesPriority Simulation engines that can be used to simulate a model ordered by priority. The first
engine on the list has the highest priority. If the Simulation Configuration does not have a
tagged value for this tag definition, Cameo Simulation Toolkit will use the values that are
defined in the registered Simulation Engine Priority in the Project Options(see page 47)
dialog.
autoStart If true, a model simulation starts running automatically once it has been initialized.
Otherwise, you must click the Start button in the Simulation pane to run the simulation.
Note
For Monte Carlo Simulation(see page 660) and Table Simulation(see page 40), the
conditions are as follows:
28 https://docs.nomagic.com/display/MD2021xR2/Package
29 https://docs.nomagic.com/display/MD2021xR2/Instance+Specification
30 https://docs.nomagic.com/display/MD2021xR2/Instance+table
31 https://docs.nomagic.com/display/MD2021xR2/Instance+Specification
32 https://docs.nomagic.com/display/MD2021xR2/Package
33 https://docs.nomagic.com/display/MD2021xR2/Instance+Specification
34 https://docs.nomagic.com/display/MD2021xR2/Instance+table
35 https://docs.nomagic.com/display/MD2021xR2/Instance+table
36 https://docs.nomagic.com/display/MD2021xR2/Instance+table
37 https://docs.nomagic.com/display/MD2021xR2/Instance+Specification
clock ratio A ratio between a simulation clock and a real-time clock (1:10). For example, if the clock
ratio is 10, it means that one second on the simulation clock is equal to 10 seconds on the
real-time clock.
autostartActiveO If the value is true, the runtime objects whose classifier is active will start their behavior
bjects automatically in an asynchronous mode. Otherwise, their behavior will start using a
startObjectBehaviorAction.
executionListene A list of execution listeners that will receive events from a model simulation. An execution
rs listener can be a SequenceDiagramGeneratorConfig.
decimalPlaces Decimal places of all displayed numerical values in a model simulation, for example, in
the Variables pane, Tooltip, and the SimulationConsole pane. Their values must be
integers. If the precision of displayed numerical values is greater than or equal to 10% of
the absolute value, the numerical values will be displayed in exponential form.
fireValueChangeE If this value is true, a parametric simulation will be repeated immediately whenever the
vent value of any structural feature changes. Repeating simulation will give an impact on both
values carried over by binding connectors and specified in a constraint.
timeValue A property that will be used in a model-based clock. If the tagged value is specified, the
run-time value specified by the property will be used as the simulation time.
timeUnit A unit of a runtime value that specifies the simulation time. If the tagged value is
unspecified, the millisecond will be used by default.
constraintFailure A flag that indicates a simulation will pause at the constraint element where the failure
AsBreakpoint occurs.
rememberFailure If true, the failure status will be remembered until the termination, and the first failure
Status status will be recorded with its timestamp as fail, even though it passes at the end.
durationSimulati Specifies a duration mode of simulation in min, max, average, or random. Cameo
onMode Simulation Toolkit uses the duration mode to calculate the duration of an Action
simulation to which a duration constraint is applied.
treatAllClassifier This option (true by default) runs all Behaviors, including the ones in the subsystems.
sAsActive Even though the isActive property is false, if TreatAllClassifiersAsActive is true, Cameo
Simulation Toolkit will run all of the Behaviors of non-active Classifiers.
initializeReferenc If true, references will be initialized by creating new objects, instead of referencing to
es existing parts of the system. See also in Initialize References property(see page 54).
stepSize Increases as simulation time does (in real numbers or decimal places).
numberOfSteps Specifies the number of steps through which simulation will run.
numberOfRuns A number of runs of a particular configuration, especially for the sample size in Monte
Carlo simulation. The value must be greater than or equal to 1.
timeVariableNam This property returns time from the simulation clock (the default value is "simtime"). It
e returns the time on the simulation clock.
stepDelay Specifies how long the delay will be, if any, for each step.
runForksInParall If the value is true or undefined, all outgoing edges from the fork will run in parallel.
el
cloneReferences If true, creates new instances for all objects recursively. Otherwise, it creates instances
only for the first level and others remain in their original locations (the default is false).
startWebServer If true, starts a web server for a remote web-based UI mockup. Note that the HTML UI
must be generated first using the Generate HTML button in the UI diagram. After starting
SimulationConfig, the web server URL will appear in the Simulation Console window.
solveAfterInitiali If true, automatically starts initial solving. If false, manual start is required via Refresh in
zation the Variables pane, or press Start (F8).
addControlPanel If the value is true, adds the simulation control panel into the exported HTML UI.
animationSpeed Specifies the animation speed of a particular configuration in percentage. The default
value is 95, but you can enter your preferred value from 1 to 100.
Note
The naming of the newly created instance will not follow MagicDraw instance
naming criteria.
If false (by default), MagicDraw instance naming will be used instead, and the timestamp
will not be recorded and appended to the instance name.
38 https://docs.nomagic.com/display/SYSMLP185/_sample+models?
preview=%2F17664205%2F17664212%2FCoffeeMachine.mdzip
Note
Initialize References appears if you open the Specification window in the All or Expert
Properties mode.
The following are two types of references that you can initialize using the Initialize References option in
SimulationConfig
Part property, CPU2, is not instantiated in the Variables pane, since it has been
set in excludedElement.
For nested Part properties, excludedElement can be set through «SelectPropertiesConfig» as shown in
the figure below. You can find the «SelectPropertiesConfig» control in the Simulation Configuration
Diagram toolbar.
Simulation log
Cameo Simulation Toolkit provides a simulation log, which is an element to record all event
occurrences during simulation of a Simulation Configuration. It is a Class element applied with a
«SimulationLog» stereotype. The «SimulationLog» stereotype comes with tag definitions as the options
for selecting information that you want to record.
Simulation log.
The tag definitions of the «SimulationLog» stereotype are as follows
• recordedValues
To specify the property whose value will be recorded to the simulation log.
• recordSignals
To specify whether the simulation log will record signals that are sent during simulation. If the
value is true, all of the sent signals will be recorded.
• recordActivation
To specify whether the simulation log will record elements that are activated during simulation. If
the value is true, all of the activated elements will be recorded.
• recordCalls
To specify whether the simulation log will record Operations/Behaviors that are called during
simulation. If the value is true, all of the called Operations/Behaviors will be recorded.
• recordConstraintFailures
To specify whether the simulation log will record elements whose runtime values or objects fail
the constraints applied on them. If the value is true, the elements that cause constraint failures
will be recorded.
You can create a new simulation log element and set it as a tagged value of the log tag definition of the
Simulation Configuration as shown in the following figure
39 https://docs.nomagic.com/display/MD2021xR2/Instance+table
• The source of various customized reports and analysis using the MagicDraw validation
mechanism (as both are model-based).
• The capability to import simulation data into any other UML compliant tools.
You can record multiple simulation sessions or test results in the same «SimulationLog» element. The
session's start time can be seen as an attribute's name. You can also record the following runtime data
(see the following figure)
Signal Instance
(when recordSignals = true) under the "Signal Instances" node: timestamp (that is the relative
occurrence time in milliseconds: '0' when the simulation starts), signal type, and target (see the
following figure).
Runtime Value
(when the recordedValues attribute has at least one Property selected) under the "Value Changes"
node: timestamp and the Property and value(s) of a selected Property.
Constraint Failure
(when recordedConstraintFailures = true) under the "Constraint Failures" node: timestamp, element,
target, and value(s).
When you simulate a model related to time (for example, a transition with a time trigger), Cameo
Simulation Toolkit will obtain simulation time from a simulation clock. The simulation time is the
amount of time spent on simulating a model. Cameo Simulation Toolkit also uses the simulation time in
a timestamp of a signal instance in the SimulationLog (see Simulation log(see page 59)), in a time series
chart (see Time series chart(see page 87)), and on messages of a generated Sequence diagram.
Note
Nanosecond and microsecond are supported only in the internal simulation clock and model-
based clock.
You can open the Simulation Clock dialog to see the internal simulation clock in real time by right-
clicking within the Simulation Sessions(see page 197) pane and selecting Show Simulation Clock.
Note
The Step button in the Simulation Clock dialog is available only for the internal simulation
clock to allow manually increasing and ticking the internal simulation clock.
Built-in clock
The built-in clock generates simulation time continuously during a model simulation. You can use the
clock ratio option in Cameo Simulation Toolkit to increase or decrease the amount of simulation time.
The clock ratio specifies the ratio between actual time and simulation time in the same interval. You can
set a ratio of the built-in clock for model simulation. The value you enter for the clock ratio tag
definition of a Simulation Config allows you to scale a ratio up or down (see the following figure). For
further information about stereotypes of the simulation configuration, see SimulationConfig
stereotype(see page 49).
Note
• The current version of Cameo Simulation Toolkit allows you to pause or resume the
built-in clock.
• When you pause running simulation by either clicking the Suspend button or using
breakpoints, Cameo Simulation Toolkit will stop the built-in clock operation and all
running sessions temporarily. You can continue all of the activities by clicking
the Resume button.
Related pages
On this page
The internal simulation clock in Cameo Simulation Toolkit allows you to use a new simulation clock that
can increase its simulation time based on time Events and duration in a model. The following
properties in the Timing group in the Simulation Configuration(see page 49) Specification window enable
you to specify necessary options in the internal simulation clock
• Start Time
An integer value applies for starting the simulation clock.
• Step Size
A decimal value applies for increasing the simulation time. This value, as 1.0 by default unless
specified, is used together with Start Time.
• Step Delay
A decimal value applies for delaying each time step in the simulation clock.
• End Time
An integer value applies for stopping the simulation clock.
• Number Of Steps
An integer value together with Start Time and End Time, to calculate Step Size (if not specified)
for the simulation clock.
Note
To enable the internal simulation clock, startTime must be specified as the Trigger, along
with stepSize, which is 1.0 by default unless specified. The FlashingLight.mdzip40,
StopWatch.mdzip41, CruiseControl.mdzip42, and CoffeeMachine.mdzip43 built-in sample
projects apply the internal simulation clock.
40 https://docs.nomagic.com/download/attachments/20851796/FlashingLight.mdzip?
api=v2&modificationDate=1505276946588&version=1
41 https://docs.nomagic.com/download/attachments/82761953/StopWatch.mdzip?
api=v2&modificationDate=1508481727076&version=1
42 https://docs.nomagic.com/download/attachments/82761953/CruiseControl.mdzip?
api=v2&modificationDate=1508481644230&version=1
43 https://docs.nomagic.com/download/attachments/82761953/CoffeeMachine.mdzip?
api=v2&modificationDate=1508484232678&version=1
From the following State Machine diagram, s1 (State 1) takes two seconds to go to s2 (State 2), and s2
takes three seconds to go to s1 again. You can see the simulation time in the following Console log.
Model-based clock
Using the model-based clock requires you to specify the property, whose value will be used as the
simulation time, as the value of a timeValue tag definition of a Simulation Config. You can specify the
unit value for the simulation time through the timeUnit tag definition of the Simulation Configuration.
If the timeUnit is unspecified, the millisecond will be used by default.
• There should be only one object of a classifier whose property is specified as timeValue. In the
preceding figure, the property time of the block Clock has been set as the timeValue of
the System Execution, which is a Simulation Config for simulating the System block. There
should be only one Clock object in each simulation.
Simulation Configuration.
If the value of autoStartActiveObjects is false, or if the Classes or blocks are not active Classes, you
have to start each object using a startObjectBehavior Action. The first figure below shows the System
init Activity, which is the Classifier Behavior of a stereo system block. This Behavior uses
the startObjectBehavior Actions to start the Behaviors of objects, which are the internal parts of the
stereo system object (big speakers, small speakers, and dvd player). You can simplify the System
init activity, as shown in the second figure below, by making the blocks typing the big speakers, small
speakers, and dvd player, to be active blocks then you can simulate the stereo system through a
Simulation Configuration with autoStartActiveObjects = true.
The MagicDraw User Interface Modeling diagram becomes even more powerful and valuable when
used with Cameo Simulation Toolkit. Supported UI components are as follows
Frames
You need to drag a Classifier to a UI Frame to bind them together (Cameo Simulation Toolkit will
automatically apply a «UI» stereotype and set its represents tag to the Classifier). Once bound, the UI
Frame can represent the Classifier. The source tag of the applied «UI» stereotype will also be set as
com.nomagic.magicdraw.simulation.uiprototype.UIDiagramFrame by default.
Note
• The represents and source tag values are necessary to run a simulation with UI.
• If you use the User Interface Configuration element on the diagram toolbars, you need
to manually specify the represents and source tag values accordingly.
Panels
A UI Panel can hold any supported UI components, such as buttons, labels, sliders, check boxes, text
fields, combo boxes, spinners, radio buttons, and even panels themselves.
• If a UI Panel resides in a UI Frame, drag the Property of a Classifier that the UI Frame represents
to the UI Panel to bind that Property to the UI Panel. The «NestedUIConfig» stereotype will be
automatically applied; its "feature" tag will then be set to the Property and its "Text" tag will also
be set to the name of that Property. In this case, the UI Panel represents the Property.
• If a UI Panel (child) resides in another UI Panel (parent), drag the Property of a Classifier that
types the Property and the parent UI Panel it represents to the child UI Panel to bind that
Property to the UI Panel. The «NestedUIConfig» stereotype will be automatically applied; its
"feature" tag will then be set to the Property and its "Text" tag will also be set to the name of that
Property. This functionality allows you to bind the nested parts (properties) of a Classifier to its
correspondent nested UI Panels in a UI Frame representing the Classifier.
Group boxes
Group boxes have similar usages to Panels.
Labels
Drag a Property to a UI Label to bind the Property with that particular UI Label. The «RuntimeValue»
stereotype will be automatically applied, its "element" tag will be set to the Property, and its "Text" tag
will also be set to the name of that Property. In this case, the UI Label represents the Property. Once
represented, the UI Label will display the value of the represented Property in the Variables pane
during simulation.
Buttons
You can use a UI button to send Signal(s), call Operation(s), or call Behavior(s).
• Drag a Signal to a UI button to associate it with the button. The «SignalInstance» stereotype will
be automatically applied, its "element" ("signal") tag will then be set to the Signal, and its "Text"
tag will also be set as the name of that Signal.
In addition, runtime values will be automatically created for all of the attributes and placed under the UI
button if the signal has attributes. You can specify the values to be used at runtime in the "value" tag of
these runtime values. If you click this UI button during simulation, it will send the associated Signal
along with its runtime values.
If you click this UI button during simulation, it will call the associated Behavior.
Radio buttons
Drag a Property typed by Enumeration to a UI Panel or GroupBox to bind the Property to that particular
UI panel or GroupBox. The «RuntimeValue» stereotype will be automatically applied, its "element" tag
will then be set to the Property, and its "Text" tag will also be set to the name of that Property. All
Enumeration Literals of the Property type will be automatically created as a vertical list of UI
RadioButtons. Each UI RadioButton will represent Enumeration Literal of the Property type accordingly.
Once represented, the UI RadioButton will display the value of the represented Property in
the Variables pane during simulation.
In addition, you can assign or re-assign other Enumeration Literals to an existing UI RadioButton by
dragging other Enumeration Literals of the same Property type to the existing UI RadioButton. Also, you
can create a single UI RadioButton to represent a particular Enumeration Literal by dragging the
Enumeration Literal to a UI Panel or GroupBox. The «RuntimeValue» stereotype will be automatically
applied, its "element" tag will then be set to Enumeration Literal, and its "Text" tag will also be set to the
name of the Enumeration Literal.
The following figure demonstrates an example of using MagicDraw's User Interface Modeling Diagram
with Cameo Simulation Toolkit.
Using the MagicDraw User Interface modeling diagram with Cameo Simulation
Toolkit.
See the Calculator.mdzip sample for detailed instructions. When you drag any GUI elements to a
diagram, click Run to simulate the animation.
Note
• The current version of Cameo Simulation Toolkit supports frames, panels, group boxes,
labels, buttons, check boxes, text fields, sliders, combo boxes, spinners, and radio
buttons only.
• Do not drag any model elements of an existing UI Frame (from the Containment tree) to
a diagram to create one more ComponentView/Frame symbol on the diagram. Cameo
Simulation Toolkit does not support two UI symbols of the same model element.
• Other samples include: SmallTestSamples.mdzip, StopWatch_advanced.mdzip, and
SimpleUI_labelUpdate.mdzip.
Sample models
The models used on this page are the CarBrakingAnalysis and Calculator sample models that come
with MagicDraw. To open a sample, do either of the following
ImageSwitcher is a predefined subtype of UI config. It is a simple, yet flexible and powerful animation
tool. You can use ImageSwitcher to represent the state or the enumeration value of a runtime object.
To easily create an «ImageSwitcher» element, specify a represented Classifier, and create as many
attributes and different States as you wish to see them animate. Each attribute is called an
«ActiveImage» and has the following properties
• Image
An image that will be used in animation either from browsing the file or dragging the image
directly from a web browser.
• activeElement
An element that will use an image once it is activated. An active image represents a State of a
runtime object, whereas an activeElement is the state of a Classifier represented by the
44 https://docs.nomagic.com/download/attachments/82762044/CarBrakingAnalysis.mdzip?
api=v2&modificationDate=1505276807370&version=1
45 https://docs.nomagic.com/download/attachments/82761894/Calculator.mdzip?
api=v2&modificationDate=1496891990023&version=1
You can use an ActiveImage to represent each state of a runtime object whose Classifier is represented
by the ImageSwitcher that owns the ActiveImage. The FlashingLight.mdzip sample is used throughout
this page. You can open the sample by downloading it from the attached link.
1. Create an ImageSwitcher element, and set its represent tag definition with a Classifier whose
state will be represented by an active image owned by the ImageSwitcher.
2. Create an ActiveImage in the ImageSwitcher for each State of the Classifier represented by
the ImageSwitcher.
3. Specify the image that will be the image attribute of each created ActiveImage and set the State,
which will be represented by the ActiveImage, as the tagged value of the activeElement tag
definition.
The following figure illustrates an example of how to use ImageSwitcher and ActiveImage to represent
the States of a runtime object (see the FlashingLight.mdzip sample)
Sample model
The model used in the figures of this page is the FlashingLight.mdzip sample model that comes with
MagicDraw. To open this sample, do either of the following
• Download FlashingLight.mdzip46.
• Find it in the modeling tool <modeling tool installation
directory>\samples\simulation\FlashingLight.mdzip.
Related pages
46 https://docs.nomagic.com/download/attachments/82761777/FlashingLight.mdzip?
api=v2&modificationDate=1496891987750&version=1
1. Create an ImageSwitcher element, and specify the enumeration, whose values will be
represented by an ActiveImage of the ImageSwitcher, as the tagged value of the represent tag
definition of the ImageSwitcher element.
2. Create an Active image for each enumeration literal owned by the enumeration.
3. Specify an image that will be the image attribute of each created ActiveImage, and set the
enumeration literal that will be represented by the ActiveImage as the activeElement tag
definition.
You can use SmallTestSamples.mdzip as your example. This file is a sample project of Cameo Simulation
Toolkit. It is located in the <modeling_tool_installation_directory>\samples\simulation folder. In this
example, an ImageSwitcher was created to represent a VerdictKind enumeration. An ActiveImage was
created for each enumeration literal of the VerdictKind as follows
The figure below shows the User Interface Modeling diagram of the SmallTestSamples.mdzip sample
project. It contains a UI frame that represents the Test Result dialog, which is the Classifier owning the
property typed by the VerdictKind enumeration. The property is result:VerdictKind, whose default
value is pass. Now, the ActiveImage that represents the value pass will be shown in the panel.
You can simulate the Test Result dialog in the SmallTestSamples.mdzip sample project. You can also
change a result value by selecting one of the radio buttons that represents the value: pass, fail,
inconclusive, or error. Now the image that corresponds to the value will appear.
The image that appears on the web UI through ImageSwitcher is the same image that represents the
current State of simulation UI. If the image on the simulation UI is changed, the image on the Web UI
will change accordingly and vice versa. Setting the show empty image for unspecified value option
(true/ false) on the «ImageSwitcher» will change the image on the web UI through ImageSwitcher to be
the same as the image that represents the simulation UI.
ImageSwitcher on the web UI representing the enumeration value that corresponds to the simulation UI.
Another more comprehensive and realistic sample is available in Cameo Simulation Toolkit is
Blackjack.mdzip. This sample contains a Blackjack game simulation in which Players can only stand or
hit, and the Dealer can stand on 17 or higher. Once you run the Run Blackjack Simulation Config, the
Blackjack game will begin by showing a Blackjack game table UI (see the following blackjack figure).
Note that this sample also demonstrates the Nested UI Configuration feature (see Nested UI
Configuration stereotype(see page 129) for more information). As the Dealer/Player has 7 possible card
slots, according to the Nested UI Configuration feature, the Dealer/Player thus has 7 corresponding
Value Properties, e.g., 'Card1', 'Card2', 'Card3', and so on.
• '0' Enumeration Literal represents a blank image; a card slot without any card.
• '1' - '52' Enumeration Literals represent the images of 52 distinct cards.
• The value of the Player's 'Card1' Value Property is '49' Enumeration Literal, which is the
activeElement of the '49' ActiveImage. The '49' ActiveImage represents the ten of spades.
• The value of the Player's 'Card2' Value Property is '28' Enumeration Literal, which is the
activeElement of the '28' ActiveImage. The '28' ActiveImage represents the two of hearts.
• The value of the Player's 'Card3' Value Property is '0' Enumeration Literal, which represents a
blank card slot. Therefore, no card is open next to the two of hearts card.
UI and Variables panel showing the value of 7 value properties and the displayed image.
Related pages
On this page
In Cameo Simulation Toolkit, a Time series chart displays plots of runtime values with respect to
simulation time. You can show a Time series chart of any runtime values during model simulation. The
Time series chart measures time on the X-axis (horizontal axis) and runtime values on the Y-axis
(vertical axis). The graph of the time series chart simulates the movement of the values or data over
time. It allows you to evaluate trend or monitor behavior in the selected values within a specific period
of time. You can use a time series chart to display real-time plotting of runtime values on the Y-axis,
along with simulation time on the X-axis (as in the simulation time and clock settings). You can also
customize most of the chart properties according to your preferences, including title, plot color, min
and max value, and external CSV. For further information, see the built-in sample
MotionAnalysis.mdzip, used throughout this page to demonstrate how to use the Time series chart in
your model.
Annotate Failures To annotate a Requirement and constraint failures as the chart plot area in red (true by
default).
Load CSV File A load CSV file is a file that the Time Series chart will load as a curved line graph. You can
import multiple CSV files into the Time series chart and load them as curved line graphs.
They will be represented with different colors and legend names (same as the filename
extension) so you can compare the differences between the actual results and the
desired line graphs.
Record Plot Data To specify the selected format of the file to be saved if Result File is specified.
As
Result File To specify the file name to be saved from the results in the selected file format specified
in the Record Plot Data As property. Otherwise, the results will be saved into model
elements.
Fixed Time Length To specify a fixed range of the time axis in a Time series chart. If you specify a value, the
time axis range will be fixed to that particular value. If you do not specify the value of
Fixed Time Location, the plot(s) will move to the left if the time range is greater than the
maximum value of the time axis. A fixed time length unit is specified by a time unit tag
definition of the simulation config. If you do not specify the time unit, Cameo Simulation
Toolkit will use the millisecond as the default unit.
Fixed Time To specify the start time of the time axis in a Time series chart. If you specify a value for
Location the Fixed Time Length but leave the Fixed Time Location value empty, the Time series
chart will work like an oscilloscope. The plot(s) will move to the left. A fixed time location
unit is specified by a time unit tag definition of the Simulation Config. If you do not
specify the time unit, Cameo Simulation Toolkit will use the millisecond as the default
unit.
Y Label To specify the label of the y-axis of the Time series chart.
Fixed Range To specify whether a Time series chart will automatically adjust the range on the Y-axis.
If the value is true, the range of the Y-axis will be fixed; otherwise, the range will
automatically change.
Keep Open After To keep the Time series chart open after the termination of the simulation.
Termination
Refresh Rate To specify a time interval to refresh a Time series chart. A refresh rate unit is specified by
a time unit tag definition of the Simulation Config. If no time unit is specified, the
millisecond will be used as the refresh rate unit.
Linear If true, the plot will connect 2 dots in a non-rectangular line at a time.
Interpolation
The following figure shows the configuration settings of both Time series chart and Simulation Config of
the MotionAnalysis.mdzip sample project. The Time series chart has been set as the "Represents" field
to the Motion Analysis block together with the "Values" field to the required properties (x, v, and a),
along with other properties as needed. Also, the Simulation Config "UI" field has been set to the Time
Series Chart (x-v-a plot).
The configuration settings of both Time series chart and Simulation Config of
the MotionAnalysis.mdzip sample project.
Once the simulation begins, the Time series chart displays real-time plotting of the x, v, and a
properties with time(s), as shown in the MotionAnalysis.mdzip sample.
Glossary
• CSV
A CSV is a comma-separated values file that stores tabular data (text and number) in plain text.
Each line in the file is a record; each record consists of one or more fields, separated by commas.
• Runtime value
A runtime value refers to the value of the structural features contained in the created object
during model simulation.
• Time series chart
A Time series chart is a graph that can simulate runtime values over a specific period of time.
Sample model
The model used in the figures on this page is the Motion Analysis sample model that comes with a
modeling tool. To open this sample, do one of the following:
• Download MotionAnalysis.mdzip47.
• Find in modeling tool <modeling tool installation directory>\samples.
Related pages
47 https://docs.nomagic.com/download/attachments/82761967/MotionAnalysis.mdzip?
api=v2&modificationDate=1496891991120&version=1
You can use the fixedTimeLength property to specify the range of the time axis. If you do not define
the value of fixedTimeLength, the time axis will expand as long as the maximum duration a simulation
will run. The following figure shows a Time series chart when the fixedTimeLength value is 100
seconds
If fixedTimeLength is 100 seconds, the range of the time axis will be [0, 100] (If you do not
specify fixedTimeLocation, the minimum time axis value will be 0). However, if your simulation model
runs longer than the simulation time or more than 100 seconds, e.g., 115 seconds, the range of the
time axis will be [15, 115]. This particular Behavior of Cameo Simulation Toolkit's Time series chart is
similar to that of Oscilloscope when fixedTimeLocation is unspecified.
A Time series chart provides two options for you to export your plot data in which time values (the
values that appear on the horizontal axis) and the corresponding recorded values (the values that
appear on the vertical axis) are plotted in a Time series chart. You can export the plot values to either a
comma-separated value file (CSV file) or the slot values of an instance model.
The values plotted in a Time series chart are exportable to a CSV file.
1. Click the Export Data toolbar button on the Time series chart's plot panel.
The following figure shows plotted values in the Time series chart
Related pages
Cameo Simulation Toolkit also allows you to export plots data in a Time series chart to an Instance
model. The model for exported plots data in the simulation profile comprises of DataSet and Data
Classes. Whenever you export plots data to an instance model, Cameo Simulation Toolkit will create an
InstanceSpecification of a DataSet Class. The slot of a data property will contain a list of
InstanceSpecifications of the Data Class. The first instance on the list is an InstanceSpecification
containing the time values while the second one is an InstanceSpecification containing the values that
appear on the vertical axis of the first plot. If a Time series chart has more than one plot, the third
InstanceSpecification on the list will be an InstanceSpecification containing the values of the second
plot and so on.
1. Click the Export to Instance toolbar button of the Time series chart's panel whose values you
want to export. The Element Selection dialog will open.
2. Select a package that will own the instance model you want to create.
3. Click the OK button. Cameo Simulation Toolkit will create the instance model containing the plots
data in a Time Series Chart as shown in the following figure
Related pages
Note
48 https://docs.nomagic.com/display/MD2021xR2/Specification+window
The following figure shows the plot image saved in the Specification of Instance Specification of the
bouncingBall model
To verify a plot image saved in the Image property of the selected InstancedSpecification
The following figure shows the CSV values saved in the Specification of Instance Specification of the
bouncingBall model
The Time series chart can read data from a CSV file and represent them in a curved line in the chart.
The property External CSV in the Time series chart enables you to import an external CSV file and load
data from the file.
The time Series Chart can read a CSV file with data in multiple columns and show them in lines in the
chart. (The first column is always the value of time on the y-axis) and read multiple CSV files and show
them all at once.
49 https://docs.nomagic.com/display/MD2021xR2/Specification+window
2. Select a CSV file (see an example of the result data in a CSV file), and the Time series chart will
show data from the columns in the file in lines.
The following figure shows a line chart. The solid line in the chart represents the values plotted
Cameo Simulation Toolkit while the dashed lines represent the values from the CSV file.
Timeline chart
On this page
Unlike a Time Series chart(see page 87), a Timeline chart allows you to see the active States of an object or
a property during simulation or the Activities simulated in an object. The Timeline plot allows you to see
the animation of all active States while a model simulation is running, as well as which objects are active
in each State or when a State starts and ends.
Similar to the Time series chart, the Timeline chart also shows the x-axis and y-axis. The x-axis
represents time while the y-axis represents object State names in different values. The Timeline chart
identifies the changes in the object states and plots them along a timeline. The States are grouped by
region. Cameo Simulation Toolkit records changes in the active States and allows you to export them to
a CSV or TSV file. You can then import the CSV file into an Excel file to analyze the exported Timeline
chart, such as calculating the simulation duration, what object is in a particular State, and how long it
was busy or idle.
We use the sample project FlashingLight.mdzip50 throughout this section to demonstrate how to use
the Timeline chart in your model.
50 https://docs.nomagic.com/download/attachments/82761805/FlashingLight.mdzip?
api=v2&modificationDate=1505276946588&version=1
Property Function
Annotate Failures To annotate a Requirement and constraint failures as the chart plot area in red (true by
default).
Dynamic If true, the chart shows only States or Actions actually used and sorted by occurrence.
Otherwise, the list of static Behaviors is shown, and the chart contains information when
open.
Fixed To specify a fixed range of the time axis in a Timeline chart in milliseconds. If you specify a
Time Length value, the time axis range will be fixed to that particular value. If you do not specify the
value of the Fixed Time Location, the plot(s) will move to the left if the time range is
greater than the maximum value of the time axis. A fixed time length unit is specified by a
time unit tag definition of the Simulation Config. If you do not specify the time unit,
Cameo Simulation Toolkit uses 20,000 milliseconds as the default unit.
Fixed Time To specify the start time of the time axis in a Timeline chart. If you specify a value for the
Location Fixed Time Length but leave the Fixed Time Location value empty, the Timeline chart will
work like an oscilloscope. The plot(s) will move to the left. A fixed time location unit is
specified by a time unit tag definition of the Simulation Config. If you do not specify the
time unit, Cameo Simulation Toolkit uses the millisecond as the default unit.
Ignored Elements A list of elements (States, Actions, and Activities) which will be ignored and not displayed
in the Timeline chart. This list takes priority over the Value list.
Keep Open After To keep the Timeline chart open after the termination of the simulation.
Termination
Linear If true, the plot will connect 2 dots in a non-rectangular line at a time.
Interpolation
Record Plot Data To specify the selected format of the file to be saved if Result File is specified.
As
Result File To specify the file name to be saved from the results in the selected file format specified in
the Record Plot Data As property. Otherwise, the results will be saved into model
elements.
9. Run the Timeline Chart. You can see the animation of the active States in the Timeline Chart
when the Context Plot option is set to False and True. The following figure shows the Timeline
chart output when the Context Plot option in the Specification window is set to False.
10. Optionally, you can specify in the Ignored Elements property what State will be ignored and
not be recorded in the Timeline chart if the user does not want to see them. The following figure
shows the Timeline chart output when the Ignored Elements property is set to ignore the ticking
State and the off State of timer, and the on State of system
Important
A Timeline chart shows only States and Actions which are actually used, e.g., Actions with
duration constraints and signaled States. The used elements will be displayed in the chart and
sorted in time order.
The Timeline Chart shows the Action names on the left-hand side and the duration simulation
performed on the Actions (not the Activities) on the right-hand side. The same thing applies to an
Action that has Behaviors assigned, but it is empty and has no diagram. The following figure shows the
Timeline chart of the empty/dummy actions from the above example.
1. On the Timeline chart pane, e.g., System, click the Export Data button on the Timeline Chart
dialog.
2. The Timeline chart will be exported as a CSV format file. The exported Timeline chart in an Excel
file is in the figure as follows.
1. Open the Specification window of a Timeline chart and click the Value tag. Boolean,
Enumeration, and Numeric primitive value types, e.g., Number, Real, or Integer, are supported as
shown in the following figure.
Glossary
• Context plot
A Context plot is a Timeline chart property that enables the plot of the context. It appears on top
of the chart as a horizontal line.
• CSV
A CSV is a comma-separated values file that stores tabular data (text and number) in plain text.
Each line in the file is a record and each record consists of one or more fields, separated by
commas.
• Oscilloscope
A piece of equipment showing oscillations in an electric current as waves on the screen.
• Timeline chart
A Timeline chart is used to describe the Behaviors of both individual Classifiers and Interactions
of the Classifiers, focusing attention on the time of events triggering a State change.
• TSV
A TSV is a tab-separated values file that stores data in a tabular structure (e.g. database or
spreadsheet data). Each line in the file is a record and each record consists of one or more fields,
separated by tabs.
Sample model
The models used in the figures on this page are the FlashingLight and OntologicalBehaviorModeling
sample models that come with your modeling tool.
Histogram
On this page
Cameo Simulation Toolkit introduces built-in support for Monte Carlo analysis, allowing you to manage
uncertainties and estimate how random variation of sensitive parameters affects the overall
performance of the system being modeled. A Histogram shows the density of the underlying
distribution of data and estimates the probability density function of underlying variables. The total
area of the Histogram used for probability density is always normalized to 1. A Histogram also allows
you to dynamically view updates on those statistical values during the simulation. In addition, you can
customize the properties, including title, plot color, and labels. For more information about using the
Histogram in your model, see the built-in HingeMonteCarloAnalysis.mdzip53 sample as a
demonstration.
51 https://docs.nomagic.com/download/attachments/82761805/FlashingLight.mdzip?
api=v2&modificationDate=1505276946588&version=1
52 https://docs.nomagic.com/download/attachments/82761805/OntologicalBehaviorModeling.mdzip?
api=v2&modificationDate=1505276945878&version=1
53 https://docs.nomagic.com/download/attachments/33195232/HingeMonteCarloAnalysis.mdzip?
api=v2&modificationDate=1511944656895&version=1
Property Function
Dynamic If true, opening the Histogram during multiple executions shows dynamic results.
Otherwise, the Histogram will be open when all executions are completed.
Note
When the Dynamic property is set to true, the animation of the Histogram with
dynamic statistical results (N, Mean, SD, and OutOfSpec) is available.
Keep Open After To keep the Histogram open after the termination of the simulation.
Termination
Record Plot Data To specify the selected format of the file to be saved if Result File is specified.
As
Result File To specify the file name to be saved from the results in the selected file format specified
in the Record Plot Data As property. Otherwise, the results will be saved into model
elements.
Note
The Histogram can be used only as a local user interface, and the Number Of Runs
«SimulationConfig» must be more than 1.
Tips
You can export the Histogram data as a CSV file by clicking the icon at the top-left of the
Histogram pane. The Histogram is exported as a CSV file, shown below.
Related pages
The following System Class diagram shows the structures of Class system and Class monitor
The following figure displays the UI configuration and the Specification of the UI Panel named panel1,
which represents the monitor1 Property, as a part of Class system
When the test_nested_panels SimulationConfig is run, the UI mockup will be displayed. The following
figure exhibits the UI Panels and UI Group Boxes that represent the parts (Properties) of the Class
system and in-depth nested parts as well
The FlashLight sample will be used to show how to model a part using an existing UI Configuration. The
following steps show you how to create a UI Mockup that represents the entire system parts, which
uses only one UI Frame
The following figure demonstrates the runtime User Interface Mockup that represents the Class
Button and Class Light
After assigning the LampBulb UI Configuration to the UI panel representing the Light
Property, you will see the tagged value Specification of the UI panel that represents the Light
property in the Specification of the UI Panel dialog as follows
8. Drag an existing UI Configuration named PowerButton to the UI panel that represents the Button
property.
10. Simulate and run the newly created Simulation Configuration. The UI Mockup will appear as
illustrated in the following figure
Cameo Simulation Toolkit improves the flexibility in user interface modeling. You can reuse UI
components by typing the property using the UI component. The object, which is the value of the
property, represents a mock-up of the UI component. Once the object is created, the mock-up UI will be
created and shown in the MagicDraw window. Whenever the object is deleted, the mock-up UI will be
deleted as well. It is not necessary to add the UI component to the UI tag definition of the Simulation
Config stereotype.
You can use a UI Frame to create other properties and define it as the type of the properties. A UI
Mockup will start and will be deleted with an object that is the value of the property typed by a UI
component (including but not limited to the property in Step 3. You can show or hide a UI Mockup by
using the context menu of the instance of the property.
To hide a UI mockup
You can also show or hide the other UI components, for example, time series chart and ImageSwitcher.
Related page
• Creating User Interface mockups for the stopwatch model(see page 635)
CSV export
On this page
As of Version 18.4, Cameo Simulation Toolkit can export simulation results to a CSV file.
A new configuration, called CSV Export, has been added to export simulation results to a CSV file. CSV
files take the following properties:
• File Name
The name of the file that the exported results are written into. The path is the same as the
project directory (by default). Alternatively, a full path may be specified as D:
\ExportedCSVResults.csv
• Record Time
If true (by default), time will be recorded in the first column of the exported CSV file.
• Represents
Specifies the Classifier represented by the Configuration.
• Value
Specifies the properties of the Classifier (including nested properties) whose values will be
recorded and written to the CSV file.
• Write At The End
Records values only once at the end of execution, right before termination, rather than listening
and recording value changes during the execution. When Number of runs is more than 1 in the
main configuration, the values are recorded once in each iteration.
1. Open a sample simulation project from the samples folder of Cameo Simulation Toolkit. Here
the HingeMonteCarloAnalysis(see page 141) sample is used.
2. Drag the CSV Export Configuration from the toolbox to the Simulation Configuration diagram.
4. Set the created CSV export as a tagged value of the executionListeners tag definition of the
Simulation Configuration. This step is important for the results to be written to file. See the CSV
export configuration below:
The Specification window for the aforementioned items will have the following two properties
• Represents
Specifies the Classifier represented by the Configuration.
• Value
The Value property takes nested property values.
The Select Nested Properties dialog will open if you click the button beside the Value property from
the Specification window.
Tip
Before the Value property can be specified, the Represents property has to be assigned a
value first.
1. If the file is in the project directory and in the attached file, the file in the project directory will be
used without any displayed messages.
2. If the file is in the project directory but not in the attached file, the file in the project directory will
be used without any displayed messages.
3. If the file is not in the project directory but is in the attached file, the file in «AttachedFile» will be
used, and the following information message will be printed in the Console pane, “INFO: Load
'aFile' of Attached File within the project.”
4. If the file is not in the project directory and not in the attached file, the following error message
will be printed in the Console pane, “ERROR: Cannot find 'aFile' from the project directory or
attached file.”
Related pages
54 https://docs.nomagic.com/display/MD2021xR2/Projects+with+file+attachments
Web Server for Cameo Simulation Toolkit is an optional free plugin. It allows Cameo Simulation Toolkit
to export, open, use UI mockups, and control a model simulation on a web browser on any remote
device. Cameo Simulation Toolkit and the Web Server plugins must be the same versions. Once the
Web Server plugin has been installed, it will appear as Installed in the Resource/Plugin Manager and
Environment Options dialogs.
1. On the MagicDraw main menu, click Option > Environment. The Environment Options dialog
opens.
2. On the left pane, click Simulation.
Activating the Start Web Server property (true) in Cameo Simulation Toolkit before running a
<<SimulationConfig>> automatically generates HTML files. When Web Server has started, and the
simulation is running, a hyperlink to each HTML file saved in the local project folder, along with the URL
of the Web UI, will appear on the Simulation Console tab. You can customize the content of the HTML
files at any time and update files by using the Generate HTML button on the diagram toolbar of the UI
modeling diagram.
Related page
Note
• Projects without Simulation Configurations will not appear on the homepage.
• If the Web UI is used, local UI mockups will not be displayed.
Tip
Opening/closing a project in MagicDraw, the home page will be the auto-regenerated project
list accordingly.
On this page
When you start the Web Server option in your model's <<SimulationConfig>>, and Start Web Server is
true, Cameo Simulation Toolkit will automatically generate HTML files from all used UI Configurations.
This feature saves you a lot of time because you are not required to manually export them to get those
HTML files. You can then use UI Mockups instead of local UI Mockups and control your model
simulation on a web browser of any remote devices.
The web server notification, URL to open web UI, and browser types in the
simulation Console pane.
Embedded browser
Clicking the URL opens a popup menu either Embedded Browser or Web Browser, where you can view
and control the simulation through the Web UI. The Embedded Browser allows showing any web pages
in dock-able embedded windows in fixed places. These windows can be moved, docked, and float in the
MagicDraw window. When you open a saved project or re-run the project with the embedded browser
option, those windows will automatically be shown in the same locations, States (docked/floating), and
sizes. When the simulation is terminated, these windows will be closed automatically. To control the
simulation through the web UI, you need to enable the Add Control Panel(see page 165) option.
Important
• To prevent overwriting, HTML files will be not be regenerated if they have ever been
generated before.
• The HTML files will be generated anew after you customize the files, e.g., add a logo or
change the text color or size, using the same filename.
• You can delete or rename the existing HTML files if you need them to be regenerated.
• Avoid a duplicate name of «ui» object. If there are two «ui» objects of the same name,
e.g. «frame», only one of them will be auto-generated.
Depending on the circumstances, you may want to manually generate HTML files for further
customization of the web UI Mockups. Manually generating HTML files through either the UI diagram or
HTML supported controls is possible using the Generate HTML command. However, if the files already
exist, a warning message box will open to prevent you from accidentally overwriting
them. All generated HTML files will be written and stored in the project's working directory.
Tip
Anyone with access to the network the web server is on will be able to access the web link via a
web-browser.
• Download Calculator.mdzip55.
• Find it in the modeling tool <modeling tool installation
directory>\samples\simulation\Calculator.mdzip.
Related page
Generating an HTML table from a UI table, Time series chart, and CSV export
configuration
On this page
55 https://docs.nomagic.com/download/attachments/82761894/Calculator.mdzip?
api=v2&modificationDate=1496891990023&version=1
56 https://docs.nomagic.com/download/attachments/82761908/SpacecraftMassRollup.mdzip?
api=v2&modificationDate=1538627026416&version=1
57 https://docs.nomagic.com/download/attachments/82761908/SpacecraftMassRollup.mdzip?
api=v2&modificationDate=1538627026416&version=1
58 https://docs.nomagic.com/download/attachments/82761908/SpacecraftMassRollup.mdzip?
api=v2&modificationDate=1538627026416&version=1
5. Select Create UI Prototype. The table headers will change from Column 1 and Column
2 to Name and Value.
Tip
If you drag the spacecraft Block to the table quickly, the column name will change
automatically, without having to select Create UI Prototype.
When you select the Create UI Prototype, the table column names change to Name and Value.
6. Right-click the UI table. Select Specification to bring up its Specification window as shown below.
Note that the Classifier is assigned to the Represents property.
11. Note that a simulation web server has started. You can open the Specification window of
Simulation Configuration to see the Start Web Server (true) option.
12. Click the HTTP link, e.g., http://10.1.1.64:8080/ in the Console pane to view the simulation in real-
time in your browser.
13. You can edit the Documentation/Hyperlink tag from the UI table's Specification window and
run the simulation again. It will show the table's descriptions. See the following two figures
The changes to the Documentation/Hyperlinks tag appearing as the HTML table's description.
14. You can edit the values from the web browser page. The simulation engine will automatically pick
the values up and re-calculate. In addition, verification status of runtime values(see page 243) is
supported and shown that there is constraint failure, which is colored in red.
Generating an HTML table from a Time series chart and CSV export
configuration
An HTML table can also be generated from a Time series chart and CSV export configuration.
To generate an HTML table from either a Time series chart or a CSV export configuration
1. Right-click a Time Series Chart or a CSV Export configuration and choose Tools > Generate
HTML Table.
Sample model
The model used in the figures on this page is the SpacecraftMassRollup sample model that comes
with your modeling tool.
• Download SpacecraftMassRollup.mdzip59.
• Find it in the modeling tool <modeling tool installation
directory>\samples\simulation\SpacecraftMassRollup.mdzip.
59 https://docs.nomagic.com/download/attachments/82761908/SpacecraftMassRollup.mdzip?
api=v2&modificationDate=1538627026416&version=1
1. Double-click the <<SimulationConfig>> on the diagram pane to open its Specification window.
2. Select the Add Control Panel check box under the Web Server option. The value will change to
true and the addControlPanel stereotype will be added in the <<SimulationConfig>>.
Sample model
The model used in the figures on this page is the Calculator sample model that comes with
MagicDraw.
• Download Calculator.mdzip60.
60 https://docs.nomagic.com/download/attachments/82761894/Calculator.mdzip?
api=v2&modificationDate=1496891990023&version=1
ImageSwitcher can also be displayed on the web UI for most common image file formats (jpg, tif, png,
and gif) along with the standard UI modeling diagram. You must select the Generate HTML menu from
either the context menu (right-click) of each ImageSwitcher element or from the toolbar of UI diagram.
The Simulation Console pane will then display the following message: INFO: HTML file(s) is/are
generated to <projectName> folder.
Related page
Additionally, you can deploy the Time series chart along with the standard UI modeling diagram on the
Web user interface. This web UI capability is enabled by selecting the menu Generate HTML from
either the context menu (right-click) of each Time series chart element or the toolbar of the UI diagram.
The chart that appears on the web UI is the same chart that represents the values of the simulation UI.
If the values on the chart simulation UI change, the corresponding chart will change accordingly. The
layout of the Time series chart is auto-aligned with the chart properties of the runtime UI, e.g., Title,
fixedRange, gridX, gridY, and plotColor.
Related pages
On this page
Simulation supports the integration of custom HTML widgets through the build-in model library named
UI Widgets Library.mdzip. You can see its usage in WebUIWidgets in Samples on the Welcome
screen under Simulation.
Note
HTML widgets work with most web browsers such as Google Chrome, Microsoft Edge
(Chromium), Mozilla Firefox, and Opera. However, if you use older versions of Internet
Explorer, e.g., IE 11, you must set the document mode to 11 by doing the following:
1. Open Internet Explorer.
2. Press F12. Go to the Emulation menu.
3. Under the Mode group, select the Document mode list and choose 11.
1. From the main menu, click File > Use Project > Use Local Project. The Use Project dialog
opens.
2. In the Use Project dialog, do the following:
• Click the From predefined location option.
• Choose <install.root>\modelLibraries.
• Select UI Widgets Library.mdzip.
1. Drag the widget from a UI Widgets Library and drop it into the IBD/Composite Structure
diagram of the simulation context. Then use a Binding Connector to connect between the value
property of the system and Port of the widget with the same Type. The widget can be resized as
needed.
Note
If the Web Server plugin is not installed, a warning message with a link to install
the plugin will be printed in the Console panel. Widgets on the IBD will not work
until the plugin has been installed.
c. The Console pane will print all generated HTML files, the generated folder, and URL of the
Web UI with links.
Note
• The Generate HTML command is available only when there is «Widget» as Part
(either Class or Block) in the executionTarget of a «SimulationConfig».
• If HTTP ERROR 404 ... occurs in the IBD/Composite Structure diagram, you must
use the Generate HTML command. This is because the error from HTML files is
not generated, but the startWebServer of the «SimulationConfig» is false.
6. However, if the HTML files already exist, a question dialog will be shown to prevent you from
accidentally overwriting them as shown in the figure below.
Note
The <project>_index.html file is always regenerated at the end of the process.
Note
When using widgets, you must define your Parts with distinctive names to shorten generated
widget file names that cannot normally be longer than 255 characters as limited by operating
systems.
1. Create an IBD and connect the Ports of the widgets with value properties to work with runtime
values.
2. Drag a property typed widget to a «Frame» «UI». Simulation will automatically set the config
according to the feature. Image of the widget will automatically be shown, and «NestedUIConfig»
will be automatically set. You can use either a group box (by default) or panel as a place holder
shown below.
Active elements on a diagram will be annotated during simulation using the same annotation
mechanism used in the active validation:
• Active and visited elements will be annotated in red and green respectively.
• Runtime values will be visible in the tooltip of annotated elements.
• Values flown through pins of action will be visible in the tooltip of annotated actions.
• Duration of called Activities will be visible in the tooltip of annotated call Behavior Actions if you
simulate the Activity with a specific duration mode.
Note
If you select true as the value of the silent tag in the Simulation Configurations, Cameo
Simulation Toolkit will not animate simulation and will simulate models in silent mode (see
Simulation Configuration and UI modeling(see page 46) for more information).
Related pages
On this page
Active Elements are the Elements a simulation session is focusing on (see Understanding simulation
sessions(see page 197) for more information). They can also be considered as the Elements that are
currently being simulated in a simulation session. They will be annotated in red by default. Once an
active Element has been simulated, it will become a visited Element and will be annotated in green by
default. The last visited element will be annotated in orange.
There are four kinds of annotated elements in a model simulation: (i) Active, (ii) Visited, (iii) Breakpoint,
and (iv) Last Visited elements. By default, active elements will be annotated with red, visited elements
with green, last visited elements with orange, and breakpoints with yellow. Cameo Simulation Toolkit
allows you to customize the colors of these annotated elements through the Project Options(see page 47)
dialog in the Animation group.
The Auto Open Diagrams option in the Project Options(see page 47) dialog and Simulation window
allows Cameo Simulation Toolkit to open a tab where you can see a diagram that contains a currently
active Element in a non-silent simulation (animation is enabled). If you want to enable this option, you
need to select true as its value. This is useful when you want to track the simulation current status.
Select false as the value of Auto Open Diagrams when you would like to focus on just one diagram
and avoid automatic switching or opening of diagrams.
If the value of Auto Open Diagrams is false and you run a silent-mode simulation of an activity
diagram that has a decision node without any decision input, Cameo Simulation Toolkit will open the
diagram and highlight all elements including the decision node and open a Question dialog to ask for a
decision when the simulation reaches the decision node. However, if the value of Auto Open Diagrams
is false, and you are running a non-silent simulation, Cameo Simulation Toolkit will open the diagram
and highlight only the decision node.
Note
The default value of Auto Open Diagrams is false.
• Click the Auto Open Diagrams toggle button in the Simulation window as follows
Information
Related page
Note
Animation Speed will not affect animation in the Parametric diagram since no animation is
delayed during parametric solving.
The Animation Speed setting is visible through diagram animation. For example, if the speed is
specified at the value of 50%, the animation must be slower than the default value 95%. The speed
setting is consistent with the Simulation speed bar control; e.g., if the animation speed is specified at
50%, the speed bar is set to the middle as shown in the following figure
The animation speed selected is consistent with the Animation speed bar.
Note
The speed of the animation does not affect the animation in the Parametric diagram as no
animation is delayed during parametric solving.
When simulating a model, you can display and manipulate simulation information in diagrams a similar
way you do it in the Simulation window. For example, you can see and edit runtime values directly on
Part shapes or send a trigger and see a flowing item with its name on a path.
Types of diagrams
You can display and manipulate simulation information only in diagrams that are based on a
Composite Structure Diagram. However, the flowing information on paths can be displayed
both in diagrams based on a Composite Structure Diagram and an Activity Diagram.
On this page
When simulating a model, you can choose to display simulation information not only in the Simulation
window but in diagrams as well. For example, you can see runtime values directly on Part shapes or a
flowing item with its name on a path.
Types of diagrams
You can display simulation information only in diagrams that are based on a Composite
Structure Diagram. However, the flowing information on paths can also be shown in an Activity
Diagram.
Exception
Active States are not displayed for Parts with the multiplicity of more than one.
Important
If you specify State images both by applying them to States and assigning an Image Switcher to
the Simulation Configuration, the images of the Image Switcher will be used when running the
Simulation Configuration.
1. Open the Specification window of the State you want to create an image for.
2. Click the specification cell of the Image property and select the image you want to use for a
specific State. Click to select an image from the default image library, click to select an
image from your file system, or click to specify an image URL.
1. Open the Simulation Configuration Diagram in which the Simulation Configuration is displayed
and create an Image Switcher.
2. In the Specification window of the Image Switcher, click the Represents property specification
cell and select the element for the states of which you want to create images.
3. For every active State image you want to create, create an Active Image element as the attribute
of the Image Switcher.
4. In the Specification window of every Active Image specify the following properties:
• Image property - select the image you want to use for a specific State. Click to select an
image from the default image library, click to select an image from your file system, or
click to specify an image URL.
Runtime values can be displayed only for the following types of properties:
• Primitive
• ValueType
• Enumeration
• Custom DataType
In addition, you can modify runtime values(see page 195) directly in diagrams and change simulation
results in real-time. If you do not want to see runtime values in diagrams during simulation, you can
disable the Show Runtime Values on Part Shapes animation option. For more information,
see Disabling and enabling animation options(see page 192).
On this page
Types of diagrams
You can manipulate simulation information only in diagrams that are based on a Composite
Structure Diagram.
Prerequisites
In order to display and change runtime values in diagrams, the Show Runtime Values on Part
Shapes animation option must be enabled. For more information, see Disabling and enabling
animation options(see page 192).
1. During model simulation, select a Part shape and click a runtime value you want to change.
2. Enter a new runtime value and press Enter. The figure below shows how to change different
types of values.
When you change runtime values of Value Properties as described above, the simulation data is
updated in real-time accordingly.
Sending a signal
When simulating a model, you can send a signal directly from a Part shape in a diagram the same way
you would send it in the Sessions pane of the Simulation window. If it is possible to send a signal, a
special button is displayed on a Part shape after selecting it.
1. During model simulation, select the shape of the Part from which you want to send a signal.
2. Click the signal icon next to the part shape as displayed below. If you can send more than one
signal, the icons of all available signals are displayed.
Related pages
Cameo Simulation Toolkit creates a simulation session(s) while a model is being simulated. A simulation
session contains a context with a specified runtime value. The context of the simulation session is the
executing UML element that can be either a Class element or a sub-type of a Class. When the context
element is simulated, a runtime object will be created to store the simulated values.
You can create multiple simulation sessions during a single simulation, such as an Activity simulation. If
the simulated Activity contains any callBehaviorAction, a new simulation session will be created to
simulate each callBehaviorAction. The Sessions pane will display all simulation sessions during
simulation and order them by context elements in a tree node, as shown below.
While executing a model, you can double-click a running session to open a diagram of that particular
session containing the progress of the simulation as shown below.
Cameo Simulation Toolkit allows you to control a model simulation using the debug buttons such
as Suspend, Resume, Step into, and Step over. The table below explains the functions of all of the
debug buttons.
Step into F5 To simulate and animate a currently active element in a selected simulation
session in the Sessions pane.
Step over F6 To simulate a currently active element in a selected simulation session and run
animation in the background.
Terminate None To stop a session in the Sessions pane. If the selected session contains sub-
sessions, all of the sub-sessions will also be terminated.
You can examine and edit variables in the Variables pane (see Variables Pane(see page 209)), pause the a
model simulation at predefined breakpoints (see Breakpoints(see page 250)), or simulate one element at a
time using the Step into or Step over button.
The Debugger pane includes a player-like control panel for a step-by-step simulation (see the table
above), threads or Behaviors with an expandable stack trace (see Understanding simulation
sessions(see page 197)), input/output console for custom commands or expressions evaluation (see
Simulation console(see page 200)), Variables pane/runtime structure (see Runtime Value Monitoring(see
page 206)), and Breakpoints pane.
Related pages
Simulation console
This chapter explains the fundamental concept and functions of buttons in the Simulation Console
pane and its displayed levels of information, log files as records of all simulation details displayed in the
Console pane during simulation, log's filter options, and constraint failures shown in the Console pane.
Related pages
Cameo Simulation Toolkit provides the Simulation Console pane in the Simulation window.
The Console pane displays simulation information during a model simulation including the date and
time the simulation engine starts and the date and time the simulation runs and stops.
The following figure shows a hyperlink resulting from errors in evaluating scripts in the Console pane.
The link points to the corresponding element in the Containment tree.
B Name Function
u
tt
o
n
Clear Console To remove all simulation information displayed in the Console pane.
Show Runtime To display the runtime information of the Cameo Simulation Toolkit in
Information the Console pane.
The runtime information consists of the Cameo Simulation Toolkit version, registered
simulation engines, and available scripting engines.
Options To filter outputs in the Console pane. There are four filter options: Debug, Info, Warn,
and Error (See Console Log's Filter Options(see page 205)
for more details.).
The following figure shows the simulation Console
Related page
Simulation information
The Console pane can display four levels of information (sorted in ascending order by priority) as
follows
log4j.category.SIM_CONSOLE=INFO,SimConsoleApp,SimXMLApp
Change the first parameter's priority level from INFO (default value) to DEBUG to display all levels of
simulation information in the Console tab.
log4j.category.SIM_CONSOLE=DEBUG,SimConsoleApp,SimXMLApp
You can see more information about customizing the information displayed in the Console pane from
the comment in the simulation.properties file.
Related page
When Cameo Simulation Toolkit is executing a model, the Console pane in the Simulation window will
show you the simulation details. However, the Console pane is limited to display only 60,000 characters
owing to the performance constraints. The characters that exceed the maximum character limit will not
be displayed. Nevertheless, your old simulation information will be automatically archived in
the simulation.log file in the Configuration file directory, as follows
Related page
When running a model, Cameo Simulation Toolkit always shows a log list in the Console pane that
records each and every element that is being simulated such as the start and end elements. If you want
to narrow down the log lists to display only specific messages, e.g., errors or warning messages, you
can use the Options button in the Console pane.
Opti Description
on
Info This option only shows information with a priority equivalent to INFO or higher (WARN and ERROR).
Warn This is the default filter option. It only shows information with a priority equivalent to WARN or higher
(ERROR).
Error This option only displays information with a priority equivalent to ERROR.
Related page
Most of model simulations involve with evaluating values that are in the model. Evaluation will fail if the
model cannot satisfy any of the constraints. Cameo Simulation Toolkit acknowledges this kind of failure
as a constraint failure and thus will print the error message in the Console pane. The message will
inform you about the unsatisfied constraint(s) including hyperlinks that help you navigate the failed
requirements and constraint(s), and the diagram where the simulation stopped.
The following figure shows an example of constraint failures printed on the Console pane
Related pages
On this page
When you are executing a model simulation, Cameo Simulation Toolkit creates the context, runtime
objects, and runtime values to store the simulated values of the model.
Context
A simulation session is always associated with its context of simulation. The context of a simulation
session is a Class or one of its subtypes. When a context element is simulated, a runtime object (of the
context's type) will be created to store the runtime values. In the following figure, the context of the
selected simulation session is the Calculator class.
Runtime object
A runtime object is the simulated value of a Class. In other words, it is a runtime instance of a Class and
of the context as well. In the following figure, the runtime object of the simulation session context is the
"Calculator@6e46ab00" instance. Since the runtime instance is the "Calculator" Class type, it can
contain structural features (which correspond to the Class attributes), such as "display" and
"operand1".
Runtime value
A runtime value refers to the value of the structural features mentioned in the Runtime object section,
e.g., "200" and "120". However, if the type of a structural feature is a Classifier, its runtime value can
also refer to another runtime object of a structural feature type.
Glossary
Class
Class is a Classifier that describes a set of objects that share the same features, constraints, and
semantics (meaning). A class is the most widely used Classifier. It is shown as a solid-outline
rectangle containing the Class name and with optional compartments separated by horizontal lines
containing features or other members of the Classifier.
Classifier
Classifier is a category of UML elements that have some common features, e.g., attributes and
methods. It describes a set of instances that have common behavioral and structural features
(operations and attributes respectively).
Element
Element is the abstract root UML metaclass, it has no superclass in the hierarchy of UML elements.
It is the superclass for all metaclasses in the UML infrastructure library.
Instance
Object is an instance of a Class. It is an individual (thing) with a State and relationships to other
objects. The State of an object identifies the values for that object of properties of the Classifier of
the object.
Structural feature
Structural feature is a typed feature of a Classifier that specifies the structure of instances of the
classifier. It specifies that instances of the featuring classifier have a slot whose value or values are
of a specified type.
Sample model
Related pages
To learn more about working with context, runtime objects, and runtime values, you can visit the
following pages
Variables pane
• Name: represents the context and structural features of a model being simulated. The [] and {}
notations are automatically shown after the structural feature as follows:
• []: the current State and number of Events of a State Machine and multiplicities.
• {}: constraint expressions with parameters and subsets.
• Value: represents runtime values of structural features from the Name column. A runtime value
can be the input or output of simulation. You can directly edit runtime values in the Value
column if they are Boolean, Integer, Real, and String.
The following table lists the toolbar buttons and options of the Variables pane
Bu Name Function
tto
n
Export to New To create a new InstanceSpecification and export a selected runtime object to a
Instance newly created Instance Specification.
Options: To allow displaying and filtering elements in the Variables pane. Each option will
be available only when the simulating model contains such kind of element to be
filtered.
• Causality To show the Causality column. The value of a property represents the result of
evaluating a mathematical equation(see page 421): None, Given, and Target. You
can change the causality of the property using the symbolic math toolbox if the
parametric evaluator, e.g., MATLAB, supports solving symbolic expressions.
• Show To display the simulation time near the Options button. The value can be paused
Simulation when clicking the Pause button and disappear when clicking the Stop the
Time simulation button.
• Show To display the Requirement column. The value is shown only for properties that
Requirement have Satisfy Relations with the Requirements in req IDs (req text format).
• Show Margin To display the Margin column. The value is calculated from value properties and
the Requirement boundary with a Satisfy Relation.
The result of selecting the Show Simulation Time, Show Requirement, and Show
Margin options of the Variables pane.
Related page
On this page
With the Watch pane, you can easily monitor selected properties and their expressions with runtime
values while debugging. The Watch pane displays a flat list of selected runtime values during model
simulation.
The Watch pane with expressions and their selected runtime values during
model simulation.
The Watch pane automatically shows all Watch actions. Also, you can manually open it by clicking the
Watch button on the Simulation toolbar. This pane contains two columns:
• Name/Expression that can be edited. When you add a Watch item(see page 214), it will be shown
in this column.
• Value that is read-only. When you add a Watch item, its value will be in this column. The Value
column will be highlighted in red or green the same as in the Variables pane. If the added item
Note
• If the Simulation toolbar is locked (in Monte-Carlo and Trade Study simulation), the
Watch pane will be disabled to maximize the performance.
• When adding items at runtime, the value will be evaluated and updated for all property
changes and state changes on each clock tick. However, if you add properties before
runtime, the value will not be evaluated until the simulation runs.
button . Simulation will automatically save the selected language in the list box.
Adding a Watch action via the Console pane using the Watch button.
Through the Watch pane, add an item manually by either clicking the + symbol in the table or on
the Watch pane toolbar. The + symbol will automatically move to the next row of the table after the
item has been added successfully.
Note
• You can add a name of a property without using the root object because the context of
the Watch pane is the main root context.
• A name of Type can also be used, if the name of a property does not exist, e.g.,
spacecraft.telecom.ma = 35.
• Multiplicity used will be shown as a flat list of an array of strings, e.g., Trade-
Study.MaxEfficiency.x = [0.4761, 0.4761,…, 0.4237].
• You can specify an index of Multiplicity starting at 1, e.g., Trade-Study.MaxEfficiency.x[1] =
0.4761.
Using SelectPropertiesConfig
You can use a «SelectPropertiesConfig» as the predefined list of properties and add it to a
SimulationConfig(see page 49) by following these steps:
Note
The Watch Properties will be shown in Expert & All view mode.
• To remove all items, click . All items will be removed after closing the project.
Cameo Simulation Toolkit allows you to show the plot between runtime values, which are the numerical
value and simulation time. This plot is called Time series chart. To view this chart during a model
simulation, right-click the row of a runtime value in the Variables pane and select Show in time series
chart.
Related page
You can create a new value or object through the shortcut menu Add Value of a property typed by a
primitive type, a Class, or a block in the Variables pane. The shortcut menu will be available only when
the number of existing values or objects of the selected property is less than the upper multiplicity of
the property.
If a property is typed by a class or a Block, Cameo Simulation Toolkit will show a list of Classes or Blocks
containing the Class or the Block that types the property and all of its subtypes, which are not abstract
Classes or abstract Blocks. When you select a Class or a Block from the list, Cameo Simulation Toolkit
will initialize an object from that Class or Block and set the object as the value of the property.
Related page
With Cameo Simulation Toolkit, you can use a Classifier with nested parts as the simulation context
without the need to create Instance Specifications for those nested parts. Cameo Simulation Toolkit will
create runtime objects for those parts automatically. If the type of a property is Data Type, the default
value of the runtime value of that property will also be created, depending on the default value of the
property's type. In addition, if the type of the part contains a specified Classifier Behavior, and the type
itself is set as active, the Behavior will run (the autoStartActiveObjects option in the SimulationConfig
must be set as true).
The first figure shows a Class diagram located in the FlashingLight.mdzip sample, demonstrating
property light, button and timer as parts of the System Class.
On this page
At the beginning of a model simulation, Cameo Simulation Toolkit will create a runtime object to store
runtime values. If the element to be simulated is an InstanceSpecification or an SimulationConfig whose
SimulationTarget is InstanceSpecification, the runtime values will be generated from the slot values.
These runtime values will later be assigned to the runtime object's structural features that are
equivalent to the defined feature of the slots.
If the slot of the InstanceSpecification is empty, and the defined feature of the slots has a defined
default value, Cameo Simulation Toolkit will generate a runtime value from the default value and assign
it to the structural feature of the runtime object.
The following figure shows the example of a runtime object that is created for executing the pipe
InstanceSpecification. The length slot of the InstanceSpecification contains only one value, which is 1.0.
The runtime value, which is produced for the length structural feature of the runtime object, will equal
this slot value (1.0), while the runtime values of radius and thickness will equal the default values of the
radius and thickness property of the Pipe class (0.05 and 0.002 respectively).
You can also see a representation of the element's name in tooltip as in the Value column if you point
over the element being activated on the diagram pane.
Note
If a runtime object is not created from an instance specification, the Go To command will be
disabled on the context menu.
To locate and highlight an Instance Specification in the Containment tree through the Variables pane
1. Right-click a runtime object in the Variables pane and select Go To. The name of the Instance
Specification that you used so as to create the runtime object will appear on the submenu.
Related pages
On this page
61 https://docs.nomagic.com/display/MD2021xR2/Containment+Tree
Cameo Simulation Toolkit is capable of initializing both context and runtime objects automatically even
if a simulation context does not exist, and no object is configured to initiate the runtime objects.
Context initialization
When executing a Behavior, Cameo Simulation Toolkit allows you to simulate its context as well.
• Right-click a Behavior or a Behavior's diagram and select Simulation > Run with Context to
execute it together with its context.
• Right-click a Behavior or a Behavior's diagram and select Simulation > Run to execute it without
its context.
If a selected Behavior has no context, the Run with Context menu will be disabled.
The value of each feature (property) will be automatically initialized only if its Lower-
value Multiplicity is more than zero or is undefined. Otherwise (the feature's Lower-
value Multiplicity is zero), the feature value will be empty (nothing is initialized). However,
The datatypes which are affected by this option are listed in the table as follows
• UML Standard Profile::UML2 All numerical data types pick up their default initialization
Metamodel::PrimitiveTypes::Integer value from Environment Options as shown in the above
• UML Standard Profile::UML2 figure
Metamodel::PrimitiveTypes::
UnlimitedNatural
• PrimitiveValueTypes::Integer (SysML
Profile.mdzip)
• PrimitiveValueTypes::UnlimitedNatural
(SysML Profile.mdzip)
• UML Standard Profile::MagicDraw
Profile::datatypes::int
• UML Standard Profile::MagicDraw
Profile::datatypes::long
• UML Standard Profile::MagicDraw
Profile::datatypes::short
• UML Standard Profile::UML2 All numerical data types picks up their default initialization
Metamodel::PrimitiveTypes::Real value from the Environment Options as shown in the above
• PrimitiveValueTypes::Real (SysML figure
Profile.mdzip)
• UML Standard Profile::MagicDraw
Profile::datatypes::double
• UML Standard Profile::MagicDraw
Profile::datatypes::float
• If the structural feature has a non-empty slot value, it will be initialized with such value.
• Otherwise, if the structural feature's default value is specified, it will be initialized with the default
value.
If the structural feature also has internal feature(s), for each internal feature, the conditions are applied
as follows
• If the Datatype has internal structural feature(s), the value of the structural feature will be
initialized as described in Structural feature typed by non-datatype(see page 0).
• If the Datatype has no internal structural feature, the following conditions are applied
• The value of the structural feature will be initialized as described in Structural feature
typed by primitive datatype(see page 232) if the Datatype is inherited from a primitive
datatype.
• The initialized value of the structural feature will be its default value if the Datatype is not
inherited from any primitive datatype. If the default value of the feature is, however, not
specified, the initialized value will be empty.
Related pages
A connector can carry a runtime value over from one connectable element to another if the following
three conditions are present
• Datatypes on both elements are the same or compatible (equality of value can be defined), or
one is the subtype of another.
• If the elements are nested features, the owner of the nested features must exist.
• If the elements are nested properties, in this example, b1, a connector must be drawn from a3 to
the port and from the port to b1 because UML does not have a concrete definition about nested
properties. However, SysML does have a definition about nested properties; therefore, the
connector can be drawn between nested properties without the help of any ports.
• Connector62
• Binding Connector(see page 484)
Cameo Simulation Toolkit will automatically run a compatibility check every time you assign a value to a
feature during simulation. It checks the value against the feature's type. The value you assign must
correspond with the type of the feature, meaning you can assign only values that are compatible with
62 https://docs.nomagic.com/display/MD2021xR2/Connector
• UML Standard Profile::UML2 Strings that can be cast to numbers (If the string is
Metamodel::PrimitiveTypes::Integer a real number, the floating point will be
• PrimitiveValueTypes::Integer (SysML eliminated).
Profile.mdzip)
• UML Standard Profile::MagicDraw Natural number datatypes
Profile::datatypes::int
• UML Standard Profile::UML2
Metamodel::PrimitiveTypes::
UnlimitedNatural
• PrimitiveValueTypes::UnlimitedNatural
(SysML Profile.mdzip)
• UML Standard Profile::UML2 Strings that can be cast into positive numbers.
Metamodel::PrimitiveTypes::UnlimitedNatural
• PrimitiveValueTypes::UnlimitedNatural (SysML Real and integer (positive) numbers including the
Profile.mdzip) following datatypes
• Primitive63
You can export the values of a runtime object through the Variables pane to the following
Specifications
• a new InstanceSpecification.
• an existing InstanceSpecification.
• the InstanceSpecification that created the runtime object. Once exported, the values of a runtime
object will be set to the slots of the InstanceSpecification.
63 https://docs.nomagic.com/display/MD2021xR2/Primitive
• A new InstanceSpecification.
• An existing InstanceSpecification.
If the element is an InstanceSpecification, you can export the values of the runtime object to either of
the following
• A new InstanceSpecification.
• The same InstanceSpecification that you used to create that runtime object.
2. The Select Owner dialog will open. Select the owner of the new InstanceSpecification (the
system folder).
2. The Select Instance dialog will open. Select an InstanceSpecification that will be used to save
the runtime object (You can select only the InstanceSpecification whose classifier is the same as
that of the runtime object).
To export a runtime value to the InstanceSpecification that has created the runtime object
3. Click the hyperlink, and you will see the exact Instance Specification in the Containment tree.
This method allows you to export the value of the runtime object to the slots of the Instance
Specification that has created the object. You can see the notification of each successful export and a
location hyperlink, if any, in the Simulation Console pane.
Note
To export the value of a runtime object using this method, the runtime object must be created
from an Instance Specification.
On this page
Prerequisites
If you want constraint failures to be displayed in an Instance Table, the Simulation Profile must
be used in your model.
The Requirement(s) table shows that the constraint in the Requirement is not met, thus the
Requirement is colored in red as follows
The instance table showing the constraints after being exported to an Instance.
VerificationStatus stereotype
The status (pass/fail), related Requirements, and instances for constraints are recorded using the
VerificationStatus stereotype that is applied on the Value specification of the properties that you are
working on. You can also see the detail of the constraint failure in the tooltip when hovering the mouse
over any highlighted red values in the Requirement/Instance table as shown in the following figure
Failed State Invariant with highlighted red values and the tooltip.
If the VerificationStatus state on the Value specification fails, the active validation will be marked for
notification with the fail status tag as shown in the following figure
Tag Description
margin The Requirement margin value calculated from value properties and the Requirement boundary
(a satisfy Relation).
Setting the Remember Failure Status tag of a SimulationConfig to record the fail status and timestamp if
available.
Related pages
• Requirement Table64
• Variables pane(see page 209)
When an object acquires the properties of another, there is an inheritance relationship between them.
The object that inherits the properties is called Subtype or Subclass (child) and the inheriting object is
called Supertype or Class (parent). This inheritance relationship allows the child and the parent to have
identical properties. If the property has a value, the Subclass will also inherits the value. Cameo
Simulation Toolkit allows you to change the default value of an object or a Subtype whose property is
defined in the Supertype or a read-only property. You can override this existing value in the subtype
without changing the default value of the property of the Supertype by creating a redefine property of
the subtype that represents the default values. The value of the property can be integer, real, or string.
When you change the inherited value in the subtype, e.g., from 2 to 3, in the Variables pane, the
simulation will initiate at 3.
64 https://docs.nomagic.com/display/SYSMLP2021xR2/Requirement+Table
2. A Question dialog will open asking if you want to redefine the values in the Subtype. Click Yes.
3. On the Variables pane, change the default value of property i, r, and s of ExternalSubSystem.
4. Each time you finish updating the value, right-click the property in the Variables pane and
select Save ToDefault Value(s).
Related page
• Redefine65
Breakpoints
Cameo Simulation Toolkit allows you to add or remove breakpoints to or from model elements. A
model simulation will pause when these model elements are activated during the simulation. You can
open the Breakpoints pane to see and manage all of the existing breakpoints in an active project.
The Breakpoints pane lists all breakpoints with their properties shown in separate columns.
65 https://docs.nomagic.com/display/CDMP2021xR2/Redefine
Colu Function
mn
Enab To display the enabled or disabled state of a breakpoint. If the value is true, the breakpoint is enabled.
led Otherwise, the breakpoint is disabled. A model simulation will be suspended at that particular
breakpoint only when the breakpoint is enabled (true).
Elem To represent a model element to which each breakpoint is applied. The model simulation will be
ent suspended when the symbol of the element is activated or deactivated (depending on the value in the
Suspend column).
Cond To represent a breakpoint condition, a boolean expression, that will be evaluated when a model
ition simulation reaches the element to which a breakpoint is applied. The simulation will be suspended at
that particular element or breakpoint when the result of the boolean expression is true. If the condition
is not defined, the simulation will always be suspended when it reaches that particular breakpoint.
Susp To suspend a model simulation. There are three kinds of simulation suspensions: On Entry, On Exit,
end and Both.
• On Entry to suspend simulation when a breakpoint's element is activated.
• On Exit to suspend simulation when a breakpoint's element is deactivated.
• Both to suspend simulation once a breakpoint's element is either activated or
deactivated.
Related pages
Adding breakpoints
You can add a Breakpoint to a model element using the model's Add Breakpoint(s) context menu.
Removing breakpoints
You can remove a Breakpoint from a model using the model's Remove Breakpoint(s) context menu.
To remove a Breakpoint
To validate a model
1. From the main menu, click Project > Options to open the model validation option in the Project
Options(see page 47) dialog.
2. On the left pane, click General > Simulation.
3. In the Simulation Framework group, select the Check Model Before Execution option.
4. Click OK.
5. Simulate your model. A dialog will open, asking whether you want to load the required profiles
that contain the validation rules to validate your model (if your project does not contain the
required validation rules).
Related page
Cameo Simulation Toolkit allows you to perform a State Machine Simulation (State Chart Simulation) on
existing State Machine diagrams, based on the W3C SCXML standard. This kind of simulation is
frequently used in the early stage of software development by designers or analysts to test the flow of
the software to be developed.
The W3C SCXML standard provides a generic State machine-based simulation environment based on
the Harel Statechart. SCXML is capable of describing complex State machines, including Substates,
concurrency, history, time events, and many more. Most of the things that can be represented as UML
statecharts, e.g., business process flows, views on navigation bits, interaction or dialog management,
and many more, can leverage the SCXML engine. When executing a State Machine, the SCXML engine is
capable of finding an initial state automatically even if the initial node is not defined. This feature is also
applicable to composite States and orthogonal States.
In addition to simulating an executable model as a demonstration tool to validate and verify the system
Behavior at key milestone reviews, the State Machine simulation supports exporting the UML State
Machine to standard SCXML files for further analyses or transformations.
Related pages
Supported elements
Most of the elements on a State Machine diagram are supported as follows
Currently, Cameo Simulation Toolkit can simulate only those elements whose types are specified in the
supported elements table in Supported elements(see page 258). Thus, you must modify your model so
that only the supported (executable) elements are included in your State Machine diagram.
State Machine simulation can be adapted in different useful ways, as shown below:
• Deferred Events
(see page 277)Utilizing deferrable Triggers to save deferred Events for future processing until States
are entered.
If you want a runtime object(see page 207) to change its State66 on a Transition67, you need to define a
Trigger68 on the Transition by assigning an Event Type to a Transition69. A runtime object will change its
State when it receives a Trigger on the Transition. A Trigger can be a Signal Event70, a Time Event71, or a
Change Event72.
66 https://docs.nomagic.com/display/MD2021xR2/State
67 https://docs.nomagic.com/display/MD2021xR2/Transition
68 https://docs.nomagic.com/display/MD2021xR2/
State+Machine+diagram+elements#StateMachinediagramelements-Trigger
69 https://docs.nomagic.com/display/MD2021xR2/Assigning+Event+Type
70 https://docs.nomagic.com/display/MD2021xR2/Event#Event-SignalEvent
71 https://docs.nomagic.com/display/MD2021xR2/Event#Event-TimeEvent
72 https://docs.nomagic.com/display/MD2021xR2/Event#Event-ChangeEvent
Tip
Optionally, you can also use a Send Signal Action73 of an Activity(see page 26) as a Signal Event of
Transition. As shown in the following figure, the stopped State can wait for the off Send Signal
Action of the do Activity to proceed to the final State.
73 https://docs.nomagic.com/display/MD2021xR2/Send+Signal+Action
Note
According to UML Version 2.5.1, the initial Transition must not have Triggers or Guards.
However, Simulation provides the validation rule to prevent the model error by displaying a
warning in the Validation Results panel74. You can select the Check Model Before
Execution option in the Simulation Project options through validation and verification(see page
254) or manually select Pre-execution constraints from the Validation Suite75 drop-down list in
the Validation dialog76.
Related page
You can specify Guard conditions on Transitions using any action language. Open
the SmallTestSamples.mdzip to see an example of how to specify Guards on Transitions.
You can use the properties of a context Classifier (the Classifier that is the context of a State Machine
diagram) in Guard expressions as variable names. The real values of the variables will be resolved at
runtime. In the example in SmallTestSamples.mdzip, the values come from the slots of the instance of
the context Classifier (see the Instance diagram in the sample project).
74 https://docs.nomagic.com/display/MD2021xR2/Validation+Results+panel
75 https://docs.nomagic.com/display/MD2021xR2/Validation+dialog#Validationdialog-
descrDescriptionofValidationdialogoptions
76 https://docs.nomagic.com/display/MD2021xR2/Validation+dialog
The Question dialog box appears for any Guard not Boolean expression
evaluation during the simulation.
Note
States can have defined Behaviors for any Activities: Entry, Exit, or Do Activity. Cameo Simulation Toolkit
creates a new simulation session to simulate those defined Behaviors. A defined Behavior can be an
Activity, a State Machine, an Interaction, or an OpaqueBehavior. The simulation engine corresponding
to a defined Behavior will be used to simulate a model. If the defined Behavior is OpaqueBehavior, the
ScriptEngine will be used to simulate the code in the body of OpaqueBehavior.
Related pages
• Opaque Behavior77
Once the Activities Entry, Exit, and Do Activity of a State have been specified with a Behavior that has
input parameters, a signal, which triggers objects to change the State, can carry values to the input
parameters.
77 https://docs.nomagic.com/display/MD2021xR2/Opaque+Behavior
• The number and order of properties of the signal must be the same as the number and order of
parameters in the Behavior.
• The type, the order (isOrdered), and the multiplicity of each property of the signal must be the
same as the corresponding parameter of the Behavior. If the type of signal properties are
Subtype of the parameter type, it is considered a match.
If one of the two conditions is not satisfied, a warning will appear once the model is validated by pre-
simulation constraints before the simulation starts.
A send signal Action in an Activity can create a signal instance with the values of its structural features.
For example, the signal MySignal shown in the following figure. It contains three properties: attrib1,
attrib2, and attrib3. They are created with Real, String, and Boolean respectively.
Now that the pins of the send signal Action have been created, you can specify the values of the signal
Instance through them (see the following figure). The figure shows the value specification Actions that
are used to create the values and add them to the pins of the send signal Action.
In the following figure, the object has accepted the signal Instance, that is MySignal, and it will move
from State1 to State2. A performOnEntry activity, which is the entry Activity of State 2 will be simulated.
The performOnEntry Activity contains three parameters which are param1, param2, and param3. They
are typed by Real, String, and Boolean respectively.
Cameo Simulation Toolkit provides State Activation Semantics as one of the simulation options. This
option allows you to determine whether Cameo Simulation Toolkit activates an Entry Behavior before
or after activating an entry of State. You can select one of the options: After entry and Before entry.
The After entry option allows activating the entry of State after the Entry Behavior is completely
activated. The Before entry option allows entering the entry of State before executing the Entry
Behavior.
Completion Events are standard UML Events which are fired during the execution of a State Machine
diagram. For composite or submachine States, a completion Event will be generated when all internal
Activities, e.g., entry and doActivity Behaviors, have completed execution under either of the
following circumstances
• If the State is a composite State, all its orthogonal Regions have reached a FinalState.
• if the State is a submachine State, the submachine StateMachine execution has reached a
FinalState.
TIP
You can enable/disable the Completion Events and Transitions option in the SCXML Engine
group in the Project Options(see page 47) dialog for completion Events and Transitions support.
Case 2
Case 3
Information
Completion Events have dispatch priority over all other Events. They are put into the beginning
of the Event queue.
Deferred Events
On this page
UML State Machines provide a special mechanism for deferring Events in States. In every State, you can
include a clause [Event list]/defer. If an Event in the current State’s deferred Event list occurs, the Event
will be saved (deferred) for future processing until a State is entered that does not list the Event in its
deferred Event list. Upon entry to such a State, the UML State Machine will automatically recall any
saved Event(s) that are no longer deferred and will then either consume or discard these Events.
Deferrable Trigger
A list of Triggers that are candidates to be retained by the State Machine if they trigger no transitions
out of the State (not consumed). A deferred Trigger is retained until the State Machine reaches a State
configuration where it is no longer deferred.
78 https://docs.nomagic.com/display/MD2021xR2/State+Machine+diagram
Important
This version of Cameo Simulation Toolkit does not support Deferred Events for Activity
diagrams. They can now only be added to a State in a State Machine diagram.
Related page
Cameo Simulation Toolkit will perform a State Machine simulation if the following elements are
selected for the simulation
• A State Machine.
• A State Machine diagram.
• A class whose Classifier Behavior is defined by a State Machine.
• An InstanceSpecification whose Classifier is a Class that has a defined Classifier Behavior with
a State Machine.
79 https://docs.nomagic.com/display/MD2021xR2/State+Machine+diagram
You can trigger a transition directly on a diagram. The menu Fire Transition on the smart manipulation
toolbar triggers a transition and sends it to the activeObject that is displayed on the diagram. The Fire
Transition command ignores guards.
• Either select a target object from the Variables pane and right-click a transition line on the
diagram, and select Fire Transition.
• During the simulation, click a transition line on the diagram and select Fire Transition.
Related pages
80 https://docs.nomagic.com/display/MD2021xR2/State+Machine+diagram
On this page
You can specify a duration constraint on any State in a State Machine. The minimum and maximum
duration spent by the State can be provided through min and max of the duration constraints.
You can use one of the four different modes: min, max, average, and random, to simulate a State that
has a duration constraint. You can select a duration mode through the value of
the durationSimulationMode tag of the «SimulationConfig» stereotype.
Cameo Simulation Toolkit supports the following time suffixes: ms (millisecond), s (second), m or min
(minute), h (hour), and d (day). You can parse the time unit that is specified as a suffix after a number or
at the end of an expression string. If you do not specify a suffix, the millisecond will be used by default.
The examples are as follows
Min
When you select min as the duration simulation mode, Cameo Simulation Toolkit will increase the time
spent on a State Machine by the min duration specified on the duration constraint when the element,
to which a duration constraint is applied, is activated.
Max
If you select max as the duration simulation mode, Cameo Simulation Toolkit will increase the time
spent on a State Machine by the max duration specified on the duration constraint when the element,
to which a duration constraint is applied, is activated.
Average
When Cameo Simulation Toolkit simulates your model with the average duration simulation mode, it
will use the average value between the max and min duration of the duration constraint as the
duration of time spent on simulating the element, to which the duration constraint applied.
If you simulate a model without specifying any duration simulation mode, Cameo Simulation Toolkit will
ignore duration constraints and obtain the time spent on simulating the States and State Machines
from the simulation clock.
If you simulation a State that has a duration constraint with a duration simulation mode and the time
spent on Entry, Exit, and DoActivity Behaviors are beyond the range of the duration constraint specified
on the State, the State will be considered as a broken constraint element, and Cameo Simulation Toolkit
will pause the model simulation at the State.
Related pages
Sample projects
On this page
The State Machine simulation sample projects are available in the built-in Small Tests samples, in
<modeling_tool_installation_directory>\samples\simulation\SmallTestSamples.mdzip or from the Welcome
screen under the Simulation group of the modeling tool. In this topic, the focus is on the State Tests
section for the State Machine simulation sample projects as follows:
81 https://docs.nomagic.com/display/MD2021xR2/State+Machine+diagram
• Do Activity in State
This test is designed to demonstrate how to use the Do Behavior in model execution. Run the
TestState_DoActivity simulation configuration to see how it works.
• Guard
This test is designed to demonstrate how to use Guards on Transitions in model execution. Run
the TestState_Guard simulation configuration to see how it works.
• History
This test is designed to demonstrate how to use the Composite State with Shallow History and
Deep History in model execution. Click the Run button on the diagram toolbar to see how it
works.
• Regions
This test is designed to demonstrate how to use the Orthogonal State with Parallel Regions and
Entry and Exit Activities in model execution. The Entry Activity is executed immediately after the
State Machine is activated before any States in the inner regions. Next, all Initial States in the
regions are activated simultaneously. The Regions sample demonstrates that multiple active
States are executed at the same time. The Event list in the Simulation Console contains Triggers
of all outgoing Transitions of all active States. If one of the parent States’ outgoing Transitions is
triggered, the Exit Activity will be executed before the State Machine is deactivated. Click the Run
with Context button on the diagram toolbar to see how it works.
• Timing Events
This test is designed to demonstrate how to use timing Events in model execution. Both relative
time and absolute time are supported (Is Relative=true/false). Click the Run button on the
diagram toolbar to see how it works.
Activity simulation
Activity simulations essentially require the Activity simulation engine in Cameo Simulation Toolkit to
perform all Activity-based simulations. The details are outlined in the following topics:
• Executing Activities
(see page 311)Suspending the simulation with breakpoints.
On this page
Cameo Simulation Toolkit provides an Activity simulation engine that allows you to run an Activity
Simulation on Activity diagrams83 or Activity Elements. Cameo Simulation Toolkit also includes the
implementation of OMG Semantics of a Foundational Subset for Executable UML Models (fUML), an
executable subset of standard UML, that can be used to define the structural and Behavioral semantics
of systems. fUML defines a basic virtual machine for the Unified Modeling Language and supports
specific abstractions enabling compliant models to be transformed into various executable forms for
verification, integration, and deployment.
Various UML Activity diagram concepts are supported, including Object and Control Flows, Behavior
and Operation Calls, sending Signals via Connectors with or without Ports in Internal Structure,
accepting Signals and Time Events, Pins, Parameters, Decisions, Structured Activity Nodes, and many
more.
82 https://docs.nomagic.com/pages/viewpage.action?pageId=17678471
83 https://docs.nomagic.com/display/MD2021xR2/Activity+diagram
Note
• SendSignalAction has the Target input Pin for specifying the signal receiver. If this
Pin is omitted, the signal instance will be sent to the context itself.
• The On Port property on SendSignalAction is used for sending signals via the
specified port.
Note
• You can simulate only Activities that are owned by a Package or a Class. As a
workaround, the CallBehavior Actions, owned by the Call Behaviors in a Package, will be
used for the entry/do/exit Behaviors in States.
1. On the main menu, click Options > Project and select Simulation on the left of the
Project Options dialog.
2. Select the Use fUML DecisionSemantics value check box so that the value becomes
false. The value is false by default in the UML mode.
• Control Flow
• Object Flow
• Input Pin
• Output Pin
• Activity Final Node
• Flow Final Node
• Activity Parameter Node
• Decision Node
• Merge Node
• Join Node
• Fork Node
• Structured Activity Node
• Conditional Node
• Loop Node (the setup part will not be executed as the fUML specification.)
• Expansion Region
• Expansion Node
• Object Node
• Central Buffer Node
• Data Store Node
• Actions
• AcceptEventAction
• AddStructuralFeatureValueAction
• CallBehaviorAction
• CallOperationAction
• ClearAssociationAction
• ClearStructuralFeatureAction
• CreateLinkAction
• CreateObjectAction
• DestroyLinkAction
• DestroyObjectAction
• OpaqueAction
• ReadExtentAction
• ReadIsClassifiedObjectAction
• ReadLinkAction
• ReadSelfAction
1. On the main menu, click Options and select Project. The Project options dialog opens.
2. On the left pane, click General > Simulation.
3. Go to the fUML Engine group and set any of the properties as desired.
The settings for the fUML engine are in the following table.
Property Function
Use fUML Decision If true (false by default when in the UML mode), all Guards will be solved to true
semantics when the flowing token value matches the Guard value (instead of evaluating every
Guard as Boolean operation).
Auto Create fUML Object If true, automatically create an fUML object of output.
of Output
Pass Caller Context If true, pass the caller context to the called Behavior if it does not have its own
context specified. Otherwise, use the Behavior itself as context.
Terminate Nested If true, terminate nested Part Behaviors if their parent object Behavior is
Behaviors terminated.
Note
You can instantiate nested composite structure using the standard PSCS construction
mechanism by default.
ReadLine support
ReadLine is a function that allows the user to enter value through the input line on the Console pane. A
Call Behavior Action can be set Behavior as ReadLine [fUML_Library::BasicInputOutput] using
fUML_Library.mdzip from the Use Project dialog. Before using the ReadLine function, you need to
include fUML_Library.mdzip in the project first.
1. Click File > Use Project > Use Local Project from the main menu to open the Use Project
dialog.
4. In the directory tree list, select fUML-Library and click Next> to proceed to the next step.
Then a Call Behavior Action can now be set Behavior as a ReadLine Element. The ReadLine Element will
be shown with two default Pins, i.e., result and errorStatus. During the simulation, the ReadLine
Element is executed to allow entering value through the input line on the Console pane. The result of
the ReadLine Element can be used by other Elements with any proper data types, e.g., Guard, as in the
following figure
Guards in Swimlanes
Simulation supports Guards in Swimlanes in the Activity diagram as shown in the figure below. See also
Using Guards on Transitions(see page 262) and Swimlane84.
84 https://docs.nomagic.com/display/SYSMLP2021xR2/Swimlane
You can simulate a UML Activity or a Classifier whose Classifier Behavior is defined by an Activity. This
section demonstrates how to create a simple but executable Activity model through the following steps
85 https://docs.nomagic.com/display/MD2021xR2/Decision+and+Merge
86 https://docs.nomagic.com/display/MD2021xR2/Action
1. To create a new UML project, click File > New Project on the main menu. The New
Project dialog will open.
2. Select SimulationProject from the Simulation group and specify the project's name, e.g.,
"SimpleActivitySimulation".
3. Specify the location where you want to save your project file, and then click OK.
4. Right-click the Model model in the containment browser and select Create Element > Class. A
new Class element, which is the context of the Activity, will be created in the containment
browser. Name the created Class, e.g., "SumPrinter".
5. Add two properties: x and y of type Integer.
Right-click the SumPrinter Class and select Create Element > Property. Type 'x' to name the
property (see the first figure below). Right-click x and select Specification to open
its Specification window. Select Integer as the property type (see the second figure below).
7. Once the Properties x and y have been created, define the Behavior of the created Class: Specify
the Classifier Behavior of the SumPrinter Class with a UML Activity element.
1. Right-click the SumPrinter Class in the containment browser and select Specification to open
its Specification window.
2. Select All from the Properties drop-down menu to make sure that all of the properties are listed
in the dialog.
3. Click Classifier Behavior and select the PrintSum Activity from the drop-down list on the right-
hand side.
To create an opaque Behavior to print the summation value of the two input parameters of
type Integer:
1. Right-click the Model model in the Containment tree and select Create
Element > Opaque Behavior. A new opaque Behavior will be created under the Model model.
2. Name it "PrintSumOfIntegers". The following figure shows the PrintSumOfIntegers Opaque
Behavior in the Containment browser.
5. Repeat Steps 3-4 to create Parameter b as shown in the following figure that shows the
PrintSumOfIntegers Opaque Behavior containing Parameters a and b in the Containment
browser.
• Open the Specification window of the PrintSumOfIntegers opaque Behavior and write a script
in the Body field (You can use any scripting language that is supported by MagicDraw's
Macro Engine, e.g., BeanShell, Groovy, JavaScript, Python, or Ruby). In this example, JavaScript will
be used to print the summation of the given integer values that are referred to by the
parameters a and b; therefore, the script will be: "print(a+b)".
The next step is to complete the PrintSum Activity diagram of the SumPrinter Class and add
a ReadStructuralFeatureAction so that the values of properties x and y, which are owned by
the SumPrinter Class, are readable. The values of a and b will later be passed on to
the PrintSumOfIntegers opaque Behavior as the values of input parameters a and b respectively.
4. Click Action and select Any Action from the Activity Diagram toolbar on the PrintSum Activity
diagram.
a. Select Read Structural Feature Action in the Select Action MetaClass dialog.
To create a ReadSelfAction to read a runtime object that will be supplied to the input pins
of readX and readY Actions
1. Click Action > Any Action on the Activity Diagram toolbar. The Select Action MetaClass dialog
will open (see the following figure).
The final step is to create an InstanceSpecification whose Classifier is the SumPrinter and assign the
values to the slots that correspond to the properties x and y. These values will be used during the
simulation.
To create an InstanceSpecification whose Classifier is the SumPrinter and assign the values to the
slots that correspond to the Properties x and y
1. Right-click the Model model and select Create Element > InstanceSpecification.
2. Name the created InstanceSpecification, e.g., instance.
5. Select the SumPrinter Class to edit the Classifier and click OK.
6. Click Slots on the left-hand side pane of the Specification window and select x:Integer.
Related pages
Executing Activities
You can add some breakpoints to the model created when Creating a model for Activity simulation(see
page 295) before executing it. This section demonstrates how to suspend the model simulation at some
specific points with breakpoints. You can use either the diagram or browser context menu to add a
breakpoint to an element.
The following example shows you how to add breakpoints to pins a and b of the action print. Once the
model simulation has reached these pins, the simulation will be suspended.
1. Right-click an element and select Simulation > AddBreakpoint(s). The breakpoints will be
shown in the Breakpoints pane of the Simulation window.
Clicking Window > Simulation on the main menu to open the Simulation window.
2. Right-click instance in the containment browser and select Simulation > Run to simulate the
model from instance, which is the InstanceSpecification of the SumPrinter Classifier.
5. Click the Resume button on the Simulation window toolbar to continue the simulation.
Note
If you do not want to display animation (silent simulation), you can create Simulation
Configuration to customize the simulation, select instance as the simulationTarget, and
set silent to true. See Simulating a Simulation Configuration(see page 42) and Simulation
Configuration and UI modeling(see page 46) for more information.
Related pages
Cameo Simulation Toolkit can simulate the time required to implement an Activity as specified by the
duration constraints. It calculates the total Activity duration by adding the simulation time of all visited
Actions, and aids in accurately identifying which activities take the longest time to complete. You can
see full details about the Activity duration for simulation, including the Activity names and the time
between the start and finish of an Activity, in the Simulation console(see page 200) by setting the Console
log's filter options(see page 205) to Info. An Activity can contain many Actions. You can specify a duration
constraint on any Action in the Activity. The minimum and maximum duration of an Action can be
provided through the min and max of the duration constraint. If you simulate the Activity with a
specific duration mode, Cameo Simulation Toolkit will compute the total time spent when simulating
the Activity for you.
When a Behavior's duration is empty or the time is unspecified, Cameo Simulation Toolkit will use the
duration of called Actions as the duration of the Behavior.
Note
If a Behavior has a property or a structural feature value named duration, Cameo Simulation
Toolkit will automatically assign the duration value to that particular feature value at runtime.
The duration value property must be defined in the Activity, e.g., Change Color as shown in the
following figure, or the parent of the duration value property. You can have only one duration
value property in the parent Activity to avoid creating multiple duration value properties.
Note
• If the Time Unit is less than 1 nanosecond, e.g. 0.5 nanosecond or 0.0005
microsecond, a warning message is displayed in the Console pane stating that the
default value of 1 nanosecond is applied.
Duration Description
Simulation
Mode
Min When you select min as the duration simulation mode, Cameo Simulation Toolkit will
increase the time spent on an Activity by the min duration specified on the duration
constraint when an element with an applied duration constraint is activated.
Max If you select max as the duration simulation mode, Cameo Simulation Toolkit will increase
the time spent on an Activity by the max duration specified on the duration constraint when
an element with an applied duration constraint is activated.
Average When Cameo Simulation Toolkit simulates your model with the average duration
simulation mode, it will use the average value between the max and min duration of the
duration constraint as the duration of time spent on simulating an element with an applied
duration constraint.
Random The random mode allows Cameo Simulation Toolkit to obtain the duration of time spent on
simulating an element with an applied duration constraint from a uniformly distributed
random number between the min and max duration of the duration constraint.
If you specify a duration simulation mode, the time spent on an Activity simulation will be calculated
from the duration constraint applied to the elements of the Activity. The duration of time spent on
simulating elements with no duration constraints will be zero. If you simulate a model without
specifying any duration simulation mode, Cameo Simulation Toolkit will ignore those duration
constraints and obtain the time spent on simulating the Actions and activities from the simulation
clock.
The Duration Simulation modes (min, max, average, and random) are available in the
model's Specification window87. You can specify the duration constraints of the Activity element by
entering the value in the element's Specification window.
87 https://docs.nomagic.com/display/MD2021xR2/Specification+window
To specify the duration simulation mode and the duration constraints of an Activity, and run the Activity
simulation
1. Either double-click or right-click a «SimulationConfig(see page 49)» (e.g., winter) on the diagram
pane and select Specification to open the Specification window.
2. From the Duration Simulation Mode property, select a duration type (e.g., min). The selected
duration mode will appear in the «SimulationConfig».
3. Click .
4. Open the rainy day scenario on the diagram pane and open the Specification window89 of each
element to specify the duration constraint for the selected duration simulation mode. In this
example, double-click 'dig the snow' and specify the duration constraint value.
88 https://docs.nomagic.com/download/attachments/20851829/DurationConstraint.mdzip?
api=v2&modificationDate=1505277500565&version=1
89 https://docs.nomagic.com/display/MD2021xR2/Specification+window
6. Right-click the «SimulationConfig» or click on the toolbar to run the simulation. View the
simulation results of the Activity duration in the Simulation window(see page 201).
The Run toolbar button triggers the command to run the simulation of
the «SimulationConfig».
If you simulate a call Behavior Action having a duration constraint with a duration simulation mode and
the time spent on the called Behavior is beyond the range of the duration constraint specified on the
call Behavior Action, the call Behavior Action will be considered as a broken constraint element. Cameo
Simulation Toolkit will then pause the model simulation at the call Behavior Action.
Note
If the duration constraints are defined on both Activity and Call Behavior Action, the constraints
of the Call Behavior Action will be used, and the constraints of the Activity will be ignored.
Concept Description
Activity(see page 26) The duration simulation mode specifies the duration to run the
simulation of the elements with applied duration constraints.
Duration constraint(see page 361) The duration constraint is an interval constraint that refers to
a duration interval. Use the duration interval to determine whether
the constraint is satisfied.
Call Behavior Action(see page 332) The call Behavior Action is a call Action that invokes
a Behavior directly rather than invoking an operation that invokes
the Behavior.
Sample model
DurationConstraint.mdzip90
Related pages
Duration analysis
Cameo Simulation Toolkit is capable of calculating the minimum, maximum, and average duration of
any Activity. It uses the values taken from duration constraints applied to each element in an Activity as
the basis to calculate the Activity's duration.
Cameo Simulation Toolkit can perform an analysis of activity duration in the two following scenarios
The duration analysis on visited elements feature is not enabled by default. To enable it, you need a
TimeHandler and register it in the execution listener of the <<SimulationConfig>>. You can create the
TimeHandler by creating a new Class and apply the <<TimeHandler>> stereotype.
90 https://docs.nomagic.com/download/attachments/82762134/DurationConstraint.mdzip?
api=v2&modificationDate=1505277500565&version=1
91 https://docs.nomagic.com/display/MD2021xR2/Specification+window
You can view the duration of a running Activity by using the diagram's context menu Analyze
Duration of Visited Elements.
1. Pause a currently running Activity by either adding a breakpoint or clicking the Pause button.
2. Right-click the diagram and select Simulation > Analyze Duration of Visited Elements.
Related pages
You can also perform an analysis of Activity duration after an Activity has been simulated. Prior to the
analysis, be sure that the simulation log has been configured and the value of a Record Activation tag
is true (see Simulation log(see page 59) for more information about the simulation log).
1. Right-click the simulation log and select Simulation > Analyze Duration of Executed Trace.
The Select Execution Session and Activity dialog will open (see the second figure below).
Related pages
When Cameo Simulation Toolkit simulates a CallOperationAction that does not have a target pin, it will
select a runtime object, which is the context of the Activity, as a target. For example, a System Class,
which owns a Sub-System Class (see the second figure below), is the context of the SystemBehavior
Activity shown in the first figure. The CallOperationAction will call the SayHello operation using the
Activity context, which in this case is the System Class.
If an Action belongs to an Activity partition, and the Activity partition represents part of a Classifier,
which is a context of that Activity, Cameo Simulation Toolkit will select the runtime object specified by
the part as the target of the Action.
However, Cameo Simulation Toolkit will direct the target object to the callOperationAction only if an
element represented by the Activity partition is a property (or an inherited property) of the Classifier,
which owns the Activity and if there is only one runtime object specified by the property represented by
the Activity partition. For example, if the CallOperationAction that calls the Print operation is in the
Activity partition, which represents the SubSystem property of the System Class, this will result in a call
to invoke the Print operation in the SubSystem property.
Related pages
If the Activity Partition represents a part/property, the object playing the Partition is the object playing a
part/ property that is represented by the Partition. If the Partition represents an InstanceSpecification,
the object which is initialized from such instance specification shall be the object playing the Partition (if
there is no object initialized from such instance specification yet, Cameo Simulation Toolkit shall
initialized when the Behavior execution of the Activity is initialized.
92 https://docs.nomagic.com/display/MD2021xR2/Call+Operation+Action
The following figure shows an example of the (Activity) system diagram on which a call Behavior
Action is placed within an Activity Partition. The context of the Activity Partition is the runtime objects of
workers. When the system model was run, the call Behavior Action was executed in the context of the
Activity Partition: workers. But since there were more than one worker, the simulation searched for a
worker that was not busy to perform the Behavior. If all the workers were busy, the simulation would
wait until one of them was available. If the call Behavior Action were outside the Activity Partition, the
context of the Behavior execution would be the system itself. The same also goes for an opaque
Action. If it is in the Activity Partition, the simulation will run the opaque Action using the context of the
property or the Classifier represented on the Partition.
• If the Behavior of the Action belongs to a Classifier of the object playing the Partition (or super
type of such Classifier), the context of the Behavior execution shall be the object playing the
Partition.
• If the Behavior does not belong to the Classifier of the object playing the Partition, but it belongs
to the Classifier of the object that is the context of the Activity containing the Action (or super
type of such Classifier), the Behavior execution shall be invoked in the context object of the
Activity containing the Action.
On this page
Previous versions of Cameo Simulation Toolkit did not support execution of incomplete or dummy
models. From the 18.4 version and above, it will be possible to execute incomplete or dummy models.
Previously, the execution would halt. Now, if any input pin does not have an accompanying value, the
Behavior of the Action will not be to halt execution, instead a null value token will be passed to that pin,
or when simulating a CallOperationAction which does not have a target pin, a runtime object, which is
the context of the Activity will be selected as the target.
The information on this page describes the Behavior of an Action when any of the input or output pins,
or any properties of the Action, are not specified or not present.
Supported Actions
The Actions which are currently supported are as follows
• AddStructuralFeatureValueAction
• ReadStructuralFeatureValueAction
• CallBehaviorAction
• CallOperationAction
• SendSignalAction
• ValueSpecificationAction
• StartClassifierBehaviorAction and StateObjectBehaviorAction
• OpaqueAction
AddStructuralFeatureValueAction
An add structural feature value Action is a write structural feature Action for adding values to a
structural feature. When any input pin is unspecified or empty, or when a Structural Feature is
unspecified or does not exist, this Action's Behavior will have the rules as follows
If an Object input pin is empty or unspecified, the runtime context of the Activity execution will be used
to add the value to the Structural Feature of the context.
ReadStructuralFeatureValueAction
A read structural feature Action is a structural feature Action that retrieves the values of a structural
feature. When any of the input or output pins are unspecified or not present, this Action's Behavior will
have the rules as follows
• If the Object pin is not specified, the runtime context of the Activity execution will be used as the
target.
• If Structural Feature is not specified or if the Structural Feature has no values, then a null
value token will be sent.
CallBehaviorAction
Call Behavior Action is a call Action that invokes a Behavior directly rather than invoking an operation
that invokes the Behavior. When any of the Argument pins are either unspecified or not present, this
Action's Behavior will have the rules as follows
• If any of the Argument input pins are unspecified, this Action will send a null value token for
that parameter.
CallOperationAction
A call operation Action is an Action that transmits an operation call request to the target object, where it
may cause the invocation of associated Behavior. When any input or output pin is unspecified or not
present, this Action's Behavior will have the rules as follows
• This Action will send a null value token for each unspecified Argument input pin.
• In case no Argument pin is specified, this Action will send null value tokens for all the
parameters.
• If the Result output pin is specified and this Action does not return any results, it will return
a null value token instead.
• If the Target input pin is not specified, the runtime context of the Activity execution will be used
as the target.
SendSignalAction
Send signal Action is an invocation Action that creates a signal from its inputs, and transmits it to the
specified target object, where it may cause the firing of a State Machine transition or the execution of
an Activity. When either Argument pin or Target input pin is unspecified or empty, this Action's
Behavior will have the rules as follows
• If there are any incomplete Argument pins, this Action will send null value tokens for those
parameters.
• If Argument pin is not present, this Action will send null value tokens for all parameters.
• If Target input pin is not present, the runtime context of the Activity execution will be used as the
target.
ValueSpecificationAction
A value specification Action is an Action that evaluates a value specification. When the value of a
ValueSpecification Action is not specified, this Action's Behavior will apply the rule as follows
• If the value of a ValueSpecification Action is not specified, a null value token will be passed.
• If the Object input pin is not present or empty, the StartClassifierBehaviorAction Action will
use the runtime context of the Activity execution as the target.
OpaqueAction
Opaque Actions are a type of Action that can be used to represent implementation information. They
can also be used as placeholder Actions until you determine the specific type of Action to use. If the
opaque Action does not return a value to the OutputValue pin, this Action's Behavior will apply the
rule as follows
• If the opaque Action does not return any value to the OutputValue pin, a null value token will
be passed to the pin at runtime.
Information
A "null value token" is an ObjectToken with has no values defined.
Simulation Toolkit has an option to support dummy tokens of CallBehaviorActions that do not have a
Behavior. Business-level abstract diagrams can be executed and animated because Simulation will
automatically create new objects according to type of those Output Pins if unspecified, even though this
action will break fUML semantics. You can set the Auto Create fUML Object of Output Pin option
(true by default) in the Environment Options Simulation dialog.
1. From the main menu, click Options > Environment. The Environment Options dialog opens.
2. On the left pane, click Simulation.
3. Under the fUML Engine group, set the Auto Create fUML Object of Output Pin option to true.
4. Select OK.
Related pages
Note
If the SimulationProfile package is not visible, click in the Containment tree pane and
select Show Auxiliary Resources.
93 https://docs.nomagic.com/display/MD2021xR2/Opaque+Behavior
On this page
You can model either non-streaming or streaming behaviors. Non-streaming behaviors consume their
input object tokens at the moment they begin executing and deliver their output object tokens when
they finish executing. If a system receives inputs and produces outputs even while behaviors continue
to execute, this is referred to as a streaming behavior.
• An Activity whose only streaming parameters are output parameters is terminated once all of its
actions finish executing.
• An Activity with streaming input parameters is terminated by an Activity final node or if the
execution is explicitly terminated by the Activity that invoked it.
• If the Terminate Streaming Behaviors by Output Parameter Multiplicity project option (or
Simulation Configuration property), is set to true, an Activity with streaming output parameters
terminates when each of its output parameters receives a cumulative number of values equal to
the upper bound of the parameter multiplicity.
• In the Specification window of a Parameter of a Pin or Activity Parameter Node, set the Is Stream
property to true.
Once you define parameter streaming rate, object tokens flow at fixed time intervals. This means that
the specified time interval (step 4) is divided by a specified number of tokens (step 2). For example, if
streaming rate is 3/min, object tokens are passed at fixed time intervals of 20 s. If a token does not
arrive at the specified time, then that time interval is skipped and object token is passed only after the
next fixed time interval. If there are more object tokens than an Action can accept, they wait in a
corresponding Pin and are passed after the next fixed time interval.
The execution of this Activity will not terminate even when all the Actions finish executing.
The following chart displays the timeline of the fully executed streaming Activity displayed above.
Interaction simulation
Cameo Simulation Toolkit comes with an interaction engine that can simulate an interaction element
based on the UML semantics. An interaction is a unit of Behavior that focuses on information exchange
among internal properties of a Class. You can use it to describe the main Behavior of the Class by
specifying the interaction as a Classifier Behavior of the Class. You can also assign it to be a method of
an operation of the Class. If an interaction is a Classifier Behavior, it will be simulated whenever the
object is started. If it is a method of an operation, it will be simulated when the operation is called.
• Message
(see page 357)Signal, Call, and Reply Messages indicating communication between Lifelines of
Interaction.
• CallEvent
(see page 360)Used when Operations are called without Methods.
• Duration constraint.
(see page 361)Delaying delivery of two Messages run consecutively.
• Time constraint
(see page 363)As timestamps when recording simulation.
• State invariant
(see page 363)Validating whether current States are true.
Lifeline
On this page
You can use a lifeline in a Sequence diagram to represent a property owned by a Class or a block that is
the context of the diagram. Sending messages between objects specifying the properties presented by
the lifelines can occur. Cameo Simulation Toolkit uses lifelines to find a source and a target object of
the message.
Note
Cameo Simulation Toolkit uses a lifeline with a dot notation to represent a nested property
when you record a simulation as a Sequence diagram. See Recording a Simulation as a
Sequence Diagram(see page 387) for more information about recording a simulation.
Information
A Found Message is a Message where the occurrence of a receiving Event is known, but the
occurrence of a sending Event is not.
Lifeline selector
If a lifeline represents a part with the multiplicity of more than 1 (neither * nor 1..*), the list will also
contain more than one object (not only one object) at runtime. The lifeline has the Selector expression
that specifies the particular part represented by the lifeline.
Cameo Simulation Toolkit supports the lifeline selector which allows specifying an exact object from the
Selector expression. The Selector expression will be evaluated as an index integer to get an Object from
the object collection.
Message
On this page
You can substitute values for input parameters of the called operation by specifying argument values
on a synchronous call message.
The simulation looked for the account object with that particular accountNumber and returned it to
the bank object with a reply message 2 (2 is a reply message of 1). The returned account object would
be specified as the value of the buyerAccount represented by the lifeline buyerAccount:Account. The
bank object would then call the operation getBalance() of the account object with a synchronous call
message 3 that caused the balance value to reply to the bank with a reply message 4 (4 is a reply
message of 3). Finally, the bank called itself to print the balance value with the
operation printBalance(balance:Real).
Note
You can stop the execution at breakpoints by setting the Constraint Failure As Breakpoint
option(see page 49) to true in the «SimulationConfig»(see page 49).
If the argument is not the name of a property, Simulation will verify (compare) the returned value from
the called operation with the argument value.
If the result of evaluating the argument is the name of a property owned by a target object, a context
object, or a source object, the value returned from the operation will be defined as the value of that
property. The reply message 2 in the preceding figure has an opaque expression whose body is
buyerAccount as an argument value.
buyerAccount is the property of the Balance Lookup Class which is the context of a sequence
diagram. Therefore, the returned account object from the operation of the ledger
object retrieveAccount(accountNumber : String) will be set as a value of the
property buyerAccount when the reply message 2 is simulated.
CallEvent
A CallEvent is a type of Event in UML elements supported by Cameo Simulation Toolkit. A CallEvent of
an Operation is triggered when you call an Operation with a specified Method. If an Operation is called
without a Method, the CallEvent will be automatically generated. You can use the CallEvent on
AcceptEventActions and Transitions as shown in the following figures.
Duration constraint
Simulation allows you to evaluate duration constraints between Call Messages and Reply Messages,
e.g., you can specify that a Call Message must get a Reply Message in 500 ms, so the actual duration of
operation method execution must be compared with the duration constraint of 500 ms. The
comparison is done as an evaluation of the constraint and will generate a fail value for testcases or stop
94 https://docs.nomagic.com/display/MD2021xR2/Accept+Event+Action
95 https://docs.nomagic.com/display/MD2021xR2/Transition
The default time unit of the duration constraint is millisecond (ms), but you can also use other time
units by specifying them after the duration value, e.g., you can use 10s to denote 10 seconds. If you
specify both the minimum and maximum values, Simulation will use the maximum value of the
duration constraint to delay the delivery of a Message.
Related pages
Time constraint
You can specify a time constraint in Messages in the Sequence diagram. During simulating an
interaction, Simulation Toolkit checks if the active State contains the required State (State Invariant(see
page 363)), and the time is exactly as specified (Time constraint). However, the time constraint is not
used as the delay time.
Related pages
State invariant
A State Invariant is one of the UML elements. It is a runtime constraint applied to a lifeline in a
Sequence diagram to specify conditions that are always true when a State is a current State. It is used
to validate States. You may also specify State Invariants in the States directly. State Invariants on
lifelines resolves variables in the same order as it does in message arguments.
When Cameo Simulation Toolkit runs a State Invariant in a model, it also evaluates its constraints. If the
constraints are not satisfied, the evaluation will fail or return false and Cameo Simulation Toolkit will
stop simulation (if "ConstraintAsBreakpoint" is set to true) at that invalid constraint or point. However,
you can still continue the simulation to the next point. You can define constraints using any of the
supported languages in Cameo Simulation Toolkit. State Invariants are used mostly in Interactions, but
you can also use them in a State Machine diagram.
96 https://docs.nomagic.com/display/MD2021xR2/Specification+window
97 https://docs.nomagic.com/display/MD2021xR2/Sequence+diagram
The time constraint of the State invariant is checked against the simulation
time.
Related pages
A testcase is one kind of Behavior Classifier. It can be a class, Behavior, activity, or operation. Since a
test case is a SysML element, you need to load a SysML profile into your model to run it. Cameo
Simulation Toolkit supports testcase verdicts.
A verdict kind is an Enumeration value in SysML. It can be error, inconclusive, pass, or fail. Cameo
Simulation Toolkit automatically assigns either Pass or Fail as the verdict value to a Testcase. If a
constraint in the test case (pre/post conditions, state invariants) is not satisfied in a model execution,
98 https://docs.nomagic.com/display/MD2021xR2/Sequence+diagram
If the "constraint as a breakpoint" option is used in the simulation, whenever the constraint fails,
evaluation will stop and will be highlighted in the model, and you will see the message in red in
the Variables pane. The requirement will be highlighted as well so that you can see what is wrong and
navigate to the requirement.
Cameo Simulation Toolkit will generate a Pass verdict value after the simulation terminates if there is
no constraint fails. If a constraint fails, the simulation will pause, and you will get a Fail verdict value in
the Console pane, but you can always resume the simulation afterwards.
Related page
Combined fragment
On this page
Cameo Simulation Toolkit supports three major Interaction operators: Alternative (alt), Option (opt),
and Loop (loop). Combined fragments with various Interaction operators will also be supported (e.g.,
alt inside loop, opt inside loop, loop inside alt, etc.).
Alternative (alt)
The Interaction operator alt signifies that the combined fragment represents a choice of Behavior. Only
one of the operands will be chosen. The chosen operand must have an explicit or implicit Guard
expression evaluated as true at a particular point in the Interaction. An implicit ‘true’ Guard is applied if
the operand has no Guard.
An operand guarded by else means a Guard that is the negation of the dis-junction of all other Guards.
If none of the operands has a Guard evaluated true, none of the operands are executed, and the
remainder of the enclosing Interaction fragment is executed.
Option (opt)
The Interaction operator opt signifies that the combined fragment represents a choice of Behavior
where either the (sole) operand happens or nothing happens. An option is semantically equivalent to
an alternative combined fragment where there is one operand with non-empty content, and the second
operand is empty. An implicit ‘true’ Guard is applied if the operand has no Guard.
Note
Any Guard that is not Boolean expression evaluation will show a Question dialog box to set the
evaluation result true or false. See also using Guards on Transitions(see page 262).
Related pages
You can simulate an Interaction element, a (UML or SysML) Sequence diagram, or a Classifier whose
Classifier Behavior is defined by an Interaction. This section demonstrates how to create a simple
executable Interaction model through the following steps
1. To create a new UML project, click File > New Project on the main menu. The New
Project dialog will open.
5. Create two more Classes and name them, e.g., 'a' and 'b.
6. Right-click the System model in the Containment tree and select Create Element > Property to
create property for the Class. Name the property, e.g., 'a1'.
1. Right-click the Class B and select Create Element > Opaque Behavior. Name the opaque
Behavior, e.g., 'Add'.
2. Right-click the opaque Behavior Add and select Create Element > Parameter to add a
parameter element to the opaque Behavior. Name the parameter, e.g., 'par1'.
4. Repeat Step 2 to create another parameter and name it, e.g., 'par2' of type Integer.
• Open the Specification window of the opaque Behavior Add and write a script in the Body field
(you can use any scripting language that is supported by MagicDraw Macro Engine, e.g.,
BeanShell, Groovy, JavaScript, Python, or Ruby). In this example, JavaScript is used:
print(par1+par2); to print the summation of the two Integer parameters par1 and par2.
To create an operation owned by the properties specified in (Class containing two properties typed by
different Classes)(see page 368), and to specify the opaque Behavior as in (opaque Behavior owned by one
of the two properties of the Class(see page 0)) as its method
1. Right-click B and select Create Element > Operation to add an operation element to the
Class. Name the operation, e.g., 'Add'.
3. Right-click the parameter par1 and select Specification. Select Integer as the parameter type
and in as the parameter direction. The Specification window of parameter par1 will be as follows
5. Right-click the operation Add and select Specification. The Specification window will open.
6. Select the opaque Behavior Add as the Method of the operation. The Specification window of
the Opaque Behavior will be as follows
To create an Interaction as the Classifier Behavior of the Class specified in (the Class containing two
properties typed by different Classes(see page 368))
1. Right-click System and select New Diagram > Sequence Diagram. Select all properties in
the Display Lifelines dialog and click OK.
1. Double-click the Interaction System to open the Sequence diagram containing two
lifelines: a1 and b1.
2. Select Call Message from the Diagram Modeling Elements toolbar and create a call message
from a1 to b1.
4. Select Argument on the left-hand side of the dialog to specify a value of the element. Type,
e.g., 4 and 5 as the values of parameters par1 and par2 respectively. The Specification window of
a call message showing its Arguments tags will be as follows
Related pages
To simulate the interaction model in section Creating a model for Activity simulation(see page 295)
1. Right-click the package Model in the containment browser and select Create
Element > Package. Name the package, for example, InstancePackage. The following figure
shows the Containment tree containing the objects within its hierarchy.
2. Right-click the InstancePackage and select Create Element > Instance Specification. Name
the instance specification, for example, Sys. The following figure shows the creation of an
InstancePackage element from its shortcut menu..
• record created objects as CreateMessages connected between Lifelines that represent the object
creator and features of the created object respectively.
• record signals as SendMessages connected between Lifelines that represent signal senders and
signal receivers respectively. Connectors will be assigned to the messages if signals are sent via
ports or connectors.
• record operation calls as CallMessages connected between Lifelines that represent operation
caller and operation owners respectively. Connectors will be assigned to messages if operations
are called via ports.
• record changes of states and primitive values as StateInvariants on Lifelines that represent
features of objects that own the states or the values.
This section demonstrates how to record signal, state change, operation call, and value change as a
sequence diagram during a model simulation. The sample StereoSystem.mdzip, located in
the <md.install.dir>/samples/simulation/ directory, will be used throughout this section.
To record signals sent from and to a runtime object and subsequent state/value changes of the related
objects as a sequence diagram
Whenever you simulate a model (for example, Stereo System as shown in the figure above, Cameo
Simulation Toolkit will
• create the first Lifeline, which represents the selected runtime object.
• record each signal sent from the selected runtime object as a Message in the sequence diagram.
• record each operation call caused by a call message, a CallOperationAction, or a
ALH.callOperation with argument and return value as messages in the sequence diagram.
• record an object that receives a signal and(or) an operation call as a Lifeline, unless it exists in the
diagram, the object will be called 'lifeline object'.
• record each change in the state of a lifeline object as a StateInvariant on the Lifeline, with the
changed state symbol.
• record each change in the feature value of a lifeline object as a StateInvariant on the Lifeline.
Changes in value are enclosed in constraint brackets, for example, {a=10}.
Note
StateInvariants are designated by yellow rounded rectangle symbols. See the following figure
for examples.
• Double-click the message or right-click it and select Specification to open the specification
window.
1. Either double-click a message or right-click it and select Specification to open the specification
window.
• owner
It is an element that owns a generated Interaction element. A generated Sequence diagram will
be created under that particular Interaction element. You need to select only the element that
can own an Interaction element, otherwise a model inconsistency will occur.
• ignoredSignals
They are signals that will be ignored (will not be recorded) during a simulation recording.
• ignoredLifelines
They are a list of elements (objects) that will be ignored (will not be recorded as lifelines) during a
simulation recording. This list takes priority over the value list.
• recordedObjectPath
It is used to specify a property path to an object that will be recorded by a sequence diagram
generator. The path must start from a property owned by either a classifier, which is the target of
the simulation configuration or a classifier of an instance specification, which is the target of the
simulation configuration. The property at each successive position following the first position
must be contained in the classier that types the property at the immediate preceding position.
• recordStateChange
This is a boolean option. If true, state changes will be recorded.
• recordValueChange
It is a boolean option. If true, value changes will be recorded.
• value
Structural feature which value is represented for the configuration.
You can specify the default values of recordStateChange, recordValueChange,
and recordTimestamp through the Project/Environment Options(see page 47) dialog. The values in
the project options will be used instead if the tagged values of the sequence diagram generator are not
specified. The default values of these project options are true, true, and false (see the following
figure). True means all values will be recorded by default.
Options in the Sequence Diagram Generator group in the Project Options dialog.
To customize a Sequence diagram recording
• In the Containment tree, right-click the Model folder (root folder) and select Create
Diagram.
4. Specify the value(s) of the tag definition(s) of the config, e.g., Name.
1. Create a use case diagram. See the following example of a Use Case diagram. The figure shows
the Use Case diagram in a block (a subject can be either a block or a class).
2. Either right-click the Use Case diagram in the Containment tree and select Simulation > Run
or click on the diagram toolbar to run the model. The classifier behaviors in the Use Case
diagram are run during simulation. Cameo Simulation Toolkit creates a window to represent
each Actor in the diagram (the preceding figure shows four actors: Worker1, Worker2, Worker3,
and Worker4.
3. You can click the button, which represents what Use Case the Actor can perform, in each window
to simulate it (the following figure shows the buttons Change Color and Paint).
Note
The Block connected by the Association with a Use Case is shown as an Actor, e.g.
Worker3, so any Use Cases connected are shown as buttons in the GUI window of the
Actor. Also, the image of the Block is shown according to the selected Image above the
list of Use Case buttons.
Parametric evaluator
Cameo Simulation Toolkit comes with the parametric evaluator to help you solve constraint
expressions in your model. The parametric evaluator is designed to work with the SysML Parametric
Diagram. But, you can also use it to solve constraints on any UML classes. With the parametric
evaluator, you can define a mathematical or a logical expression as a constraint on a block or a class to
limit the values of its properties. If the expression is an equation, the parametric evaluator will evaluate
the expression of the constraint and update the values of the properties with the result of the
99 https://docs.nomagic.com/display/MD2021xR2/Specification+window
The parametric evaluator only evaluates expressions that are written in the syntax it supports. By
default, the parametric evaluator uses the built-in math to solve expressions. The built-in math uses a
syntax that is similar to the Octave syntax (see Built-in Math(see page 434) for more information about
built-in math). You can also write an expression using a scripting language that is supported by
MagicDraw.
You can specify a scripting language to evaluate an expression through the Specification dialog of the
opaque expression, which is the specification of the constraint.
1. Right-click a SysML constraint block or a constraint property typed by the constraint block on the
diagram.
2. Click Language and select any supported language to evaluate constraint blocks from the list.
The language of the Default Parametric Evaluator in Cameo Simulation Toolkit is Built-in Math.
Therefore, it will use Built-in Math to evaluate an opaque expression whose language is not specified.
You can see the Default Parametric Evaluator language option in the Parametric Evaluator group in
the Project Options(see page 47) dialog.
Related pages
The Solve After Initialization option can initialize objects and values
automatically.
The value of the Solve After Initialization option is true by default to enable automatic initial solving.
If you wish to manually invoke initial solving, you can do so by clearing the check box (the value will
change to false), clicking Refresh in the Variables pane, or pressing Start (F8).
4. Select true for the Solve After Initialization option, and run the Simulation Config. All related
results will be calculated automatically (see the following figure)
Value binding is the method to maintain values of properties, which are bound together, to be the
same. The properties whose values are bound, must be connected together with a connector. The type
of the properties which are bound together must be the same or one is a subtype of another. If the
type of the properties is a primitive type, you can bind them with either a UML connector that does not
have a type, or a SysML binding connector with a «BindingConnector» stereotype applied. If the type of
the properties is a class or a block, you can only use a SysML binding connector to tie them.
Related pages
Object binding
If a binding connector connects properties that is typed by either a class or a block, the runtime value
that specifies each property will be the referent of the same block object. Since you can use only a
SysML binding connector to bind objects, the SysML plugin is required.
The following figure illustrates an example of binding where the aggregate structure is complex. It
shows an executable InstanceSpecification of the block System, which is system:System. It has three
instances of subsystems as the values of the slot subsystem:Subsystem[0..]. In the SysML
Parametric diagram, the value property *value of the slot subsystem:Subsystem[0..]* are bound
to the value property value of the block System. So, the values of the value property value of
object System will be [25, 50, 75] respectively.
Evaluating expressions
This section explains how to evaluate the mathematical equations and logical expressions in Cameo
Simulation Toolkit.
Cameo Simulation Toolkit provides constraint parameters substitution in the expressions to improve
the human readability of the constraint parameters. All user interface objects (including tooltips,
Console panel, and Variables panel related to a constraint property connected to a value property) will
display the value property name (actual binding) instead of the constraint parameter name. This
feature is applicable at the user interface level only, not at the original constraint property. For
example, “Width” and “Height” (value properties) are used instead of “w” and “h” (parameter properties)
in constraints, as shown in the following figure.
Related pages
Mathematical equation
The following figure shows an example of constraint parameters target and given in a mathematical
equation.
If you simulate the block Circle, the parametric evaluator in Cameo Simulation Toolkit will create an
object Circle and its internal values. It will substitute the value of radius of the block object Circle to the
equation and calculate the value of area. Once it obtains the value of area, parametric evaluator will
assign it to the area value property of the object Circle. If you change the value of the radius, Cameo
You can also define a constraint on a UML class to constrain the values of its properties. The following
figure shows a constraint on the UML class Circle. The constraint is defined by the same Mathematical
expression as in the figure below {area = 3.14159 *** (radius ^ 2)}. If you simulate the class Circle, the
parametric evaluator will evaluate the value of radius in the equation. It will then use the value resulting
from evaluating the value of radius to update the value of property area.
Related pages
Logical expression
A logical expression is an expression that uses comparison operators. You can use a logical expression
to define a constraint. Cameo Simulation Toolkit uses the expression to validate values at runtime.
Note
A logical expression must contain a comparison operator (==, <, >, <=, >=, and <>) as shown in
the following examples:
• val1 >= "500" is a valid expression.
• val2.equals("500") == true is a valid expression.
• val2.equals("500") is an invalid expression.
Furthermore, both the values and validation that are highlighted must always be consistent with the
labels and text boxes of both the UI modeling diagram(see page 70) and the HTML UI during simulation.
A tooltip will also appear if you hover the mouse over the failed constraint. Each parent of the failed
constraint will appear with a contextual path "dot notation" starting from the node on which tooltip is
shown.
The parent node with a red background indicates failures deeper in the structure tree.
This example uses the block Circle100 previously shown in the section Mathematical equation(see page
414). If we modify the expression of the constraint block Circle Area by changing the assignment
operator "=" to the equality operator "==", the parametric evaluator will use the expression to validate
the values of both area and radius. If the result is false, the values will be highlighted in red (see Figure:
The parent node with a red background indicates failures deeper in the structure tree). But, if the result
is true, the values will be highlighted in green (see Figure: Nodes with green background indicating valid
values).
100https://docs.nomagic.com/download/attachments/82761453/equationSysml.png?
api=v2&modificationDate=1496891962856&version=1
Finding a constraint object that binds the value property through the shortcut menu.
When you export the object to the instance specification, if the exported object contains a constraint
object (an object of a constraint block) and if the expression of the constraint block is a boolean
expression, Cameo Simulation Toolkit will set the result of the evaluation, which is a literal boolean, to a
slot defined by the constraint property typed by the constraint block.
As described in the section Mathematical equation(see page 414), the parametric evaluator is capable of
solving expressions in the mathematical equation to find the value of the target from the value of the
given. We could say that the target is an unknown value that you want to find and the given is a known
input value. Normally, a target is a variable on the left-hand side of an equation and a given is a variable
on the right-hand side.
Sometimes, however, you know the value of the variable on the left-hand side of an equation and need
to find the value of the variable on the right-hand side. You can use Cameo Simulation Toolkit to obtain
the given variable if you integrate an external evaluator, which supports solving symbolic equations, to
Cameo Simulation Toolkit. MATLAB with Symbolic Math Toolbox101 is one of the external evaluators you
can use.
Note
As a prerequisite, you must integrate MATLAB with Symbolic Math Toolbox102 successfully. See
also Integration with MATLAB(see page 451).
If the language that defines an expression of a constraint block needs to be solved by an external
evaluator that is capable of solving symbolic equations, you can specify what property is the target and
the given through the Causality column in the Variables pane.
101 https://www.mathworks.com/products/symbolic.html
102 https://www.mathworks.com/products/symbolic.html
The expression of the constraint block Circle Area in the figure shows two roots: (i) a positive value
2.8209 and (ii) a negative value -2.8209. The parametric evaluator needs only one root to evaluate the
value of a radius from the given value of an area. Therefore, the Roots selection dialog will open for
you to select which root you want as shown in the following figure.
Scenario 1
The following figure shows the constraint Test Multiple Root 1 is applied to block A.
Related pages
Constraints on parts
In a particular system or context where blocks are used, it is possible to add constraints on parts and
constraint value ranges. To better explain how it works, see the following example of a car model.
A car model has front: Wheel and rear: Wheel. The diameter of the Wheel block is specified as diameter:
Real value property. It is possible to add different constraints to different parts; e.g., the front wheel’s
diameter is {diameter < 19} and rear wheel’s diameter is {diameter < 20}.
The following figure demonstrates a Car (block) along with the diameter of Wheel (constraints) applied
to the rear, front, and spare wheel (part properties).
If the constraints of the block are applied to the part properties through another block with constraints
inside, you will get the following results.
1. The value ranges will be evaluated through all of the applied constraints. The constraints may
reside in the part properties, main block, or constraint blocks. For example, front wheel {diameter
>= 15, diameter < 19}.
2. If a constraint fails during evaluation, a failure message will appear on the owned constraint; e.g.,
part properties, main block, or constraint blocks In the Simulation Console panel.
3. In the Variables pane, the constraints applied to the part properties appear together with the
constraints of its own part properties in {...}. Cameo Simulation Toolkit highlights failed
constraints with a red background and opens the failure message in the tooltip of the applied
constraint.
This figure depicts the constraints failure message in the Console panes and the
details of failed constraints (in red background) that are applied to part
properties front : Wheel in the Variables pane.
Dynamic constraint
Sample model
The model used in the figures on this page is the ForwardContractValuation.mdzip sample model
that comes with the modeling tool.
• Download ForwardContractValuation.mdzip103
• Find in the modeling tool <modeling tool installation
directory>\samples\simulation\Parametrics\ForwardContractValuation.mdzip.
Related pages
3
10 https://docs.nomagic.com/download/attachments/82761412/ForwardContractValuation.mdzip?
api=v2&modificationDate=1499237732932&version=1
In the figure below, Simulation pauses at the margin breakpoint in the Parametric diagram in which you
can debug the model. You can also find the sample model of parametric debugging on the Welcome
screen by going to the Simulation sample group and selecting SpacecraftMassRollup.
Changing values on a property of an object will cause the parametric evaluator to automatically update
the other related values with the constraint defined on the object. Or, you may want to update the
values with the constraint once you set all necessary values of the properties. The latter is possible by
executing your model with the SimulationConfig whose fireValueChangeEvent = false (see section
SimulationConfig stereotype(see page 49) for more information about the SimulationConfig and its tag
definitions) and call the API provided by the parametric evaluator whenever you desire. The following
figure shows an example of updating values manually with the parametric evaluator.
Signature: com.nomagic.magicdraw.simulation.parametrics.ParametricsEngine.executeObject(Object
object)
You can call the API with the MagicDraw script engine. For example, you may define it in the body of an
opaque behavior. Then, use a call behavior action to call the opaque behavior somewhere in your
model.
Sample model
The model used in the figures on this page is the CylinderPipe.mdzip sample model that comes with
the modeling tool.
You can communicate with a parametric evaluator directly through the command prompt, which is
located in the lower part of the Simulation Console pane. You can click the arrow of the language
selection drop-down list to the right of the command prompt and select a language you want. Once
selected, the language will appear in the command prompt in the Console pane. For example, if you
select Matlab, the language in the command prompt will change from "»" to "matlab»" (see the
following figure).
104https://docs.nomagic.com/download/attachments/82761470/CylinderPipe.mdzip?
api=v2&modificationDate=1499237909759&version=1
Note
You can also use the command prompt in the Simulation Console pane to communicate with
the script engine by selecting a scripting language from the language selection drop-down list.
For example, selecting JavaScript will cause the language to change to "js»".
Related pages
Built-in Math
Cameo Simulation Toolkit comes loaded with a built-in Math Solver. As a default Parametric Evaluator,
Math Solver can solve simple mathematical and logical expressions. You can use it to evaluate as
follows
• Mathematical and logical expressions defined in the Constraints of Constraint Blocks for
Parametric Simulation on a SysML Parametric diagram.
• Mathematical and logical expressions in Simulation Console.
Related pages
• math» x = 10;
• math» y = 20;
• math» z = x + y
Note
The result of a calculation expression that ends with a semicolon (;) in the built-in Math will be
assigned to the corresponding variable in the selected built-in math environment. It will not be
displayed in the simulation Console tab.
Or, if you type, e.g., in command input of the Simulation Console, the examples are as follows
• math» a = true;
• math» b = false;
• math» c = a & b;
If false is the result of a calculation, it will be assigned to the variable c, but it will not be displayed in
the simulation Console tab.
If an expression does not contain any assignment operators, the result will be assigned to the variable
'ans'. The examples are as follows
• math» x = 10;
• math» 20 + x
• ans = 30.0000 will be displayed in the simulation Console tab.
You can calculate multiple expressions at the same time by ending each expression with a semicolon (;).
The examples are as follows
Variables
You can use variables (operands) in the built-in Math Solver if they conform to the naming conventions
as follows
Values
The valid values that you can use in an expression are as follows
• Real Number
• Complex Number
• Boolean
• Matrix
Real Number
x = 3.14159
y=2
Complex Number
c = 3 + 4i
d = 1.25 + 0.25i
Note
An 'i' character in an expression can be parsed as either an imaginary unit or a character of a
variable name. If the character 'i' is placed after a number, and the next character is neither an
alphabet nor number, it will be parsed as an imaginary unit. Otherwise, it will be parsed as a
variable. The examples are as follows
• ca = 1i 'i' is parsed as an imaginary unit.
• cb = i 'i' is parsed as a variable.
• cx = 3.25i 'i' is parsed as an imaginary unit.
• cy = 4i4 'i' is parsed as the first character of a variable name 'i4'
Boolean
a = true
b = false
You can add a matrix to the built-in Math Solver by using the following syntax (a semicolon is used as a
row separator and comma or space is used as a comma separator). The examples are as follows
You can refer to a matrix element with the row and column index specified in round brackets after a
matrix name. The examples are as follows (see U above)
U(1, 1) is 1.0
U(2, 3) is 6.0
You can also refer to a matrix element with only one index specified in round brackets after a matrix
name. In this case, the matrix will be considered as a column-major order matrix. The elements on the
given column-major order index will be returned. The examples are as follows (see U above)
U(2) is 4.0
U(6) is 8.0
Constants
Constant Value
E A real value that is closer than any other to e, the base of natural logarithms.
PI A real value that is closer than any other to pi, the ratio of the circumference of a circle to its
diameter.
Important
• x and y represent numerical values or variables.
• m, n, and p represent integer values or variables.
• a and b represent boolean values or variables.
• U and V represent matrices of numerical values.
• A and B represent matrices of boolean values.
Arithmetic operators
+ Addition x+y
- Subtraction x-y
* Multiplication x*y
/ Division x/y
% Modulus m%n
! Factorial m!
^ Power x^y
Note
An Element-wise operator performs an operation on each pair of Elements, which is in the
same location, of the operand matrices.
Assignment operators
= Assignment x=y
a=b
U=V
Comparison operators
== Equality x==y
a==b
U==V
!= Inequality x!=y
a!=b
U!=V
Boolean operators
! NOT !A
NOT NOT A
not not A
AND A AND B
and A and B
| OR A|B
OR A OR B
or A or B
XOR A XOR B
xor A xor B
Important
All boolean operators operate element-wise on matrices in the example as follows
A = [true; true; false; false];
B = [true; false; true; false];
Then
A&B is [true; false; false; false];
Functions
Note
• x and y represent real values or variables.
• c and d represent complex values or variables.
• m and n represent integer values or variables.
• U represents a matrix of values.
• A matrix can be passed to a function that operates Element-wise on matrices, as its
argument in the example as follows
X = [1, -2, 3; -4 5 -6; 7 -8 9];
Y = abs(X)
result:
Y = [1 2 3; 4 5 6; 7 8 9]
abs abs(x) To return an absolute value of x or a complex modulus of c. This function operates
Element-wise on matrices.
abs(c)
acos acos(x) To return an arc cosine of an angle in the range of 0.0 through pi. All angles are
measured in radians.This function operates Element-wise on matrices.
acos(c)
acosd acosd(x) To return an inverse cosine of a given value expressed in degrees. This function
operates Element-wise on matrices.
acosd(c)
acosh acosh(x) To return an inverse hyperbolic cosine of a given value. This function operates
Element-wise on matrices.
acosh(c)
acot acot(x) To return an inverse cotangent of a given value. This function operates Element-
wise on matrices.
acot(c)
acotd acotd(x) To return an inverse cotangent of a given value expressed in degrees. This function
operates Element-wise on matrices.
acotd(c)
acoth acoth(x) To return an inverse hyperbolic cotangent of a given value. This function operates
Element-wise on matrices.
acoth(c)
acsc acsc(x) To return an inverse cosecant of a given value. This function operates Element-wise
on matrices.
acsc(c)
acscd acscd(x) To return an inverse cosecant of a given value expressed in degrees. This function
operates Element-wise on matrices.
acscd(c)
acsch acsch(x) To return an inverse hyperbolic cosecant of a given value. This function operates
Element-wise on matrices.
acsch(c)
asec asec(x) To return an inverse secant of a given value. This function operates Element-wise
on matrices.
asec(c)
asecd asecd(x) To return an inverse secant of a given value expressed in degrees.This function
operates Element-wise on matrices.
asecd(c)
asech asech(x) To return an inverse hyperbolic secant of a given value. This function operates
Element-wise on matrices.
asech(c)
asin asin(x) To return an arc sine of an angle in the range of -pi/2 through pi/2. This function
operates Element-wise on matrices.
asin(c)
asind asind(x) To return an inverse sine of a given value expressed in degrees. This function
operates Element-wise on matrices.
asind(c)
asinh asinh(x) To return an inverse hyperbolic sine of a given value. This function operates
Element-wise on matrices.
asinh(c)
atan atan(x) To return an arc tangent of an angle in the range of -pi/2 through pi/2. This function
operates Element-wise on matrices.
atan(c)
atan2 atan2(x,y) To return an arc tangent of an angle in the range of -pi through pi. atan2(U, V)
returns a matrix of the same size as the U and V matrices containing the Element-
atan2(U,V) by-Element, inverse tangent of the real parts of U and V.
atand atand(x) To return an inverse tangent of a given value, expressed in degrees. This function
operates Element-wise on matrices.
atand(c)
atanh atanh(x) To return an inverse hyperbolic tangent of a given value. This function operates
Element-wise on matrices.
atanh(c)
ceil ceil(x) To return a smallest (closest to negative infinity) value that is not less than the value
of x and is equal to a mathematical integer. This function operates Element-wise on
matrices.
conj conj(c) To return a conjugated value of c. This function operates Element-wise on matrices.
cos cos(x) To return a trigonometric cosine of an angle. This function operates Element-wise
on matrices.
cos(c)
cosd cosd(x) To return a cosine of a given value expressed in degrees. This function operates
Element-wise on matrices.
cosd(c)
cosh cosh(x) To return a hyperbolic cosine of a given value. This function operates Element-wise
on matrices.
cosh(c)
cot cot(x) To return a cotangent of a given value. This function operates Element-wise on
matrices.
cot(c)
cotd cotd(x) To return a cotangent of a given value expressed in degrees. This function operates
Element-wise on matrices.
cotd(c)
coth coth(x) To return a hyperbolic cotangent of a given value. This function operates Element-
wise on matrices.
coth(c)
csc csc(x) To return a cosecant of a given value. This function operates Element-wise on
matrices.
csc(c)
cscd cscd(x) To return a cosecant of a given value expressed in degree. This function operates
Element-wise on matrices.
cscd(c)
csch csch(x) To return a hyperbolic cosecant of a given value. This function operates Element-
wise on matrices.
csch(c)
diag diag(U) To return a diagonal matrix and diagonals of the matrix. If U is a row matrix or a
column matrix of n Elements, this function will return a square matrix of order
diag(U,m) n+abs(m), with the Elements of U on the kth
diagonal. k = 0 represents the main
diagonal. k > 0 is above the main
diagonal. k < 0 is below the main
exp exp(x) To return a Euler's number e raised to the power of a or c. This function operates
Element-wise on matrices.
exp(c)
floor floor(x) To return a largest (closest to positive infinity) value that is not greater than the
value of x and is equal to a mathematical integer. This function
floor(c) operates Element-wise on matrices.
IEEErema IEEEremain To compute the remainder operation in two arguments as prescribed by the IEEE
inder der(x,y) 754 standard.
imag imag(c) To return a real value of an imaginary part of a given complex number. This function
operates Element-wise on matrices.
invert invert(U) To return an inverse or pseudo inverse of a given matrix. If the given matrix is a
square matrix, the inverse of a U matrix will be returned using the LU factorization.
If the given matrix is not a square matrix, a pseudo inverse matrix will be returned
using the QR factorization.
In ln(x) To return a natural logarithm (base e) of a given value. This function operates
Element-wise on matrices.
ln(c)
log log(x) To return a natural logarithm (base e) of a given value. This function operates
Element-wise on matrices.
log(c)
log10 log10(x) To return a logarithm base 10 of a given value. This function operates Element-wise
on matrices.
log10(c)
log2 log2(x) To return a logarithm base 2 of a given value. This function operates Element-wise
on matrices.
log2(c)
max max(x,y,...) To return a greater of the given values. max(U) returns the largest Element of a
given matrix. max(U, V) returns a matrix the same size as U and V with the largest
max(c,d,...) Elements taken from U or V. The dimensions of U and V must be the same.
max(U)
max(U,V)
mean mean(U) To return a mean or average value of a given matrix. U is a row or a column matrix:
mean(U) returns the mean value of all Elements in the given matrix.U is a 2-D
matrix: mean(U) returns a row matrix that contains the mean value of each column
of the given matrix.
median median(U) To return a median value of a given matrix. U is a row or column matrix: median(U)
returns the median value of all Elements in the given matrix. U is a 2-D matrix:
median(U) returns a row matrix that contains the median value of each column of
the given matrix.
min min(x,y,...) To return a smaller of the given values. min(U) returns the smallest Element of a
given matrix. min(U, V) returns a matrix the same size as U and V with the smallest
min(c,d,...) Elements taken from U or V. The dimensions of U and V must be the same.
min(U)
min(U,V)
num2str(c)
pow pow(x, y) To return a value of the first argument raised to the power of the second argument.
pow(U, c) This function operates Element-wise on a given matrix U.
pow(c, d)
random random() To return a real value with a positive sign, greater than or equal to 0.0 but less than
1.0.
real real(c) To return a real value of the real part of a given complex number. This function
operates Element-wise on matrices.
rint rint(x) To return a value that is closest in value to an argument and is equal to a
mathematical integer. This function operates Element-wise on matrices.
round round(x) To return a closest value to an argument and is equal to a mathematical integer.
This function operates Element-wise on matrices.
secd secd(x) To return a secant of a given value expressed in degree. This function operates
secd(c) Element-wise on matrices.
sech sech(x) To return a hyperbolic secant of a given value. This function operates Element-wise
sech(c) on matrices.
sin sin(x) To return a trigonometric sine of an angle. This function operates Element-wise on
sin(c) matrices.
sind sind(x) To return a sine of a given value, expressed in degree This function operates
Element-wise on matrices.
sind(c)
sinh sinh(x) To return a hyperbolic sine of a given value. This function operates Element-wise on
sinh(c) matrices.
size size(U) To return a size of a given matrix. If only the matrix is passed to the function as an
size(U, m) argument, the returned value is a 1x2 matrix. The first Element
is the number of rows and the second Element is the number of columns.If the
second parameter (m) is specified, this function will return the size of an mth
dimension of a given matrix as a scalar value. The second argument can be 1 or 2 (1
for the row size and 2 for the column size). For example:
U = [1, 2, 3; 4, 5, 6];
size(U) is [2, 3]
size(U, 1) is 2
size(U, 2) is 3
sort sort(U) To sort the Elements of a given matrix in an ascending or descending order. If the
sort(U, second argument is specified with ‘ascend’ or ‘descend’, the Elements will be in an
‘descend’) ascending or descending order respectively. If this function is called without a
second argument, the Elements will be sorted in an ascending order.
U is a row or column matrix:
sort(U) and sort(U, ascend) sort all Elements in the given matrix.
U is a 2-D matrix: std(U) and std(U,flag) sort Elements in each column of the given
matrix.
ssqrt sqrt(x) To return a correctly rounded positive square root of a double value.This function
sqrt(c) operates Element-wise on matrices.
std std(U) To return a standard deviation of a given matrix. The ’flag’ argument can be 0 or 1. It
std(U, flag) specifies the method for calculating the standard deviation.
If the flag = 0, the standard deviation is normalized by N-1. If the flag = 1, the
standard deviation is normalized by N where N is the number of data.
The value of the flag will be zero by default. U is a row or column matrix:
std(U) and std(U, flag) returns the standard deviation of all Elements in the given
matrix. U is 2-D matrix: std(U) and std(U,flag) returns a row matrix that contains the
standard deviation of each column of the given matrix.
tan tan(x) To return a trigonometric tangent of an angle. This function operates Element-wise
tan(c) on matrices.
tand tand(x) To return a tangent of a given value expressed in degree.This function operates
tand(c) Element-wise on matrices.
tanh tanh(x) To return a hyperbolic tangent of a given value. This function operates Element-
tanh(c) wise on matrices.
Cameo Simulation Toolkit allows you to use an external Evaluator to evaluate an opaque expression in
your model. Therefore, you can use any language supported by the external Evaluator in the body of
the opaque expression.
You must specify the name of the language in the opaque expression. If you do not specify the
language of the opaque expression, Cameo Simulation Toolkit will use the Default Language option
specified in the Simulation Framework group in the Project Options(see page 47) dialog as follows.
105 https://docs.nomagic.com/display/CST2021xR2/Integration+with+MapleTM
Note
• For successful integration, you must use either the 64-bit or 32-bit version of MATLAB to
align it with the 64-bit or 32-bit version of modeling tools, e.g., MagicDraw or Cameo
Systems Modeler.
• To enable the Integrations menu, you must change the perspective to Full Featured,
System Engineer, or Software Architect (from the main menu, select Options >
Perspectives > Perspectives, select Full Featured, System Engineer, or Software
Architect, and click Apply).
• When integrating with MATLAB for the first time or changing the MATLAB version, you
must restart your system. If the system has been previously integrated with MATLAB,
restart only the modeling tool.
• If there are problems with integrating MATLAB on Windows, please ensure that
MagicDraw is running with the administrator's privileges, and then try to integrate again.
To integrate a modeling tool with MATLAB (on Microsoft Windows and Mac OS X)
1. From the main menu, click Tools > Integrations. The Integrations dialog opens.
3. Click Browse to specify the MATLAB home directory, e.g., C:\Program Files\MATLAB\R2019b.
4. Click OK and restart your system or the modeling tool.
Note
You can manually verify the MATLAB integration process, e.g., setting the path of system
variables in the Environment Variables to the correct MATLAB path of each operating
system, through the following links:
• Using MATLAB on Microsoft Windows(see page 453)
• Using MATLAB on Mac OS(see page 456)
• Using MATLAB on Linux(see page 458)
Related pages
1. Install MATLAB®.
2. Press Windows + R to open the Run dialog.
3. Type cmd in the open combo box and click OK to open the command prompt window.
4. Type "matlab /regserver" and press Enter to register the MATLAB® components to Windows.
The MATLAB® command prompt opens and is ready to use.
5.4 In the Variable value box, enter the path to MATLAB®...\bin and ...\bin\win64 (or ...
\bin\win32) folders, for example:
• C:\Program Files\MATLAB\R2010b\bin;
• C:\Program Files\MATLAB\R2010b\bin\win64;
5.5 For earlier versions of MATLAB®, you must enter the path of the runtime directory of
MATLAB® ...\runtime\win32 (or ...\runtime\win64), for example:
• C:\Program Files\MATLAB\R2010b\runtime\win32;
5.6 Click OK.
6. Restart Windows.
Related pages
Important
Simulation cannot integrate with MATLAB versions earlier than 2016b because of the new
security policies of the Mac OS.
1. Install MATLAB®.
2. Type the following commands in the terminal to show all files in Finder
• $ defaults write com.apple.finder AppleShowAllFiles TRUE
• $ killall Finder
3. Add the DYLD_LIBRARY_PATH variable to Mac OS:
3.1 Create an empty text file in the /etc folder and name it: launchd.conf.
3.2 Open it with a text editor, for example, TextEdit, and type the following text (no space)
setenv DYLD_LIBRARY_PATH /Applications/MATLAB_R2010b.app/bin/maci64:
/Applications/MATLAB_R2010b.app/runtime/maci64
6. Create a link to the MATLAB® executable file in /usr/bin if it does not exist, by using the
following command in the Terminal
• $ cd /usr/bin
• $ sudo ln -s /Applications/MATLAB_R2012a.app/bin/matlab matlab
Note
You need to change the /Applications/MATLAB_R2012a.app in the command line to your
MATLAB directory.
Related pages
3. Create a link to the MATLAB® executable file in /usr/bin if it does not exist, and type the following
commands in the terminal
• ~$ sudo -i
• ~$ cd /usr/bin
• ~$ ln -s /home/username/MATHWORKS_R2011A/bin/matlab matlab
4. Use a text editor to open the magicdraw file in the bin folder in the MagicDraw installation
directory. Type the following text under the line that contains cd"$APP_HOME" to add the
MATLAB® bin folder to LD_LIBRARY_PATH of Java and save the magicdraw file.
• On Linux 32-bit, type: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/username/
MATHWORKS_R2011A/bin/glnx86:/home/username/MATHWORKS_R2011A/sys/os/glnx86
• On Linux 64-bit, type: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/username/
MATHWORKS_R2011A/bin/glnxa64:/home/username/MATHWORKS_R2011A/sys/os/glnxa64
Simulation Toolkit can make connection to a running MATLAB session, thus all variables in the
workspace can be used.
Note
• MATLAB must be integrated successfully(see page 0) before the connection is made.
• If the sharing command shown above is not executed, the other MATLAB session loaded
by Simulation Toolkit will be used instead of the shared one.
After the session connection, Simulation Toolkit can access variables in the MATLAB shared workspace
that are not in the SysML model. You can define some variables in MATLAB, e.g., m1 and m2 and solve
parametric in Simulation Toolkit. These two groups of variables are then merged and can be accessed
in MATLAB as shown in the following figure.
Simulink co-simulation
On this page
Cameo Simulation Toolkit supports Simulink (MATLAB) co-simulation. Simulation executes the entire
Simulink model (*.slx) on all steps, if there are any value changes in the input, which is similar to FMI.
Simulation works with Simulink models as attached files and Simulink models located in the same
directory of the project.
Warning
• You must successfully integrate MATLAB Version 2016b or later before using Simulink co-
simulation. See Integration with MATLAB(see page 451).
• Any duplicated Simulink model is not allowed in the project.
Note
• Simulink models without input/output Ports are not executed because there is no
connectivity, and value change is not propagated to the Block.
• This type of Simulink integration is for atomic calculations. When any input changes,
outputs such as the parametric diagram are calculated, e.g. In1 → Gain5 → Out1. It
occurs as one step of Simulation time, the same as FMU.
• If the simulink file (.slx) is updated or modified, Simulation needs to restart the MATLAB
session by calling the kill matlab command in the Simulation console.
Warning
• The Interface Block of a Proxy Port must have only a Flow Property.
3. Connect those Proxy/Flow ports through binding Connectors106 in the Internal Block/Parametric
diagram.
4. Run the simulation. When inputs are available for initialization (e.g., passed via binding),
«SimulinkBlock» will be run at the first time and on every input change. You can also see
animation of Flow Ports and set breakpoints for debugging.
From the figure below, a system is with two Simulink models: GainAdd and Gain5. GainAdd will multiply
Port In1 by 10, multiply Port In2 by 2, and add the two results to Port Out1. Gain5 will multiply Port m by
5. Therefore, result will be [(2 * 10) + (2 * 2)] * 5 = 120.
The Simulink co-simulation result from the system which has two Simulink models (GainAdd.slx and
Gain5.slx) connected via Flow Ports.
106 https://docs.nomagic.com/display/SYSMLP2021xR2/Binding+Connector
First, you must install Maple™ on your local machine and set up your system in order to call Maple™
and use it in Cameo Simulation Toolkit.
1. Install Maple™.
2. Add the path of the Maple™ bin folder to the path environment variable using the steps as
follows
2.1 Double-click System in the Control Panel to open the System Properties dialog.
2.2 Click the Advanced tab.
3. Restart Windows.
3. Open the /etc/launch.conf (if this file does not exist, create launch.conf with any text editor) and
follow these steps:
3.1 Type setenv DYLD_LIBRARY_PATH <BINDIR> where <BINDIR> is the bin dir from step 2.2
3.2 Type setenv MAPLE <MAPLEDIR> where <MAPLEDIR> is the maple dir from step 2.1
3.3 Save launch.conf.
Footnote
First, you must install Mathematica® on your local machine, and then set up your system to allow
Cameo Simulation Toolkit to use the installed Mathematica®.
1. On the MagicDraw main menu, select Tools > Integrations. The Integrations dialog opens.
1. From the main menu, click Tools > Integrations. The Integrations dialog opens.
3. Specify the directory where you have installed Mathematica® and click OK.
4. Restart the modeling tool.
Information
(Only for integration with Mathematica Version 12.3) After completing the steps above using
the Integration dialog, you must change JAVA_HOME to JDK 11 by following the steps below:
1. Download JDK 11 (11.0.12 recommended) according to your operating system from
https://www.oracle.com/java/technologies/downloads/#java11. Alternatively, you can
use the bundled java from Mathematica 12.3 (JDK 11.0.10) in the [Mathematica
installation dir]\SystemFiles\Java\Windows-x86-64 directory.
2. Open the property file of the modeling tool, [Modeling Tool dir]/bin/[Modeling
Tool].properties, with a text editor, e.g., magicdraw.properties.
3. Change JAVA_HOME to the JDK 11 directory and save the file, for example:
JAVA_HOME=C\:\\Program Files\\AdoptOpenJDK\\jdk-11.0.12
On this page
Dymola overview
Dymola107, an abbreviation for Dynamic Modeling Laboratory, is a complete tool for Modelica modeling
and simulation of integrated complex systems used with automotive, aerospace, robotics, process and
other applications. You can download and install Dymola from https://www.3ds.com/products-services/
catia/products/dymola/ and set up your modeling tool to allow integration between Simulation (2021x
and later) and Dymola , which can be specified as a language of Opaque expressions.
1. On the modeling tool main menu, select Tools > Integrations. The Integrations dialog opens.
107 https://www.3ds.com/products-services/catia/products/dymola/
4. The Dymola integration dialog will be shown. Click OK. The Dymola integration status will
change to Integrated.
To use Simulation with Dymola through the scripting language (Steps 4 and 5 are optional)
1. Drag a Modelica model file, e.g., BouncingBall.mo, into the modeling tool to attach a Modelica
model to the project.
2. In the Console pane, select the language list box and choose Dymola. The input prompt will be
changed to dymola>>.
3. Enter the command below and press ENTER:
The Starting Math Engine dialog appears shortly, and results will be shown in the Console
pane.
4. Create an Opaque Behavior to call the model using the following tags:
• language: Dymola
• name (optional): e.g., simulateExtendedModel(“BouncingBall”)
• body: Use the command from Step 3.
5. Run the Opaque Behavior. The results will be displayed in the Console pane as shown below.
1. Create an Opaque Behavior to call the model with the following tags:
• language: Dymola
• name (optional): e.g., simulateExtendedModel
• body: (isSuccess,results)=simulateExtendedModel(problem,stopTime=stpTime,
initialNames=iniNames,initialValues=iniValues,finalNames=fnlNames);
• parameters: create parameters according to the command with valid Types and
Multiplicities, e.g., in modelName : String; in stpTime : Real; in fnlNames : String [1..*]; in
iniNames : String [1..*]; in iniValues : Real [1..*]; out isSuccess : Boolean; out results : Real [*].
3. Create an Instance Specification to specify parameter values, e.g., CoupledClutches. Run the
simulation through the instance to get results from Dymola back to Simulation as shown below.
Note
All of the sample projects of the Parametric Simulation engine include a Simulation
Configurations package that contains two SimulationConfig elements for normal and silent
simulation. You can select this SimulationConfig class to start the Parametric Simulation
engine.
Related pages
Cameo Simulation Toolkit is capable to read FMU files. Before simulating FMU blocks that are in the
FMU file (FMU blocks apply the <<FMU>> stereotype thus are recognizable), you have to be sure of the
following
• The FMU file and the project you are working on (in which you want to simulate the FMU blocks)
are in the same directory folder.
• The FMU file supports the platform you are using because Cameo Simulation Toolkit does not
support cross-platform execution of FMU files. You can see all supported platforms in the
Binaries folder of the FMU file. If the platform you are using is not in the Binaries folder, it is not
supported.
In order to co-simulate FMU blocks represented in SysML models, you need to have
• a config that specifies the start time, end time, and either step size or number of steps
properties.
You can click and drag the FMU file to your project to simulate it. When simulating the FMU blocks,
Cameo Simulation Toolkit does the following
FMI is a standard that supports model exchange and co-simulation of models. A component that
implements FMI is called FMU (Functional Mockup Unit). Cameo Simulation Toolkit is also capable of
reading FMU files. An FMU is a zipped file containing an XML description file and implementation in
binary form that executes the equation representing the component’s Behavior.
Important
Before simulating FMU files, you must make sure the following conditions are met:
• The FMU files and the project must be in the same directory.
• The FMU files must be OS-platform supported, e.g., Win64, Win32, linux64, linux32, etc.
(Cross-platform execution of FMU files is not supported.). You can see all supported
platforms in the Binaries folders of the FMU files. If the platform you are using is not in
the Binaries folder, it will not be supported.
• An FMU Block requires a SimulationConfig(see page 49) with endTime (optional) to provide
the reference time in the simulation (shown in Step 3 below). Please see also the
WaterTankFMI build-in sample of Simulation.
1. Drag FMU files into a Block Definition diagram of the SysML project. The FMU files will be
presented as «block» and «fmu» stereotypes along with ports. You may create associations
(aggregations) with the main system block to make the FMU files become part properties.
2. If there is only one FMU file to simulate, proceed to Step 3. Otherwise, you will have to create an
Internal Block diagram for the main system block to automatically include part properties in the
diagram. Select the Flow Port context menu to show flow ports of those properties and create
connections as needed.
The SysML elements that Cameo Simulation Toolkit supports are outlined below:
Adjunct property
An Adjunct Property is a property to which the stereotype «AdjunctProperty» is applied. Its tag
definition principal : Element[1] is for an element to determine the value of an adjunct property. With
regard to the SysML Specification, a principal can be a Connector, a CallAction, an ObjectNode, a
If you use an adjunct property to represent an entry/do/exit behavior of a state, an effect behavior of a
transition, and a method behavior of a call operation in a CallMessage in MagicDraw SysML plugin and
Cameo System Modeler, you can use Cameo Simulation Toolkit to show you the value of such adjunct
property during simulation.
Note
• CallBehaviorAction and CallOperationAction are subtypes of CallAction.
• ActivityParameterNode is a subtype of ObjectNode.
Block
A SysML block is a UML Class stereotyped with «Block». Cameo Simulation Toolkit simulates a SysML
block the same way it simulates a UML Class.
Association Block
A Block stereotype extends Class so it can be applied to any specialization of Class including Association
Classes. Association Classes are informally called “Association Blocks.” An Association Block can own
properties and connectors just like any other Block. Each instance of an Association Block can link
together instances of the end Classifiers of the Association. To refer to the linked objects and values of
an instance of an Association Block, it is necessary for the modeler to specify which (participant)
properties of the Association Block identify the instances being linked at which end of the Association.
The value of a participant property on the instance (link) of the Association Block is the value or object
at the end of the link corresponding to this end of the Association.
BoundReference
According to the SysML specification, a bound reference must have a binding connector to a property
or a nested property of an owning block. Therefore, Cameo Simulation Toolkit will set the value of the
bound reference so that it works with the properties connected with the binding connector. In
exceptional circumstances, for example, if a Classifier that types a bound reference is a subtype of a
Classifier that types a property at the other end of a binding connector, Cameo Simulation Toolkit will
use the Classifier that types the bound reference to initialize the object. You can see more information
about binding connector simulation in Binding Connector(see page 484).
8
10 https://docs.nomagic.com/download/attachments/82762215/execute_objectwithAdjunct.png?
api=v2&modificationDate=1496892014926&version=1
Simulation console messages showing Block System1, System2, Super1 and Super2 all running
asynchronously.
Constraint Block
A constraint Block is a subtype of a Block. It is a class stereotyped with «ConstraintBlock». It has a
constraint with an expression to constrain the values of its constraint parameters. If an object initialized
from a constraint Block and a value bound to a constraint parameter of that object is changed, Cameo
Simulation Toolkit will evaluate the expression of the constraint. You can see more information about
how Cameo Simulation Toolkit evaluates an expression in Evaluating expressions(see page 413).
Flow property
A flow property is a property to which the stereotype «FlowProperty» is applied. A flow property has a
flow direction. A flow due to flow properties will incur flow properties matching. Matching flow
properties must have the same direction and type. If the direction and type of multiple flow properties
at either end of a connector match, a flow will occur between the flow properties with the same name.
Port
Note
• A conjugated Port (isConjugated = True) is indicated with a tilde (∼) in front of the Port
type, showing that the property Flow direction of the Port is reversed, from in to out and
from out to in.
• For the nested Port, if the parent Port is conjugated, all of property Flow directions of its
children and grandchildren will be reversed.
Related pages
Flow Port
Flow Ports with animation of value propagation in the Internal Block diagram.
Related pages
Full Port
A Full port is a port stereotyped with «FullPort». It specifies a separate Element of an owning block.
Initializing the owning block will cause Cameo Simulation Toolkit to initialize a port object from a
Classifier that types the full port.
109 https://docs.nomagic.com/display/SYSMLP2021xR2/Flow+Port
Related pages
Proxy Port
A Proxy Port is a Port stereotyped with «ProxyPort». When Cameo Simulation Toolkit simulates an
object that has a proxy Port, the value that specifies the proxy Port will be the reference of the object
that is the target of the Flow. A Classifier of the target object must be inherited from an interface Block
If the proxy Port is not connected by a delegation Connector to the internal structure of the owning
object, the target will be the object itself.
Features defined by Interface Block, e.g., Flow properties, can be displayed in the Variables pane (when
selecting the Show Ports option for the Variables pane in the Environment option dialog) under
Proxy Port nodes during simulation as shown in the figure below.
Note
Other properties which are not part of the Ports, e.g., minlevel and maxlevel of Controller are not
shown because Ports can be only accessed and display what is defined by «interfaceBlock».
Related pages
Probability
Probability is a stereotype in SysML. You can apply it to outgoing edges of decision nodes and object
nodes. When Cameo Simulation Toolkit simulates a decision node or an object nodes whose outgoing
edges stereotyped with probability, it will use the probability values collected from all outgoing edges to
select one outgoing edge that it will go to.
Value type
On this page
1. Right click a constraint property object in the Variables pane and select Go To (see the following
figure).
2. Select the name of a requirement that appears on the sub menu. Cameo Simulation Toolkit will
show you the SysML requirement that is related to the constraint property specified by the
selected object in the Containment tree.
The preceding figure shows the block Circle whose constraint property typed by the constraint
block Maximum Area, which refines the requirement Maximum Area. It also shows you that if you
right-click the object that specifies the constraint property when Cameo Simulation Toolkit is executing
the block Circle, and select the Go To context menu, you will see the requirement Maximum Area.
Selecting the requirement on the menu will highlight that requirement in the Containment tree.
A tooltip message of a failed test case in the Variables pane is in the example as follows.
Non-normative extensions
Non-normative extensions to SysML considered for standardization in future versions of the language
consist of stereotypes and model libraries and are organized by major diagram types, which are
consistent with how the main body of this specification is organized.
110 http://sysml.org/docs/specs/OMGSysML-v1.4-15-06-03.pdf
Related pages
Normally, a script will be defined in an opaque expression. Therefore, if your model has any value
specifications (like guards, constraints, decisions, default values, and opaque Behaviors) that can be
defined with opaque expressions, they will be simulated during the model simulation.
Some special cases, however, apply for Activity edges that do not have any guard expression and
decision nodes that do not have any Decision Input specified. The name of the Activity edge and the
decision node will be evaluated by Cameo Simulation Toolkit using a default scripting language as
shown in the figure as follows.
The decision input that is unspecified and the guards that are empty.
You can use different languages for different opaque expressions in your model. Cameo Simulation
Toolkit will use a scripting engine that matches the specified language of the opaque expression to
simulate the script content.
When CST is integrated with external Math engines (e.g. MATLAB, Mathematica, OpenModelica or
Maple), corresponding languages are also added into the supported language list.
Additionally, you can download and install any other JSR-223 standard compatible language.
The following figure demonstrates how you can read Enumeration literal value by name directly
through the property Change Expression colour=="Green" and setting the guard condition
colour=="Red" instead of colour.getName()=="Green", and colour.getName()=="Red" accordingly in the
Specification window of the Transition<>.
Cameo Simulation Toolkit can make references to model Elements using HTML through the Edit
Hyperlink dialog(see page 509). Those objects that allow references are ValueSpecification.Value,
LiteralString.Value, OpaqueExpression.Body, OpaqueAction.Body, OpaqueBehavior.Body,
Constraint.Specification, and ObjectFlow.Guard.
This feature has been developed to have references in text to model elements in various scripts.
Cameo Simulation Toolkit converts HTML into plain texts before execution. In the following figure,
ValueSpecification.Value (b) can refer to slot (b = 4) of an InstanceSpecification (Ins). If the value of slot
(b = 4) changes, ValueSpecification.Value (b) will change accordingly.
Related page
111 https://docs.nomagic.com/display/MD2021xR2/Tag
You can also run the command without the runtime object even if no runtime object is provided, e.g.,
ALH.getTagValue(String tagName), as shown in the following figure.
Note
Only *.jar files are supported as the external libraries.
1. Click Options > Project on the main menu to open the Project Options dialog.
2. Select General project options on the left-hand side of the dialog and select External
Libraries from the Simulation Script Engine option.
$signal$ or _signal_ The last signal Instance in an Event pool of a specified object.
$state$ or _state_ An active State of a context or a runtime object of a current script evaluation.
sig_ + "property name" The specified property value of the last signal.
ALH APIs
This section contains all available ALH (Action Language Helper) APIs that you can use in Cameo
Simulation Toolkit, e.g., to get and specify a Structural Feature value. You can also call a specific
Behavior and operation by using ALH APIs. Creating a runtime object and getting its current State or
creating Signal instance are also possible. With ALH APIs, a Signal instance can even be sent to a specific
target object. Additionally, you are able to get a token value, retrieve the last signal instance from a
runtime object, evaluate an expression, create an Array list in Java, check the State of an object, add a
value to an object or remove it, get a context or runtime object of a current script evaluation, access
current simulation time and simulation time unit, and add a value to, get a value from, check an
existing, or remove a global variable. You can also check a specified State to see if it was visited and
trace the caller of a script to access it.
Information
• You can find more examples of ALH usage at <installation
directory>\samples\simulation\SmallTestSamples.mdzip (ALH Tests section).
• For more information, see the JavaDoc of ALH at <installation
directory>\openapidocs\SimulationJavaDoc.
Related pages
The following example shows how to get the value of the structural feature indicated above in ALH API.
Information
While using Rhino JavaScript, the return value of ALH.getValue() is not automatically UnBoxed
to a primitive type. Users needs to handle such UnBoxing by themselves, by using
ALH.getValue(object, "speed").intValue() to get the value of primitive integer type.
Information
Alternatively, you can use ALH API through the fUML object syntax, with
object.get(featureName). For example:
• value = object.get("speed");
The following example shows how to specify the value of the structural feature in ALH API:
Information
Alternatively, you can use ALH API through the fUML object syntax, with
object.set(featureName, value). For example:
• value = object.set("speed", "10");
The following example shows how to call the "test" specified Behavior in ALH API
value = ALH.callBehavior("test");
You can also give initial parameter values in which the arguments lists must be created.
arguments = ALH.createList();
arguments.add("value1");
arguments.add("value2");
value = ALH.callBehavior("test", arguments);
If a found Behavior value is null or an argument's size is not equal to the in or inout parameter's size of
the found Behavior, an IllegalArgumentException will be thrown.
The following example shows how to call a specified operation in ALH API by passing the operation's
name
value = ALH.callOperation("test");
You can also give initial parameter values in which the arguments lists must be created by executing
the following code
arguments = ALH.createList();
arguments.add("value1");
arguments.add("value2");
value = ALH.callOperation("test", arguments);
If a found Behavior value is null or an argument's size is not equal to the in or inout parameter's size of
the found Behavior, an IllegalArgumentException will be thrown.
The following example shows how to create a runtime object (Object_), typed by a specified Classifier in
ALH API.
If a passing parameter is typed by a String, the API will find a Class in the model that has a matching
name, and then create the runtime object typed by that Class.
ALH.createObject("Car");
ALH.createObject(a);
ALH.createSignal("start");
ALH.createObject("statemachine::signals::start");
ALH.createSignal(s); ---> if 's' is an instance of a Signal.
The parameter of this API can be either a String or a Signal. If it is a String, the system will find a Signal
whose name or qualified name contains the String.
• If a signal name contains "::", it will find the signal from a qualified name. The signal will be found
if its qualified name is ended with signalName.
• If an object is an instance of an Object_, send the signal to that Object_ directly.
• If an object is an instance of a String, there are two possible cases as follows
• It will find the target object(s) from all waiting objects whose part/property names match
the target's String parameter.
• It will find the target object(s) through connected ports, given that the port is the name of
the current object.
The following example shows how to send a specific signal to a specific target object in ALH API
All parameters must not be null, otherwise the ScriptEngine errors will be thrown.
object getTokenValue()
The following code fragment shows how to get a token value of an active model element in ALH API
ALH.getTokenValue();
The following code fragment shows how to get the current state of a specified object using ALH API
ALH.getState(o);
com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.State.
SignalInstance getLastSignal(Object_ o)
The following code fragment shows how to get the last signal instance in the event pool of a specified
object using ALH API
ALH.getLastSignal(o);
fUML.Semantics.CommonBehaviors.Communications.SignalInstance.
Evaluating an expression
You can use the following API to evaluate an expression
The following code fragment shows how to evaluate expressions in ALH API
result = ALH.evaluate("a+b");
ALH.setValue($context$, "display", result);
A Java List will be required under certain circumstances, e.g., if you want to create Argument values that
will be passed to some calling Behaviors or operations. In scripting languages, the built-in functions
importPackage and importClass can be used to import the Java packages and Classes.
The following code fragment shows how to create a Java ArrayList in the scripting language using a
"new" operator
importPackage(java.util);
arguments = new ArrayList();
arguments.add("value1");
The following code fragment shows how to create the Java ArrayList in the scripting language with ALH
arguments = ALH.createList();
arguemnts.add("value1");
arguments = ALH.createList("value1");
Note
• Only one initial value of the list is allowed.
• Variable-length argument lists are not supported.
Unless the object is specified, it will use the current active object, for example:
if (ALH.inState(ccobj, "Operating")) {
Information
Alternatively, you can use ALH API through the fUML object syntax, with object.in(stateName).
For example:
• ccobj.in(“Operating”);
If you have more than one value to add to an object, e.g., the value of the upper bound of the
multiplicity is more than one, you can still add the values by using the parameter insertAt.
The following code fragment shows how to add values to an object, e.g., System.p1, through ALH API.
Information
Alternatively, you can use ALH API through the fUML object syntax, with
object.addValue(featureName, value) and object.addValueAt(featureName, value,
insertAt). For example:
• System.addValue(”p1”,10); // System.p1 = [10]
• System.addValue(”p1”,30); // System.p1 = [10, 30]
• System.addValueAt(”p1”,20,2); // System.p1 = [10, 20, 30]
You can remove an object's value by executing the following code fragment
If you want to remove more than one value from an object, e.g., the value of the upper bound of the
multiplicity is more than one, you can remove them by using the parameter removeAt.
The following code fragment shows how to remove values from an object, e.g., System.p1, through ALH
API.
Information
Alternatively, you can use ALH API through the fUML object syntax,
with object.remove(featureName) and object.removeAt(featureName, removeAt). For
example:
• print(System); // System.p1 = [10, 20, 30]
• System.removeAt(”p1”,3); // System.p1 = [10, 20]
• System.remove(”p1”,20); // System.p1 = [10]
Getting a context
You can use ALH API to get a context or a runtime object of a current script evaluation. It is equivalent
to $context$ and self.
Object_ getContext()
The following code fragment shows how to get a context of a runtime object through ALH API.
double getCurrentTime()
double getCurrentTime(String timeUnit)
The following code fragment shows how to get the simulation time of execution through ALH API.
ALH.getCurrentTime();
ALH.getCurrentTime("ms");
The following code fragment shows how to get the TimeUnit tag of a SimulationConfig through ALH
API.
ALH.getTimeUnit(); // millisecond
The example code assigns 1 to a global variable named GLOBAL_COUNT. If the global variable with the
given name does not exist, this method will create a new global variable with the same name and add
the value to it.
var a = ALH.getGlobalVariable("GLOBAL_COUNT") + 1
Note
You can obtain the value of a global variable directly by using its name.
var a = GLOBAL_COUNT + 1;
The following code fragment shows how to remove a global variable, e.g., GLOBAL_COUNT, that was
previously defined through ALH API.
ALH.removeGlobalVariable("GLOBAL_COUNT");
The following code fragment shows how to check if a global variable, e.g., GLOBAL_COUNT, is defined
through ALH API.
The following code fragment shows how to check whether a specified State of State Machine, e.g.,
State1, was visited through ALH API.
NamedElement getCaller()
It will return the Caller element of the script. For example, if a Behavior that runs a script is called from
a callBehavior, you will get a callBehavior action as the Caller.
The following code fragment shows how to trace from where the script was called, e.g., from State1,
through ALH API.
If the RuntimeObject is omitted, $context$ or self will be used as an object. The context object in the
parametric is the constraint block object that owns the constraint, not the actual context of the
diagram. The following example shows how to get a tag value without specifying a RuntimeObject in
ALH API:
The following code fragment shows how to get tag values, e.g., max, through ALH API. See also Value
access and references by tags(see page 510).
ALH.getTagValue(d, “uniform.max”); // 10
Information
Alternatively, you can use ALH API through the fUML object syntax, with
object.getTagValue(tagName). For example:
• d.getTagValue(“uniform.max”); // 10
The provided APIs in Cameo Simulation Toolkit are given in the following pages
The APIs can ignore the sheetName and use the first sheet of the selected spreadsheet instead.
The following API will read the values from multiple rows of the selected spreadsheet in the Excel file,
and then create the fUML ValueList to store the values.
The APIs can ignore the sheetName and use the first sheet of the selected spreadsheet instead.
If you want to read all values from the selected spreadsheet, you can use the following API:
The API can ignore the sheetName and use the first sheet of the selected spreadsheet instead.
The mappingClass parameter can be a String or an element for representing a mapping Class name or
a mapping Class element.
Information
«ImportMap»112can be used as the mappingClass. However, it is strongly recommended that
you define the distinctive name of «ImportMap» and the «DiagramTableMapToDataSource» (an
Instance table linked to an Excel file) when using to avoid conflict of object mappingClass.
The APIs can ignore the mappingClass then create the runtime object of the file schema element that is
matched with filename.
The following API can assign a name parameter to check the name of a mappingClass or a sheetName.
If the matching mappingClass cannot be found, this API will use the file schema element to create a
runtime object and check the sheet name of the Excel file with the name parameter.
112 https://docs.nomagic.com/display/MD2021xR2/Saving+an+Import+Map
The APIs can ignore the sheetName and use the first sheet of the selected spreadsheet instead.
The mappingClass parameter can be String or Element for represent the mapping Class name or
mapping Class Element. The APIs can write the runtime objects of the file schema element to
spreadsheet that is matched the file name by ignore the mapping class.
Information
You can also write runtime values to an Excel file (.xlsx) as an attached file supported(see page
145).
The APIs can ignore the sheetName and use the first sheet of the selected spreadsheet instead.
Server-side simulation
On this page
If you work with Teamwork Cloud projects, you can simulate them on the server without using a
modeling tool. You can execute your models either by using REST API or via Cameo Collaborator for
Teamwork Cloud user interface (if there are Cameo Collaborator documents published from those
models).
flexnet.server.name=<server_ip/server_address>
113 https://docs.nomagic.com/display/TWCloud2021xR2/Teamwork+Cloud+Documentation
114 https://docs.nomagic.com/display/TWCloud2021xR2/Installation%2C+configuration%2C+and+licensing
• Currently, there is no UI in the simulation web application, so UI-based features (like charts,
timelines, controls, breakpoints, animation, variables tree, etc.) are not available.
• You can execute only one simulation at a time.
• Project options cannot be read, so default option values are always used instead of the actual
ones.
• Math engine integrations (Matlab, Mathematica, etc.) are not available.
• FMI/FMU co-simulation is not available.
• UseCase Execution is not available.
• Execution of historical project revisions is not available.
• Validating Requirement-based runtime models is not available.
• Lifelines representing Properties with nested paths in InteractionEngine are not available.
• DSL stereotypes are not applied to created Slot and InstanceSpecification elements
• Finding elements by Name (e.g Signals, Operations with ALH, mapping with ExcelHelper) is not
available.
Related pages
On this page
It is possible to simulate Teamwork Cloud projects on the server by using REST API. The topics below
describe all available REST API requests and provide examples of how to use them.
Prerequisites
Before starting the simulation, make sure you have prepared your environment and projects
for server-side simulation as described in the following topics:
• Preparing the environment for server-side simulation(see page 534)
• Preparing projects for server-side simulation(see page 535)
You can use the following REST API requests to simulate Teamwork Cloud projects on the server:
• GET /simulation/api/start/project/<project>/branch/<branch>/element/<element_id>/config/
<config>(see page 536)
• GET /simulation/api/status/<simulation_id>(see page 538)
• GET /simulation/api/results/<simulation_id>(see page 539)
• GET /simulation/api/running(see page 540)
• GET /simulation/api/terminate/<simulation_id>(see page 540)
• GET /simulation/api/hasConfigs/project/<project>/branch/<branch>(see page 541)
• GET /simulation/api/configs/project/<project>/branch/<branch>/element/<element_id>(see page
541)
Start simulation
POST /simulation/api/start/project/<project>/branch/<branch>/element/<element_id>/config/
<config>
This REST API request starts the simulation. It connects to Teamwork Cloud, finds the element to
execute, and starts the simulation if the element exists. After the simulation is complete, the request
constructs and returns a unique ID (per application) for the given execution.
The following table describes the parameters used in the REST API request:
branch path optional The project branch name or ID. If the branch is omitted, the trunk is
used instead.
? quer optional A new project version is committed with the simulation results.
commitRes y Available values are true or false (default).
ults
inputs body optional A set of input parameters with values, which will be provided for the
simulation.
outputs body optional A set of output parameters, which will be obtained after the simulation
is complete. If no output parameters are specified, all initialized values
are returned.
/simulation/api/start/project/SpacecraftMassRollup/branch/2/element/519701b0-
bec8-4f51-aad5-152a5411d60b/config/spacecraft mass analysis?resultAsJson=true
{
"simulationId": "c7944233-a1cb-4310-a62f-48bce07dd71c"
}
{
"simulationId": "cf83877b-86cc-466c-89a1-af97619a9a86"
}
/simulation/api/start/project/8715fcfa-fd34-4928-8480-13f4439cec3d/element/519701b0-
bec8-4f51-aad5-152a5411d60b/config/7915fcfa-fd88-4910-8560-13f4439cec3d
{
"simulationId": "b7bdf933-f58d-4e7e-b73b-8370c60485cd"
}
Response:
{
"simulationId": "b7bdf933-f58d-4e7e-b73b-8370c60485cd"
}
GET /simulation/api/status/<simulation_id>
This REST API request gets the status and elapsed time for a specific simulation. It returns the actual
elapsed time of the simulation thread and the simulation state (RUNNING, COMPLETED, TERMINATED,
ERROR).
The following table describes the parameters used in the REST API request:
/simulation/api/status/ce8c8215-0515-43fd-9d34-92d1d7a95d87
{
"state": "COMPLETED",
GET /simulation/api/result/<simulation_id>
This REST API request returns the results of the specified simulation. In the start REST API body, you can
specify what output parameters should be returned. If output parameters are not specified, all output
parameters are obtained. In addition, if the CSV export results are available, they are returned in JSON
format.
The following table describes the parameters used in the REST API request:
/simulation/api/results/ce8c8215-0515-43fd-9d34-92d1d7a95d87
{
"outputs": {
"me": 98.0,
"propulsion.me": 68.0,
"propulsion.tank.me": 38.0,
"propulsion.thruster.me": 30.0,
"telecom.me": 30.0,
"telecom.antenna.me": 10.0,
"telecom.amplifier.me": 20.0
},
"csv exports": {
"'SpaceCraftResults' csv export":
"me,propulsion.me,propulsion.tank.me,propulsion.thruster.me,telecom.me,telecom.amplif
ier.me,telecom.antenna.me\n98.0000,68.0000,38.0000,30.0000,30.0000,20.0000,10.0000\n9
8.0000,68.0000,38.0000,30.0000,30.0000,20.0000,10.0000\n98.0000,68.0000,38.0000,30.00
00,30.0000,20.0000,10.0000\n"
}
}
GET /simulation/api/running
This REST API request gets the list of all currently running simulations that you have started.
/simulation/api/running
["9bc18e3e-b544-4652-9bdb-6da1d75f7ea1"]
Terminate simulation
GET /simulation/api/terminate/<simulation_id>
The following table describes the parameters used in the REST API request:
/simulation/api/terminate/4e35bc60-2c66-48e8-96e2-80f5270c08cf
/simulation/api/status/4e35bc60-2c66-48e8-96e2-80f5270c08cf
{
"state": "TERMINATED",
GET /simulation/api/hasConfigs/project/<project>/branch/<branch>
This REST API request checks if the project has any Simulation Configurations.
The following table describes the parameters used in the REST API request:
branch path optional The project branch name or ID. If the branch is omitted, the
trunk is used instead.
/simulation/api/hasConfigs/project/SpacecraftMassRollup
{
"hasConfigs": true
}
GET /simulation/api/configs/project/<project>/branch/<branch>/element/<element_id>
This REST API request retrieves element IDs, names, and descriptions of the Simulation Configurations
available for the given executable element.
If the executable element is an Instance Specification, the method returns the following Simulation
Configurations:
branch path optional The project branch name or ID. If the branch is omitted, the
trunk is used instead.
/simulation/api/configs/project/SpacecraftMassRollup
{
"configId": "7915fcfa-fd88-4910-8560-13f4439cec3d",
"configName": "spacecraft mass analysis",
"documentation": ""
}
Prerequisites????
Before starting the simulation, make sure you have prepared your environment and projects
for server-side simulation as described in the following topics:
• Preparing the environment for server-side simulation(see page 534)
• Preparing projects for server-side simulation(see page 535)
• In Jupyter Notebook, run the following command to install a Python package from the
websimR1.zip file (contact your sales executive to get the archive file):
Use the following requests to simulate Teamwork Cloud projects on the server:
This request starts a work session and provides authentication to Teamwork Cloud.
Start simulation
branch path optional The project branch name or ID. If the branch is omitted, the trunk is
used instead.
commit_res path optional A new project version is committed with the simulation results.
ults Available values are True or False (default).
data path optional A set of output parameters, which will be obtained after the simulation
is complete.
# SpaceCraftMassRollup sample
parameters = {
"inputs":
{
"telecom.antenna.me":10,
"telecom.amplifier.me":20
},
"outputs":
[
"me",
"propulsion.me",
"propulsion.tank.me",
"propulsion.thruster.me",
"telecom.me",
"telecom.antenna.me",
"telecom.amplifier.me"
]
}
branch pat optional The project branch name or ID. If the branch is omitted, the trunk is used
h instead.
commit_r pat optional A new project version is committed with the simulation results. Available
esults h values are True or False (default).
data pat optional A set of output parameters, which will be obtained after the simulation is
h complete.
# SpaceCraftMassRollup sample
parameters = {
"inputs":
{
"telecom.antenna.me":10,
"telecom.amplifier.me":20
},
"outputs":
[
"me",
client.get_status(<simulation_id>)
client.get_result(<simulation_id>)
client.get_running()
This request gets the list of all currently running simulations you have started.
Terminate simulation
client.terminate(<simulation_id>)
branch path optional The project branch name or ID. If the branch is omitted, the
trunk is used instead.
client.has_configurations(<project>, branch=<branch>)
This request retrieves the names and descriptions of the Simulation Configurations available for the
given project.
branch path optional The project branch name or ID. If the branch is omitted, the
trunk is used instead.
On this page
• Preparing projects for simulation in Cameo Collaborator for Teamwork Cloud(see page 548)
• Simulating projects in Cameo Collaborator for Teamwork Cloud(see page 551)
Cameo Collaborator for Teamwork Cloud(see page 548) has a user interface that allows you to simulate a
project directly in the Cameo Collaborator document published from that project.
• The project must have an Instance Table with the instance you want to execute, because
simulation in Cameo Collaborator is only possible using Instance Tables.
• For simulation results to be saved, you need to specify the Result Location property of a
Simulation Configuration. The value of the Result Location property should be the instance in
which you want to save simulation results.
• The executable model should not require any user input because Cameo Collaborator does not
support UI. This means that simulation needs to be performed fully automatically.
• The executable model must end automatically without any user input.
To prepare the SpacecraftMassRollup.mdzip sample for simulation in Cameo Collaborator for Teamwork
Cloud
3. Open the Specification window of the spacecraft mass analysis Simulation Configuration and
specify the Result Location property. Its value should be the instance in which you want to save
simulation results. Let's say you want to save the results in the same spacecraft instance which
you intend to execute.
4. In the same window, make sure the UI property is not specified because simulation should not
require any user input. If the UI is specified, it will be ignored.
6. Save and add the project to Teamwork Cloud115 (if the project is local).
7. Publish the project to Cameo Collaborator for Teamwork Cloud(see page 548).
Now you can open the Cameo Collaborator document and simulate the model on the web.
1. Open the Cameo Collaborator document(see page 548) published from the project you want to
simulate.
2. Navigate to the Instance Table with the instance you intend to simulate.
115 https://docs.nomagic.com/display/MD2021xR2/Adding+projects+to+Teamwork+Cloud
Note
When you simulate a project in Cameo Collaborator for Teamwork Cloud, a new project
version is created with the following commit message: Simulation WebApp: '<Simulation
Config Name>' execution results.
Prerequisites
To run the simulation with a Simulation Template from Simulia, the following conditions must
be met:
• The Process Composer Integration plugin has to be installed in your modeling tool.
• You need to have access to a Simulation Template in Simulia.
• The Simulation Profile must be used in the project you want to simulate.
1. In the main menu of a modeling tool, select 3DEXPERIENCE > Login and log into the
3DEXPERIENCE platform116.
116 https://docs.nomagic.com/display/MD2021xR2/Authentication+with+3DEXPERIENCE+platform
4. Model the Activity diagram to provide inputs and outputs for the Simulation Template (the Call
Behavior Action created after dragging the template to the diagram).
On this page
Activity simulation
Question 1:
Why isn't an operation outside a context object executed, e.g., an operation referring to an Activity
outside a Block?
Answer: According to the fUML specification, an operation will be dispatched to the target object only,
which is the context of the execution. You need to move the Activity into the Block and use it as a
CallBehaviorAction with the Behavior setting.
Answer: Yes, you can set the Auto-Create fUML Object of Output Pin option in the
Simulation Project Options(see page 47) dialog to true, which is the default value in Version 19.0 SP2 and
later. Please see also Dummy tokens of Actions through Output Pins(see page 342).
Parametric evaluation
Question 1:
Why can't I use MATLAB as an external evaluator even after integration with MATLAB(see page 451) of the
modeling tool?
Answer: You must use either the 64-bit or 32-bit version of MATLAB (Version 2012a or later) to align it
with the 64-bit or 32-bit version of the modeling tool you are working with, e.g., MagicDraw or Cameo
Systems Modeler. According to using MATLAB on 32-bit and 64-bit Microsoft Windows117, you must also
ensure that Path of System variables in the Environment Variables dialog is set to the correct
MATLAB path.
Question 2:
Answer: Yes, you can use MATLAB 2019b as an external evaluator. MATLAB R2019b has a new option,
Single simulation output, set true by default in Simulink, which doesn’t affect the simulation.
However, there are a few limitations as follows:
• If Simulation cannot load the Simulink, e.g., an invalid URL/ filename, both warning and script
exception messages will be printed in the Console panel. In this case, the MATLAB engine cannot
be used, so you will need to manually restart MATLAB.
• If there is no input for the In Port, Simulation will skip the evaluation, and a warning message will
be printed in Console panel.
Can I change State activation semantics from before entry (official UML semantics) to after entry?
117 https://docs.nomagic.com/display/CST2021xR2/Using+MATLAB+on+32-bit+and+64-bit+Microsoft+Windows
Related pages
On this page
• Don’t: Create an fUML loop without any Action Activation(see page 557)
• Do: Add an Action Activation in the loop(see page 558)
118 https://docs.nomagic.com/display/MD2021xR2/Call+Behavior+Action
The model runs an infinite loop without StackOverflowError, and the execution
is not terminated.
Related pages
Developer Guide
All material contained herein is considered proprietary information owned by No Magic, Inc. and is not
to be shared, copied, or reproduced by any means. All information copyright 2010-2021 by No Magic,
Inc. All Rights Reserved.
Introduction
This document describes the Application Programming Interface (API) of Cameo Simulation Toolkit,
which is categorized into two fundamental APIs: (i) Java API and (ii) Action Scripts API.
The Java API is mostly used together with the MagicDraw plugin and the Action Script API is used
independently for each supported model element in a MagicDraw project.
All of the Cameo Simulation Toolkit API classes are packaged in the jar file simulation_api, which is
located in
• URL: http://jdocs.nomagic.com/190/CST121
• <MagicDraw installation directory>/openapi/docs/simulation/SimulationJavaDoc.zip
For more information about creating a new MagicDraw plugin, see the MagicDraw Open API user guide
located in
Note
Before going through each example given in this document, make sure that simulation.jar and
simulation_api.jar has been added to your IDE classpath.
SimulationOptionProvider interface
Simulation provides an internal API so that execution can have all simulation options from the
SimulationOptionProvider interface as shown in the figure below. You can use the Simulation API
independently in Teamwork Cloud or other platforms without modeling tool environment, e.g.,
MagicDraw.
119 https://docs.nomagic.com/display/MD2021xR2/Action
120 https://docs.nomagic.com/display/MD2021xR2/Call+Behavior+Action
121 http://jdocs.nomagic.com/190/CST/
SimulationOptionProvider interface.
Information
You can find more details about the Simulation JavaDoc file at <MagicDraw installation
directory>/openapi/docs/simulation/SimulationJavaDoc.zip.
Java APIs
Through Java APIs, a simulation execution starts when the specific element is executed. You can start
the execution(see page 561), stop the execution(see page 561), and create and register a new Simulation
Execution Listener(see page 562) using Java APIs. Regarding the core component of the entire execution
mechanism, the execution engine(see page 564) defines how to execute a set of Element types. fUML
Helper(see page 568) is also available as a Class that provides Helper methods related to the fUML
structures. The Parametric engine also provides Java APIs for a parametric execution with a runtime
object of a Classifier.
Information
Related pages
Execution
A simulation execution represents a model execution of a specific element. It is the top level of the
model execution which contains running execution sessions and execution engines. A simulation
execution will start when the specific element is executed (through the graphical user interface or Java
API). The following APIs are available for handling executions.
• Start Execution
• Stop Execution
• Creating and Registering a New Execution Listener
Related pages
Starting execution
With Cameo Simulation Toolkit, you can start executing an element using the following Open APIs
• The specified element could be any executable element, such as a Class, a Behavior, or an
simulation configuration element.
• If the executed element is intended to be the main element of the execution, set the
"isMainSession" flag to true. Then, the created session will become the main session of the
execution. The main session is the first session created once the execution starts. If the main
session is terminated, all executions will be terminated accordingly.
• If the "start" flag is set to true, the created session will start itself automatically (similar to the
'autorun' option in an SimulationConfig).
Stopping execution
You can stop an execution by terminating its main session. Cameo Simulation Toolkit allows you to
terminate any simulation session using the following Open API
122 http://jdocs.nomagic.com/190/CST/
• An execution is started.
• An element is activated.
• An element is deactivated.
• A signal event is triggered.
• An operation is called.
• A behavior is called.
• A runtime object is created.
• An execution is terminated.
Once you have created the execution listener, you can register it to a list of global execution listeners.
To register a new execution listener to a global list, type the following code
SimulationManager.registerSimulationExecutionListener(listener); //listener is an
instance of SimulationExecutionListener.
All registered listeners will be cleared and removed automatically when the execution is terminated.
All open APIs below are used by the Simulation Dashboard plugin and can be added for particular
purposes.
SimulationManager.registerSimulationExecutionListener(SimulationExecutionList Registers
ener listener, SimulationExecution execution) SimulationExecution
Listener dynamically
during the
execution.
SimulationManager.unregisterSimulationExecutionListener(SimulationExecutionL Unregisters
istener listener) SimulationExecution
Listener.
SimulationManager.unregisterSimulationExecutionListener(SimulationExecutionL
istener listener, SimulationExecution execution)
Engine
An Execution Engine is a core component of the entire execution mechanism. It defines how to execute
a set of Element types, e.g., Elements in an Activity diagram, Elements in a State Machine diagram, and
so on.
API developers can create their own execution engines with the corresponding engine descriptors and
listeners, and register those engines to the simulation manager.
API developers can insert any desired code into the above abstract methods and get the events when
the execution engine is initialized, executed, and terminated.
You can execute the following code to create a MyExecutionEngine class
@Override
public void execute(Element element) {
...
}
@Override
public void init(Element element) {
Project project = Project.getProject(element);
// add engine listener if needed
EngineListener listener = new MyEngineListener(project);
addEngineListener(listener);
}
@Override
public void onClose() {
...
}
}
The created class MyExecutionEngine must be returned from createEngine() of its descriptor as defined
in Creating an execution engine descriptor(see page 565).
The new execution engine descriptor must implement the ExecutionEngineDescriptor or extend the
AbstractExecutionEngineDescriptor abstract Class. You can find details about these Classes in JavaDoc.
@Override
public ExecutionEngine createEngine() {
return new MyExecutionEngine(this);
}
@Override
public String getEngineName() {
return "My Execution Engine";
}
}
The created execution engine descriptor must then be registered to the simulation manager (see
Registering an execution engine to the Simulation Manager(see page 567)).
@Override
public void elementActivated(Element element, Collection<?> values) {
System.out.printIn("--Activate Element-- : element name =
" ((NamedElement)element).getName());
}
@Override
public void elementDeactivated(Element element, Collection<?> values) {
System.out.printIn("--Deactivate Element-- : element name = " +
((NamedElement)element).getName());
}
@Override
public void eventTriggered(String eventID) {
NamedElement element = (NamedElement)project.getElementByID(eventID);
System.out.printIn("--Event Trigger-- : event name = " +
((NamedElement)element).getName());
@Override
public void executionTerminated() {
System.out.printIn("--Engine Terminated--");
}
}
Once you have created an EngineListener, you can register it to the specified ExecutionEngine if you
want to receive events occurring in each execution engine. All engine listeners of a specific engine will
be activated under the conditions as follows
• An element is activated.
• An element is deactivated.
• An event is triggered.
• An engine is terminated.
See Creating a new execution engine(see page 564) for more information about adding execution engine
listeners to the MyExecutionEngine class.
Note
You can add more than one execution engine listener to an execution engine.
SimulationManager.registerEngine(new MyEngineDescriptor());
Triggering an Event
An execution engine can trigger a given Event by calling the triggerEvent(String event) of an
ExecutionEngine. Just like the activateElement() and deactivateElement() methods, this method is
mostly used in the ExecutionEngine.execute(element).
If the triggerElement(String event) is called, the eventTriggered(String eventID) of all registered engine
listeners will be activated.
fUML Helper
An fUMLHelper is a Class that provides Helper methods related to the fUML structures. See JavaDoc for
more details about this Class.
com.nomagic.magicdraw.simulation.parametrics.utility.ParametricsHelper.executeObject(
Object object);
An argument object is a runtime object of a classifier to be executed. To obtain this particular runtime
object, you can use some UML actions, e.g., ReadSelfAction, ReadStructuralFeatureValueAction,
ValueSpecificationAction, or the Cameo Simulation Toolkit Open API. The following figure shows the
Parametric Activity diagram in the CylinderPipe.mdzip sample. The action : ExecuteParametric is used
to run the parametric execution. The runtime object, which will be executed, is obtained from the value
Specification Action rawMaterialSupplier.
Tutorial
All material contained herein is considered proprietary information owned by No Magic, Inc. and is not
to be shared, copied, or reproduced by any means. All information copyright 2010-2021 by No Magic,
Inc. All Rights Reserved.
This tutorials provides the instructions to create a stopwatch model with MagicDraw and execute the
stopwatch model step-by-step. You will also learn how to create a mock-up user interface to use with
the stopwatch execution.
Before modeling a stopwatch, you will need to know the stopwatch structure and the stopwatch
Behavior.
Stopwatch structure
The structure of the stopwatch model in this tutorial is very simple. It only contains a time property,
which is typed by an integer. The time property will record the elapsed time when the stopwatch
receives a starting Signal. Therefore, the structure of the stopwatch system contains a StopWatch class
that has the time property.
Stopwatch Behavior
This tutorial uses the State Machine diagram to describe the main Behavior of the stopwatch. The
stopwatch has two stages: Initial and final.
• Ready
The State where the stopwatch is ready to start.
• Running
When it receives the start Signal, the stopwatch will run, and the timer will start. In this State, the
stopwatch will be triggered by a time Event to increment the time value by 1 per second.
• Paused
The State where the stopwatch is paused and waiting for the user to restart it.
• Stopped
The State where the stopwatch stops running.
Related pages
This section guides you through the steps required to create a stopwatch model in Cameo Simulation
Toolkit. You will learn how to create a new UML project as the first step, followed by creating the
stopwatch structure through defining the stopwatch Classifier and its structural features and adding a
123 https://docs.nomagic.com/display/MD2021xR2/State+Machine+diagram
Related pages
1. Click File > New Project on the main menu. The New Project dialog will open.
2. Select UML Project from the General-Purpose Modeling group and enter the project name and
location. The project name will be "StopWatch" in this example.
3. Click OK.
1. Right-click Model in the containment browser and select New Element > Package. A new
package will be created under the Model node. Name the created package "system".
2. Create a new Class diagram in the system package by clicking the Class Diagram button on
the Diagrams toolbar. The Create Diagram dialog will open.
Note
You can also use the context menu of the system package to create a new Class diagram
by right-clicking the system package and select New Diagram > Class Diagram.
5. Use the diagram toolbar of Class Diagram to create a new Class Element and name the
created Class "StopWatch".
1. Click the manipulated button (the small orange button) in the StopWatch Class. A new Attribute
will be created in the StopWatch Class.
2. Name the Attribute "time" and type it with an Integer by directly typing it into the Attribute
compartment of the StopWatch Class.
To define the Classifier Behavior for the StopWatch Class, you have to create the Behavior on the
StopWatch, which will be assigned later as the Classifier Behavior of the StopWatch automatically.
1. Right-click the StopWatch symbol on the Class diagram and select New Diagram > State-
Machine Diagram.... A new State Machine Element will be created under the StopWatch Class
with a new State Machine diagram.
2. Name the State Machine diagram "StopWatch".
3. Make sure that the StopWatch State machine is the Classifier Behavior of the StopWatch Class.
To see the Classifier Behavior of the StopWatch Class, right-click the StopWatch symbol on the
Class diagram and select Specification from the context menu. The Specification window will
open.
4. Select All from the Properties drop-down menu.
• Click Initial on the State Machine diagram toolbar, and then click any area on the State Machine
diagram to place the Initial stage.
1. Click State on the State Machine diagram toolbar, and then click any area on the diagram to
place a State. Name the created State "ready".
• Click Final State on the State Machine diagram toolbar, and then click any area on the diagram
to place the final stage.
1. Click a stage (the Initial stage in this example) that will be the source of the transition to be
created. The smart manipulator toolbar will open.
2. Click the Transition icon on the smart manipulator toolbar.
3. Click a State (the ready State in this example) that will be the target of the transition.
6. Now your StopWatch State machine will look similar to the one shown in the following figure
1. Right-click the Model node in the containment browser and select New Element > Package.
2. Name the created package "signals".
1. Right-click the signals package and select New Element > Signal.
2. Name the created signal "reset". The reset signal will be created and stored in the signals
package.
To create signal Events for the transitions on the StopWatch State Machine diagram
• Drag a signal Element from the containment browser to a transition on the State Machine
diagram. The signal Event will later be specified as the trigger of the transition.
1. Drag the start signal to the transition between the ready and running States.
2. Drag the split signal to the transition between the running and paused States.
3. Drag the stop signal to the transition between the running and stopped States.
4. Drag the unsplit signal to the transition between the paused and running States.
5. Drag the stop signal to the transition between the paused and stopped States.
6. Drag the reset signal to the transition between the stopped and ready States.
7. Drag the stop signal to the transition between the stopped and Final States.
Now each and every transition between the States has its own signal Event. Next, you will also need to
create a signal Event for the transitiontoself of the running State. The signal Event that will be created
as the trigger for the transitiontoself is called TimeEvent.
To create a signal Event for the transition to self of the running State
1. Right-click the Transitiontoself of the running State and select Specification to open
its Specification window.
2. Click the Categorized View button to open the properties of the transition in the categorized
view.
3. Click the EventType row in the Trigger category and select TimeEvent from the drop-down
menu.
5. Click Close. You will see all of the created stages, States, transitions, and signal Events are shown
on the StopWatch State Machine diagram.
This section defines the values of the elapsed time among the States in the StopWatch State Machine.
When the stopwatch enters the ready State, the elapsed time defined by the Attribute time:Integer[1]
should be reset to zero. In addition, the elapsed time should increment by 1 every second while the
StopWatch is at the running State. Therefore, we need to add two new operations: (i) ResetTime and (ii)
increaseTime to the StopWatch Class to define the elapsed time at the ready and running States. The
resetTime operation will reset the elapsed time to zero, and the increaseTime operation will
increment the elapsed time by one.
Related pages
1. Right-click the StopWatch Class in the containment browser and select New Element >
Operation.
Next, we will use an Activity to define the resetTime operation. The Activity will contain the Actions and
the flows that will show the steps to set the time value to zero.
1. Right-click the StopWatch Class in the containment browser and select New Element > Activity.
2. Name the created Activity "resetTime".
3. Add an Activity diagram to the resetTime Activity by right-clicking the resetTime Activity in the
containment browser and select New Diagram > ActivityDiagram. The new Activity diagram will
be created under the resetTime Activity. We will use the default name of this diagram, which is
"resetTime".
To reset the time value of the StopWatch Object to zero using an AddStructuralFeatureValueAction
1. Click Action > Any Action... on the Activity diagram toolbar (see the following figure). The
Select Action MetaClass dialog will open.
6. The Attribute time:Integer[1] of the StopWatch Class will be selected as the structural feature of
this Action in this example.
7. Click OK to close the SelectProperty dialog and return to the Specification window.
8. Click the Is ReplaceAll row and select the check box. The AddStructuralFeatureValueAction
will remove any existing value and assign a new value to the structural feature.
3. Name the input pin "t" and specify its type as Integer.
To allow the object of the StopWatch to supply the value to self input using a ReadSelfAction
1. Click Action > AnyAction... on the Activity diagram toolbar. The SelectActionMetaClass dialog
will open.
2. Select ReadSelfAction and click OK.
3. Click the resetTime Activity diagram. A ReadSelfAction will be created on the diagram.
4. Click ObjectFlow on the Activity diagram toolbar and click the self output pin of the
ReadSelfAction and the self input pin of the AddStructuralFeatureValueAction. An object flow will
be created to connect these two pins together.
1. Click Action > AnyAction... on the Activity diagram toolbar. The Select Action MetaClass dialog
will open.
2. Select ValueSpecificationAction and click OK to close the Select Action MetaClass dialog.
3. Click the resetTime Activity diagram to create a ValueSpecificationAction.
4. Right-click the ValueSpecificationAction on the resetTime Activity diagram and select
Specification to open its Specification window.
5. Select the Value row and click the ShowShortcutMenu button, and select Value Specification
> Literal Integer to create a Literal Integer.
9. Add an Initial stage and an Activity Final stage to the resetTime Activity diagram.
10. Click ControlFlow on the Activity diagram toolbar to connect the Initial Node to the
AddStructuralFeatureValueAction and the AddStructuralFeatureValueAction to the Final stage.
1. Right-click the resetTime Activity in the containment browser and select Specification to open
its Specification window.
2. Select the Specification row and click the button (see the following figure). The
Select Element dialog will open.
1. Right-click the StopWatch Class in the containment browser and select New Element >
Operation.
2. Name the new operation "increaseTime".
3. Right-click the StopWatch Class in the containment browser and select New Element > Activity.
4. Name the new Activity "increaseTime".
5. Right-click the increaseTime Activity in the containment browser and select New Diagram >
ActivityDiagram to add an Activity diagram to the increaseTime Activity. The new Activity
diagram will be created under the increaseTime Activity. We will use the default name of this
diagram, which is "increaseTime".
To increase the time values, the increaseTime Activity will do the following
(ii) get the object of the StopWatch using a ReadSelfAction
(ii) obtain the current time value using the ReadStructuralFeatureAction
(iii) increment the time value by one using an OpaqueBehaviorAction
(iv) set the increased time value to the object of the StopWatch using AddStructuralFeatureValueAction
(v) set the specification of the IncreaseTime Activity to the IncreaseTime Operation
The Object of the StopWatch, which contains the time value, must be obtained by using a
ReadSelfAction. To create the ReadSelfAction, you can follow the same steps used to create the
ReadSelfAction in the resetTime Activity. In this example, the Object, which is the value of the output
pin of the ReadSelfAction, needs to be supplied to multiple Actions (ReadStructuralFeatureAction and
AddStructuralFeatureValueAction that will be created later). Therefore, a Fork must be added to this
Activity.
Once you have obtained the object of the Stopwatch, you will need to get the time value.
1. Click Action > Any Action on the Activity diagram toolbar. The Select Action MetaClass dialog
will open.
2. Select ReadStructuralFeatureAction and click OK.
3. Click the increaseTime Activity diagram. A new ReadStructuralFeatureAction will be created on
the diagram.
4. Right-click the ReadStructuralFeatureAction symbol on the diagram and select Specification to
open its Specification window.
6. Select the Attribute time:Integer[1] of the StopWatch Class and click the OK button.
7. Click ObjectFlow on the Activity diagram toolbar to connect the Fork and the self input pin
of ReadStructuralFeatureAction.
1. Right-click the increaseTime Activity in the containment browser and select New Element
> Opaque Behavior. A new Opaque Behavior will be created under the increaseTime Activity.
2. Name it "increase".
3. Right-click the increase Opaque Behavior in the containment browser and select Specification
to open its Specification window.
4. Select the Parameters node in the Specification window and click the Create button . A new
parameter will be created for the increase Opaque Behavior, and the Parameter Specification
window will open.
5. Name the parameter "ti", select Integer as its type, and select in as its direction.
9. Click the Back button to return to the Specification window of the increase Opaque Behavior.
Once the parameters "ti" and "to" have been created, we will write a simple JavaScript that will be
executed during the simulation.
1. Open the increase Opaque Behavior's Specification window and select the increase
Opaque Behavior node on the left-hand side of the dialog.
2. Type a JavaScript into the Body row, e.g., "to=ti+1".
Note
You can use any scripting language that is supported by JSR-223. To specify the scripting
language that you are going to use, type it directly in the Language row. JavaScript will
be used by default if no scripting language is specified.
Once the time value has been increased using the inc:increase OpaqueBehaviorAction, you need to set
it back to the Object of StopWatch. To do this, you can follow the same steps used to create the
AddStructuralFeatureValueAction on the resetTime Activity.
1. Follow the same steps used to create the AddStructuralFeatureValueAction on the resetTime
Activity diagram.
2. Get the AddStructuralFeatureValueAction to set the value to the time:Integer of StopWatch. Make
sure that the IsReplaceAll of the AddStructuralFeatureValueAction is set to true.
3. Click ObjectFlow on the Activity diagram toolbar to connect from the output pin to of
inc:increase OpaqueBehaviorAction to the input pin t of the AddStructuralFeatureValueAction
(see the steps required for resetting the time value of the StopWatch object to zero with
AddStructuralFeatureValueAction in Creating resetTime Operation and resetTime Activity(see page
587)).
4. Add an Initial Node and an Activity Final stage to the increaseTime Activity and click
ControlFlow on the Activity diagram toolbar to connect between the Actions.
(v)Setting the specification of the increase time Activity to the IncreaseTime Operation
Next, we are going to add some Activities to the ready and running States. These Activities will be
executed when these States are entered.
Related pages
1. Right-click the ready State on the StopWatch State Machine diagram and select Specification to
open the State's Specification window.
2. Select the Entry row and click the button. A context menu will open.
3. Select Activity. A new Activity will be created for the entry to the ready State.
124 https://docs.nomagic.com/display/MD2021xR2/State
6. Add an Activity diagram to the created reset Activity of the ready State by right-clicking the reset
Activity in the containment browser and select New Diagram > Activity Diagram. A new Activity
diagram will be created.
1. Right-click the running State on the StopWatch State Machine diagram and select Specification
to open the State's Specification window.
2. Select the Entry row and click the button. A context menu will open. Select Activity to add a
new Activity to the Entry to the running State.
3. Name the created Activity "increase".
5. Add an Activity diagram to the created increase Activity and use the default name, which
is "increase".
6. Add a CallBehaviorAction to the increaseTime Activity on the increase Activity diagram by
dragging the increaseTime Activity from the containment browser to the increase Activity
diagram.
7. Add an Initial stage and a Final Activity stage to the increase Activity diagram and connect the
two stages and the increaseTime action with ControlFlow, which is on the Activity Diagram
toolbar.
At this point, the StopWatch has been completely modeled. You can now execute the StopWatch class
using Cameo Simulation Toolkit.
This section shows you how to execute the StopWatch model with Cameo Simulation Toolkit. The
StopWatch Class will be selected to execute the model.
Related pages
1. Either (i) select the StopWatch class in the containment tree and click the Run button on
the Simulation Control main toolbar or (ii) right-click the StopWatch class and
select Simulation > Run.
Once you have clicked the Run Execution button, the Object of the StopWatch Class will be created
and shown in the Variables tab. The Classifier Behavior of the StopWatch class and the StopWatch
State Machine will be executed respectively. A new session to execute the StopWatch State Machine
will be created under the simulation session of the StopWatch class, and the StopWatch State
Machine diagram will be open and ready for the simulation.
The StopWatch State Machine execution will start from the initial stage and automatically move to the
ready state because the transition which connects between the initial stage and ready state does not
have a defined trigger. When the ready State is entered, the reset Activity, which is assigned as the
entry to the ready State, will be invoked. This Activity also calls the resetTime activity of the StopWatch
Class for setting the time value to be zero. At this point, a new simulation session will be created to
execute the resetTime Activity, and the resetTime Activity diagram will be open and animated.
1. Select the StopWatch node in the Variables tab. The signals that can be sent to the StopWatch
will be listed in the Trigger drop-down menu.
2. Select the start signal from the Triggers drop-down menu (see the following figure).
Note
You can click the arrow button on the left or right-hand side of the Simulation window toolbar
to scroll the toolbar to the left or to the right.
The StopWatch object will still be at the running State and the time Event will be triggered at this State
every second. Therefore, a new simulation session will be created to execute the increaseTime activity
every second, and the time value will increment by one every time the increaseTime Activity is
executed.
You can change the paused StopWatch object to the running State by sending an unsplit signal to the
object.
In this tutorial, our StopWatch contains only one value property, which is time. The time value will
always reset to zero whenever the system enters the ready State. If we create an InstanceSpecification
of StopWatch and use it for model execution, the result will be the same as the model execution of the
StopWatch Class.
1. Right-click the symbol of the stopwatch InstanceSpecification and select Specification to open
the Specification window of the stopwatch InstanceSpecification.
2. Select the Slots node on the left-hand side of the dialog.
3. Select the Structural Feature of the slot to which the values will be applied. In this case,
select time:Integer[1].
To start executing the stopwatch InstanceSpecification, right-click it either on the System Class diagram
or in the containment browser and click Execute. A simulation session will be created in the Sessions
tab of the Simulation window to execute this instance. The steps to run the execution are the same as
those to execute the StopWatch Class.
1. Click File > Use Project on the main menu. The Use Project wizard dialog opens.
2. Select the From predefined location option.
3. Select <install.root>\profiles in Project modules paths, and then select SimulationProfile.mdzip.
Next, we will create a SimulationLog to record the runtime events occurrence and assign this
SimulationLog to the SimulationConfig.
To record all runtime events occurrence and assign a SimulationLog to the SimulationConfig
1. Create a new Class Element by clicking the Class button on the Class diagram toolbar.
2. Click the diagram to create the Class Element.
3. Name the created Class "SimulationLogs".
4. Right-click the SimulationLogs Class and select Stereotype to apply the
«SimulationLog» stereotype to the created Class. The Stereotype context menu will open.
1. Right-click the SilentStopwatch symbol on the diagram and select Simulation > Execute.
2. Click the RunSimulation button on the Simulation window toolbar to start the simulation. The
StopWatch Class will then be executed without animation. You will need to wait until the
runtime object of StopWatch is at the ready State. You can see the State of the runtime object at
the Variables tab. The State of the object will be displayed in square brackets.
3. Select the StopWatch node in the Variables tab.
4. Select the start signal from the Triggers drop-down menu on the Simulation window toolbar.
Now, you can see that the value of time:Integer, which is displayed in the Variables tab, will increase
by one every second.
1. Right-click the Model node and select New Element > Package to create a new package for the
UI Elements.
2. Name the created package "ui".
3. Click the button on the Custom Diagram toolbar to create a new User
Interface Modeling Diagram. The Create Diagram dialog will open.
4. Name the diagram "StopWatchUI" and select the ui package as the owner of the diagram.
12. Create a Signal Instance Prototype by dragging the Signal from the containment browser to each
of the buttons. The buttons will send the dragged signals to the runtime object when you click
them during the execution. Therefore, each signal in the stopwatch model will be dragged to
each button that has a corresponding name. For example, the start signal will be dragged to the
start button, and the stop signal will be dragged to the stop button.
The modified SilentStopwatch is now ready to run the stopwatch with the UI mockup. Next, you need to
run the SilentStopwatch Simulation Configuration.
Click the stop button to stop the execution and click it again to go to the final stage, which is the
termination of the execution.
On this page
Note
All required resources must be available for the Simulation Configs, e.g., loadCSV and
fmu. All features preventing simulation from the start/terminate, e.g., false autoStart,
context without Classifier Behavior, chart windows at the end of execution, or output
parameters at the end of execution (running Activity) will also be automatically started/
terminated.
4. Run each Simulation Config to verify that an expected result, either pass or fail, must be
returned.
5
12 https://docs.nomagic.com/download/attachments/82761156/TestSimulationCommandLine.zip?
api=v2&modificationDate=1537518855106&version=1
1. Include the JUnit library in the Java project by creating a new Java project and adding the JUnit 4
library in current location using the Eclipse's JUnit.
2. Create a new JUnit test case, e.g., Test Simulation Command Line.java(see page 654).
3. Compile the test case and create a JAR file, e.g., TestSimulationCommandLine.JAR from the test
case.
4. Create properties file, e.g., TestGeneratePassResult.properties and
TestGenerateFailResult.properties.
5. Create an Ant configuration file(see page 656), e.g., run_junit.xml.
Tip
The path containing the property files can be either an absolute (full) path, e.g., C:
\Users\User\Desktop\TestSimulationCommandLine\tests or relative path, e.g., tests.
9. Go to Post-build Actions and click Add post-build action. Select Publish JUnit test result
report.
10. In the Test report XMLs box, specify a path to JUnit XML files, e.g., test-reports/**TEST*.xml.
Test Result of the simulation command line is shown on the Jenkins page.
Mandatory -project Specify a file name with the path of a MagicDraw project. Both relative and
arguments absolute paths are supported.
Note
If SimulationConfig has duplicate names (in different package), a
warning message will be displayed in the Simulation log, and the first
name will be used.
Note
• If the -properties option is specified, the argument is the
name of a properties file, and the mandatory argument is
no longer required.
• A properties file contains -project and -config, along with
the specified data of each parameter.
Optional -inputs Specify one or more properties with values that will be provided to the
arguments elementNam Simulation Configuration.
eListWithVal
ue
-inputsFile Specify the name of the properties file containing the parameters with values
propertiesFil that will be provided to the Simulation Configuration.
eName
Note
If you provide both -inputs and -inputFile arguments, parameters
are collected from both arguments.
-outputs Specify one or more properties whose values should be obtained during the
elementNam simulation
eList
-outputsTem Specify the properties file that contains the parameters whose values should
plate be obtained during the simulation.
propertiesFil
eName
Note
If you provide both -outputs and -outputTemplate arguments,
parameters are collected from both arguments.
6
12 https://docs.nomagic.com/download/attachments/33212749/TestSimulationCommandLine.zip?
api=v2&modificationDate=1537518855106&version=2
Optional -servertype Specify type of the server to connect, <tw> or <twcloud>, where <tw> is
(server) Teamwork Server, as the default type of the server, and <twcloud> is
arguments Teamwork Cloud.
-leaveproject Leave the project open per property file after simulating the project, in a series
open of project simulation. The default value is false.
Note
To generate an encrypted password for this option, use the following
command line (the characters of the encrypted password will be
returned, e.g., 49034c0439….):
generate -generatepassword “Administrator”
-ssl Specify to use and enable Secured Connection (SSL), <true> or <false> as the
default value.
Note
• -tag can't be used with -pversion.
• If multiple projects are returned, only the latest version
will be run.
-updatemod Specify update project usages if required, <true> or <false>, where <false> is
ule the default.
Simulate a project with an encrypted simulate -project "HingeMonteCarloAnalysis" -config "Monte Carlo
password and enable a secured Analysis" -servertype "twcloud" -server "localhost:1234" -login
connection (-spassword, -ssl). "Administrator" -spassword "49034c0439…" -ssl "true"
Simulate a project by specifying a project simulate -project "HingeMonteCarloAnalysis" -config "Monte Carlo
version and project password (-pversion, Analysis" -servertype "twcloud" -server "localhost" -login
-projectpassword). "Administrator" -password "Administrator" -pversion "5"
-projectpassword "Administrator"
Simulate a project by specifying a tag simulate -project "HingeMonteCarloAnalysis" -config "Monte Carlo
name and branch (-tag, -branch). Analysis" -servertype "twcloud" -server "localhost" -login
"Administrator" -spassword "49034c0439…" -tag "duplicatedTag"
-branch "19.0 SP2"
Note
If there are any duplicated tags
in the branch, the latest version
will be run.
127 https://docs.nomagic.com/display/MD2021xR2/Using+Teamwork+Cloud
Simulate a project in Teamwork Server by simulate -project "HingeMonteCarloAnalysis" -config "Monte Carlo
specifying a project version (-pversion). Analysis" -servertype "tw" -server "localhost" -login "Administrator"
-password "Administrator" -pversion "2"
Simulate a project in Teamwork Server by simulate -project "HingeMonteCarloAnalysis" -config "Monte Carlo
specifying an encrypted password and Analysis" -servertype "tw" -server "localhost" -login "Administrator"
tag name (-spassword, -tag). -spassword "49034c0439…" -tag "run2000"
Tip
When large-size projects need to
be loaded and closed for many
property files, it takes longer
time to simulate projects. In this
case, you can use
-leaveprojectopen as an option
to reduce memory for loading
each project.
Simulate a project in Teamwork Cloud simulate -project "SpacecraftMassRollup" -config "spacecraft mass
while specifying several input parameters analysis" -inputs telecom.amplifier.me=8 telecom.antenna.me=29 -
that will be provided for the Simulation outputsFile “SimResults” -servertype "twcloud" -server "localhost”
Configuration (-inputs). -login “Administrator" -spassword "49034c0439…"
Simulate a project in Teamwork Cloud simulate -project "SpacecraftMassRollup" -config "spacecraft mass
while specifying the properties file that analysis" -inputsFile “D:\\Simulation\\InputsParams.properties”
will be provided to the Simulation -outputsTemplate “D:\\Simulation\\OutputParams.properties”
Configuration (-inputsFile), the properties -outputsFile "D:\\Simulation\\SimResults.properties" -servertype
file containing the parameters whose "twcloud" -server "localhost” -login “Administrator" -spassword
values should be obtained "49034c0439…"
(-outputsTemplate), and the properties
file that will contain output parameters
with their values after the simulation (-
outputsFile).
project=Project1
config=Config1
servertype=twcloud
package com.nomagic.magicdraw.simulation;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Path;
import org.junit.Before;
import org.junit.Test;
/**
* A test class for running the simulation command line and checking for the pass/
fail result.
* @author Chanon S.
*/
@Before
public void assertBuildExist() {
System.out.println(MD_ROOT_PROPERTY + "=" + MD_DIR);
System.out.println(PROPERTIES_FILES_PROPERTY + "=" + PROPERTIES_FILES_DIR);
@Test(timeout = 120000)
public void testGeneratePassResult() {
// This project and Simulation Config generate "pass" as the result of
TestCase.
String propertyFilePath = PROPERTIES_FILES_DIR + "/" + PASS_PROPERTIES;
String consoleOutput = runWithProperties(propertyFilePath);
System.out.println("Console output=" + consoleOutput);
boolean result = consoleOutput.contains(SYSTEM_NEW_LINE + "pass" +
SYSTEM_NEW_LINE);
assertTrue(consoleOutput, result);
}
@Test(timeout = 120000)
public void testGenerateFailResult() {
// This project and Simulation Config generate "fail" as the result of
TestCase.
String propertyFilePath = PROPERTIES_FILES_DIR + "/" + FAIL_PROPERTIES;
String consoleOutput = runWithProperties(propertyFilePath);
boolean result = consoleOutput.contains(SYSTEM_NEW_LINE + "pass" +
SYSTEM_NEW_LINE);
assertTrue(consoleOutput, result);
}
String line;
while ((line = input.readLine()) != null) {
result.append(line);
result.append(SYSTEM_NEW_LINE);
}
} catch (IOException e) {
e.printStackTrace();
}
return result.toString();
}
<batchtest todir="${test.reports.dir}">
<zipfileset src="lib/TestSimulationCommandLine.jar">
<include name="**/*.class"/>
</zipfileset>
</batchtest>
Analysis pattern
On this page
Cameo Simulation Toolkit supports rollup calculations of total mass, cost, power, and another system
dimension, based on individual values of all the parts in the model. Please refer to Rollup Pattern
Wizard128, applying Rollup Pattern Blocks129, and LaptopCostAnalysis and SpacecraftMassRollup
built-in samples for more details.
128 https://docs.nomagic.com/display/SYSMLP2021xR2/Rollup+Pattern+Wizard
129 https://docs.nomagic.com/display/SYSMLP2021xR2/Applying+Rollup+Pattern+Blocks
130 https://docs.nomagic.com/display/SYSMLP2021xR2/Applying+Rollup+Pattern+Blocks
On this page
Cameo Simulation Toolkit introduces built-in support for Monte Carlo analysis, a technique that
involves using random numbers and probability to solve problems. You can manage uncertainties and
estimate how random parameters affect the overall performance of the system being modeled. Please
The Block Definition diagram of the Hinge model with distributed value
properties applied.
6. Create a parametric diagram in the system to bind the value properties to the parameters of the
constraint Block, e.g., Clearance equation.
1
13 https://docs.nomagic.com/download/attachments/75335382/HingeMonteCarloAnalysis.mdzip?
api=v2&modificationDate=1511944656895&version=1
Note
• For a model that has Behaviors (Classifier Behavior and/or Part Property
with Behaviors), see the autoStart tag in SimulationConfig(see page 49).
• If numberOfRuns of any table (executionTarget) is more than 1, it will be
ignored in the Monte Carlo simulation. The table, however, will be run only
once.
• If silent is set to false, the simulation will run with animation and idle time
for each iteration, which is not practical for the Monte Carlo simulation.
2. Drag a Histogram(see page 125) control from the Simulation toolbar to the Simulation
Configuration diagram. You can use the histogram as a local user interface by setting the
following tags:
On this page:
A trade study or trade-off study is the activity of a multidisciplinary team to identify the most balanced
technical solutions among a set of proposed viable solutions (System Engineering Manual, Federal
Aviation Administration, 2006).
Cameo Simulation Toolkit has built-in support for trade study analysis. The TradeStudyExamples
sample model is used as a demonstration for trade study analysis through the following steps.
Note
• «objectiveFunction» is a special type of a constraint Block for determining all
values of weighted alternatives in terms of weighted criteria.
• The specification of the constraint must be an equation with LHS = RHS, where
LHS contains only one parameter to bind with TradeAnalysis::^score, and RHS can
contain multiple parameters (bound with corresponding value properties) to
evaluate as winner criteria.
• The output of «objectiveFunction» will be compared with previous weighted
results. If an alternative is greater, it will be set as the winner (maximum value by
default). However, if you want the minimum value, use a negative value, e.g., value
= -distance.
5. Create alternatives by creating references properties typed by a Block of alternatives and apply
«alternatives» to the newly created references properties, e.g., C : Caliper, R : Rotor, and P : Pad as
shown in the figure below.
Inheriting the Analysis Block from the Trade Study Analysis Block
1. From the Containment tree under the MD Customization for SysML::analysis patterns::trade
study package, drag TradeStudy «Block» «Analysis» into the Block Definition diagram (BDD)
created in the previous section.
Note
The TradeStudy package is available in all SysML projects. If the MD Customization for
SysML package is not visible, click in the Containment tree pane and select Show
Auxiliary Resources.
2. To inherit the TradeStudy «block» «Analysis», create a Generalization Relation from the
TradeStudyInstances Block to TradeStudy «block» «Analysis» as shown in the figure below.
Binding of the TradeAnalysis Block in the Internal Block diagram (kind = TABLE).
132 https://docs.nomagic.com/display/MD2021xR2/Saving+an+Import+Map
133 https://docs.nomagic.com/display/MD2021xR2/Sync+with+Excel+or+CSV+files
Binding of the TradeAnalysis Block in the Internal Block diagram (kind = EXCEL,
source = Import Map).
1. Refer to Step 1-3 about creating an Internal Block diagram for alternatives kind = Instance
Table(see page 668).
Note
• If the values tag is specified together with step, numberOfPoints, min, or max, only
the values tag will take precedence and be used in parameter sweep.
A warning will be printed on the Console pane when one or more of the following
occurs:
• The min value is not specified that the default value (zero) will be used instead.
• The max value is not specified in the following combinations: [min, max, step], [min,
max, numberOfPoints], or step < 0.
• There are invalid values excluded from the Trade Study analysis.
Note
• If you do not create a SimulationConfig and run the TradeAnalysis Block directly,
TradeStudy will not be triggered, but the TradeAnalysis Block will be run as
normal .
• If the executionTarget of a SimulationConfig is the TradeAnalysis Block,
TradeStudy execution will override other executions, so Monte Carlo simulation
will not be triggered even if numberOfRuns is more than 1.
Note
• The Starting Math Engine progress bar will be shown in this sample because
MATLAB is used as the external evaluator. See also Integration with MATLAB(see
page 451).
• Any alternatives violating any of the attached constraints/Requirements will not be
considered as the winner. They will be used in the calculation of OutOfSpec.
• The rememberFailureStatus of a SimulationConfig will be used when evaluating
those alternatives.
• When more than one alternative has the same winning score of a Trade Study, a
warning message is printed.
• In some cases, you can click Unlock in the Simulation pane to see execution
details during the execution.
Note
The winner string is printed with the formats as follows:
AlternativeProperty.Name1 : StringKind [, AlternativeProperty.Name2 : StringKind,
AlternativeProperty.Name3 : StringKind, …]
where StringKind will apply the following rules, depending on kind of alternative:
• kind=TABLE: then StringKind=InstanceName, e.g., P : Saphire 66, C : Alphine
K7, R : Rotus 30.
• kind=SUBTYPES: then StringKind=subtypesName, e.g., power : Diesel,
support : Wheels, stopping : Brakes.
• kind=EXCEL: then StringKind=#Row, e.g., R : #5, P : #21, C : #21, where Row is
the number of Excel rows.
• kind=Parameter Sweep: then StringKind=GeneratedValue, e.g., brakeMU :
0.66, centerLength : 0.12, outerDiameter : 0.29, thickness : 0.04, width :
0.038.
134 https://github.com/aterrien/jQuery-Knob
1. See what information is needed to create the widget, e.g., the jQuery Knob widget needs an input
element, scripts, and jQuery Knob library, as displayed below.
<script>
$(function() {
$(".dial").knob();
});
</script>
widget.HTML
<!doctype html>
<html>
<head>
<title>@title@</title>
</head>
Information
• class="widget" informs the simulation web server that this file is widget.
• paths="@paths@" is used for generating HTML code from the widget, and the
simulation web server will use the value of the paths attribute to register for value
change.
Note
@title@ can be optionally replaced with any title. It is a predefined variable in simulation
which will be replaced by the property name whose type is of this widget.
3. Create a new js folder. Copy the jQuery Knob library to the created js folder.
Note
Different widgets require different numbers of jQuery library files, including CSS files.
Please ensure that you copy and include all those files.
4. Import required jQuery libraries and CSS files, if any, to the HTML head element, and add the
widget code to the body element, as shown below.
widget.HTML
<!doctype html>
<html>
<head>
<title>@title@</title>
<script>
$(function(){
$(".dial").knob();
});
</script>
</body>
</html>
5. Because this widget requires the jQuery library, it needs to also import the jQuery library before
the widget import statement. Alternatively, the @scripts@ predefined variable can be used so
that simulation will generate jQuery files and replace this variable with jQuery import
widget.HTML
<!doctype html>
<html>
<head>
<title>@title@</title>
@scripts@
<script type="text/javascript" src="js/jquery.knob.js"></script>
@simulation_js@
</head>
<script>
$(function(){
$(".dial").knob();
});
</script>
</body>
</html>
6. Add the following attributes to the widget element, where the value of the paths attribute is the
name of a property/Port that will be used as input/output in simulation.
widget.HTML
<!doctype html>
<html>
<head>
<title>@title@</title>
@scripts@
<script type="text/javascript" src="js/jquery.knob.js"></script>
@simulation_js@
</head>
<script>
7. If the widget can be used as an output to display a value from simulation, you can override the
customSetHTMLValue method and set the widget value in the overridden method, e.g., the
jQuery Knob widget sets the value by using the following code.
<script>
$('.dial')
.val(27)
.trigger('change');
</script>
widget.HTML
<!doctype html>
<html>
<head>
<title>@title@</title>
@scripts@
<script type="text/javascript" src="js/jquery.knob.js"></script>
@simulation_js@
</head>
<script>
$(function(){
$(".dial").knob();
});
/**
* This method will be called when a value of the widget element is
changed.
* @param item is an element with matching attribute paths in the
body and the element itself.
* @param data represents a new value.
* @param formattedValue indicates a new value formatted by the
simulation web server.
*/
Note
The line of code shown below is needed to prevent the customSetHTMLValue method
from being called when there is a value change from any other widgets with the same
property paths. The following line of code checks if the updating widget (the item
parameter), is the same element as this Knob widget.
if ($(item).is($(".dial"))) {
8. If the widget can be used as an input to change simulation value, you can call the
doSetWidgetValue method when the widget changes the value, e.g., the jQuery Knob widget has
a hook to tell when the value is changed, as demonstrated below.
<script>
$(".dial").knob({
'change' : function (v) { console.log(v); }
});
</script>
widget.HTML
<!doctype html>
<html>
<head>
<title>@title@</title>
@scripts@
<script type="text/javascript" src="js/jquery.knob.js"></script>
@simulation_js@
</head>
/**
* This method will be called when a value of the widget element is
changed.
* @param item is an element with matching attribute paths in the
body and the element itself.
* @param data represents a new value.
* @param formattedValue indicates a new value formatted by the
simulation web server.
*/
9. If the widget has options, these options can be modified to customize in the widget Class in
MagicDraw, e.g., the jQuery Knob widget has the min and max options in the code below.
$(".dial").knob({
'min':-50,
'max':50
});
When integrated for simulation, the value for each option can be defined by using the
$widget_property$ format, where widget_property is the name of a property owned by the
widget Class in MagicDraw as shown below.
widget.HTML
<!doctype html>
<html>
<head>
<title>@title@</title>
@scripts@
<script>
$(function(){
$(".dial").knob({
'min' : $min$,
'max' : $max$,
'release' : function(value) {
//call the doSetWidgetValue method to set simulation
value.
doSetWidgetValue($(".dial"), value);
}
});
});
/**
* This method will be called when a value of the widget element is
changed.
* @param item is an element with matching attribute paths in the
body and the element itself.
* @param data represents a new value.
* @param formattedValue indicates a new value formatted by the
simulation web server.
*/
Note
The widget.HTML file and all related resources must be archived into a zip file and the
widget.HTML file must be the root directory of the zip file.
Information
You can also create other kinds of project, but you need to use the Simulation profile in
your created project before proceeding to the next steps.
14. Drag the zipped widget file from File Explorer to the widget Class and select Create Attached
File.
15. Create a Port element with any corresponding widget type. The name of the Port must match
the value of the paths attribute of the widget element in the widget.HTML file.
17. Capture the screen of jQuery Knob on the jQuery Knob Web site and save it as an image to be
used as the icon of the widget Class.
18. Open the Specification dialog of the widget Class. Find and select the value field of the Image
property to set an icon for the widget Class.
20. Create the SysML Block diagram and a property with Integer as type, and specify 10 as the
default value, as illustrated below.
22. Drag the Knob widget in the Containment browser to the IBD to create a widget symbol.
23. Specify a name for the widget property and create a binding Connector between the value Port
of the widget and the value property.
25. Right-click the Simulation Config element. Set the Auto Start option as true and the Silent
option as false. Also make sure that the startWebServer option is set true.
Predefined variables
The table below explains how predefined variables will be replaced when widget files are generated.
On this page
Web page
To download the demo of this version and to get contact information or purchase details, please visit
http://www.nomagic.com/.
Note
You must add our news server, news.nomagic.com, to your server list before you can access
this forum.
E-mail
• support@magicdraw.com136 - for questions about product installation, features, questions about
how-tos, and suggestions.
• sales@magicdraw.com137 - for questions regarding academic and site discounts, delivery,
customer profile, invoices, and related issues.
• contact@magicdraw.com138 - for all other contact.
We are awaiting your comments and suggestions. More than half of the features of the current version
has been added because our demo version users have requested them. Do not miss the chance to see
your desired features in the future versions!
Bug reports
Your bug reports are welcome at support@magicdraw.com139. These reports allow us to fix bugs as
soon as possible and release the known-bug-free maintenance releases. While sending the bug report,
please include the following (if applicable):
• MagicDraw version number and the name of the edition (Standard, Enterprise, Professional Java,
Professional C++, Professional C#, Demo, or Academic).
• Source where you got the version from (demo CD or our homepage download).
• Your OS name and version.
• JDK version and JVM vendor.
• Cameo Simulation Toolkit plugin version (you can go to Help > About MagicDraw from the main
menu to open the About dialog and click the Licensing tab to see this information).
For information about your JVM and OS, see the Environment tab in the About dialog from the
MagicDraw Help main menu. If you have a file that the MagicDraw is not able to load, and it is not the
confidential one, please attach it as well. This will help us analyze the problem.
Bugs can be submitted directly from the MagicDraw application by going to Help on the main menu >
Report an Issue.
135 http://school.nomagic.com/
136 mailto:support@magicdraw.com
137 mailto:sales@magicdraw.com
138 mailto:contact@magicdraw.com
139 mailto:bugs@magicdraw.com
Constraint-violations 87
A Constraints 437
Accept-change-structural-feature-event-action 482 Constraints-on-parts 425
Action-languages 507 Context 207
Action-script-api 515 Context-initialization 227
Active-elements 180 Control-panel-for-web-ui 165
Active-image 75 Creating-objects-in-variables-tab 220
Active-objects 69 Creating-values-in-variables-tab 220
Active-state-images 186 Csv-export 141
Active-states-in-diagrams 186 Csv-file-data-in-time-series-chart 109
Activity-duration 317 Custom-html-widgets 171
Activity-execution 311 Customizing-animation 182
Activity-partition-execution 332
Activity-simulation 26, 286 D
Activity-simulation-engine 287 Deactivating-licenses 16
Activity-state-behaviors 264 Debug-buttons 199
Adapting-model-for-state-machine-simulation 259 Debugging 197
Adding-breakpoints 251 Deffering-events 277
Adjunct-property 482 Developer-guide 559
Alh-api 516 Diagram-of-executing-behavior 184
Animating-parametrics 430 Diagram-simulation 36
Animation 180 Disabling-updates-in-simulation-pane 254
Animation-customization 182 Displaying-parts-of-simulation-context 130
Animation-options 186 Displaying-parts-using-ui-configurations 134
Animation-speed 183 Dummy-models 334
Association-block 484 Dummy-tokens 342
Attached-file-support 145 Duration-analysis 326
Auto-save-plot-values 100 Duration-constraint 361
Automatic-start-of-active-objects 69 Dymola-integration 470
Dynamic-constraint 426
B
Basic-concepts 12 E
Behavior-simulation 25 Element-simulation 22
Behaviors-of-activity-states 264 Enumeration-literal-value 508
Binding-connector 484 Enumeration-value-representation 79
Binding-in-aggregate-structure 409 Error-messages-about-constraint-failures 206
Block 484 Evaluating-expressions 413
Bound-reference 485 Evaluating-strings 435
Breakpoints 250 Evaluation-with-causality 421
Built-in-clock 63 Event-deffering 277
Built-in-math-solver 434 Executed-trace-duration 329
Executing-activities 311
C Executing-state-machines 279
Call-action-simulation 331 Exporting-plot-data 97
Call-event 360 Exporting-plot-data-to-csv 98
Carrying-values-via-connectors 234 Exporting-plot-data-to-instance-model 100
Change-structural-feature-event 486 Exporting-runtime-objects 237
Changing-runtime-values 194 Exporting-runtime-values 237
Checking-runtime-values 235 Exporting-simulation-results-to-csv 141
Class-simulation 32 Exporting-timeline-chart 111
Classifier-behavior-property 486 Expression-evaluation 413
Combined-fragment 366 Expression-language 400
Communicating-with-parametric-evaluator 432 External-evaluators 449
Completion-events 274 External-libraries 512
Concepts 12 Extracting-constraints-from-text-based-requirements
Connecting-to-matlab-session 460 503
Connectors 234
Console-log-filter 205 F
Console-tab 201 Features 18
Constraint-block 488 Flow-port 489
Constraint-failures 206 Flow-property 488