[PNtalk]

A Brief Description of the PNtalk System

Department of Computer Science and Engineering, Technical University of Brno, Czech Republic
e-mail: vojnar@dcse.fee.vutbr.cz, janousek@dcse.fee.vutbr.cz
WWW: The Petri Net Research Group at the DCSE TU Brno, PNtalk's Home Page


Contents



A Brief Introduction To OOPNs

The OOPN formalism is characterized by a Smalltalk-based object-orientation enriched with concurrency and polymorphic transition execution, which allow for message sending, waiting for and accepting responses, creating new objects, and performing primitive computations.

OOPNs are based on viewing objects as active servers which offer reentrant services to other objects. Services provided by objects, as well as independent activities of objects, are described by Petri nets -- services by method nets, object activities by object nets. Tokens in nets represent references to objects.

An OOPN consists of Petri nets organized in classes. Every class consists of an object net describing the internal activity of objects of this class and a set of dynamically instantiable method nets describing how these objects respond to messages. All method nets of a given class share access to the appropriate object net (places of the object net are accessible for transitions of method nets). Each method net has parameter places and a return place. Class inheritance is defined by the inheritance of object nets (Inherited transitions and places identified by their names can be redefined and new places or transitions can be added.), together with sets of method nets (The implementation of inherited methods can be changed and new methods can be added.). Classes can also contain predicate methods which allow for atomic testing their objects' states without any side-effects.

Every object is either trivial (e.g. a number or a string) or it is an instance of some Petri net-described class consisting of one instance of the appropriate object net and several currently running instances of method nets. When an object receives a message, a new instance of the corresponding method net is created, parameters are put into the parameter places and the instance of the method net is being executed concurrently with all other net instances until the return place receives a token. Then the value of the token in the return place is passed to the message sender as the result of the requested service, and the instance of the method net is deleted. Message sending and object creations are specified as actions attached to transitions. Execution of transitions is polymorphic -- invoked methods depend on classes of message receivers which are unknown at the compile time.

The basic notion of OOPNs is demonstrated by this simple OOPN class, further examples in the form of files which can be loaded into PNtalk can be found at this URL. Similarly, next information about OOPNs can be obtained from the articles which can be downloaded from the homepage of the The Petri Net Research Group at the DCSE TU Brno, eventually from the homepages of its members.



Obtaining and Installing PNtalk

To obtain and install the PNtalk system, please perform the following steps:
  1. Download the license agreement form, fill it in and send it back to vojnar@dcse.fee.vutbr.cz.
  2. Download the encrypted and compressed PNtalk image for Solaris or Windows (about 2 MB).
  3. If you are using Solaris, decrypt the file pntalk.tar.gz.pgp by means of the pgp utility (pgp -d pntalk.tar.gz.pgp), and uncompress the resulting file by means of the standard gunzip and tar utilities (gunzip pntalk.tar.gz, tar xvf pntalk.tar). If you are using Windows, uncompress and decrypt the file pntalk.zip by means of pkunzip (pkunzip -s pntalk.zip). For decrypting use the password which will be sent to you by e-mail after finishing the first step.
  4. If you do not have the object engine, you can download it for using together with PNtalk in Solaris or Windows. After having downloaded it, you can decrypt and uncompress it in the same as the image in the previuos step. In Solaris, perform "chmod a+x oe20" to make the engine executable.
    As for the new (free) version of VisualWorks (3.0), see the remark in the section describing the PNtalk launcher ...
  5. Start the VisualWorks system using the command "oe20 pntalk.im" provided that you are in the directory where there is the pntalk.im file stored and that the system knows where to look for oe20 (if it is not in the same directory). Subsequently you can adjust some parameters of the Smalltalk environment (such as the amount of the initially allocated memory space -- default is 64MB in Solaris and 32MB in Windows). For further information see the section Managing PNtalk.
  6. Start the PNtalk system from the VisualWorks Launcher by pressing the button PNtalk (all other buttons and menu items do not concern PNtalk but Smalltalk - see the section Managing PNtalk).


Managing PNtalk

In this section, there is described working with the Smalltalk environment in which PNtalk runs (i.e. starting it, adjusting the initial memory consumption, finishing it) and about the PNtalk Launcher which is a central tool of PNtalk.



A Minimum Information about Working with the Smalltalk System

Starting the Smalltalk Environment
Let us suppose that the system knows where the object engine oe20 is installed. Then simply type oe20 pntalk.im in the directory where pntalk.im is stored.
Adjusting the Amount of Consumed Memory
You can use the lines written in the window of the VisualWorks system. Find a line with a suitable amount of memory, use your mouse to highlight the appropriate command ObjectMemory sizesAtStartup: #(....) (push down the left button, move along the text, and release the button), use the middle button of the mouse to launch a menu and perform the ``Do It'' action. Subsequently, perform ``File|Exit VisualWorks...'' with saving the image. Restart the system. If there is no amount of memory suitable for your needs, you can create your own line by means of suitably multiplying/diving numbers in some existing line with some constant.
Note that you specify only the initial amount of memory, Smalltalk can later occupy some additional memory space. The currently occupied amount of memory can be find out by highlighting the prepared command ObjectMemory dynamicallyAllocatedFootprint and performing ``Print It'' on it.
Further Adjusting Smalltalk Parameters
Use the menu item ``File|Settings''.
Performing Garbage Collecting
Before starting a simulation run, it is good to perform garbage collecting -- use the menu item ``File|Collect all Garbage''.
Exiting the Smalltalk Environment
Use the menu item ``File|Exit VisualWorks...''. Choose ``Exit'' if you have not created any code in Smalltalk, otherwise choose ``Save and Exit'' -- be beware, in this the size of image quickly increases, so do not use this option unless it is necessary.


The PNtalk Launcher

The PNtalk system is an additional tool incorporated into the ParcPlace VisualWorks Smalltalk environment. This environment allows us to write Smalltalk classes, create graphical interfaces, communicate with databases, etc. All these features can be used from the object oriented Petri nets as well -- in this case, it is good to install the whole Smalltalk system and not only the object engine oe20. Nevertheless, it is of course possible to work with Petri nets only. In this case, the VisualWorks system is used only for launching the PNtalk system -- this can be done simple by clicking on the large button with logo of PNtalk.

A new version of the whole VisualWorks system (VisualWorks 3.0) can be obtained for free (Linux and M$ Windows version) from the WWW site of ObjectShare which is a new name for ParcPlace. However, it is impossible to run the current version of PNtalk under the object engine (visualnc) from this version of VisualWorks because of binary incompatibility of images for VW 2.0 and 3.0. Currently, we are trying to import source files of PNtalk into VisualWorks 3.0 and produce the appropriate image file but it seems that this will take some time because there have been some (from our point of view) serious changes in the new object engine :-(. Nevertheless, interested users can use VW 3.0 for developing their own Smalltalk classes to be used within OOPNs. These classes can then be ``filed out'' from VW3.0 and ``filed in'' into VW2.0 and used within OOPNs.

The so called PNtalk Launcher is used as a control panel of PNtalk -- it is possible to start all other tools from here. In particular, a user can launch a browser, a debugger or a tool for manipulation with breakpoints. It is also possible to start multiple browsers or debuggers for working with various parts of the modelled system.

The launcher also contains buttons for OOPN class system compiling, for adjusting various simulation options, and, of course, for starting and terminating simulation runs. Before starting a particular simulation run, the user must specify the main (primary) class in the launcher. This will be used when starting the simulation in such a way, that the simulator will automatically create one instance of the main class.

Further, the PNtalk launcher is used for displaying the current status of the PNtalk system, and also for displaying the current simulation time during simulation runs. It also contains the so called transcript which is used for displaying various system messages, computed statistics, as well as user defined messages which can be sent from transition actions.



Editing OOPNs

The tool of PNtalk intended for editing nets is called the PNtalk Browser and it can be started from the PNtalk Launcher (see Managing PNtalk). The window of the browser is divided into three parts:
  1. the top left part containing a list of classes,
  2. the top right part containing a list of methods of the selected class, and
  3. the bottom part containing the graph of the selected method or of the object net if no method was selected.
Note that you can use more browsers at the same time.

In the following there are described menus which can be launched in different parts of the editor and which are used for controlling it. If you know the action you want to perform, we suggest you to try to find its description by means of the ``Find'' command of your HTML browser.



The Class List Menu

If you press the middle button of your mouse on the top left part of the PNtalk Browser, you will obtain a menu which will allow you to perform the following actions which work with the selected class or method:

The Method List Menu

If you press the middle button of your mouse on the top right part of the PNtalk Browser you will obtain a menu with the following items:

The Object Net Menu

If you select an object net (some class is selected in the top left part of the PNtalk Browser, no method net is selected in the top right part of the PNtalk Browser, and the graphical representation of the object has black squares in its corners -- to achieve this click on some free space inside the bounds of the object net), you can launch the following menu by using the middle button of your mouse:

The Method Net Menu

If you select a method net (some class is selected in the top left part of the PNtalk Browser, some method net is selected in the top right part of the PNtalk Browser, and the graphical representation of the method net has black squares in its corners -- to achieve this click on some free space inside the bounds of the method net), you can launch the following menu by using the middle button of your mouse:

The Outer Method Net Menu

This menu is launched when some class and some of its methods are selected in the appropriate list, but the graphical representation of the method net is not selected (there are no black boxes in its corners -- to achieve this click on some free space outside the bounds of the method net). This menu serves for manipulating relations between object nets and method nets:

The Place Menu

This menu is launched when a place is selected (has black boxes round it -- to achieve this click on it) and the middle button of the mouse is pressed:

The Transition Menu

This menu is launched when a transition is selected (has black boxes round it -- to achieve this click on it) and the middle button of the mouse is pressed:

The Substitution Transition Menu

This menu is quite similar to the Transition Menu, apart from that there cannot be put breakpoints on substitution transitions.



The Arc Menu

This menu is launched when an arc is selected (has black boxes round it -- to achieve this click on it) and the middle button of the mouse is pressed: Note that arcs going to/from method icons in object nets are not regular arcs (they represent some arcs displayed in the definitions of the methods) and therefore they cannot be manipulated in a the common way.



The Method Icon Menu

This menu is launched when a method icon (representing a folded net) is selected (has black boxes round it -- to achieve this click on it) and the middle button of the mouse is pressed:

The Predicate Menu

This menu is launched when a predicate is selected (has black boxes round it -- to achieve this click on it) and the middle button of the mouse is pressed:

Simulating OOPNs

In the following there is sketched how to start, control, and terminate simulation runs.



Starting the Simulation

When starting a simulation run you should do the following steps:
  1. Compile your OOPN by pressing ``Compile'' in the PNtalk Launcher.
  2. If there were syntactical or simple semantical errors, their description was printed out into the transcript of the PNtalk Launcher and it is necessary to remove their causes.
  3. If there were no errors, specify simulation options in the ``PNtalk Options'' dialog which can be launched from the PNtalk Launcher. The following things can be specified here:
  4. In the PNtalk Launcher, specify the main class, i.e. the class whose instance should be automatically created at the beginning of the simulation -- other objects and method net instance are then created transitively from this object.
  5. Press the ``Run'' in the PNtalk Launcher.
Note that before starting a longer simulation run it is sometimes advantageous to make Smalltalk to clean its memory, i.e. to perform garbage collecting -- use the menu item ``File|Colect all garbage'' from the VisualWorks Launcher.



Controlling the Simulation



Interrupting the Simulation

There are two possibilities of interrupting the simulation, one is normal, the second one should be used only in emergency: Note that this manipulation need not to be successful and, moreover, it can take quite a long time to stop all processes and then to parse messages produced by them (in this there is already written ``STOPPED'' in the Launcher, but you still cannot work ...).



Debugging OOPNs

The tool of PNtalk intended for debugging nets is called not surprisingly the PNtalk Debugger and it can be started from the PNtalk Launcher (see Managing PNtalk). The procedure of starting it is described in the section Simulating OOPNs.

The window of the debugger is divided into three parts:
  1. the left part containing a list of processes (i.e. object and method net instances),
  2. the middle part containing the graph of method or of the object net corresponding to the selected process,
  3. the right part containing information about the selected place or transition instance.
Note that you can use more debuggers at the same time.

In the following there are described particular parts of the debugger.



The List Of Processes

The List of Processes is organized by using spaces on the beginnings of lines in such a way that it creates a tree. This tree reflects relations caller x launched method net instance and creator x created object. Processes correspond to running net instances, i.e. instances of object nets (one for every object) and instances of method nets (their number depends on how many times they were called and how many of them have terminated).

Items in the List of Processes have the form: class_name [object_id] >> method_name [net_instance_id]. The class_name specifies the class of the object we are working with. The object_id is unique integer identifying the object. The method_name is the name of the method the process belongs to -- in the case of an object net, the name is object. Finally, the net_instance_id is unique integer identifying the net instance, i.e. the process. In the case of an object net, object_id = net_instance_id - 1.

Items in the List of Processes can be typed in three ways:
  1. The default font is used for alive net instances but with no enabled transition instances.
  2. The bold face font is used for net instances with enabled transition instances.
  3. The italics is used for net instances which have already terminated -- this can be used for method nets only.
You can launch a menu with the following items on the List of Processes:

The Display of Net Instances

This is the middle part of the PNtalk Debugger and it displays the net of the net instance selected in the List Of Processes (see above). Fireable transitions are drawn using thick lines. You can use this part to select places and transitions (by simply clicking on them) you want some information about -- this information will be described in the right part of the debugger.



The Display of Information about Places and Transitions

This is the right part of the PNtalk Debugger. It displays information about place and transition instance selected in the middle part of the debugger.

In the case of a place, its current marking is displayed.

In the case of a transition, information about its fireable bindings and about its invocations is printed out. As for the invocations, there is always information about the unfinished ones and there can be also information about the finished ones if they have not been scavenged yet. The information is summarized in the message number_of_fireable_bindings F/number_of_active_invocations T -- T means ``tail'' and it is an obsolete term which arose from the implementation of PNtalk. Then you can use the arrows on both sides of this information to view records about particular bindings and invocations. In the case of bindings, there said to which object the variables are bound. In the case of invocations, there is also a list of processes which were launched within it.

By means of the middle button of your mouse, you can launch a menu on the right part of the debugger which will allow you to do the following:

Using Time In OOPNs

This section describes the way how timing is incorporated into the current version of PNtalk.

Note that when you want to simulate timed OOPNs you have to specify you are going to use time in the ``PNtalk Options'' dialog which can be launched from the PNtalk Launcher -- more information can be found in the section Simulating OOPNs.



Structural and Value Aspects of Timing

Timing is joint with transitions in PNtalk and it is based on the principle firing times, i.e. an enabled timed transition consumes input tokens, but does not produce the output ones before some time passes. Values of firing times can be specified by means of arbitrary Smalltalk methods. Therefore it is possible to use deterministic timing, interval timing, stochastic timing, as well as their various mixtures here. What is worse is that in PNtalk there is currently only one possibility how to evaluate timed nets (even with restricted timing) and this is by means of simulation.

From a syntactical point of view, transition delays can be specified by means of using the method wait: which is implemented in the class PN, i.e. in the parent of all PNtalk classes. Thus it is possible to invoke this method in actions of all transitions by means of the message self wait: delay where delay is an arbitrary Smalltalk expression. For example, if we want to specify a deterministic delay of the length 5, we write self wait: 5 in the action of the appropriate transition.

As for generating stochastic delays, there are currently implemented two random generators supporting it. The class Uni represents a uniformly distributed generator and it can be used for generating random numbers via the method l:min_delay h: max_delay, i.e. if want to create a transition with uniformly distributed delay within the range 3 to 5, we place into its action the following construction: self wait: (Uni l: 3 h: 5). Similarly, the class Exp represents an exponentially distributed generator whose values can be sampled by means of the method mv: average_delay. We can e.g. create a transition with the action self wait: (Exp mv: n) where n is a variable on an input arc of the transition. Other generators can be easily implemented but it requires some knowledge of programming in Smalltalk -- an interested modeller can be inspired by the code of classes Uni and Exp which are present in the category PNtalk-Simulation-Support.



Collecting Statistics about the Behaviour of Stochastic OOPNs

If we use stochastic timing we usually want to derive average performance characteristics of the modelled system, such as average waiting times, average lengths of queues, etc. Collecting such kind of data is supporting by statistics in PNtalk, i.e. by objects of classes derived form the class PNStatistics which can be found in the category PNtalk-Simulation-Support. This class monitors all instances of its subclasses and after the end of simulation it reads data collected by the them and prints them out to the transcript. Resulting data are collected by means of calling the method printResultOn: aStream which must be implemented in all subclasses of PNStatistics. Apart from that, it is good to implement also the method printOn: aStream which is used during debugging for collecting intermediary results for displaying them into the debugger.

Apart from the restrictions presented in the previous paragraph, subclasses of PNStatistics can be implemented in Smalltalk in an arbitrary way. Once we have such classes we can use them in OOPNs. If we e.g. we want to create a statistics describing some facility, we create some subclass FacilityStatistics of PNStatistics. The we add a place Stat into the OOPN class describing the facility. The constructor of the facility can the create an instance of FacilityStatistics, e.g. by the action facStat := FacilityStatistics withName: name (we suppose withName: to be a Smalltalk constructor of FacilityStatistics and name an input variable of the appropriate transition), and store it to Stat. All methods seizing or releasing the facility must then read the contents of Stat and send it some messages updating its contents.

Modellers interested in using statistics can be inspired by the example ``MedicalCentre'' which can be obtained at this URL. The appropriate statistics are represented by classes FacilityStatistics and GeneralStatistics in the category PNtalk-Simulation-Support.



Known Bugs (and Things to Be Changed)

  1. If a no name element is created and then a name is additionally assigned to it, the name does not appear immediately, but only after several redrawing of the editor window. The same is true the other way round.
  2. If a subclass of some class is created and the OOPN is saved before looking at this subclass, then when the OOPN is loaded in, inherited elements of the subclass are misplaced.
  3. If a non existing method is called, the compiler only announces that there is an unknown error in an unknown class.
  4. The mechanism of breakpoints is not elaborated and debugged enough -- it seems that is completely unreliable. The simulation runs automatically till some transition with a breakpoint is fireable, then it is interrupted and a debugger window is launched, but after that the system behaves in an indeterministic way ...
  5. It is necessary to manually center nets in the browser before printing them out -- otherwise they can be printed on the edge of the paper.
  6. Sometimes when printing out transitions with long inscriptions the graphical representation of the transitions is too small and the inscriptions does not fit into it.
  7. Clipping regions of produced Encapsulated Postscript files are generated in a wrong way.
  8. The right part of the debugger window is not automatically cleared when switching from one process into another.
  9. Net comments are not generated into the appropriate TeX files when generating the description of the whole model.
  10. Using the release method inherited from PN causes some exception to be announced and the simulation is stopped.
  11. There is a possibility of intererleaving between removing tokens when firing a transition and starting its action. This must be changed because it is at variance with the definition of OOPNs.


If you have any comments to this document or to the PNtalk system itself please send a message to vojnar@dcse.fee.vutbr.cz.
Last modified at 15/6/1998.