Petri Net: nnNET2

 

 


printf("I am nnNET2\n");
	
	nnDebug = TRUE;
	
	nnPetriMatrices(&net, 3, 4);
	
	/* map the transitions into progs */
	InitProgs();
	/* FIXME: these should be in a file  */
	net.PetriNet.progs[0] = nnBoot;
	net.PetriNet.progs[1] = nnPartitionI;
	net.PetriNet.progs[2] = nnTeach;
	
	
	/* FIXME: Petri Net should be read from a text file */
	/* TODO: Option should be provided for over the net Petri Net specification */
	
	/* initialize the petri net, only do 1s since we used calloc */
	net.PetriNet.I[0][0] = 1.0;
	net.PetriNet.I[1][1] = 1.0;
	net.PetriNet.I[1][2] = 1.0;
	net.PetriNet.I[2][1] = 1.0;
	net.PetriNet.I[2][3] = 1.0;
	
	net.PetriNet.O[0][1] = 1.0;
	net.PetriNet.O[1][1] = 1.0;
	net.PetriNet.O[2][1] = 1.0;

	
	nnPetriPostProc(&net);
	
	
	/* setup markings */
	array_zero(net.PetriNet.IMarks, net.PetriNet.place_num);
	net.PetriNet.IMarks[0] = 1.0; /* boot, all networking set up at boot */
	nnPetriFire(&net);
	print_array(net.PetriNet.IMarks, net.PetriNet.place_num);
	
	/* redundant firing, just for testing purposes */
	nnPetriFire(&net);
	
	
	/* setup markings */
	
	/* TODO: net.partitionI here... */
	net.PetriNet.IMarks[2] = 1.0; /* Partition */
	nnPetriFire(&net);
	print_array(net.PetriNet.IMarks, net.PetriNet.place_num);
		
	
	
	/* setup markings */
	for ( ; ; )
	{
	net.PetriNet.IMarks[3] = 1.0; /* teach the remote NN! */
	nnPetriFire(&net);
	}
	

 

 

 

This entry was posted in C/C++, Documentation, Software. Bookmark the permalink.

Leave a Reply