DTU 
 

 

02341: Model-based Software Engineering (f16)

Assignment 6: The ePNK: Defining concrete syntax for a Petri net type
 
 

In this assignment, you will define the concrete/graphical syntax for YAWL nets, which you had defined as a Petri net Type Definition in Assignment 5 (see lecture 4 and project slides concerning the expected graphical syntax for YAWL nets).

 

You will learn how to

  • implement figures for places, transitions and arcs, which define the appearance of the respective Petri net object dependent on the attributes and context of the respective element, and how to
  • create and plug in a graphical extension for the ePNK based on the figures defined above.
Section 4.6 of the ePNK: Users' and Deveopler's Guide (pp. 130–138) provides detailed information and an example on how to equip a Petri net with graphical syntax in the ePNK.

 

  1. Before you start implementing the graphical appearance for YAWL nets, import the org.pnml.tools.epnk.pntypes.signalnets example to your workspace, and have a look in the Java package org.pnml.tools.epnk.pntypes.signalnets.graphics and its sub packages, which are relevant for defining the graphical syntax of Signal/Event-nets; the code is discussed in Section 4.6 of the ePNK manual.

     

  2. After you have an overview of the steps of defining a graphical extension, create a new plug-in project in your workspace (New -> Other... -> Plug-in Project) with a reasonable name e.g. ( ... .yawl.graphics); do not use any of the existing templates when going through the wizard for creating a new Plug-in project (just create an empty Plug-in project).

     

    Before adding any code, add some dependencies to this new project. To this end, double-click on the MANIFEST.MF file in the folder META-INF of the project, and, in the opened editor, navigate to the Dependencies tab at the bottom of the editor window. Add your project with the EMF-model for YAWL nets, which you created in Assignment 5, as well as the following two projects to the "Required Plug-ins": org.pnml.tools.epnk.diagram and org.eclipse.swt (on OS X, you might need to add org.eclipse.swt manually to the MANIFEST.FM file; ask for help in the tutorial, if you do not know how to do that).

     

  3. In the source folder src of the new project, create a Java package for graphical figures called ... .yawl.graphics.figures and create a Java class for the YAWLArcs with super class ArcFigure from the package org.pnml.tools.epnk.gmf.extensions.graphics.figures in project org.pnml.tools.epnk.diagram. Override the update() method, where you need to find out what the type of the arc that is attached to the ArcFigure is; if it is a normal arc set the solid line style for the ArcFigure; if it is a reset arc set a dashed line style for the figure. You can do this by:
    this.setLineStyle(SWT.LINE_DASH); and this.setLineStyle(SWT.LINE_SOLID);
    Also make sure that the line style is set properly initially in the constructor.

     

    NB: Later in your project, you should also define a dedicated arrow head (decoration) for reset arcs (e.g. a double arrow). But, you do not need to do that for now.

     

  4. In order to plug in the figure for arcs to the ePNK, you need to create a class implementing a graphical extension for the ePNK. I suggest that you create a class YAWLGraphics inheriting from the ePNKs GraphicalExtension class.

     

    In the class for the graphical extension, implement (override) at least the methods getExtendedNetTypes(), getExtendedNetObjects(), and createArcFigure(). The getExtendedNetTypes() should return a list with a single EClass representing the YAWL net type, the getExtendedNetObjects() should return a list with a single EClass representing the YAWL arc (for now). See Listing 4.37 (on page 137) of the ePNK Manual. The method createArcFigure() should return a new instance of the ArcFigure you implemented in the previous step (with the current arc as its parameter to the constructor).

     

  5. Now, you can plug in the YAWLGraphics extension which you have created in step 4 to the ePNK, by adding some xml similar to the one shown in Listing 4.38 of the ePNK Manual to the plugin.xml; note that the class attribute needs to refer to the class you implemented in step 4 (with its fully qualified Java name).

     

  6. Once you did that and the project does not show any errors in the Java code or the plugin.xml, start the runtime workbench of your Eclipse. In the runtime workbench, create a PNML document (see Assignment 5) and a YAWL net in it. Create a page and open the graphical ePNK editor on that page and create a simple YAWL net with at least one arc. Change the type of the arc between a normal and a reset arc, and see whether the graphics adjusts automatically (as defined above).

     

  7. Once the graphics for arcs works properly, start implementing a Java class that defines the figure for places (see Listing 4.36 of the ePNK Manual) inheriting from the PlaceFigure from the ePNK (you can add it to the same package as the figure for arcs in step 3). You need to implement/override methods fillShape() and update(). For now, it would be enough that the place shows a small square inside the place, when it is an finish or end place and shown as a normal place otherwise.

     

    NB: Later in the project, an arc should show a small triangle for start places too, but you do not need to do that now.

     

  8. In order for the ePNK to use also your new PlaceFigure, you need to change the class YAWLGraphics from step 4. Method getExtendedNetObjects() needs to also return the class for YAWL places now, and you need to implement (override) the method createPlaceFigure(), so that it returns a new instance of the class for the place figure you implemented in the previous step (attached to the provided place). See Listing 4.37 of the ePNK manual.

     

  9. If your project builds correctly, you can restart the runtime workbench and check whether start places are graphically shown with a small box inside and other places without that box.

     

  10. NB: Later in your project, you also need to implement a figure for transitions graphically showing the join and split types of the transition. But, this is not part of this assignment; but if you want you can try already now.

     

Material on the ePNK
 

 

Ekkart Kindler (), March 9, 2016 (last updated March 11, 2016)