DTU 
 

 

02341: Model-based Software Engineering (f16)

Assignment 4: GMF, finishing your graphical Petri net editor
 
 

In this assignment, you finish and polish your GMF editor for Petri nets from Assignment 3 and make it work together with your simulation command from Assignment 2.

 

You will learn how to

  • add nodes that are graphically contained in another node to the GMF models,
  • add OCL constraints that guarantee that an arc cannot run between two transitions or two places (as required by Petri nets — see lecture 1), and how to
  • make the command from Assignment 2 work together with your GMF editor.
Below, the assignment is broken down into simple steps starting from your solution for Assignment 2 and Assignment 3. The implementations for assignment 1 and 2 are made available via the student folder for this course on Campus net.

 

  1. If you did not finish Assignment 3 and in particular can not edit tokens yet with your graphical editor, finish Assignment 3: For adding tokens to your graphical editor, manually change the GMF tooling definition, graph definition, and mapping models. Note that this can NOT be done via the GMF dashboard; you need to change the ".gmftool", ".gmfgraph", and the ".gmfmap" file manually (remember to do all these changes via opening the "gmfmap" file and save all changes there).

     

    You need to add a tool for tokens in ".gmftool", the graphical representation for tokens in ".gmfgraph", and then define a ChildReference in the Place mapping in ".gmfmap" which maps the Token element to its graphical representation and its creation tool (see slides for tutorial 3).

     

    Regenerate the ".gmfgen" model and regenerate the diagram code from there. Start the runtime workbench and check whether your graphical editor works properly showing the tokens.

     

  2. In the grahical editor, it is still possible to connect places with places and transitions with transitions with arcs, which should not be possible in Petri net. To change this, you can add a so-called link constraint to the link mapping for arcs in the ".gmfmap" model. In the link constraint, create a source end constraint with body

     

    (self.oclIsKindOf(Place) and oppositeEnd.oclIsKindOf(Transition) ) or
    (self.oclIsKindOf(Transition) and oppositeEnd.oclIsKindOf(Place) )

     

    and language "ocl". The body and language can be added and editred in the properties view of a newly created constraint. Then regenerate the ".gmfgen" model and regenerate the diagram code (you will learn a bit more about OCL later in this course).

     

    Try out the regenerated code by restarting your runtime workbench of Eclipse.

     

  3. At last, you need to adjust your simulator from Assignment 2 to work with your graphical editor.

     

    To this end, you need to add a dependency to your dk.dtu.compute.se.mdsu.tutorial1.simulatorX project (by opening the Manifest editor (double click on plugin.xml or on MANIFEST.MF in META-INF) and select "Dependencies". You need to add a dependency to the project org.eclipse.gmf.runtime.diagram.ui.

     

    Then you need to update the getTransition() method in class SimulatorCommandHandler and the respective imports as shown in getTransition.java. If you want, you can also download the solutions from the student folder for this course on Campus net and import the dk.dtu.compute.se.mdsu.tutorial1.simulator project and adjust it to your setting (replace the dependency and the imports to your model project).

     

    By re-starting the runtime workbench, check whether your simulator is working now (including the redo/undo of transition firings).

     

Material on GMF
 

 

Ekkart Kindler (), Feb. 22, 2016