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

page 552

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

petri_add_tokens(&net, p1, 1); petri_add_tokens(&net, p2, 1); petri_add_tokens(&net, p5, 1); petri_add_tokens(&net, p6, 1);

petri_print(&net);

petri_event(&net, t1); petri_print(&net); petri_event(&net, t3); petri_print(&net); petri_event(&net, t4); petri_print(&net); petri_event(&net, t2); petri_print(&net); petri_event(&net, t4); petri_print(&net);

return error;

}

20.4.3 An Exclusive OR Transition:

The inhibitory inputs are complimentary to the exclusive or function. Thus another research proposed an Exclusive or transition which will fire when one (and only one) input is from a place with tokens. An example of a problem using this, a ring shift register was modelled. This net is modelled as shown below.

page 553

 

 

 

 

 

 

 

 

 

 

 

 

 

p7

 

 

 

 

 

 

 

 

 

 

t1

 

 

 

 

 

 

t2

 

 

 

t3

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

p1

 

 

 

 

 

 

p3

 

 

 

 

 

p5

 

 

 

 

 

 

 

 

 

t4

 

 

 

 

 

 

t5

 

 

 

 

 

t6

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

p2

 

 

 

 

 

 

 

 

 

p4

 

 

 

 

 

 

p6

 

p8

p9

 

 

 

 

 

 

 

 

p10

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

EOR transition

 

 

 

 

 

 

 

 

 

t7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

In this example the EOR transition is marked with a plus in a circle (at ‘t7’). When run, a token will appear in p1, p3, and p5 in a repeating cycle. The program to set this up is seen below.

int test3() /*

*EOR TEST NET (Peterson book, 1981, discussed pg. 190)

*This is for a single bit shifter

*/

{

static int error;

static struct petri_net net;

static int p1, p2, p3, p4, p5, p6, p7, p8, p9, p10; static int t1, t2, t3, t4, t5, t6, t7;

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”);

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

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

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

page 554

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

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

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

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

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

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

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

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

petri_input(&net, p6, t1, 1); petri_input(&net, p7, t1, 1); petri_input(&net, p2, t2, 1); petri_input(&net, p7, t2, 1); petri_input(&net, p4, t3, 1); petri_input(&net, p7, t3, 1); petri_input(&net, p1, t4, 1); petri_input(&net, p3, t5, 1); petri_input(&net, p5, t6, 1); petri_input(&net, p8, t7, 1); petri_input(&net, p9, t7, 1); petri_input(&net, p10, t7, 1);

petri_output(&net, p1, t1, 1); petri_output(&net, p3, t2, 1); petri_output(&net, p5, t3, 1); petri_output(&net, p2, t4, 1); petri_output(&net, p8, t4, 1); petri_output(&net, p4, t5, 1); petri_output(&net, p9, t5, 1); petri_output(&net, p6, t6, 1); petri_output(&net, p10, t6, 1); petri_output(&net, p7, t7, 1);

petri_type_transition(&net, t7, EOR);

petri_add_tokens(&net, p1, 1);

petri_print(&net);

petri_event(&net, t4); petri_print(&net); petri_event(&net, t7); petri_print(&net); petri_event(&net, t2); petri_print(&net); petri_event(&net, t5); petri_print(&net); petri_event(&net, t7); petri_print(&net); petri_event(&net, t3); petri_print(&net); petri_event(&net, t6); petri_print(&net); petri_event(&net, t7); petri_print(&net);

return error;

}

page 555

20.4.4 Colored Tokens

This section should be considered incorrect. The theory has not been found, although the approach should adhere to the concept. The concept is that each token may now have a color, and a second bit of private information. If a transition is specified to be colored, it will only fire if tokens of the specified color are available at the inputs. The subroutines will then require that the user supply a new set of instance information so that new tokens may be issued.

The net used has tokens of mixed colors in it, an is seen below.

p3

p1

p2

t1

t2

The code is shown below. The reader should note that a second subroutine is used. This is done because there is a bit of code which would be repeated for each update of tokens at the transition.

int test4()

/*

*COLOR TEST NET (Assumed for now)

*Two consumers of different colors and one input. The instances of tokens

*are kept track of.

*/

page 556

{

static int error, i;

static struct petri_net net; static int p1, p2, p3; static int t1, t2;

static int color1 = 1, color2 = 2; static int instance[20], instance_pnt;

error = petri_init(&net);

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

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

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

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

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

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

petri_output(&net, p1, t1, 1); petri_output(&net, p2, t2, 1);

petri_type_transition(&net, t1, COLORED); petri_type_transition(&net, t2, COLORED);

for(i = 0; i < 20; i++) instance[i] = i; instance_pnt = 0;

petri_add_color_token(&net, p1, color1, instance[instance_pnt]); instance_pnt++;

petri_add_color_token(&net, p2, color2, instance[instance_pnt]); instance_pnt++;

petri_add_color_token(&net, p3, color1, instance[instance_pnt]); instance_pnt++;

petri_add_color_token(&net, p3, color2, instance[instance_pnt]); instance_pnt++;

petri_print(&net);

sub4(&net, t2, color1, instance, &instance_pnt); petri_print(&net);

sub4(&net, t1, color1, instance, &instance_pnt); petri_print(&net);

sub4(&net, t1, color1, instance, &instance_pnt); petri_print(&net);

sub4(&net, t2, color2, instance, &instance_pnt);

petri_print(&net);

return error;

}

int sub4(net, transition, color, instance, instance_pnt) struct petri_net *net;

int transition, color, *instance, *instance_pnt;