You are on page 1of 4

DSL Workshop Belgrade 2014

Domain-Specic Modeling with metaDepth and AToMPM


Prof. Dr. Hans Vangheluwe
hv@cs.mcgill.ca
Bart Meyers
bart.meyers@uantwerpen.be
21-24 May 2014
Introduction
The aim is to design a TracLight Domain-Specic Language (DSL).
The models in this DSL are specications of both behaviour and visualization of a trac
light. The behavioural part is very similar to state automata with time. It describes both the
autonomous, timed behaviour and the reactive (to external stimuli) behaviour of a trac light.
This language allows one to model dierent types of trac lights as they are used in dierent
countries and for dierent specic trac situations.
To specify the TracLight DSL, it will be necessary to model its
abstract syntax,
concrete syntax,
the mapping between abstract and concrete syntax,
operational semantics,
translational semantics.
The operational semantics allows for (non-realtime) simulation of a tracLight model in
the TracLight language. The translational semantics species how to translate a tracLight
model to Python code to be executed in realtime.
Abstract Syntax
A model in the TracLight language consists of a number of states. Each state has a unique
name (a string). Exactly one of the states is a start state. There is no explicit end state, but
a trac light will stay forever in a state without outgoing transitions (see the descriptions of
transitions and operational semantics).
States may be connected by zero or more transitions. There are two types of transitions:
timed transitions and interrupt transitions. A timed transition is labelled with an integer number
(milliseconds) time delay. An interrupt transition is labeled with the name of an interrupt (a
string). There should be at most one timed transition going from a state. This is reasonable
as our transitions do not have guards (as Statecharts do). If we allowed more than one timed
transition, only the one with the lowest time delay would be used. All interrupt names on
1
OPERATIONAL SEMANTICS
transitions going out of a single state must be distinct. If this were not the case, the behaviour
(described later) would be non-deterministic.
Associated with each state is a description of the visualization of the trac light when it is in
that state. The description species, for each of the three coloured lights (Red, Green, Yellow)
in a trac light, whether it is on or o. A state red for example may have the visualization
{Red=on, Green=off, Yellow=off} associated with it.
Multiple states may refer to the same visualization.
The interrupt-producing environment in which the trac light will operate needs to be
modelled too. This is done by means of a time-ordered interrupt list. The interrupt list consists
of linearly connected interrupt notices. An interrupt notice has a non-negative integer absolute
time (milliseconds) timestamp as well as the name of the interrupt (a string).
For simulation purposes only, a (singleton) global time entity holding a non-negative integer
absolute time (milliseconds) value is needed. This value should be initialized to 0 and will only
be updated (increased) by the simulator (operational semantics).
Also for simulation purposes, a current state will refer to the state the model is in at any
given time.
Concrete Syntax
In metaDepth, the default textual concrete syntax will be used. Examples can be found on the
metaDepth website[2].
In AToMPM, you can choose your own visual concrete syntax.
Mapping Abstract to Concrete Syntax
In AToMPM, a 1-to-1 mapping by naming convention will be modelled between meta-model
classes and their concrete visual syntax icons.
Operational Semantics
First, the global time is initialized to 0. Then, the current state is made to refer to the start
state of the model.
The simulation specied below continues until no more state transitions are possible.
A state transition T from the current state C to a new state (possibly the same) N occurs
when:
if there is a timed state transition T from the current state C to a new state (possibly the
same) N, this transition will be taken if the global time + the time delay of the transition
is strictly smaller than the time of the earliest interrupt notice in the external interrupt
list (if any is present: the interrupt list may be empty). Combined with the description
of the interrupt transition below, the strictly smaller required will ensure that an external
interrupt takes priority over a timed transition, if they happen to occur at exactly the
same time (a so-called event collision). The eects of this state transition are:
1. the global time is updated to the global time + the time delay of the transition;
2. during non-visual simulation, the global time, interrupt name, old current state C and
new current state N are printed (forming a simulation trace); during visual simulation,
the eect will be visible on the model.
3. the current state is updated to state N
2
APPENDIX: INSTALLATION INSTRUCTIONS
if there is an interrupt transition from the current state C for which the interrupt name is
equal to the interrupt name in the earliest interrupt notice in the external interrupt list.
The eects of this state transition are:
1. the global time is updated to the time in the interrupt notice;
2. during non-visual simulation, the global time, interrupt name, old current state C and
new current state N are printed (forming a simulation trace); during visual simulation,
the eect will be visible on the model.
3. the current state is updated to state N
4. the interrupt notice is removed from the interrupt list
Appendix: Installation Instructions
metaDepth
The installation instructions for metadepth are:
1. download and install Java: http://www.java.com/
2. add your Java/jre7/bin folder to your PATH environment variable
3. download and unpack metadepth: http://astreo.ii.uam.es/
~
jlara/metaDepth/metaDepth.
jar or the metadepth jar le is included in the atompm.zip package, in the exported to md
folder
Getting started with metaDepth:
1. start metaDepth from the command line by navigating to the metaDepth folder and en-
tering the command: java -jar metaDepth.jar
2. an interactive mode starts, press help to see the available commands
3. examples of models can be found at the metaDepth website[2]
4. a manual for the EOL language (for specifying constraints and transformations) can be
found at the Epsilon website[1]
5. some small notes on the use of EOL in metaDepth can be found here: http://msdl.cs.
mcgill.ca/people/hv/teaching/MSBDesign/assignments/MetaDepthEOL.txt
AToMPM
The installation instructions for AToMPM are:
1. download and install Python 2.7.6: https://www.python.org/downloads/ (use an instal-
lation directory without spaces - recommended to use the default installation directory)
2. install python-igraph 0.6.5:
Windows: http://msdl.cs.mcgill.ca/people/bart/python-igraph-0.6.5.win-amd64-py2.
7.exe (for 64-bit Python installation) http://msdl.cs.mcgill.ca/people/bart/
python-igraph-0.6.5.win32-py2.7.msi (for a 32-bit Python installation)
Unix: use yum or any other installation program, and type yum install python-igraph.
Alternatively, download and install setuptools 3.6: https://pypi.python.org/pypi/
setuptools, open a command-line prompt and type: easy install python-igraph
3
REFERENCES REFERENCES
3. download and install node.js: http://nodejs.org/
4. add your nodejs folder to your PATH environment variable
5. download and unpack atompm: http://msdl.cs.mcgill.ca/people/bart/Belgrade/
atompm.zip
Getting started with AToMPM:
1. the le install.txt in the AToMPM folder contains instructions on how to start the
AToMPM server, transformation server, and client
2. the le manual.pdf in the AToMPM folder contains instructions on how to use AToMPM.
A manual can also be found here: http://msdl.cs.mcgill.ca/people/hv/teaching/
MSBDesign/assignments/atompm_manual.pdf
References
[1] Epsilon. The Epsilon Book. page http://msdl.cs.mcgill.ca/people/hv/teaching/
MSBDesign/EOL_EpsilonBook.pdf.
[2] Juan de Lara. metaDepth website. page http://astreo.ii.uam.es/
~
jlara/metaDepth/.
4