DTU 
 

 

02341: Model-based Software Engineering (f16)

Assignment 5: The ePNK: Defining a new Petri net type
 
 

In this assignment, you will create a new Petri net type and plug it in to the ePNK. Moreover, you will create a first instance of this new Petri net type by using the ePNK. This Petri net type is an initial simple version of YAWL nets (see lecture 4 and project slides), which you can use (probably slightly extended) in your project later.

 

You will learn how to

  • install the ePNK in your version of Eclipse,
  • create an EMF model for a Petri net type, which extends an existing model (the ePNK core model),
  • plug this Petri net type to the ePNK, and how to
  • use the ePNK for create and edit a Petri net of this type.
Generally, you will find most information on how to use the ePNK as an end user and as a developer in the ePNK: Users' and Developers' Handbook, which refers to version 1.0.0 of the ePNK. But, for this course, you should the ePNK version 1.0.2 which provides some useful extensions, which will make it easier for you to implement the YAWL simulator (explained in some of the next tutorials).

 

  1. Get an overview of the idea and how to use the ePNK, by skimming Chapters 2 and Sections 3.1 to 3.4 of Chapter 3 of the ePNK: Users' and Developers' Handbook.

     

  2. Install the ePNK version 1.0.2 in the Eclipse version for this course. To this end, start the "Install" dialog (Help -> Install New Software...), type the updates site URL http://www2.imm.dtu.dk/~ekki/projects/ePNK/mars/update/ into the "Work with" field of the "Install" dialog, then select all features showing up in the selection dialog (6 features from three categories), and follow through the installation dialogs. Remember to accept the license agreements and to give your OK to install unsigned content. At the end restart your Eclipse.

     

    In order to test whether the ePNK installation worked, create a first Petri net (Section 3.2 to Section 3.4 of the ePNK: Users' and Developers' Handbook:

     

    • In a new project (could be of any kind, but best select "Project" from category "General"), use "New -> Other... -> PNML Document" (in category "ePNK").
    • In the opened tree editor, you will find a top element "Petri Net Doc"; in this element create a new child element which is a Petri net of type P/T Net ("Petri Net http://www.pnml.org/version-2009/grammar/ptnet").
    • On the newly created PT Net element, create a new page.
    • Then double-click on the newly create Page element (and answer "OK" on the question whether you want to proceed).
    • This will open a graphical editor with a canvas (similar to your GMF editor from Assignment 3). Create a simple Petri net with this editor by adding places, transitions and arcs.
    • Note that you cannot add tokens in this editor; but you can create a label and link it (tool "Link Label") to a place; you will be asked whether this label should be the name of the place or the marking. Add a marking to the place and change the value to 1 for those places where there should be a token. If you want, you can also add names to places and transitions.
    • At last, save the net. Not that you can not do that directly from the graphical editor; you need to do that in the still open tree editor.

     

    If you want, you can open a simple simulator on this net. To this end, open the "ePNK Applications View" (Window -> Show View -> Other... -> ePNK: Applications). Once this ePNK Applications view is open, click into the canvas of the graphical editor of the Petri net that you have edited above. Then you can start an application on that net with the "Start application" dropdown menu in the toolbar of the ePNK Application View (left of the "red cross"); select "P/T-Net Simulator". Then you can play with this simulator application; the enabled transitions are highlighted with a coloured overlay, and when you double-click on it, the respective transition fires. To shut down the application you need to select its checkbox in the "Application View" and click on the delete symbol ("red cross").

     

  3. The main task of this assignment is to create an EMF (Ecore) model for a Petri net type, which represents the features of YAWL (see lecture 5 and Section 4.5 of the ePNK: Users' and Developers' Handbook).

     

    Before you actually create the Ecore model in Eclipse, think about which concepts the model should cover, draw it on a piece of paper, and discuss it in your group. Only after this paper drawing is finshed, start creating it in an Eclipse project:

    1. First, create a new empty EMF project (New -> Other... -> Empty EMF Project) with a reasonable name. Then, in the model folder of this new project, create a new Ecore model, and in the opened tree editor give the package a name and create a class Place in this package (see Assignment 1).

       

    2. This class should actually inherit from the Place class of the PMLCoreModel, which is a model which comes with the ePNK. To this end, in the tree editor of your new Ecore model, right-click and select "Load Resource..."; in the opened dialog select "Browse Target Platform" and there select the package "http://org.pnml.tools/epnk/pnmlcoremodel". Then select the Place that you have created before and, in the properties view, select its super type "Place -> PlaceNode" from the PNMLCoreModel. Save the Ecore file.

       

    3. After this step, you can either continue editing the Ecore model in the tree editor or you can create a diagram as discussed in the end of Assignment 2.

       

    4. Create all the parts which you need for defining a Petri Net Type Definition (PNTD) as discussed in the lecture. The package needs to contain a class representing YAWL nets, which inherits from PetriNetType from the PNMLCoreModel, and it needs to have a class for Transitions, Places and Arcs, with the necessary extensions which should inherit from the class Attribute from the PNMLCoreModel and need to have a text attribute. The type of the attributes could be enumerations which you define for the respective types of splits, joins, arc types, and place types. You can find some inspiration it the Petri net type that come with the ePNK (see project "org.pnml.tools.epnk.pntypes.signalnets", which you can import to see it in your workspace by opening the Plug-ins view, right-clicking on the project, and selecting Import As -> Source project).

       

    5. Once you have represented all the additional features of YAWL nets represented in the model (as Attributes attached to the respective Petri net elements) and validated the model, create the gen model for the Ecore model (see Assignment 1). There is a minor but important difference in the step "Package Selection" though: Select your new package in the top window ("Root Packages"); the Gen model for the PNMLCoreModel should be selected in the "Referenced Gen Models:" window. Then continue the dialog until the gen model is created.

       

    6. You need to do two manual changes in the created gen model though. You need to change one property in the Gen Model itself (represented by the topmost icon): The property "Operation Reflection" in category "Model" should be set to false. Moreover, you need to set the attribute Base Package to some reasonable Java Package name (see Assignment 1).

       

    7. Generate the model and the edit code from your gen model and check whether the code compiles and builds correctly (except for the class representing your YAWL net type).

       

    8. The class implementing you net type will show an error. You must implement the toString() method in this class (as discussed in Sect. 4.5.1.3 of the ePNK Handbook) and you must make the constructor of this class public (don't forget to mark the changed code with @generated NOT). The toString() must return the URI which must be unique for this Petri net type.

       

    9. At last, you need to plugin your new Petri net type to Eclipse (as discussed in Sect. 4.5.1.3 of the ePNK Handbook). Basically, you need to add something like the following snippet plugin.xml to the plugin.xml of your EMF project, where class is a fully qualified name of the Java class representing your YAWL net type; also add a name and description for your new net type and a description of it. The id, should be some unique id representing your new Petri net type.

       

  4. Now start the runtime workbench of your Eclipse, create another PNML document and check whether you can create a Petri net of your new type now.
Material on the ePNK
 

 

Ekkart Kindler (), March 1, 2016