-
Notifications
You must be signed in to change notification settings - Fork 4
GuideTutorialMarkedGraph
This tutorial aims at demonstrating the power of the GEMOC studio to define an executable semantics and provide graphical animation for a DSML. It relies of the marked graph language.
The following animation shows the expecting results of this tutorial: according to the fired transitions, tokens move from place to place.
The domain model is implemented with several EMF projects that you need to import into your workspace. A graphical editor defined with Sirius is also available to visualize Marked Graph models.
Download the provided archive containing the projects and unzip it. Then, with the GEMOC Studio, select import… / General / Existing Projects into Workspace and import all the projects from the archive file.
Here is the archive containing all the projects that will be created during this tutorial.
Marked Graph is a kind of Petri net in which every place has exactly one incoming arc and exactly one outgoing arc. As a consequence, it a concurrent language (several transitions may be fired) and has no conflict.
The Domain Model, also called Abstract Syntax or Metamodel, defines :
-
A marked graph as a set of places and transitions.
-
Each Place has exactly one input transition and one output transition and a token count.
-
A transition has several input places and several output places.
The graphical concrete syntax draws places as circles and transitions as squares. Inputs and outputs of places and transitions are designated by arrows. The following picture shows the graphical representation of the Marked Graph model of wikipedia (using a graphical syntax defined using Sirius).
In this section, we first create an xDSML project for MarkedGraph and initialize it with the provided Abstract Syntax (AS) and Concrete Syntax (CS).
First, check that the current perspective is "xDSML" (top right of Eclipse frame). The perspective can be changed thanks to the menu "Window > Open Perspective > Others".
Create a "New xDSML project" (New > Project > GEMOC Project / new GEMOC Concurrent xDSML Project).
The first dialog of the wizard asks for the name of the project. Define it as org.gemoc.sample.markedgraph.xdsml.
Click on Next and define the properties of the language (markedgraph). The 'Package' property is already defined (based on the project name). The othe properties include the name of melange file (used to link together the different parts on an xDSML), the name of the language and the location of the Ecore file. The two other properties 'DSA projects' and 'ECL path' will be created latter in this tutorial.
Use 'markedgraph' for the Melange file name, 'MarkedGraphL' for the Language name and select the markedgraph.ecore file by Browsing the 'org.gemoc.sample.markedgraph.model' project (found in 'model' directory).
The Melange file summarizes all the important resources used in an xDSML project (which are part of and managed by other projects). Completion (CTRL-SPACE) can be used to launch wizard but it will not be used in this tutorial. The Melange file is found in the 'org.gemoc.sample.markedgraph.xdsml' project in the 'src' directory.
A transition can be fired if there is at least one token in every of each input place. When a transition is fired, one token is removed from each of its input places and one token is added to each of its output places. Several transitions can be fired as the same time.
Defining the execution semantics consists in implementing the previous behavior. In the GEMOC approach, it is split in different concerns:
-
The definition of Execution Data (ED) like the runtime count of tokens in a place and Execution Functions (EF) like fire a transition. ED and EF constitute the DSA.
-
The definition of the model of concurrency as a set of events and constraints on these events. It is the MoCC concern that is defined in a DSE project (using ECL, Event Constraint Language) possibly completed with MoCCML projects to define libraries of constraints.
-
The mapping between the DSA and the MoCC.
In the current version of the GEMOC studio, the MoCC and the mapping are tightly coupled and described in ECL (Event Constraint Language).
During execution of a MarkedGraph, the number of tokens of a place has to be recorded and changed according to the fired transitions. Thus, we have to manage an execution data (ED) called runtimeTokenCount and an execution function (EF) on Transition called fire(). Furthermore, the runtimeTokenCount of each place must be initialized at the start of the execution. It is the purpose of the EF called initialize() on the MarkedGraph element.
The DSA of Marked Graph is composed of :
-
one ED called runtimeTokenCount defined on Place . It represents the number of token in a place when the model is executed.
-
one EF called initialize() defined on MarkedGraph. It initializes the runtime token count of each place with the initial token count.
-
one ED called fire() on Transition. It to remove one token from each of its input places and add one token to all its output places.
In the Project Explorer, right click on any file of the xDSML project and choose GEMOC Languge > Create DSA Project for language to start the wizard.
The wizard first add for the language: select 'MarkedGraphL' and click OK. On the next screen, the project name is already initialized. Click 'Finish' and the 'org.gemoc.sample.markedgraph.k3dsa' is created and the Melange file is completed with references to aspects implemented the ED and EF.
Open the markedgraphAspects.xtend file. It is located in the org.gemoc.sample.markedgraph.k3dsa project in src/markedgraph.aspects. The file has been initialized with a template that can be discarded and replaced with the following text.
link:MarkedGraph/markedgraphAspects.xtend[role=include]
There is an error in the Melange file because no aspect has been defined on the NamedElement metaclass. Just comment out the corresponding line.
TODO: To be added as a next tutorial. WARNING: Errors are present because the used Relations are not yet defined… They will be solved during the next step of this tutorial.
TODO: Separate the MoCC part. We could define several relations : onlyOnce, beforeAll, and delayedPrecede.
TODO: Say that the Precede relation is defined in kernel.ccslLib or CCSL.ccslLib.
TODO: Add a link to another tutorial which uses an automata to define the MoCC.
TODO: Tricks: Limitation of ECL for Integer type : use of a local expression.
In the xDSML editor, we can select the animation viewpoint by selecting the newly created project (org.gemoc.sample.markedgraph.animation)
TODO: What about the timeline ? * Time Line (bottom middle): the logical steps available at each steps and the selected one. component of the Modeling Workbench.