Tasks
In this assignment, we will implement a new Petri net type defintion (PNTD) for
the ePNK, which represents a simplified version of PNVis nets. To this end,
the "empty" Petri net type from the PNML Core model should be extended with:
- an attribute for places that represents the initial marking,
- an attribute for arcs that indicates whether the
tokens consumed by this arc need to have finished their animation
or not (synchronisation attribute),
- a label for places that represents the name (just a String)
of the geometry object on which the token should be animated, and
- a structured label for places that represents the animation functions,
which could consist of a semi-colon separated list of the functions
"move", "appear", and "trigger". This text feature should be parsed
and, if syntactically correct, the structural content should be added
to the structural label.
Note that, in the ePNK, an attribute is a feature of a Petri net object
that is shown in the properties view of that object only. A label
is a feature that is shown in the graphical editor as an annotation attached to
the respective object. A structural label is a label that is parsed
and stored as text as well as in its internal structure (which can be inspected
in the ePNK tree editor). See ePNK Manual for details. There are also some slides on the extension mechanisms of the ePNK
avalialbe: ePNK-details.pdf.
Section 4.5 of the ePNK Manual explains all the steps of how to implement a new Petri net type
and how to plug it in to the ePNK.
The major steps are explained below.
- If you did not do it yet, install the ePNK (version 1.0.1) in your Eclipse
installation and make yourself accquainted with the ePNK user interface (see
Assignment 1).
- Create a new empty EMF project with a reasonable name for the new Petri net type
and create a new EMF model and diagram, which represents the
extensions of your new type (see Assignment 2,
if you do not know how to do that).
- Create all the attributes, labels and structured labels in the ecore model. Note that in order
to access classes and features from the PNML Core model (PetriNetType, Place, Transition, Arc,
Attribute, Label) or Structured PNType Model (StructuredLabel), you need to create a shortcut
to these elements.
To create a shortcut in the diagram editor, press the right mouse button somewhere on the canvas
of the diagram and select "Create Shortcut"; in the opened dialog, navigate to the respective
model and, within the model, to the model element and press okay. After the selection, this element
should show up with an addional icon showing that this is a shortcut. The needed models from
the ePNK can be found in the plugin project "org.pnml.tools.epnk" in the folder models.
Follow the principles of PNTDs as explained in Section 4.5 of the user manual. For the
attributes, you should derive the "labels" from the class Attribute from the PNML Core Model.
Note that your Ecore package should also contain a class "PNVisNet" (etc), which needs to
have supertype PetriNetType. This class must to be there, even if it is not related to
any of the other elements!
- After you have validated your ecore model. Create the generator model for this model
(see Assignment 2) and change the base package path in
the generator to some reasonable name. Note that when generating the gen model, you
need to add and select the existing
gen models for the packages to which you have shortcuts. This is done via the "Add"
button in the respective dialog, after which you can select the respective gen models
(these can also be found in the plugin project "org.pnml.tools.epnk" in the folder models).
IMPORTANT NOTE:
In the new generator model you
must make a manual change. Open the generator model and select the top-level element
in this gen-model. Then, in the properties view, select the "Operation Reflection"
property in categorty "Model" and set it to false. Don't forget to save the
changed gen-model. If you do not set this property to false, the generated code
will contain some errors (attributes that cannot be resolved).
Now generate the model and the edit code from this gen-model (see Assignment 2,
if you forgot how to do that).
- Next you need to make two manual changes in the generated code. You need to make
the constructor of the "impl" class of your new net type public (actually, it would
be better, if you manually created a derived class with a public constructor). And
you need to implement the "toString()" method that returns a fixed URL uniquely
representing your new net type.
- After these manual changes, you can plugin this type. To this end, open the
plugin.xml and add an extension "org.pnml.tools.epnk.pntd" (see Sect. 4.5 of
the ePNK Manual). The most important part is the reference to the class of your
new net type (with the public constructor).
- Start the run-time workbench and create a new PNML document. Create a new Petri net
and add your new type. Check whether the graphical editor has all the labels and
attributes of your definition.
Note that you will get an exception, when you start editing the label of your animations.
The reason is that you yet need to implement the parsing function.
- In the generated implementation class of your structured label for animations, you
need to implement the parse function that, for a given string, returns an object
that contains a structured representation of the animation.
- It would also be good, if you added the constraint that you cannot connect places
to places and transitions to transitions (see Sect. 4.5.1.4 of the ePNK Manual).
Now check again whether the graphical editor of the ePNK can properly handle all
your features and knows the constraints.
|