Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Jack H.Integration and automation of manufacturing systems.2001.pdf
Скачиваний:
80
Добавлен:
23.08.2013
Размер:
3.84 Mб
Скачать

page 548

• Petri nets have been used for the modeling, control and validation of the control model [Teng and Black, 1988]

20.4 USING THE SUBROUTINES

20.4.1 Basic Petri Net Simulation

The subroutines are applied in a methodical manner. Before the user can integrate the subroutines into their program, they must draw out the petri net, and label all places and transitions. The example given above is illustrated below.

p3

p1

 

t1

 

p2

 

 

t2

t4

 

p5

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

t3 p4

After these labels are determined, they are defined using the petri net subroutines. The arcs in the petri net are also defined in the program. There are defined with respect to the transitions. That is to say that an arc is an input to, or output from a transition. After the petri net structure has been defined, tokens may be placed in the places of the net. The tokens are as given in the previous example.

page 549

p3

p1

 

t1

 

p2

 

 

t2

t4

 

p5

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

t3 p4

The transitions are then selectively fired in the net, by function calls in the program. This program also has calls to functions which print the petri net structure after each transition. The code is show below for the example above.

#include <stdio.h> #include <stdlib.h> #include <string.h>

#include “global.h” #include “petri.h”

int test1() /*

* BASIC TEST NET (Peterson book, 1981, pg. 19) */

{

static int error;

static struct petri_net net; static int p1, p2, p3, p4, p5; static int t1, t2, t3, t4;

error = petri_init(&net);

p1 = petri_place(&net, “p1”);

p2 = petri_place(&net, “p2”);

p3 = petri_place(&net, “p3”);

p4 = petri_place(&net, “p4”);

p5 = petri_place(&net, “p5”);

t1 = petri_transition(&net, “t1”);

t2 = petri_transition(&net, “t2”);

t3 = petri_transition(&net, “t3”);

t4 = petri_transition(&net, “t4”);

petri_input(&net, p1, t1, 1); petri_input(&net, p2, t2, 1); petri_input(&net, p3, t2, 1);

page 550

petri_input(&net, p4, t2, 1); petri_input(&net, p4, t3, 1); petri_input(&net, p4, t3, 1); petri_input(&net, p5, t4, 1);

petri_output(&net, p2, t1, 1); petri_output(&net, p3, t1, 1); petri_output(&net, p4, t1, 1); petri_output(&net, p4, t1, 1); petri_output(&net, p2, t2, 1); petri_output(&net, p5, t3, 1); petri_output(&net, p3, t4, 1); petri_output(&net, p4, t4, 1);

petri_add_tokens(&net, p1, 1); petri_add_tokens(&net, p4, 2); petri_add_tokens(&net, p5, 1);

petri_print(&net);

petri_event(&net, t4); petri_print(&net);

petri_event(&net, t1); petri_print(&net);

petri_event(&net, t3); petri_print(&net);

return error;

}

As can be seen this method of implementation is very simple. The user is able to define a number of nets, and refer to transitions and places by name.

20.4.2 Transitions With Inhibiting Inputs

In some cases we want to prevent a transition from firing. To do this, the idea of inhibiting inputs has been proposed. If a transition has an inhibiting input from a place, that has any tokens in it, then the transition cannot fire. Otherwise the transition may fire normally. A sample net has been devised for this case, it is seen below.

page 551

p1

p2

 

 

 

 

 

 

 

 

 

 

 

 

 

t1

p3

 

 

 

 

 

 

 

 

 

 

 

 

 

t2

 

 

 

 

 

 

 

 

 

 

p4

Inhibiting input

 

 

 

 

 

 

p5

 

 

p6

 

 

t3

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

t4

 

 

 

 

The program below shows that the inhibiting input is simply defined when the arc is defined.

int test2() /*

* INHIBITED TEST NET (Peterson book, 1981, pg. 196) */

{

static int error;

static struct petri_net net; static int p1, p2, p3, p4, p5, p6; static int t1, t2, t3, t4;

error = petri_init(&net);

p1 = petri_place(&net, “p1”);

p2 = petri_place(&net, “p2”);

p3 = petri_place(&net, “p3”);

p4 = petri_place(&net, “p4”);

p5 = petri_place(&net, “p5”);

p6 = petri_place(&net, “p6”);

t1 = petri_transition(&net, “t1”);

t2 = petri_transition(&net, “t2”);

t3 = petri_transition(&net, “t3”);

t4 = petri_transition(&net, “t4”);

petri_input(&net, p1, t1, 1); petri_input(&net, p2, t2, 1); petri_input(&net, p3, t2, 1); petri_input(&net, p5, t3, 1); petri_input(&net, p3, t4, INHIBIT); petri_input(&net, p4, t4, 1); petri_input(&net, p6, t4, 1);