[Pntool-developers] SF.net SVN: pntool:[237] codegen/src
Brought to you by:
compaqdrew,
miordache
From: <com...@us...> - 2009-08-23 07:45:20
|
Revision: 237 http://pntool.svn.sourceforge.net/pntool/?rev=237&view=rev Author: compaqdrew Date: 2009-08-23 07:45:14 +0000 (Sun, 23 Aug 2009) Log Message: ----------- better documentation Modified Paths: -------------- codegen/src/codegen.xcodeproj/drew.pbxuser codegen/src/supervisorCompiler.c codegen/src/supervisor_static_include.h Modified: codegen/src/codegen.xcodeproj/drew.pbxuser =================================================================== --- codegen/src/codegen.xcodeproj/drew.pbxuser 2009-08-23 07:44:51 UTC (rev 236) +++ codegen/src/codegen.xcodeproj/drew.pbxuser 2009-08-23 07:45:14 UTC (rev 237) @@ -17,15 +17,15 @@ 3A3A77E70FC891BD00DB2D28 /* petriNetSerializer.c:33 */, 3A3A783D0FC894C600DB2D28 /* supervisorCompler.c:116 */, 3A13FC180FDA5F3C0051F833 /* supervisorCompler.c:176 */, - 3A13FC1E0FDA5F810051F833 /* supervisor_static_include.h:310 */, - 3A13FC220FDA5F970051F833 /* supervisor_static_include.h:303 */, + 3A13FC1E0FDA5F810051F833 /* supervisor_static_include.h:314 */, + 3A13FC220FDA5F970051F833 /* supervisor_static_include.h:307 */, 3A13FC250FDA5FBA0051F833 /* supervisorCompler.c:174 */, - 3A13FC660FDA62D90051F833 /* supervisor_static_include.h:326 */, - 3A13FC680FDA62DA0051F833 /* supervisor_static_include.h:301 */, - 3A13FC750FDA64190051F833 /* supervisor_static_include.h:339 */, - 3A13FC780FDA64220051F833 /* supervisor_static_include.h:332 */, - 3A13FC800FDA64DC0051F833 /* supervisor_static_include.h:341 */, - 3A13FC830FDA66170051F833 /* supervisor_static_include.h:334 */, + 3A13FC660FDA62D90051F833 /* supervisor_static_include.h:330 */, + 3A13FC680FDA62DA0051F833 /* supervisor_static_include.h:305 */, + 3A13FC750FDA64190051F833 /* supervisor_static_include.h:343 */, + 3A13FC780FDA64220051F833 /* supervisor_static_include.h:336 */, + 3A13FC800FDA64DC0051F833 /* supervisor_static_include.h:345 */, + 3A13FC830FDA66170051F833 /* supervisor_static_include.h:338 */, ); codeSenseManager = 3A232C630FB214E900A5C7C2 /* Code sense */; executables = ( @@ -194,7 +194,7 @@ modificationTime = 267922699.957455; state = 2; }; - 3A13FC1E0FDA5F810051F833 /* supervisor_static_include.h:310 */ = { + 3A13FC1E0FDA5F810051F833 /* supervisor_static_include.h:314 */ = { isa = PBXFileBreakpoint; actions = ( ); @@ -206,12 +206,12 @@ functionName = "do_new_contract(char* buffer, int plant, reservation_structure *r)"; hitCount = 0; ignoreCount = 0; - lineNumber = 310; + lineNumber = 314; location = codegen; modificationTime = 267922699.957462; state = 2; }; - 3A13FC220FDA5F970051F833 /* supervisor_static_include.h:303 */ = { + 3A13FC220FDA5F970051F833 /* supervisor_static_include.h:307 */ = { isa = PBXFileBreakpoint; actions = ( ); @@ -222,7 +222,7 @@ fileReference = 3A99A6500FB8E06100B1F47C /* supervisor_static_include.h */; hitCount = 0; ignoreCount = 0; - lineNumber = 303; + lineNumber = 307; location = codegen; modificationTime = 267922699.957612; state = 2; @@ -243,7 +243,7 @@ modificationTime = 267922699.957716; state = 2; }; - 3A13FC660FDA62D90051F833 /* supervisor_static_include.h:326 */ = { + 3A13FC660FDA62D90051F833 /* supervisor_static_include.h:330 */ = { isa = PBXFileBreakpoint; actions = ( ); @@ -255,12 +255,12 @@ functionName = "do_new_contract(char* buffer, int plant, reservation_structure *r)"; hitCount = 0; ignoreCount = 0; - lineNumber = 326; + lineNumber = 330; location = codegen; modificationTime = 267922699.957726; state = 2; }; - 3A13FC680FDA62DA0051F833 /* supervisor_static_include.h:301 */ = { + 3A13FC680FDA62DA0051F833 /* supervisor_static_include.h:305 */ = { isa = PBXFileBreakpoint; actions = ( ); @@ -271,12 +271,12 @@ fileReference = 3A99A6500FB8E06100B1F47C /* supervisor_static_include.h */; hitCount = 0; ignoreCount = 0; - lineNumber = 301; + lineNumber = 305; location = codegen; modificationTime = 267922699.957816; state = 2; }; - 3A13FC750FDA64190051F833 /* supervisor_static_include.h:339 */ = { + 3A13FC750FDA64190051F833 /* supervisor_static_include.h:343 */ = { isa = PBXFileBreakpoint; actions = ( ); @@ -288,12 +288,12 @@ functionName = "do_new_contract(char* buffer, int plant, reservation_structure *r)"; hitCount = 0; ignoreCount = 0; - lineNumber = 339; + lineNumber = 343; location = codegen; modificationTime = 267922699.957918; state = 2; }; - 3A13FC780FDA64220051F833 /* supervisor_static_include.h:332 */ = { + 3A13FC780FDA64220051F833 /* supervisor_static_include.h:336 */ = { isa = PBXFileBreakpoint; actions = ( ); @@ -305,12 +305,12 @@ functionName = "do_new_contract(char* buffer, int plant, reservation_structure *r)"; hitCount = 0; ignoreCount = 0; - lineNumber = 332; + lineNumber = 336; location = codegen; modificationTime = 267922699.958003; state = 2; }; - 3A13FC800FDA64DC0051F833 /* supervisor_static_include.h:341 */ = { + 3A13FC800FDA64DC0051F833 /* supervisor_static_include.h:345 */ = { isa = PBXFileBreakpoint; actions = ( ); @@ -322,12 +322,12 @@ functionName = "do_new_contract(char* buffer, int plant, reservation_structure *r)"; hitCount = 0; ignoreCount = 0; - lineNumber = 341; + lineNumber = 345; location = codegen; modificationTime = 267922699.958088; state = 2; }; - 3A13FC830FDA66170051F833 /* supervisor_static_include.h:334 */ = { + 3A13FC830FDA66170051F833 /* supervisor_static_include.h:338 */ = { isa = PBXFileBreakpoint; actions = ( ); @@ -339,7 +339,7 @@ functionName = "do_new_contract(char* buffer, int plant, reservation_structure *r)"; hitCount = 0; ignoreCount = 0; - lineNumber = 334; + lineNumber = 338; modificationTime = 267922700.446616; state = 0; }; @@ -847,7 +847,7 @@ fRef = 3A99A6500FB8E06100B1F47C /* supervisor_static_include.h */; name = "supervisor_static_include.h: 15"; rLen = 0; - rLoc = 14715; + rLoc = 15456; rType = 0; vrLen = 292; vrLoc = 0; @@ -894,7 +894,7 @@ fRef = 3A99A6500FB8E06100B1F47C /* supervisor_static_include.h */; name = "supervisor_static_include.h: 471"; rLen = 0; - rLoc = 11646; + rLoc = 12387; rType = 0; vrLen = 1036; vrLoc = 6557; @@ -934,7 +934,7 @@ fRef = 3A99A6500FB8E06100B1F47C /* supervisor_static_include.h */; name = "supervisor_static_include.h: 231"; rLen = 0; - rLoc = 5521; + rLoc = 6240; rType = 0; vrLen = 751; vrLoc = 5032; @@ -944,7 +944,7 @@ fRef = 3A99A6500FB8E06100B1F47C /* supervisor_static_include.h */; name = "supervisor_static_include.h: 471"; rLen = 0; - rLoc = 11646; + rLoc = 12387; rType = 0; vrLen = 1036; vrLoc = 6559; @@ -1058,7 +1058,7 @@ fRef = 3A99A6500FB8E06100B1F47C /* supervisor_static_include.h */; name = "supervisor_static_include.h: 471"; rLen = 0; - rLoc = 11646; + rLoc = 12387; rType = 0; vrLen = 1249; vrLoc = 6344; @@ -1266,7 +1266,7 @@ fRef = 3A99A6500FB8E06100B1F47C /* supervisor_static_include.h */; name = "supervisor_static_include.h: 471"; rLen = 0; - rLoc = 11646; + rLoc = 12387; rType = 0; vrLen = 1036; vrLoc = 6557; Modified: codegen/src/supervisorCompiler.c =================================================================== --- codegen/src/supervisorCompiler.c 2009-08-23 07:44:51 UTC (rev 236) +++ codegen/src/supervisorCompiler.c 2009-08-23 07:45:14 UTC (rev 237) @@ -44,16 +44,16 @@ { blockedTransitions[i]=NO; } - for(plant = 0; plant < how_many_plants; plant++) + for(plant = 0; plant < how_many_plants; plant++) //for each plant { pns * petri = prarray[plant]->pn; - for(t = 0; t < petri->tnum; t++) + for(t = 0; t < petri->tnum; t++) //for each plant transition { - for(it = 0; it < supervisorPetrinet->tnum; it++) + for(it = 0; it < supervisorPetrinet->tnum; it++) //for each of our transitions { - if (petri->t[t].l == supervisorPetrinet->t[it].l) + if (petri->t[t].l == supervisorPetrinet->t[it].l) //if our transition has the same label as some plant transition { - blockedTransitions[it]=YES; + blockedTransitions[it]=YES; //block our transition (flag as non-local) } } } Modified: codegen/src/supervisor_static_include.h =================================================================== --- codegen/src/supervisor_static_include.h 2009-08-23 07:44:51 UTC (rev 236) +++ codegen/src/supervisor_static_include.h 2009-08-23 07:45:14 UTC (rev 237) @@ -94,6 +94,7 @@ ///////////////////////////////////////// */ +//informs a plant that it should fire a transition (that it has permission) void send_fire_msg(unique_identify_fire_something *u,int rid,int pipe) { char firemsg[BUFFER_SIZE]; sprintf(firemsg,"___Y%d:%d-%d\n",rid,u->label,u->t); @@ -101,6 +102,7 @@ write(pipe,firemsg,strlen(firemsg)); } +//attempts to fire type unique_identity_fire_something. If it was able to fire, it returns YES, if it was unable to fire, it returns NO char attempt_fire_something(pns* supervisor, int how_many_plants, unique_identify_fire_something *u, int id, int pipe) { int ourt = get_local_transition_by_label(supervisor, u->label); @@ -124,6 +126,8 @@ return NO; } } +//loop through each reservation and attempt to find a firemsg that can be sent. +//If the reservation can be resolved, sends the firemsg and updates the datastructures appropriately void attempt_close_reservation(pns* supervisor, int how_many_plants, reservation *r, int pipe) { int i; @@ -132,8 +136,8 @@ if (attempt_fire_something(supervisor, how_many_plants, &r->u[i], r->id,pipe)) { - r->selected_fire_something = i; - r->sent = 1; + r->selected_fire_something = i; //indicates which element of the reservation we've elected to fire + r->sent = 1; //indicates that we've sent a firemsg and no further communication to the plant is necessary return; } } @@ -141,14 +145,14 @@ void close_reservation_pass(pns* supervisor, int how_many_plants, reservation_structure *r, int pipe) { int p, i; - for(p = 0; p < how_many_plants; p++) + for(p = 0; p < how_many_plants; p++) //for each plant { - for(i = 0; i < HOW_MANY_RESERVATIONS; i++) + for(i = 0; i < HOW_MANY_RESERVATIONS; i++) //for each reservation { reservation *res = get_reservation_by_id(r, p, i); if (res!=NULL) //open reservation { - if (!res->sent) + if (!res->sent) //only attempt to close reservations that have not been sent a firemsg. Duplicate firemsgs cause unexpected plant behavior. { attempt_close_reservation(supervisor, how_many_plants, res, pipe); } @@ -373,7 +377,7 @@ break; } default: - printf("WTF? I've got nothing for you %d\n",buffer[3]); + printf("The supervisor received an unknown control character %d\n",buffer[3]); exit(1); break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |