Title: Using DesignCPN at UniSA
1 USING DESIGN/CPN AT UNISA Current at
25/03/04 This document describes all the steps
which you must take to build, simulate and
analyse a simple Coloured Petri net using
Design/CPN version 4.0.4 in the SCT Real-time Lab
(SCT1-40). The lab contains a mix of Sun Blades
and older PCs, however you will be using the Sun
Blades ONLY. The Sun Blades are running Solaris.
Design/CPN is maintained by the CPN group at
the University of Aarhus, Denmark. For those who
can't get by without knowing the full story,
there is more detailed information available from
the University of Aarhus on the web at
- http//www.daimi.au.dk/designCPN/
- Feedback on this document is more than welcome.
Send email to guy.gallasch_at_postgrads.unisa.edu.au
- Contents
- Preliminary Steps (running, setup)
- Drawing the CPN
- Simulation
- Occurrence Graph Analysis
- Finishing Steps (saving, printing)
WARNING! NEVER EVER attempt to close a window
in Design/CPN by clicking on the X in the top
right-hand corner. This will cause Design/CPN to
close without warning you. YOU WILL LOSE ALL
UNSAVED WORK! To close a window, select it and
press CTRLW. Make sure you save your models
regularly, to minimise the loss of work, if you
click on the X by mistake.
2USING DESIGN/CPN AT UNISA - PRELIMINARY
STEPS Launching Design/CPN The first thing your
group must do is choose a Sun machine to work on.
You will need to use the same machine each week.
The next step is to log in to the computer using
the username and password that you have been
allocated. The username takes the form of
sdtxx where xx is the computer number, e.g. 06,
followed by an a for groups in the Monday prac
class or a b for groups in the Tuesday class.
The password is the same as your user name. For
example, a Monday group working on machine
sun40-06 will have username sdt06a and password
sdt06a. After you log in for the first time,
change your password! If you do not know how,
please see the supervisor.
On the desktop there is an icon called CPN that
starts Design/CPN. If this is the first time you
have used Design/CPN, a popup window about your
settings may appear
Click OK to create the settings file. This
shouldnt appear anymore (unless you delete the
settings file). The following menu-bar (or one
similar) should appear on your screen
3 Create a New Page Go to the File menu and
select New. A window (containing a page called
"New") will appear as follows
You will create your CP-net on the page in this
window.
4Set the Prime Page In the C programming language
execution always begins with the main procedure.
Similarly in Design/CPN execution begins with
prime pages. In this simple example our one page
should be made a prime page. Go to the Page menu
and select Open Page. A window containing two
nodes will appear
Click on the "New" node, go to
the Set menu and select Mode Attributes. A pop-up
will appear. The Prime Page option should be set
as follows
5USING DESIGN/CPN AT UNISA - DRAWING THE CPN Now
we can build the CP-net. If you have used xfig or
some other vector or object drawing package
before then you will be familiar with the way
that the Design/CPN editor works. The CPN
Menu A CP-net diagram consists of declaration
nodes, places, transitions and arcs. These
objects are selected from the CPN menu
and then drawn on the page. Create the
Global Declaration Node Click on the window
containing the page called "New" (so that it
becomes the target page). Go to the CPN menu and
select Declaration Node. A pop-up appears. Select
Global
Now draw the node on the page (click the left
mouse button where you want to put the node and
then hold-and-drag to re-size it). This node will
contain all the colour set definitions. Since our
CP-net has only one colour we can use a very
simple declaration
6 Press the Escape key, or click on any menu to
finish editing the declaration. Add Places and
Transitions Go to the CPN menu and select Place.
Now put the place on the page (left-click and
then hold-and-drag to re-size). When you release
the left button the place is covered with a
text-entry box. Enter a place name in the box and
then press Escape or click on any of the menus in
the menu bar to dismiss the box
Alternatively, to give a place a name you can
select the place, go to the CPN menu, and select
CPN Region. A pop-up will appear. Select Name
Then click where you want the name for the place
and type it in. This option for the place name
has precedence over the first, and is useful when
you want to move the position of the name with
respect to the place position. As a personal
choice, I use this second option for naming
places.
The place needs a color set, so again using the
CPN Region option put a color set region on the
page near the place (click on left mouse button).
Enter the colour set name (e.g. E) at the cursor
which appears. Your place should now look like
this
7 Transitions can be created in a similar
fashion. However, transitions don't need colour
sets. Add a transition and two more places so
that the page looks as follows
8Add Arcs Go to the CPN menu and select Arc.
Left-click (and hold) on the place "Foo". Hold
the left button down and move the pointer over
the transition "Bar" and release. An arc now
connects "Foo" to "Bar". Repeat this procedure
until the CP-net looks like this
Now the arcs must be inscribed. First get out
of "arc mode" by clicking on the menu bar or
pressing Escape. Next, left-click on an arc, go
to the CPN menu and select CPN Region. Left-click
near the arc. Text may now be entered. Make sure
your CP-net looks like this
9Note the quote symbol () used here is the back
quote (or left quote, usually on the same key as
the symbol) and not the apostrophe. 1e is
read as one of e.
Make the arc from "Foo3" a bi-directional arc.
Left-click on the arc, go to the Set menu, select
Shape Attributes. Select Both directions
Initial Markings "Foo" and "Foo3" need initial
markings. First, left-click on "Foo" and go to
CPN Region in the CPN menu. Select Initial
Marking and left click near "Foo". The initial
marking text (2e) may now be entered. Repeat
steps for "Foo3" and make sure your CP-net looks
like this
10Syntax Check
The CP-net is complete (we hope). Perform a
syntax check (Menu CPN, option Syntax Check).
Errors appear as boxes of text on the CP-net
page. Make the necessary corrections, re-check
your CP-net and then save it once it has passed
successfully.
11USING DESIGN/CPN AT UNISA SIMULATION Go to the
File menu and select Enter Simulator. After a few
seconds your model will change appearance as it
is initialised for simulation
Interactive Simulation Go to the Set menu and
select Interactive Simulation Options. Choose
Breakpoints Between Steps so that the simulation
pauses at every step (you may want to unset this
option once you are more familiar with the tool
and can keep up). Go to the Sim menu and select
Interactive Run. The CP-net will execute
according to the token game and will prompt you
to continue after each step. Verify that the
CP-net halts with "Foo" empty, "Foo2" containing
two "e" tokens and "Foo3" containing one "e"
token.
12Firing Specific Binding Elements Using
interactive and automatic simulations usually
select random binding elements to fire. If you
want to investigate specific sequences, select
the transition you want to fire and use the Bind
command in the Sim menu
Selecting All will list all available binding
elements. To fire the transition with a specific
binding element, select from the list and then
press Up. Now press the Occur button and the
transition with your selected binding element
will occur. In the cases when there are only one
binding element for a transition, once the Bind
window pops up, simply press Occur.
Initial State Once you are happy with the
simulation behaviour go to the Sim menu and
select Initial state (select No when you're asked
if you want to save here). The CP-net returns to
its initial marking. DON'T forget this when you
want to do occurrence graph analysis for the
complete Occurrence Graph.
13Saving Simulation Reports If you wish to save
the sequence of transition occurrences that
constitute the simulation you have just run, you
can do so by selecting the Save Report command
from the Sim menu. Simulation reports, or
traces, can be useful during debugging or
validation of a model. As an example, it could
be used to record a specific sequence of
transition occurrences with specific binding
elements that causes the model to reach an
undesirable state. Alternatively, you may wish
to record a possible sequence of transition
occurrences leading from the initial state to a
terminal state. Selecting Save Report from the
Sim menu will open a dialog, allowing you to
specify the location and file name of the
Simulation Report. After firing all enabled
transitions, the simulation report file for our
example contains the following
Each transition that occurred is listed, along
with the page that the transition belongs to.
The binding element for each of these is listed
in braces beneath the transition. Note that all
binding elements are empty (i.e. empty braces)
indicating that there were no variables
associated with the corresponding transition that
needed to be bound to values.
Clearing the Report When you perform a
simulation, ALL steps are recorded in the
simulation report. To clear the steps from a
previous simulation, select Clear Report from the
Sim menu. This erases all previous steps from
the simulation report. This is useful, for
example, to clear the steps from a previous
simulation that you do not wish to record, or
that you have already saved to disk. Selecting
Initial State from the Sim menu will also clear
the simulation report.
14USING DESIGN/CPN AT UNISA - OG ANALYSIS Switching
to OG Mode Go to the File menu and select Enter
Occ Graph. This may take some time (especially if
the system load is high). Calculate the OG Go
to the Occ menu and select Calculate Occ Graph.
Next, go to the Occ menu and select Show
Statistics. You should get the following
Draw the OG Go to the Page menu and select
New Page. A new page will appear. Go to the Set
menu and select Page Attributes. A pop-up will
appear. Change the name of the new page, e.g.,
15Click on the window containing the new page (so
that it becomes the target page) and then go to
the Occ menu and select Display Node. A pop-up
will appear, asking whether to display node 1
(representing the initial marking). Click on OK.
Next go to the Occ menu and select Display
Successors. This displays node 2. Again select
Display Successors and node 3 appears. Space the
nodes out a bit and then double-click on the
nodes and arcs. Notice that regions of text
appear. You should have the following
16Here the text region on each arc describes which
transition fired (and how). The text region next
to each node describes the marking of the CP-net
at each step.
Save Occ Report Go to the Occ menu and select
Save Report. A pop-up will appear. Check all the
boxes, click on OK and enter a suitable name for
the report file when prompted. The text in this
file provides more information about the CP-net
properties
17USING DESIGN/CPN AT UNISA - FINISHING
STEPS Saving the CPN Go to the File menu and
select Save State. Notice that Save and Save As
are disabled (they only work in the editor
mode). When you "Save State" instead of just
"Save" or "Save As" you are also saving
simulation and O-graph information. This means
you don't have to go through the time consuming
steps of Enter Simulator and Enter Occ Graph the
next time you load your model. Note Each
Design/CPN model that you save has three files
associated with it, e.g., foobarfoobar.DBfoobar
.ML The ML file is very large, around 10
Mbytes. (This means you cannot save the ML file
to a floppy.) So, if you save too many models you
will run out of disk space. If you run into disk
space problems it is recommended that you delete
the ML files of all but your best model. If you
then find that you have to re-visit an old model
you can still load it but you will have to redo
the simulator switch and O-graph switch (which
were preserved in the ML file). If you are in
the editor mode, the Save and Save As commands in
the File menu are enabled. Selecting either of
these will only save the foobar and foobar.DB
files. Saving to a Floppy Disk To save your
CPN models to a floppy disk on the Sun machines,
you will need to copy or save the foobar and
foobar.DB files to the shared scratch folder,
/opt/SUNWspci2/scratch, and from Windows 2000
(Shared SUN-Win scratch area, drive G) you can
copy them to your disk in the usual way.
WARNING The scratch area is not erased when
you log off. YOU MUST ERASE ALL DATA FROM THIS
SCRATCH AREA before logging off. If you do not,
the other group working on your machine in the
other practical class will have access to any
data saved in the scratch area. Plagiarism
(intentionally or accidental) will be dealt with
severely. Note that data saved to your local
user account is safe - it will not be visible to
the other group.
18 Printing the CPN and OG There are (at least)
two ways to print from Design/CPN. Both
approaches involve saving pages of your model to
files and then printing from there. The first
approach saves a page as an Encapsulated
PostScript (eps) file. These can be imported into
many programs, most notably Microsoft Word. So if
you want to create an elegant report, it is worth
the time to import your diagrams into Word. The
second approach saves as PostScript which can
then be sent directly to a printer. You can then
manually include these printouts in your
report. PLEASE NOTE Currently, printing
facilities are not set up for easy printing of
PostScript files (the second option above). For
this reason, please print to Encapsulated
Postscript as described below. I strongly
recommend this in any case, as it allows you to
insert the .eps graphics into Microsoft Word to
create a better looking report. To save the .eps
files to a floppy disk, the procedure is the same
as saving CPN models to floppy disk. Once again,
be sure you delete the .eps files from the
scratch area before logging out! Printing to
Encapsulated PostScript Go to the File menu and
select EPS Setup. A pop-up will appear. A typical
setup looks like this
Go to the File menu and select Save EPS. A file
with the name of the page your saving will be
written to your current directory. This file can
be printed from the scratch area using the GSview
program in Windows 2000.
19Microsoft Word allows you to import EPS files,
although it doesnt let you view them in the
document - you only see the diagram when it is
printed. It may take several goes to get the
layout you want. The printer must also support
PostScript. The printers in the main computer
pools, such as in the GP, F and P buildings, do
support this. Printing to PostScript NOTE
THIS FEATURE MAY CRASH DESIGN/CPN IF NOT SETUP
PROPERLY. ENSURE YOUR CPN IS SAVED BEFORE
PRINTING TO POSTSCRIPT. ASK THE SUPERVISOR IF YOU
HAVE TROUBLES. Go to the File menu and select
Print Setup. A pop-up will appear. Make sure it
looks like this
Ensure that the paper size is set to A4 letter,
and that Scale To Fit is selected. You may
choose Portrait or Landscape. Go to the File
menu and select Print. A file with a name
beginning with Meta will appear in your home
directory. You will need to copy the .ps file to
the shared scratch folder and print using GSview
from Windows 2000. Congratulations. You have
built, simulated and analysed your first CP-net!