Download A Graphical Petri Nets Simulator - Rochester Institute of Technology
Transcript
ROCHESTER INSTITUTE OF TECHNOLOGY SCHOOL OF COMPUTER SCIENCE AND TECHNOLOGY A Graphical Petri Nets Simulator by Shye-Chyun Huang A thesis, submitted to The Faculty of the School of Computer Science and Technology, in partial fulfillment of the requirements for the degree of Master of Science in Computer Science ~_0_?_·'h_0_(f~ Approved by : _ Dr. James Heliotis G/2-7 J88 j Prof. Alan Kaminsky '2. y :r~L n ~8 Dr. Peter G. Anderson -1- Title ofThesis : A Graphical Petri Nets Simulator I Shye-Chyun Huang hereby grant permission to the Wallace Memorial Library, of RIT, to reproduce my thesis in whole or in part. Any reproduction will not be for commercial use or profit. Date: July 27,1988 Shye-Chyun Huang Table Title and of Contents 1 Acceptance Page Abstract 2 Computing Review Subject Code 2 1. Introduction and 1.1 Introduction 3 1.2 Basic Petri Nets 4 1.3 Subclass of Petri 1.4 Requirements 8 Nets of Petri a Petri Net Tool 15 2.1 SPECS Project 15 2.2 PSI 16 2.3 Tool Overview 18 20 3.1 NetEditor 21 3.2 Simulator 24 Auxiliary Application Program 24 Program Description 25 4.1 Overview 25 4.2 The System Organization Chart 26 4.3 Data Structure Formates 27 4.4 The Flow Chart of the Shell Program 29 of the Main Function 30 4.6 The Graphics Driver 31 4.7 The User Interface 32 4.8 Hierarchical Process Diagram 33 4.9 The Simulator 52 4.10Function List 54 Conclusion 66 5.1 Problem Encounted 5.2 Limitation 6. Petri Net Tools 21 4.5 The Algorithm 5. and other Function Specification 3.3 4. 14 Previous Work 2.4 Comparisons between GPNS 3. 12 Net Tool 1.5 The Advantages of Using 2. 3 Background of the Lession Learned and Solved System 66 67 68 7. 6.1 Alternative Approaches for Improved System 68 6.2 Suggestion for Future Extension Reference 68 Reference 70 Appendix A Users' Manual Abstract This thesis is nets interactive GPNS it for Petri simulator (PT-nets). It make application GPNS) providing simulator interface an system This nets. simulator to design (Graphical Petri Net menu-driven and graphical window-oriented, allows users is based on and simulate Place/Transition PT-net an under graphical environment. also provides a more useful. in the AAP Whenever a software can an be utility, Auxiliary When applying the AAP attached enabled to a net with the GPNS, transition in the Petri Net is fired than a (AAP), each executed. will In this case, It is Place/Transition net, except that to function corresponding transition in the Petri corresponding function in the AAP to be Predicate/Action Application Program cause closer net. the to a no predicates are attached. This Petri Net Subject to environment. modeling and simulator can some ACM a very good restrictions, it tutorial tool in can be a very an educational useful tool for designing a system. Computing The be following are the Review Subject Codes classification codes for this paper as specified Computing Reviews (1986) Classification System. Primary: 1.3.4 Graphics Package Secondary: F.l.l Computability Theory 1.6.0 Simulation and Modeling General - in the 1. Introduction Real systems are systems will sufficient eventually too can be to be complex fully exhibit an enormous have become serious research and experimentation^]. master Background complexity on only used to models rather Petri Net is a small part and the complexity model and the than the manipulating the to problems, ignoring "understand" real systems or real be and the in and maintenance of the subject of much modeling tool developed system. develop small when examined the majority system, the cost, real system can a Even understood. detail. Therefore, the design, implementation, complex systems focusing and of the by system to This modeling tools a new one. studying the By inconvenience, or danger of avoided. 1.1 Introduction Petri Nets, introduced by Carl Adam Petri in his thesis[13], have simple graphical and excellent the representation, widely ability to structure and elaborated theoretical background, represent synchronous and asynchronous events. the behavior of a system can be described a with the Both same graphical notations[9]. The properties, concept, and techniques of Petri Nets are being developed in a search for natural, simple, and powerful methods for describing and analyzing the flow of information and control in systems. The major use of Petri Nets has been the modeling of systems of events in which it is possible for to occur concurrently, but there are constraints the concurrence, precedence, or frequency of these some events on occurrences[5]. Petri Nets have been systems especially on used as a powerful those systems modeling tool in modeling that may concurrent activities. 3- real exhibit asynchronous and 1.2 Basic Petri Net The Fig. 1 is an example of Petri Nets: Fig.l A basic Petri Net directed instead from arcs. of graph consists of S-elements and From S-element a place to a on, the now and a circles, express a condition changes of some other author's The set of or bipartite, directed Net is map to the "place" from works); the input function / defines, for transition to graph[5]. An be either arcs are Petri Net function, each drawn Therefore, the Petri places, represented as true two sets: are specified transition -4 O, tjt used or not true. Transitions bars in as arrows. contains and be arc can connect either a place. Graphically, which could transitions, T. Two functions /, a respectively. will conditions, and are represented as boxes (or structure of a transitions: "transition" and word T-element, transition T-elements, connected with the the to a set of connect output set of Places, P, the and a places and the function. The input input places for it. The function O defines, for output Formally, a Petri Net C is defined Fig. 2 is the C = each structure of the transition tj, the set of output places the four-tuple C as for it. (P,TJ,0). = Petri Net represented in Fig. 1 (P,T,I,0) P = (Pl> P2, P3, P4, P5, P6, P7J T = {ti,t2,t3,t4, t5,t6} /(ti) = {P2} O(ti) = {pi} Z(t2) = {pi} 0(t2) = {p2,P3} /(t3) = {p3,P5} 0(t3) = {p3} /(t4) = {p4} O(U) = (P5l Z(t5) = {p3,P7} 0(t5) = {p6} /(t6) = {P6l 0(t6) = {P7l Fig. 2 The information In content of both Net has dynamic are used to are called condition transition empty. to the addition model is The enabled enabled place at where Petri Nets if all its input transition and the same can called a time have has be fired a Petri Nets Petri with tokens the corresponding is condition token a Tokens (black dots) on a place means its that not its and all by removing the no more are safe nets. no more which k-bounded enabled without all the graph, by execution. of a system. places could is identical[5]. true. A outputs are enabling token depositing each of its output places with a new token. time. A Petri Net in is from its behavior are constructed such in any be concurrent result is true. Otherwise, the corresponding Petri Nets that by k that Marked Nets. A token residing from its input places same graph and structure static properties represented properties the the net. the than one The definition could than k tokens in any number of be can ever be extended to given place at tokens in any Of course, in this situation, outputs token a place the is bounded transition could being empty. If tokens are used to represent -5- resources, then it follows that destroyed, tokens conservative To if the total reduce considered probability should also resources of number of tokens the complexity any two of in the Petri or more events cannot time factor is fire are neither created nor net Nets, to be instantaneous. Since time is two transitions where a be since nor destroyed. A Petri Net is firing a continuous A created is never changed. the happening simultaneously. neither of a is transition variable, then the simultaneously is zero, special extension of and Petri Nets called a timed Petri Petri Net defines the state of the attached to transitions of tokens in or places is net. The distribution is net and firing of enabled. of them conflict. marking. The marking may changed as a result of In a marking, more than one disable the others, they to be in concurrency. transition are said Fig. 3. a could to be in shows be enabled. conflict. Otherwise, they two transitions that also the output of the transition, then, this transition has a Fig. 3 Fig. 3.b Fig. 3.c Conflicting Concurrent Transitions loop Transitions A transition is dead in can If firing one are in Fig 3.b shows two transitions that are in concurrency. If the input of a transition is that the transitions. In different markings, different transitions may be will are said its called a marked enable a marking if there is no sequence of transition firings it. A transition is potentially firable if there -6 loop. exists some sequence that will enable potentially firable in transitions would be are sequence of to fire. of a all reachable markings. live. A live reflected as it. A transition net is a transitions transition firings deadlock-free which cannot will take the net Petri Net is live if it is A Petri Net is live if net. A deadlock in fire (are to a a all Petri its net not enabled), and no marking that allows them 1.3 Sub-class Many of Petri Net extensions power of modeling Petri Net descriptions gives short One of the resource reaction by to change that allowing needs to one two P and multiple arcs between the remove token from the that three to produce between transitions Petri Nets that Using places and weighted Petri Nets and of a For example, CI2 that This the section a place than one identical consider the chemical two PCI3. This is and may transition[10]. This modeled places, signifying the allow multiple arcs have been an arc with a weighted number transitions is extend Net. constraint firing called weighted Fig. 4.a Generalized Petri Net Both on real systems. might need more another state. Petri Nets[5]. multiple arcs is to systems number of tokens needed. generalized to basic Petri Nets to of various extensions of Petri only is for those added applying it when extensions contribute or receive extension have been called instead of Petri Net. Fig. 4.b Weighted Petri Net generalized Petri Nets have the same properties. A can special extension of fire only when some of Petri Nets is the input so-called zero -testing: a places have no transition token residing on them. The arcs that connect the input places and the transitions are called inhibitor arcs. 1.3.1 State Machines State machines are transition has only basic Petri Nets that input one finite-state. conservative and and one They have output. that are restricted so These are nets each obviously very high decision power, but are of limited usefulness in modeling systems that are not finite[5][7]. 1.3.2 Marked Graphs from Differing the not the dual one algorithms that reachability that show problem for input and so no branch control a marked graph marked graphs. flow, This is live Thus, be can rule eliminates There eliminates conflict. decision power, but have limited modeling have It and one output. of state machines. between transitions the places, but marked graphs restrict machines, to only transitions, marked graphs are places state and safe, Since parallel activities can that sharing are of known the and solve marked graphs power[5][7]. said have high marked graphs be easily modeled, but not alternative activities. 1.3.3 Free Choice Nets In free the place or there is its a choice nets each arc the unique token in unique output a place free a and safeness for free (C/E nets). A C/E choice net the token which of Petri Nets either the unique output of restriction means will remain in that are multiple outputs that if place until for the place, the transitions is fired. The liveness are decidable and have necessary and properties[5]. above are has the is transition. This either to for these described of a a place fires or, if there choice as sufficient conditions nets then transition then there is Those input from generally following called Condition/Events special characterstics. 9- nets 1. A C/E than one token 3. A C/E is loaded net is a safe net can reside 2. A transition in places be net must a C/E in (1-bounded a place at a only be net can with a token and all always a pure net. is identical to its output net). In words, no more time. enabled when each of its outputs are If a transition has place), it other can never be its input unloaded. a loop (its input place enabled. 1.3.4 Place-Transition Nets (PT-nets) A PT-net has the following properties[10]. 1. For every transition, there 2. More than one 3. A transition is number of token may enabled place and output arcs need not be 1.3.5 Place-Coloured Nets In a PT-net, all introduce the each the arcs are colored an labeled same time. input places has weight of transition, but those the an integer arc connected places connected via (PIC-nets) are identical. But, sometimes, it is necessary net for modeling identity. In that indicates its with expressions some real systems. colored PIC - Petri nets, identity, denoting functions or sets (bags) of tokens, initial marking of the than the the output. empty. the tokens a color a place at when each of its notation of token token has in greater to distinguish these tokens in the nets be multiple input and multiple reside only tokens that is between the can which associates initial colors, -10 to every place, a set of given values the firing transition is of a transition hold tokens a set of only if the input possible required by the labels on of a places the arcs from the input place to the transition. 1.3.6 Predicate-Transition Nets (PrT-nets) A PrT-net The net specifies contains a set the relationship between tokens of predicates (inscriptions in the transitions); they tokens that can are when the PrT-net, predicates operations give new an expression of the A PrA-net is one). In associated with fired the relationships apply to the input places of order to output places. enable to it In addition, Action" a safe net( the transition action attached transitions. transition between the input a transition is true. (PrA-nets) form "Predicate be each PrT-net, predicate tokens in must a the names match and 1.3.7 Predicate- Action Nets net the necessary for the transition to fire. In only be fired In give with associated and a must attached that implies the transition in be true, will also when be taken. 11- a the transitions and transition has each to it. weights of all arcs PrA-net, the the enabled in the predicate transition is 1.4. Requirements The "Petri Net of Petri Net tool requirements Tools" by Frits consists of two separate - - The (logical) a layout description. net with net In the the net description in structure, defined structure, values such as positions of net elements and net order graph form by sets, relations, of attributes associated contains additional attributes, necessary to drawing as it was made by the user. to provide a user should contain a rich set of editing add/remove net - net The layout description etc. element, marking, information, construct a mathematical describing etc. Feldbrugge[4]. A is illustrated in net-editor description, and description is functions, graphical a but related data sets: a net of functions to at a graphical net-editor least do the following: elements, reposition net elements, fill in modify and/or friendly interface, net inscriptions (such as capacities, predicates, markings), zoom in/out work at various hierarchical levels, relate net elements on different levels to relationships. provide - copy total net overview, net parts(also between levels), 12- one another and change these The GPNS only implements a simple net-editor without entire overview of the a subset of hierarchical GPNS will be seen 13 the model described net structure and above. It is copy function. The in the later chapter. 1.5 The applying the Petri Net tools By advantagest 14]. results. and The The first computer possible time consuming if done The computer obtain based the net, it process. If the tool the arcs when the user can avoid possible system, of the Finally, making the for errors net, and each of them. by the very up the that the node, would results. A or step to do computer based in modifying some error make the to realign checking, corrected. interactive an net simulator makes a net. Users can it trace the by step, and observe the result immediately. tools may have the process by refine some of This and such as later have to be occurrence sequences net drawing adjustments, by offered the net, moving part of which he advantage of obtains the drawing a complicated big net they force then offered error-prone or the functions is the possibility to computerized of user with precision using Petri Net tools is the copying the speed node or erase in structuring the a small such as provides some automatic designed example, instead of By taking remarkably to demonstrate the behavior user can advantage results. advantage presentation of be better obtain techniques obtain results which could faster moving the A third analysis gain some may by manually. drawing part of the drawing systems provide important second possibility to to user is the possibility to advantage based the on a computer drawing quality. Also, by applying the computer, it is net Petri Net tool advantages of using a the nodes in this net, process results 14 in a assisting the results. the user an to draw by drawing hierarchy of small nets. As a new 2. Previous Work 2.1 SPECS Project A Petri Nets tool graphical Project (SPEcification Swiss paradigm Its purpose is to support use of the the design is and the remain unchanged in of attributes individuals, modified or each level in a tested. The forms to associating time delays on the place for at be integrated into the net editor. user specified attached to in units during to make which a token token when each delay means that a token time then be a colored before it timed Petri Nets. The At any time net carries can remains be fired. simulator the design process, the is net simulated. The following correctness at - used as S-elements objects can This feature is much like a net applying functions to be defined by the be of large part, to describe the the Conditions may be Such a to subnets; of states of can a given number of nets can be The the basis on Every token in the Instead mechanism also can Therefore, SPECS can connected object. tokens used. with places. least allows users be objects. of the form is to be PIC-net. A timestamp of distributed systems. pointing device. To of abstraction. like any Smalltalk messages are sent of particular It can a simulation more understandable. token implemented in the facility prototyping self explanatory. only T-elements list extended with an object-oriented mouse as a hierarchically, but a some high-level Petri Nets interface has been implemented menus and editor by environment on a powerful graphical workstation. net editor's user windows, pop-up SPECS- in the and was supported on self-modified hierarchical structuring a Smalltalk programming The is based set Predicate/Transition-nets), and accomplished Concurrent System)[9], This tool companies. (similar to the of has been set any time Variables Tokens syntax are is checked by the tool. It guarantees syntactical during the design process. identifiers. are represented by the list of their attributes. -15- Predicate inscriptions - lower case marking, letter), which consist of: an optional name delay an optional is a (possibly delay or (beginning interval , and with a the initial empty) sequence of tokens with constant attributes. Connector inscriptions attributes of The latter the token may be can be also in the The simulator transitions be and all removed inscriptions do set are set randomly. from the set. More details set. firable. The If the transition is If the transition is of this Variables appearing potentially firable transition not objects. have to be declared. the transitions that might become firable into the Smalltalk program. programs. not token. The single variables or constant Smalltalk maintains a in this not transition in the will connector are of one by any Smalltalk represented Transition inscriptions - descriptions are simulator will not firable, after firable, set. All pick one the transition the transition is fired this firing will be added tool are described in [9]. 2.2 PSI A Petri Net based PSI is developed CP/M[4]. The memory the on a code of simulator Z80-based the microcomputer under simulator maximum size of for flexible manufacturing is written the Petri net boolean variables, 50 integers. Since it microcomputer, a new version is under systems called the operating system in PASCAL. With 64K bytes of is 150 places, 150 transitions, 50 works very slowly development on on 16-bit an and 8-bit 32-bit machines. This simulator does necessary information is timed Petri Net not offer a graphical acquired by using combined with a colored list net is the new version will eliminate not allowed and no an interface for users; be on Hierarchically describing associated with these limitations[12]. 16- the input language. It is based Petri Net. of attributes can all tokens, but There information Net Tools" are more about [4] and Petri Net tools available or under the tools that are currently available can "Petri Net Tool Overview 1986"[15]. -17- development. More be found in "Petri 2.3 Tool Overview The following table Tool edit Net Type ana simu or lysis lation existing Petri Net tools. Computer/OS DAIMI hi-level a/n yes no DEMON stoch. gr yes yes DESIGN any gr no no Macintosh GALILEO timed gr yes yes VAXA/MS GreatSPN timed/stoch. gr yes yes SUN 3 /UNIX 4.2 ISAC-GR. C/A gr no no IBM PC/MSDOS CADMUS/MUNIX MARS timed a/g no yes IBM360/370 ESER NECON PrfT gr. yes no IBM 4381 /VM-SP gr. no yes (micro) VAXA/MS 1MB PC/MSDOS HP9836 NET Pr/T + timed VAXA/MSPDPl0/tops10 SUN3/UNIX4.2 IBM370/MVS-XAorVM NET-LAB PfT gr- yes yes OVIDE P/T a/n yes no PN. Mach PrfT a/n yes yes IBM PC/MSDOS P. Pote PfT gr. no yes ICL.PERQ/POS PROTEAN PrfT gr. yes yes VAXA/MS ROPS stoch. a/n yes no VAXA/MS SERPE PrfT a/g yes yes VAXA/MS SIBUN timed a/n no yes any Simula SPAN stoch. gr. yes yes SUN2/120 a/n yes no (micro) VAXA/MS TEBE a/n gives an overview of some = stoch. safe alphanumerical = P/T gr. = graphical a/g stochastic 18 = IBM/OSA/S-VMS mixture of both + ICLPERQ system Tool edit Net Type ana simu or lysis lation Computer/OS CACAPO C/E a/n yes no FUN stoch. a/g yes yes VM GACOT timed a/g yes yes DEC-VAX, UNIXA/MS GASP PfT a/n yes no DEC-VAX, SUN GTPN timed a/n yes no DEC-VAX-780/750, Simemen BS UNIXA/AX 2000, 370 BSD 4.2 ITI/OPA hi-level a/n no no TYMNET Engine, ISIS,TYMCOM-10 PES PfT a/n yes no Simemen 7xxx, BS 2000 PeSys C/E, PfT, a/n yes yes PCS Cadmus, 9230V MUNIX timed TOPAS-N PrfT a/n no yes DEC-VAX, VMS SPECS timed, PrfT a/g yes yes SUN, Smalltalk timed, a/n no yes CPM,PC PSI colored a/n = stoch. alphanumerical gr. = = graphical a/g = mixture of both stochastic analysis : such as produce a reduced net of the same classes. simulator : such as playing the token game on 19- the screen. 2.4 Comparisons between GPNS There and other many Petri Net tools, are simulators and analytical abilities. the and Petri Net Tools they have It is very diffuclt to GPNS has a graphical GPNS is with function easier fancy a to copy applying the designed erasing automatic system mode, the in the hierarchical net of automatic is that it higher priority to be fired automatic mode weight of the by GPNS. result of a special can observe allows when it is mode. the the By firing result when The outstanding user enabled to decide which by specifing the transition. Safe-net, K-bounded simulated user interactive pratical environment. transition has a the user can observe the net, Weighted net, Each place in the and net can Place/Transitions be either safe or nets can bounded so whole net. The the editing a place/transition should gain provides automatic and characteristic of other a poor to those for GPNS. By using the probability compared editor, GPNS seems has or moving using the interactive mode, the sequence. friendly. But, function. However, the capability For the simulator, GPNS is the with without a graphical net a one-screen net editor without subnet adjustment of arcs when some credits use and more user graphical net It has only set. structure and be GPNS compare interface, menu driven net editor with some very basic editing functions. Compared to those tools tools editors, tools. other editor, offered various exciting feature most tools is that it has Auxiliary a utility of GPNS that makes which can expand Application Program (AAP). The function templates simulation of the generated by GPNS designed Petri Net. 20 the it different from the power of user can the simulator modify the AAP to do many kinds of analysis or 3. Functional Specification The GPNS is graphical net for Petri Net a software package editor, a simulator and a simulation. It provides a tool, the Auxiliary Application Program(AAP). The GPNS has been implemented on the basis of a graphical interface, pop-up menus and with mouse as a pointing device. It can be used to simulate can be Place / Transition either k-bounded, nets. Depending on the user's both. The AAP is weighted or application, the net an optional tool for enhancing the analyzing ability of GPNS. This section GPNS's functions MANUAL in the is an overview of and how to GPNS. To GPNS, use the get a more user should refer clear idea of to the USER'S appendix. 3.1 Net Editor The net editor allows Because it is at most 30 and a one-screen net places and Most of user to editor, the Petri Net is limited to GPNS and Erase, user can change represents mouse the screen. a small size of is mouse used as the input device to draw the net will be used to input the text by GPNS. provides seven Arcs, Token on 30 transitions. the time, the required Petri Net construct a issue the commands; Occasionally, keyboard information The the the editing to let the current the desired editing to specify the location modes Select, Text, Place, Transition, user construct a editing mode on - the mode in the by Petri Net selecting the panel. Then, user area where the on the screen. symbol which user uses the the function is to be performed. Select select a graphic user can move icon to be the currently it or set its properties. -21 active icon, so the Text put a piece of text on Place draw a place on Transition draw a Arcs draw an arc Token set the token transition, Erase delete By switching between the screen. The Then, user the list highlighting under seven the under each menu FILE- EDIT menu icon from the working are as by of a selecting the clicking the draw a Petri Net on of the Petri one of the five EXIT from the Then, area. user can the behavior and title. command and title transition. place, probability weight editing modes, commands the area. or weight of an arc. user can simulate issues area. the working count of a a graphic these on area. connect a place and a FILE, EDIT, EXEC, OPTION command the working transition to the working issue user can mouse menu net. menu titles bar to get a a command button. The - by commands listed. Open retrieve an Save save Clear clear Properties set the the the existing file. network into a file. screen and start a new session. properties of a place, transition or arc. Move move a place or a transition to a new location. EXEC - Automatic simulate the Petri Net in a free-running mode. Interactive simulate -22 the Petri Net in a step mode. Prog Generate the generate sourde code templates log file firings of the AAP. OPTION- Log generate a of during simulation. the token limit for the K-bounded set Speed change the speed of places. the automatic simulation. Run AAP execute the AAP while simulating the Petri Net. EXIT All exit commands offered "QUIT" which is used by GPNS can to stop the from the GPNS. be found simulation during the simulation session. 23 on the only menu bar. A appears on the command menu bar 3.2 Simulator The simulator design process, the two modes : is integrated into the net can interactive be decide and marking. The simulation can be during the in executed and automatic. In the interactive mode, the step The simulated. At any time net editor. transition which enabled through the user can go should simulation be fired in the step by current firing sequence of transitions in this user can examine a special mode. When simulating in the enabled way the transition form the until it reaches a user can choose speed to 3.3 fast order to make fires it, by the to let the simulator run user. and continues In the or stopped the GPNS more Auxiliary Application Program GPNS in this automatic quickly, corresponding transition link AAP functions to be with powerful, GPNS has (AAP). or mode, the slow AAP, on written by an additional templates for user, can be user executed when and simulate to modify. attached the Petri Net. After modifying the the GPNS tool By issuing the Prog Generate will generate program Each function in the are and a Auxiliary Application Program command, the can speed marking picks allow easier observ action of the process. In called current deadlock mode, GPNS randomly automatic AAP, the Petri Net to to the the cause user AAP the corresponding transitions in the Petri Net fired. The AAP is application system's value purposes, work, and to GPNS continue such as: the GPNS. The debugging user can use the Petri AAP for many Net, simulating analyzing the Petri Net. Each AAP function after GPNS to hold the decide to an extension of it was executed. simulation and the A display simulation or must return a non-zero return value will cause a message stop the 24 a real box. The simulation to check user can then the program. 4. PROGRAM DESCRIPTION 4.1 Overview The Simulator, Program-generator editor, with sets the graphics primitives that up the users user to draw the graphics graphics net a net. interacts and linked with GPNS, program. and The Driver deals in the Net-editor. The Net-editor offers handles simulator then the Net-editor to The Program-generator was Shell all functions that the data derives the information it with users can - the screen, the screen, simulator (AAP) templates that AAP on layout description. The the Petri Net screen. The on and a were used interface (desktop) Petri Net Netby five components Driver, is made up program of this project creates modify each display Auxiliary and link structures of needed simulates will cause the results on procedures. msicon.h, six with Those header files setup. graphics. c, h, and are : system.h. files, 14 attached program program sgp.c, maputil.c, rectutil.c, menu.c, segment.c, sim.c, form.c, generator.c, apply -25- .c, firing to a of a executed. files consdef.h, structdef.h, The 14 the the GPNS. After the function in the AAP is header of Application Programs the corresponding AAP function to be The Project includes from the the behavior corresponding transition in the Petri Net. While simulating, the transition allow files with 162 iconfont.h, are: objects. c, and applydo.c. main.c, action. c, 4.2. The System Organization Chart USER Program Generator SIMULATOR Auxiliary Application Program 1 Petri Net Simulator System Organizational Chart -26 4.3. Data Structure Format The following formats that are structure used are int Short Pixel short x, short y; pixel y: that points int structure to the # of unsigned short of width /* the # of unsigned short of height to used y specify the y specify the bitmap memory */ point pixel pixel to the address save # # of a the first the */ */ of width of heigh */ */ short of an arbitrary size pattern of a rectangular bitmap. height in shorts. rectangle's width and rectangle's width and height in pixels. type RECT_T left, up, right, bottom; This data size /* the /* the y /* the /* the y x coordinator of upper-left corner coordinator of upper-left corner the */ coordinator of right-bottom corner right-bottom corner of of rectangular */ x coordinator of right-bottom corner structure specifies a rectangle region upper-left corner and specify the important data /* /* This array is x and pixel /* /* x, x and short structure of some project. *map; pixel a pointer of shorts. Net-editor and type MAP_T int array Driver descriptions in the unsigned short map is of bitmaps and by two points the rectangle. It is the exact position and SEG_ T int type; /* specify the icon type */ int id; /* the int token; /* token # / probability int cap; char /* *text; struct SEG_P * from, *to; RECT_T * bbox; identify # of entry */ capacity of the place wt. / wt. */ */ /* text string or /* the input icon /* the output /* the boundry box of the icon */ 27- name of the of the arc icon entry */ */ of the arc */ */ the used boundary box of icons. ture type */ to the * RECT_T SEG_P struct Type indicates and TEXT. Id is place and is token of used after count and weight capacity of the place internal name of /* *next; the if the type is ARCS, It is type. It is the PLACE not used and icon. Bbox is the and output of next to are only the icon on not used other and used used by established. next structure. 28 It is used and out matrixes. weight to store by Token if the type is in TEXT type. type. Text used Cap is the to store the the text string for the ARCS type to indicate the boundary box the working */ entry be: PLACE, TRANS, ARCS in the in in the TRANS input icon location could to if the type is PLACE, probability and exact pointer position icon */ exact position of the information is matrix the TEXT type. From the the the icon is. It transition to indicate the used as TRANS type what /* pos; area. of the icon. Pos Next is the specifies pointer to the 4.4. The Flow Chart of the Shell Program If No One parameter one paremeter - file parameter Find gptns ///e.rnak file fi/e.cand file do. c files compile executable file Link with gptn.o file END Shell Program's Flow Chart 29- 4.5. The Algorithm while of the Main Function (not done) { read mouse location; if (located in panel) set else else the selecting editing if (located in user mode as current editing mode; working area) taking the action according the if (located in menu bar) current editing mode; display the corresponding menu; get the command; if ((command done= = = EXIT) && confirmed) true; else carry out the command; } 30- 4.6. The Graphical Driver The the core of graphical driver Graphical Package(SGP)[6]. It dimensional objects application program order The SGP is divided into 1. Graphic on 2. the to six user to twopictures of display actions distinct classes found in the Simple concepts from the establish user-computer user to the interaction. : the functions that output primitives result in CPU to display view surface. the functions that determine the line Attribute-setting subsequent 3. Segment lines and into of Viewing (the Functions segments, which was produced operation style of color of all subsequent output primitives. segments display program). the visibility the the functions that group control primitives 4. the allows the transmits input and in uses logically related output the units of selective modification of are available and to delete, rename, to translate the image or change the on screen by a segment. the two functions that together specify to the - package what part of the world coordinate system to display on what portion of the screen. 5. Input the functions that - control user interaction with the application program. 6. Control tables - the INITIALIZE function helps the and the graphics status and mode initializes the default viewport (the entire screen). screen and closes out The details of the SGP Graphics[6], This class is values can project the for the window package initialize its flags / registers; it (the unit device to provide and be found in Fundamentals only developed omitted. -31 of also square) and the The TERMINATE function graphics own clears orderly the exit. Interactive Computer a one screen net editor, so the fourth The User Interface 4.7. The Data Structure The user includes: The desktop, desktop working The one a interface is is a desktop for the four is the User Interface forms, by up bitmaps are constituted viewing surface by by a menu bar, a panel, an user lines. three memory for the panel and one pointing device (mouse). messages and a window constituted message made design. It a window-orinted and menu-driven style menus, bitmap area and of objects (screen). Those user bitmaps, working (icons) that one area. for the by bar, Those three memory are refreshed objects are created menu (mapped) to the using the functions of SGP. The menus, formes The details MANUAL - of and messages are utilities how to menu(3T), use these tools can that be found in form(3T) and Messages(3T) -32- offered by UNIX UNIX PC. USERS' main.c menu.c objects.c form.c action. c segment.c maputil.c rectutil.c sgp.c graphics.c Hierarchical Process Diagram 0 33 4.8 Hierarchical Process Diagram Main desktop create read mouse read seg loc in rect ~2 take action ~9 menu select panel select T highlight msgs initialize I X winit wcreate X X keypad newview curs off terminate close ? wexit ioctl The bold rectangle represents a hierarchical function call. The number below the function name is the diagram number where you can find the details of the function. This type of the rectangle represents an elementary function call. Hierarchical Process Diagram 1 34 created esktop I font select init set userarea set panel map to frame del menubar map select map set crt rect map hline text draw panel icon set set token set ~"3 trans 1 Hierarchical Process Diagram 2 -35 set place 3 set init select map select map frame map menu I file_menu edit_menu exec_menu 4 4 4 fill rect rect paint map map clear_map map select ~F I paint color token select map set trans set set init fill set map 1 init place T option 1_menu option2_menu message disp menu Hierarchical Process Diagram 3 36 file | disp menu form save I menu read work clear message seg "6 form open screen empty select write_all_seg new_all_seg 7 map 7 | edit X | menu I I message erase in icon bound set rect draw hilit text icon "6" I I X draw msgs offset related rect read mouse erase Ti form prop clear T X I X disp work draw menu all draw seg icon 7 6 exec menu i msgs I icon hilit manualsim autosim 8 8 "6 I save related Ti form write all l translate seg "~ 8 7 Hierarchical Process Diagram 4 37 prog generator 8 draw icon X draw draw trans X drasw draw draw arrow I select map map angle rotate I X 2 abs line abs 2 draw shift line I X to crt del map erase erase weight arc get map text I draw ratio line X move draw arc I draw token draw init I X draw place place erase trans icon erase arc erase text Hierarchical Process Diagram 5 38- draw weight hilit icon I hilit hilit place init open form save form hilit trans map map form bound hilit arc crt del form prop to text 1 disp text map form I form trimming form Hierarchical Process Diagram 6 -39 add inst mst seg seg rect set sel bbox add entity seg I sel entity I loc write write all seg seg in new new rect all near del seg del seg by seg entity Hierarchical Process Diagram 7 40 draw all seg draw seg draw icon generator prog pheader pdecl pbody ptail psetup pfhead pfunc pmake 1 manual hilit select icon H disp manualsim quit autosim translate T fire random find select enable X dofunction* X de H initialize* up* set X hilit del list erase quit message terminate* translate find find rel hilit loc in enable icon add active rect dummy function in AAP template Hierarchical Process Diagram 8 -41- enabled take action rrZTTTT H-EXt"1 H^LACe"1 ^RANS1 'SELECT1 II II irrxzri ARCS II 'TOKEN1 select1 sel 1 u pdate seg II II hilit TEXT add H^l" "ce"1 1 in bound message add seg add seg Tr" "ns1 l__ 1 in bound A case message in take action function Hierarchical Process Diagram 9 -42 seg ERASE1 n^Rcs"1 sel hilit seg icon message I read msgs mouse I drawn get angle I connecting get_c_point I add overlap seg get_r_point X 1 inter getcode inter x y overlap icon erase 1 1 angle get set split get_r_point rotate 1 rect set 1 1 get_c_point 1 | bbox draw icon Hierarchical Process Diagram 10 -43- shift ^token" I hilit I icon message sel "6 X erase token erase seg draw token T I X draw ratio ratio erase draw icon icon erase_weight X draw_weight Irase"1 I erase I del icon delete seg related clear draw_all_seg work T del draw X connecting 7 erase seg arc related erase related X set rect erase X set bbox I overlap Hierarchical Process Diagram 11 44- arc The linked lists (segment). The linked list They have "phead" contains descriptions of all If a icon is and added deleted, the icon is into the to a new When the Save the a file content of manipulated The structure was contains drawn format descriptions "thead" contains (icon) graphics net are the SEG T. of all the - graphical net contains the descriptions on four "ahead" the of text. the working area, an entity the linked lists according to the icon's type. If the corresponding entity in the linked list is moved to the graphical net "chead" one of corresponding entity is written the graphics symbol the icon is data same of the transitions in the Petri Net. The descriptions of arcs file, the in the Petri Net. The linked list places is to represent the layout structures used location on an also removed. the working area, the contents of of If the updated. command is issued, the ".ptn" with a extension. the file is in the GPNS retrieved contents of the four linked lists When opening ".ptn" an existing to form four linked lists that session. following are some scenarios of how GPNS doing its job. 45 will be Adding a place Starting Conditions : The current circle when Event editing located in the user clicks Response The user working mode. The cursor is shaped like a area. the mouse and finds out it is in the user user actionO tests the editing mode and actionO calls in Take working area. area, then take Add boundedO to Assume the the = location. It tests working area, it so calls default capacity text = default place = to = is totally inside the is totally inside the the user working of a SEG T structure. It fills in the place, of -1, name "placeioP, NULL (not used by places, only by arcs), boundary rectangle of the place icon based on the current position. = a rectangle created rectangle Then circle seg(). instance sequence number of the = bbox if the mode. follows: cap = check find it is PLACE default token count of 0, token form circle action calls add segO creates a new structure as list area. working action(). The take pos user mouseO to get the current mouse main() calls read take button in the : that location to is PLACE : The id mode add 2 pixels larger in all dimensions than the (used for detecting selection of this icon). seg() adds the newly-created structure to of places. Then add newly- the plist, the linked segO refreshes the screen, causing the new place appear. 46- Erasing a place Starting Conditions: The current pistol when Event editing mode located in user is ERASE mode. The cursor is shaped like a working area. : The user clicks Response The the on one of the places of the net. : main() calls read that location take button mouse and mouseO to get the current mouse finds out it is in the user location. It tests working area, so it calls action(). The take actionO tests the current editing mode and finds it is ERASE mode. Take actionO calls sel segO to decide which instance in the plist is to be deleted. Take actionO calls the selected place from alist delete relateO to delete all the arcs related to the (the linked list of arcs). icon() to delete the instance from the Take actionO calls erase Take actionO refresh the screen, causing the selected place and related arcs disappear. -47- plist. its Moving a place Starting Conditions: The the Event is cursor cursor shaped to select like a finger in the The a place. user selected place working area. is highlighted. The user uses . : The user presses Response The issues down the menu() calls edit command new cursor mouse mouse hilit icon() user edit working and erase working the user area. location (The two button down then icon() to make the selected area. mouseO, changing the option move to the desired location a to get the mouseO calls require the user to read to mouse cursor mouseO with MSUP menu() calls read user releases edit the on Edit menu() calls read the current mouse cursor's shape push and release the button now) rect() to update the contents of pos and bbox location. mouseO with MSOUT option to change the back. menu() calls erase that mouse menu() calls set based arcs user Then, menu. button). (the Edit from the EDIT button in the menu() calls read Then circle. The mouse disappear from the Then the Move : edit place a are related to the relatedO and moved draw place, from 48 old relatedO to adjust all the location to new location. Adding an arc Starting Conditions : There current editing it is in the Event transitions existing are places and user mode is ARCS. The the on cursor is user shaped working like a area. The big arrow when area. working : The user clicks Response mouse button icons of the on one of the net. : The main() and location. It tests mouseO to get the current mouse calls read that location take the finds out it is in the user working area, it so calls actionO. The take actionO tests the current editing mode and find it is ARCS mode. The take based actionO calls the sel location. (The on current mouse icon another of segO to the net) The take out an error message and abandon icons is not two instance if actionO either of they have the check second selected overlaps with the selected of SEG the take new arcs action or to icon() (take if the button will print the two same on mouseO and selected type). arc connected from the icon is already drawn. Assume it is actionO calls connectingO to calculate the exact points of the update mouse selected yet. The take Then, drawn() the actionO calls read the TRANS type, icon to the selected drawn new or actionO calls the The take first PLACE icon is first which user clicks segO again to get the second selected sel not decide T icons, draws an structure action calls the new one. alist calls add if there is a existing If overlap does occur, overlapO the two selected segO to add a (linked list of arcs). overlapO to check structure contains of between the two into arc, then connecting calls arc that split() to overlapped arcs and redraw two icons without overlapping each other. 49 Automatic simulation Starting Conditions : The Event user has drawn user issues Automatic command from EXEC a Petri net on the user working area. : The Response : The autosimO menu disp calls calls matrices (the formate The autosimO current Then and that translateO to calls find marking random of the first to display the QUIT related menu on the matrices find is called the to a net layout information to two is described in the out all the linked list enabled - select an enabled selected next section). transitions in list. active transition randomly transition (update token counts of the to the fired transition). The autosimO then above steps until a and calls del deadlock Then the autosimO bar two the link them into and selectO convert enableO to fireO is called to fire menu quit() bar. Then it the menu. list() occures or calls erase terminate the to the the issues a QUIT command. user quit() to erase simulation. 50 list destory active the QUIT and repeat menu from the Reading a file Starting Conditions : User working Event area is : The user Respone issues menu() empty, it then strcatO first read from the FILE menu. add first instance into the For the opens area name and calls add tlist, find three segO to read the is empty. from the If it is user and use read types, only mode, then linked list. It alist and clist. rel() to find menu() close the reads starts segO file. 51- four linked lists When the out which pointer and read data from the file. to read segO to add the new created structure NULL. Then the file working to get the file the file in fills in the from other user extension. appropriate plist, segO calls arc and form() menu() calls read segO sequence if the checks ".ptn" the data from the file read command calls open function to Then the file The Open an : The file the empty. to mode two icons pointer just fill by the is ARCS, the were connected in SEG pointers from T by structure. and to with 4.9 The Simulator The Data Structure The structure of the [OHO] Not used of in phead the Simulator and out matrix is as fig. 2. CXX>I' t t t Fig. 2 52- The in first row of first column the matrix points of the from place./ will point to the If arc. to ahead connected to the entity of For each row number pointed to linked list After the the arc token numbers selected i (i > 0), element of the Each Net; then, the which contains ahead an pointer is arc in[i][/] the information out[i][/] linked list. Otherwise, the it to the comes user to for enabled transitions in all non-null than the in[i][/], if enabled. GPNS a the arc weight pointed by in[i][0] is transition (selected time to by the in to goes user or selected and out matrices randomly to update by the to the fired transition. interactive automatic mode selects an enabled mode requires and the following this algorithm. of the places connected when out all greater pointed automatic mode and that in to find GPNS) is fired, GPNS goes through both except the from transi to place/, then, the by in[0][/] is then the transition through every transition The phead. element of entity in the thead. If an to transi in the Petri matrices are used certain marking. by in[i][/], entity in the an type. Each be null. These two token is an arc pointer will point out[i][;]will and entity in the an to same structure matrix points connected of the and out matrix share mode use select an enabled the same transition randomly, but the select one. 53 algorithm, transition to fire, the interactive Function List action.c int in boundO Return true if the icon is totally inside the boundary of the user working area. int drawn() Return true if the selected void icons is already drawn. Erase the existing split() between the two arc separated arcs arc and draw two between the two connected icons. int Return true if the overlapO existed one. void delete relatedO Erase the arc if overlapped, related arcs of split the delete the icon entity from into two erased erase relatedO Erase the related arcs of the moved void draw relatedO Draw the related arcs of void update hilit() the arcs entities Highlight the the arcs. icon and icon. moved in the current an segment. void update with overlaps icon and segment. selected icon and dehighlight the previously selected icon. void take actionO Edit the Petri Net according to the editing mode and update segments. -54 the current contents of the form.c int disp form() Display a form on the from the int bound int open form() form() screen and get the data user. Update the k-bounding value. Open an existing Petri Net file in current directory. int save form() Get filename from the user, to a graphic int prop int trimmingO form() text form() will be the saved. Update the icon's properties. Trim a string. char* description which string from the first blank in the Return true if string is trimmed. Get the text string to be displayed. 55 genera tor.c "file.h" void pheader() Print out header file void pdecl() Print out the declaration void psetupO Print out purpose function a is to update "filedo.c" section of called the "setup". Its value of the place variables. id pheadO Print out "dofunction" in the "dofunction" in the "dofunction.c" in the the head of the body of the "filedo.c" id pbodyO Print out the "filedo.c" id Print ptailO out the tail of the "filedo.c" id pfunc() Print out the file id pmakeO Print out a :"file.c" description file for make with extension name".mak" void prog generatorO command. Generate four files that to be linked gptn.o -56- with graphics.c int newviewO Open a graphics window. void write Turn a pixel on or off. void read void highlightO Highlight a rectangle region. void curs off() Turn the cursor off. void curs on() Turn the cursor on. void msgs() pixelO pixelO Return true if the Display messages the void initializeO terminateO is on. the bottom four lines at on screen. Set the terminal into the default void specified pixel graphics mode and set values. Terminate the graphics mode and return to text mode. void set mouseO Enable the enabled, it sends the void read void select mouseO font() Once the mouse. reports mouse to terminal is when specified event occurrs. Read the mouse report Select the character from the terminal. font to be used editor. void gentextO Draw a character on void text() Draw a text string 57- the on screen. the screen. in the net mam.c Set all icons used in the void set icon() void set menu void set panel() void draw void set void createdcesktopO Display the whole desktop on the screen. void menu Select one void hilit bar() panelO userareaO selectO panicon() Display the menu bar on the screen. Display the panel frame on the screen. Display the symbols of the panel. Display the frame of the user working area. panel void main() selectO of the menu Highlight the panel and void net editor. Set the selected panel menu icon Main function editing mode. of the project. bar. on display on-line help message. current -58- titles from the maputil. c MAP_T* init map() Allocate Select a memory space bitmap to be for a bitmap. void select void clear map() Set all the bits of the bitmap to 0. void paint map() Set all the bits of the bitmap to 1. void del void map void clear map() map() to crt() work() a Free the allocated active. memory of the bitmap. Map the bitmap contents to screen. Clear the user working area. menu.c int empty int disp screen() menu() Return true if nothing is the void file menu() the Display on menu and get the working the selection area. from user. Open, save or clear a graphics description file. void edit void exec menu() menu() Move an new void option 1 cap() menu() Update the capacity Set the optiion2 menu() Set the 59 properties. or automatic mode, or menu is of all places. options of simulating. when no This AAP is linked options of simulating. only displayed GPNS. its AAP. displayed void or update Simulate in interactive generate void icon when an with This GPNS. menu AAP is linked is with objects.c Display "QUIT" Remove "QUIT" void disp void erase void set void draw placeO Draw void erase placeO Erase the void hilit void set quitO quit() placeO placeO transO menu. menu. Create the bitmaps for place manipulations. a place on area. selected place. Highlight the Create the working selected place. for bitmaps the transition manipulations. void draw transO Draws void erase transO Erase the void hilit double get_angle() transO a transition selected Highlight the Get the angle on the working area. transition. selected transition. between the drawn line and the horizontal line. void rotateO Rotate the void shiftO Shift the coordinates void draw line() Create bitmap and draw a solid line on it. void draw arrowO Draw a a coordinates arrow indicate the Draw on by an angle. by a distance. the end of the line to flowing direction of the token. directed line to void draw void get void inter_y() Calculate the y-intercept. void inter Calculate the x-intercept. void get c point() Get the actual connect point of circle. void get r point() Get the actual connect point of rectangle. arc() code() x() a Get the represent an arc. outcode of a point 60- to a rectangle. (continued) objects.c void connectingO Calculate the four two void erase void hilit void set arc() arc() token() points to be connected arcs. Erase the selected arc. Highlight the Set the selected arc. bitmap for token, prob. wt. and arc wt. manipulations. void draw token() Display the token number of the place. void erase token() Erase the token void draw ratio() Display the probability wt. of a transition. void erase ratio() Erase the probability void draw weightO Display the weight of an arc. void erase weightO Erase the void draw text() Display a piece of text on working area. void erase text() Erase the void hilit__text() Highlight the void draw icon() Draw an icon. void erase icon() Erase an icon. void hilit icon() by number of the place. transition. weight of an arc. selected text. selected Highlight an icon. 61 wt. of a text. rectutil.c int loc in rect() Return true if the location is inside the rectangle. int equal rect() Return true if the two rectangles are identical. RECT_T* RECT_T* set copy rect() rectO Set a rectangle region and return a pointer. Create a new rectangle the same as one. RECT_T* RECT T* set inst bbox() rect() Set the boundary box region. Instantiate -62- a rectangle region. the old segment.c char* char* strsaveO Save a string somewhere. read Read a text string from stringO a file. SEG_T* inst seg() Instance void add entityO Add an entity into a segment. add_seg() Add an entity into one of the segments. int del entityO Delete an entity from a segment. void del seg() Delete an entity from one of the segments. int near SEG_T* of a segment entity. Return true if the distance between the by() location and distance(15 SEG_ SEG_ rp# rp* the line is smaller than pixels) sel entityO Select an entity from a segment. sel segO Select an entity from one of the segments. void draw seg() void draw all void read void write segO void write all void new segO void new all segO Draw the contents of a segment. Draw the contents of all segments. Draw the data from segO seg() segO a file into segments. Write the contents of a segment Write the contents of all segments into a file. into Free the memory space of a segment. Free the memory space of all segments. -63 a a file. sgp.c void set void set_fill() void set void move abs void move rel Set the colorO color mode Set the fill mode line() - BLACK FILL - or Set the line mode SOLID - 2() 2() Move the or WHITE. NOFILL. or DASH. pen position. Move the pen position relative to current the pixel. position. void point abs void point rel 2() 2() Move the pen position and Move the pen position and position turn hline() Draw a void vline() Draw a vertical void drawlineO Draw a void line Draw a 2() the on relative to current pixel. horizontal line. void abs on turn line. line. line from pen position to a specified pen position to a specified position. void line abs 2() Draw a line from relative position. frame. Draw a rectangle Draw a rectangle and void frame void fill_rect() void circle fillO Draw four lines to fill void circle point() Draw eight symmetrical points. void circleO Draw a circle rect() 64 - fill fill the region. a circle. or not fill. sim.c void void redraw init placeO mat() Redraw all places for updating the token number after an enabled transition Initialize the of contents two is fired. matrixes to NULL. LIST_T* inst list() Instantiate void add activeO Add void del_list() Free the memory void de_hilit() Dehighlight all the highlighted transitions. void delayO Delay a small amount of time. int enabledO Return true if the transition is int find Find enabledO print log() Print all the void fireO Fire the void translateO Translate random int get_quit() selectO linked list. linked list. space of active enabled the internal transition into int active active linked list. enabled. transitions in the marking of the Petri Net. out matrix entity for entity to an current void an "log" of the fired file. selected enabled graphics name transition. layout description into information. Randomly select an enabled transition. Return true if the user issued the command. Simulate in void autosimO void manual void manualsimO selectO Select automatic mode. an enabled transition by Simulate in interactive mode. -65- user. "QUIT" 5. Conclusions As the popularity increases, available. An interactive acceptable than GPNS Petri Net draw a and user-friendly Just by Petri Net the graphical environment. mouse as a screen and simulate GPNS in to simplify the The user who provides a GPNS's It a safe net analytical ability. Petri Net to This is the develop their own problems is that that by most of application and not work for be most a users can nets, loops in the an and application program net. But construction of a safe this. It users expand exciting feature offered also the by GPNS. to study the behavior opened. Then, Solved during project AT&T UNIX PC utilities on the order such as to use development system. The system were graphical application. together. Function groups text window. This kind the and arose the designed for text mode. In must to draw by writing their own functions. system utilities offered problem safe simulate a safe net should aware of 5.1 Problem Encountered Most not allow tool, Auxiliary Application Program, to let allows users of a exist tries to more its behavior in P/T nets, k-bounded nets, does net. users device pointer, of a safe net to becoming interface is interface for that the formal definiation loop their by GPNS. One thing that must mentioned here is weighted nets are provided allows a are and users. using the on drops, facilities graphical offers a menu-driven and graphical a small size computers more and more graphics-based text interface to on screen. interactive in price of graphical capabilities concerned most troublesome developed for text It is very dificult to the menu(3T) the and make /brm(3T) them are all menu, form and message, a text window a graphics window is opened of the problem always got program simple and structured. -66 that overlaps with in the way of the trying to make 5.2 Limitations The System of the following are the limitations of the system: 1. GPNS is a one screen editor. limited to at most 30 Restricted places and by the screen size, the Petri Net is 30 transitions. In addition, no hierarchical constructs are available. 2. GPNS only allows one size of place and one size of impossible to enlarge importance. It is the also size of name and 4. The the will place of impossible to transition to label it. The text Net is complex, it the must be put transition. It is transition to text inside the put outside of emphasize place copy the the icon. If the Petri be hard to discern the relationship between the symbol. user can not or its part of the net from -67- one place to another. 6. Lessons Learned 6.1 Alternative Approaches for Improved System Microsoft company had developed provides a good very operating environment, application programs with a graphic environment interface, family a that sits on library top It routines that interface. and also provides a can interface be used the Petri Net. flexible operating application By graphics user used is develop to an operating to Software Development Kit develop environment "Windows", interface application with programs. designed specially for programs, the developer using be "Windows" which hardware independence for the PC "Windows" was an and can "Windows", of MS-DOS and provides a graphics-oriented user multitasking capability, of computers. a package called focus can on the 350 Since graphics simulation of a more powerful simulator and a more should be possible. 6.2 Suggestions for Future Extensions When as designing GPNS, independent as possible. editor and simulator. added the net-editor, simulator, This project can For the net-editor, and AAP be improved in two some new kept were aspects editing functions - net- could be into it. zoom in and zoom out work at various hierarchical levels relate net elements on inter-net copy different levels to one another and change these relations net parts (also between levels), merge nets animination A variety ability of the graph of functions could be added of to enhance simulator: -68 the analysis function of the reachability of system states deadlock / lifelock analysis liveness checking concurrency timed analysis net finding dead places / transitions -69 REFERENCE [1] Dr. Wolfgang Resisig Berlin [2] : "Petri Nets An Introduction", Springer- Verlag Heidelberg New York 1982 Robert A. Nelson, Lois M. Petri Nets into Haibt, and Peter B. Sheridan Programs", IEEE Transactions on : "Casting Software Engineering, Vol. SE 9, NO. 5. September 1983 [3] M. Ajmone Marsan, G. Balbo, G. Ciardo Tool for The Automatic Analysis and G. Conte : "A Software Generalized Stochastic Petri of Models', Dipartimento do Elettronica, Politecnico di Torino, Corso Duca degli Abruzzi [4] Frit Feldbrugge 24, 10129, Torino, Intaly "Petri Net : Springer- Science Vol. 222, Tools", Lecture Notes in Computer Verlag; Berlin, Heidelberg, New York, Tokyo; 1985 ISBN 3-540-16480-4 [5] James L. Peterson 223 [6] - "Petri : Nets", ACM computer surveys, Vol. 9, p.p. 252, Sept. 1977 J. D. Foley, A. Van Dam : "Fundamentals of Interactive Computer Graphics", Addison- Wesley Publishing Co. ISBN: 0-201-14468-9 [7] James L. Peterson Electron. Conf. Vol. [8] Tilak Agerwala : Electron. Conf. Vol. [9] J. Dahahler, P. for the Design Software [10] : "An Introduction to Petri Nets", Proc. Nat. 32, Nat. Eng. Consortion, Oct. 1978. PP 144-148. "Some Applications of Petri Nets", Proc. Nat. 32, Nat. Eng. Consortion, Oct. 1978. PP 149-154. Gerber, H-P. Gisiger, A. Kvindig and Prototyping of : "A Graphical Tool Distributed Systems", ACM Engineering Notes Vol 12 No. 3, Jul. 1987, PP 25 36 Michel Diaz Cooperation - : "Modeling Using and Analysis Petri Net Based of Communication Models", North-Holland Publishing Company, Computer Network 6 (1982) PP 419 441 - -70- and [11] Leon J. Mekly, Stephen S. Yan : "Software Design Representation Using Abstract Process Networks", DZEE Transactions on Software Engineering Vol. SE-6, Steptember 1980 [12] P. : Alanche, K. Benzakour, F. Dolle, P. Gillet, P. Rodrigues, R. Vallette "PSI : A Petri Net Based Simulator for Flexible Systems", Lecture Notes Manufacturing in Computer Science Vol. 188, Springer Verlag; Berlin, Heidelberg, New York, Tokyo; 1984 PP 1 14, ISBN 3- 540-15204 [13] Petri, C. A. "Kommunikation Automaten," mit Schriften des Rheinisch-Westfalischen Institute fiir Instrumentelle Mathematik der Universitat F. Bonn, Heft 2, Bonn, W. Germany 1962; translation: C. Greene, Supplement 1 to Tech. Rep. RADC-TR-65-337, Vol. 1, Rome Air Development [14] Center, Griffiss Air force Base, N. Y., 1965, K. Jensen "Computer Tools for Analysis of Petri Nets" Construction, 89 pp. Modification Lecture Notes in Computer and Science, Vol. 255, Springer Verlag; Berlin, Heidelberg, New York, Tokyo; 1986 ISBN 540-17906-2. Edited by Goos [15] an and 3- J. Hartmanis F. Feldburgge, K. Jensen "Petri Net Tool Overview 1986", Lecture Notes in Computer Science, Vol. 255, Springer Verlag; Berlin, Heidelberg, New York, Tokyo; 1986 ISBN 3-540-17906-2. Edited by Goos and J. Hartmanis 71- GPNS USERS' o MANUAL Table of Contents Introduction 1 1. System 2. Getting Started 3. Introduction to the 3.1 1 requests 2 user 4 Interface 4 Terminology 3.2 The Menu Bar 3.2.1 The Structure 3.2.2 The 9 of the menu bar contents of menus 10 14 3.3 Panel 4. 9 GPNS 17 4.1 Using the Net Editor 17 4.2 Simulating 24 How to use 4.3 the Auxiliary Application Program 27 Users' Manual Introduction This describes how to user's manual Simulator (GPNS). GPNS is designed structure, help which provides messages. faster and Users better can use the with and as a window-oriented and menu-driven and simulate a interface, Petri Net and on-line to on screen get a result. Before reading this Petri Nets the Graphical Petri Net menu style user graphics, draw use have Auxiliary reference manual, users experience with the should UNIX system. Application Program (AAP), they be familiar If users should also with to attempt be familiar the C programming language. 1. System Requests 1.1 Hardware Requirements To PC is run GPNS, an AT&T equipped with a device pointer UNIX PC is floppy disk driver, (a three button a required. A standard UNIX hard disk, monitor, keyboard and a mouse). 1.2 Software Requirements The version UNIX 3.51 PC used established on to run the GPNS it. Of course, codes and an executable shell program compiler, etc.) is required to use is AAP. 1- a should have UNIX System disk containing the GPNS's also needed. The development object set (C Users' Manual Getting Started 2. To start a gpns < to GPNS session, type Return > a shell. A few called seconds later, the screen of the terminal will look like Fig. 1. This is the desktop. FILE EDIT EXEC OPTION EXIT H TT O ? h The \ cursor of pointer 5 Fig.l device Users' The entire screen(desktop) Manual is divided into four (see Figure 2) areas MENU BAR P A N E L WORKING AREA MESSAGE AREA Fig. 2 On the top for users the of to select. which consists of is screen Along editing mode. contains are The to editing The four lines show rest of the the detail. side of mode. Selecting of on-line current area. the bottom called for extension one of of give following user can of the submenus a panel (or icon table) with area. draw section will icon symbols; the purposes. will change the called The functions hints to the working desk. The them the screen, messages. states, and to is The help the screen, is them are filled reserved area at screen of are piece of blank paper on a the working the left ten boxes. Seven remaining three boxes represents an bar containing the titles a menu users as of to Each icon the current message area, those message what The working to do next. area and simulate a is like a Petri Net in describe these four areas in Users' 3. Introduction to the 3.1 Manual interface user Terminology Before reading this manual, These terms terms may be needed. frequently show up in this manual. POINTER The the (mouse pointer except bar. But, in text editing when you move area, the or panel is the tool pointer worked on or moving the on : the shape the to specify to as mode when pointer pointer will used is the symbol into either to the an in the a vertical bar menu arrow. The which object should be taken. which action should mouse you can position to indicate it becomes change identify shape the to any pointer be By position screen. Clicking is the mouse issued SELECTING its cursor) will change editing mode, its current panel, CLICKING some explanation of action of pressing and button. It is the way to or the object :An object can object and be an on-line the other confirm the command to be worked on. selected clicking one, to be immediately releasing a one of by the positioning the mouse buttons pointer on the the left (usually help message will indicate when to click one of two buttons). Once selected the will be rectangle, an object highlighted. ICONS FILENAME An icon is a graphics object, such as a arc(directed line), that may be selected and worked on The length of format filename in GPNS of a periods, text, etc. a The icons are the objects during a GPNS session. the filename is limited to 25 characters. The hyphens never appear at a a piece of circle, hidden file in and underscores. the a allows characters, numbers, However, a period should beginning of the filename, it will UNIX directory. When the GPNS become requires Users' to input user the extension name. name after In what the to order is to be operate worked on, action specified on Pop-up user does GPNS automatically should not type in adds an extension the filename. GPNS, the and what the the object following two things must be known is to be done. The GPNS then : carries out indicated. menu On the top of the screen, the EDIT, EXEC, OPTION up filename, the a Manual menu appears on the and menu bar EXIT. Whenever screen. A pop-up menu contains a menu four titles : FILE, title is selected, a pop looks like Fig. 1. MENU TITLE current **^ selected item OPEN SAVE Items CLEAR Cancel of this menu E Key fig.l The menu used now. title at At the the center of title. The desired item position bottom the can pointer on corner of called a cancel the top of the pop-up be menu menu selected menu is is in the the desired item the pop-up icon. the pop-up a indicates list of commands same way and click a cross sign a menu -5 the menu being related to the title is selected the left button. At the left- in a square. This Clicking on it causes the pop-up menu to be screen and none of the commands on is which menu is chosen. symbol removed is from Users' Manual Forms Sometimes, the appears on form looks as after a command from screen and requires some a pop-up menu information or is selected, data to be form a entered. A Fig. 2. Form's Name prompt : llllllllll prompt : [OK] OK Icon -< n K f^anc^l Iron < s Fig. 2 The form's of name specifies which input data fields. The entered. The the current the list, list. It is and next the also possible to go key puts the cancel to any field one shown nothing resides at menu. happen. It is as Clicking if the form "Using Forms" of on it has the of will remove of the field, key or clicking the form. function the Please as form, refer the editing details. It is Working With Commands on page 3-46. -6 changes to that field and remove same to be the bottom pointer Enter never existed. out key list a need to the desired data the input data back to GPNS AT&T UNIX PC Owner's Manual to find the title cursor corner at is field back to the top by positioning the the left-bottom in the pop-up will field is by using the keyboard. Pressing the will pass all icon name data fields that current current clicking the left button. After moving the entered Under the form's names of input field. If the pressing the Return the OK icon The prompts are use. input data field is highlighted. The Return field to the data may be on current form is in the and to the under Users' Note: If the disappear mouse and Shift- Resume Manual was clicked outside GPNS will repeatedly be until the suspended. the message -8- If message this box box, situation re-appear. the message happened, will press Users' 3.2.2 The Manual contents of menus FILE The FILE Clear. All of has the menu these items following are commands three items in it : Open, Save that have something to do with and file manipulation. Open The Open current directory extension this Save ".ptn", the displayed requires you Note form to to saves screen enter not - be entered. GPNS to the adds a a message working area. up file. It box to to directory). also of If the work confirm the the user to a form and the information. for the file not action should by itself. entire has Selecting the Petri Net displays filename the implicit screen. extension name erase an and requires store extension you a new session of GPNS. displays show the filename to The Clear command allows begin current the information When the filename is entered, the : Clear the be in the file to be brought to the command on (the filename has opened and must name of the The Save - to be command causes a enter existing Petri Net data file in the command allows an working area and been saved, GPNS before cleaning the EDIT The EDIT has the menu Properties. These two following commands require two the commands user in it to select : an Move and icon before issuing them. Move - The Move and command moves automatically the adjusts all the icon. -10 selected the arcs icon to that a new place are connected to Users' Note : Arcs can not Properties - be moved, they Issuing The this Manual must be command causes a properties icon of an keyboard. The default sequence default name number name of a of can be appear on the place by changed when the screen. using the is "placei"(i is the it was drawn). The transition is "transi". For arcs, the default is "untitled". The default token weight of for number transitions places is 0. and weights of is 1. It is faster to use the properties command number, probability weight, increase TYPE form to name of a place The default probability arcs erased and redrawn. or decrease it by change or weight of an one at a PROPERTIES to time, if the the token icon than to change is large DEFINITION Internal Name name of the place, used as variable name. PLACE Number Token of Tokens in the place. Maximum token capacity Capacity Name TRANSITION Internal name of the function name. of the place transition, used as Probability weight of the transition.* Prob. Wt. Internal Name name of the arc ARC Weight of the ARC Weight * Probability weight will be explained in the section entitled 'Simulating in the Automatic Mode'. EXEC Under the EXEC title and Net; Prog are three Generate. The first two the third one generates commands : commands start four files in the 11- Interactive, Automatic the current simulation of the directory. Petri Users' Interactive Issuing - this interactive highlights the command mode. the all GPNS fires the the marking This the the simulation, GPNS transitions, and waits until one of The GPNS highlights all moves the and fires it. Then it the in the enabled deadlock occurs or chooses one of goes the transitions in a deadlock is issued. simulation all Then, the Petri Net to enabled automatic mode. transitions just does in the interactive mode, but instead selection, it randomly pointer. process repeats until quit command the by using the transition, This command puts step selected highlights new marking. occurrs or Automatic and in the simulate of each enabled selected GPNS makes During transitions is enabled next Manual to the the next cycle. quit command of as it waiting for a enabled It transitions continues until a is issued to halt the simulation. Prog Generate this Issuing command requires a following the filename. It four file templates in the current filename.mak, filename. h, filenamedo.c (refer to section on and generates directory: filename.c. AAP) OPTION The not contents of the the AAP is linked when option menu will change with GPNS. These items simulating the Petri Net. Some opposite choice will appear Log file : Selecting this transition No to boolean on whether or set the options items; only the in the menu. option causes GPNS to current generate a log file log file contents of the simulation. The log file Net without generating the log file. firing sequence in the are used options are simulating the Petri Net. The "log" depending in the directory. log file : Simulating the Petri -12- while is the name is Users' Fast Causes the speed : Slow The two K-bounded Set the : Note The : boundary '-V value automatic mode simulation speed options of tokens to automatic mode simulation Causes the speed : Manual have value residing in no affect on to faster. work more slowly. the interactive k for the Petri Net. The total one place can never exceed the form indicates the shown on work mode. number k. boundary value of the Petri Net is infinite. The following three items only appear when AAP was linked with GPNS. Run AAP Execute the AAP functions : as the transitions are fired during the simulation. No AAP The "Log them "Log "No When simulating, do : will file" and appear on file" , log "No then the log the next file" for "Fast will show and up are a pair of menu time file" speed" not run with on at a when the inverse commands; time. For example, if the the OPTION pop-up menu "Slow speed", AAP. instead and "Run of menu "Log file". The AAP" and Only one of user selects appears, the same is true "No AAP". EXIT EXIT is the only the user exit Petri Net is menu the GPNS not confirm action title without a submenu. session and return Selecting this title lets to the UNIX environment. saved, the GPNS displays a message box before leaving the GPNS session. 13- If the which requires a Users' Manual 3.3. Panel Fig. 5 introduces the listed on the functions meanings and of the seven icon symbols panel. SELECT fa TT Selects icon in working icon an area as the current active TEXT- Puts the text to where the pointer is positioned PLACES- Draws a circle as the working O TRANSITIONS ARCS - \ - the notation of a place in area. Draws a square as the notation transition in the working area. of a Draws a directed line as a notation of an arc between two selected icons of different types. TOKENS- Adjusts the probability token count of places, weight of transitions, and weight of arcs. ERASE -Erase when the icon which was pointed clicking the Fig 5 14 mouse button. to by the gun Users' The boxes on the automatically turns the editing mode. the symbol as the screen Selecting the The editing the sets edit icon the The icon and active then issue the text a finger. mode. a command screen and area The tab). and the OK icon working symbol be will draw the is the mode, draws The arc. icon, The of from the pointer the area as , current edit menu title to is mode the a circle any is in a the text A form mouse. the text will wanted (it characters key entered show on circle. is In the clicked place or the to represent GPNS of by a acts drawing mode, in the working in the working area. The button circle will was clicked. the transitions and just as it does in the a circle as a place, it transition. directed line. After selecting source, then Petri Net 15 place printable the text notation of a a anywhere on striking the Enter pointer symbol used the text place selected. user selects a arcs the cursor was when mouse represented the on By character. to the can enter Then, that instead a rectangle as the ARC new except arc mode inside using the By pointer allows transition mode. In this mode, place the will make of a place rectangle of Clicking an uppercase user starting from the right on where The the line, but one space on by the bottom 'T' is the left button start and click area, GPNS ARCS- is the working on mode First, area. clicking represents an icon. whenever and wherever - mode position including on editing mode. the working the them mode represented user can put a piece of is limited to TRANS in the box selecting this mode, the appear on of one on-line message at the GPNS to selecting symbol of is to - The of the current user can select an active PLACE mode. symbol the editing can set the selecting symbol of this box Each icon them one of current turning mutually exclusive; others off. tells the functions SELECT- TEXT are panel Manual express destination, for the the relationships Users' between the user attempts TOKENS - the transitions. It places and to connect a place Manual transition a a The black dot in the big warning message different things and : adjusts the token zero). The the token same of transitions ERASE - The symbol used to and remove to weight of icon by and the arcs clicking the one; clicking the middle by one; be taken and clicking the right change and user pointer is weight or its the when its The default probability represent erase is one. is mouse button will area and redrawn the clicking the working arc weight mode editing eliminate additional arcs. 16 three the left place. the default weight of an the icon from the entire screen represents Clicking the transition to Positioning the gun to an icon type, GPNS back to the default value (which is respectively. is one, If the the transitions. In the editing number will positioned on an arc or a to action. the places, the number number action probability weight, the used a place. same box actually number of button decreases the token sets the pointer on a place button increases the token button of weight of mode, positioning the of and cancels panel the token the probability mouse transition to or a to connect two icons displays only be can a pistol. Users' 4. How to use GPNS Using the Net Editor 4.1. This section describes a GPNS Producer-and-Consumer problem by some step clear Manual and idea of performing how to use Consumer Petri Net is send ready to produce is developed. working Petri Net for the By following the example reader should obtain a result of the step very session Producer-and- ready to consume 4.1 Places To draw drawing which a in Fig. 4.1. Fig Drawing in experiments, the GPNS. The final given ready to session a Petri Net transitions. The on GPNS, following one either starts process area. 17 drawing is how to draw places or a place on the Users' 1. Set the current editing inside the cursor panel mode box Manual to place which has mode by positioning the a circle reside in it and mouse clicking the left mouse button. 2. Move the to the desired pointer position on the working area and click the left button. After drawing five places, the working area should look like O Fig 4.2 O o o o Fig 4.2 Drawing Transitions After drawing five places, now draw four transitions as follows: 1. Set the cursor current editing inside the panel mode box to transition which has mode by moving the a rectangle symbol and mouse clicking the left mouse button. 2. Move the draw After a to the desired place and click the left button to the four transitions, the resulting working area should now mouse cursor transition. drawing look like Fig. 4.3 18- Users' Manual O O o o O 4.3 Fig Drawing Arcs Drawing needs a few is an arc more not as steps. as easy drawing transition; it a place or a Arcs may be drawn only between places and transitions. To draw 1. set an arc the current inside the editing panel box mode which to has arcs mode a - moving the mouse cursor big arrow in it and click the left mouse button, 2. 3. Note select the icon (it start, and select the icon to If the first : must which icon is a be a place or the arc is to transition) from which the arc is to point. place, then the second one must be a transition or vice versa. In arc mode GPNS does some error checking. following events to occur: 19 It will not allow the Users' drawn between two 1. an arc 2. an arc connected 3. an arc to or Manual places or from another two transitions, arc, drawn between two icons twice, unless directions. In this case, GPNS automatically avoid Note an arc, ways icon has already been selected, but it is GPNS to get out requires has the drawing drawn should same the of this trap. make a mistake on After adjusts those two second icon to be First, draw purpose, such as to selecting the There erase second similar area after to Fig. 4.4 4.4 Drawing Text next desired to draw selected. the arc, then the ten arcs, the resulting working be not it. are two Second, icon which type of the first icon. Fig The arcs having them overlap each other. If the first : they have different step is to label each place and each 20- transition. ten arcs are Users' 1. Move the and click Manual mouse cursor into the the left button to mouse panel set box the "T" with a upper case current editing mode in it to Text mode. 2. Move the mouse cursor to where the text is to be started and click the left mouse button. 3. Wait until keyboard, the form and press shows on up the Enter key the screen, or click on enter the text from the OK icon. Now the working area should look like Fig. 4.5 ready to ready to send ready to produce receive ready to Fig consume 4.5 Assigning Tokens The only thing left to be done is to Net by putting the tokens into 1. Set the the current editing mouse cursor set the initial marking of the Petri places. mode inside the to Token panel 21 box mode which by has a moving and big black dot. clicking Users' 2. Move the mouse cursor Manual inside the desired 3. Click the left button to increase token button to decrease the token set the token number back to number place. number by one; by click one; the or click the right middle button to zero Assigning the Probability Weight Probability weights are They automatic simulation mode. should 1. have current 2. Move the to indicate are used editing mode to Token right mouse cursor set which in the transitions inside the desired transition. button to decrease the probability button to used only mode. 3. Click the left button to increase probability middle and are to be fired. a greater chance Set the to transitions assigned the probability weight by weight weight by click the or click the one; one; back to the default value of one. Assigning a Weight Weights tokens to the are assigned are needed arc. It 1. Set the an arc place to order enable to specify the desired Click the left button to increase weight back to default value - by one; one. 22 least how many will connected be deposited into the by the arc is fired. mode. arc. weight or click at the transition that is which connected editing mode to Token mouse cursor on to decrease the in to specify how many tokens the transition current 2. Move the 3. in the input also used output place when to by the one; right click the middle button button to set the weight Users' This is only probability go back a simple Manual example, so, do not weights of transitions. After change the entire session and perform some experiments on weights of arcs is finished, the changing probability and user can weight or weights. Note : Limited by the size of the icon, a number bigger than 99 is represented by a '*'. ready to ready to send ready to receive produce ready to consume Fig 4.6 -23 Users' 4.2. Manual Simulating Petri Net Now, the whole on the screen and can showing modes : Interactive Set the be GPNS simulated. at slow speed simulation mode by default the value of is "No log file" be one. set So, to the select Petri Net to simulating in when places of automatic mode. Petri Net is infinite. That should select be fired to the mode menu the Interactive finishing the above current right end side of the menu select one of next no title and set the value of number is boundary the places assumed value of to the mode gives control of which If the user. is the user right mode has to firing sequence an exact choose. enabled To simulate in the mode. transitions in the 3. menu in the interactive 1. Select the EXEC After there is means Interactive Mode in mind, the interactive 2. The default one. Simulating interactive boundary buffers. Here, the buffer the OPTION run has in one time. a place can number of Simulating in the transition simulation "No AAP". It also and In the Producer-Consumer problem, the be two offers is Automatic. limit on how many tokens should problem simulation mode option The default boundary and the Producer-and-Consumer of from the command menu bar, from the EXEC pop-up two steps, the GPNS marking and and will display highlight of the all "QUIT" a menu the enabled title on the bar. The final step is: the highlighted transitions (GPNS marking menu. Petri Net). 24 will fire it and go to Users' Step 3 can to stop the be repeated until a deadlock in Simulating goes to transition to fire, it randomly with a transition a 1. select the EXEC 2. select the Automatic Now, a menu the GPNS enabled transitions deadlock Note is issued menu title probability from the fires the appears on Then, it to has a the Petri Net choose an enabled fires it. An and bigger in the chance to be same marking. selected the cursor) out of the menu. right end side of by itself. game selects transition. This simulation stops. Moving and the randomly one the menu It highlights of the process will not all enabled until a stop is issued. menu appears when simulation. to user weight bar, menu "QUIT" command occurs or a (mouse whenever from the EXEC pop-up command "QUIT" when As in the interactive transition weight to play the simulating starts transitions. and for the picks an enabled happen if automatic mode: The QUIT : command see what would transition of waiting with a smaller in the and enabled bigger probability simulate bar is the way to a practical situation. marking, but instead transition fired then To to simulate GPNS highlights every a new enabled the QUIT Mode automatic mode system were used mode, the occurs or simulation. Simulating in the Automatic the Manual In the simulation and disappears mode, moving the automatic working starts, area GPNS to pause area causes GPNS causes the pointer inside the working pointer resume simulation. The probability transitions that are how to calculate certain marking. of an enabled enabled at the the probability transition to same be fired depends on the time. The of each enabled 25 following is other a example of transition to be fired in a Users' In a certain The probability probability marking, there are four ratio of each of each transition to be fired = 1/(1 + 5 + 3 + 8)= 0.06 T2 = 5/(1 + 5 + 3 + 8) = 0.29 T3 = 3/(l +5 + 3 + 8) = 0.18 T4 = 8/(1 + 5 + 3 + 8) = 0.47 Total Thus, the probability of an transitions, Tl, T2, T3, T4, transition is Tl enabled Manual 1, 5, 3, 8, should be respectively. enabled. Then the : 1 enabled transition to be fired is different in different marking. -26- when it is Users' 4.4 .The Manual Auxiliary Application Program (AAP) GPNS not supplies a tool only the ability to provides AAP for simulate a users' application purposes. GPNS files for users; filename.mak, filename.h, filenamedo.c filename here is the name the user gave to GPNS issued. The GPNS automatically command was adds also generates four filename.c. The and when the Net, but Petri the Prog generate extension name after the filename. The file filename.mak is with the GPNS. The file filename.h is files filenamedo.c the variables filenamedo.c and (places' filename.c. It contains should never modified and all by users. be It a contains two functions: and changed. contains and AAP linking the header file that will be included in the names) and all the the interface between GPNS files file for compiling a make the external functions setupO and the AAP. The declarations names). contents of of : The dofunction(). This file is the above Filename.c is the only file that the function titles of all (transitions' three should be initializeO, terminateO, the transition functions. How to generate After a AAP Petri Net has been drawn transition in the Petri Net should be 1. Select the desired icon (place on the screen, assigned a unique or each internal transition) to be place name. assigned an name. 2. Select the EDIT menu from the 3. Select the Properties 4. Enter the internal menu command name of the 5. Press the Enter key or click on bar. from the EDIT pop-up icon. the OK icon. -27 and menu. internal Users' Note the internal If : name variable corresponding to the changed network of a place or a name same name. file, but do Manual or transition function was name This is only necessary not regenerate changed, the should if you also change be the the program. After modifying the filename.c file, type filename gpns or just type filename to get back to the GPNS directly the on screen. difference is the AAP is same as the Note by to the underscores, so crashes so will not same as can transitons be names are as expect the blanks used as variable names and be able to bugs, your tty see what you type. To fix settings will this, type back. following the places and they the GPNS. The internal because of some program are the four files that GPNS generates for the Producer- Consumer Petri Net. The internal same as with still display before, the and [ Enter ] sane bring the echo The linked interface is directory program. be wrong, stty now user current will "C" If GPNS : The external names of were substituted functions in In this situation, the GPNS the filename.ptn file from the retrieve the Petri Net environment. names labeled on the names of places and graph. 29 transitions are the Users' Manual procon.mak procon : gptn.oprocon.o procondo.o echo linking cc gptn.o procon.o procondo.o procon.o : procon.c echo cc procondc.o : -c procondo.c echo cc compiling procon.c procon.c -c compiling procondo.c procondo.c procon. h extern extern extern extern extern extern extern extern extern int int int int int int int int int ready re ady to to send; to to receive; produce ; buffer; ready ready consume ; produceO; send(); receiveO; consumeQ; -30 -o procon Users' Manual procondo.c #include #include extern "structdef.h" "procon.h" SEG_T char pn int int int int int ready ready void set *pn_in[30][30]; actfile[30] "procon"; = to to send; to to receive; consume; produce; buffer; ready ready up() to to ready ready buffer = ready ready send = pn produce pn to to = in[0][l]-> token; in[0][2]-> token; pn in[0][3]-> token; = pn in[0][4]-> token; = in[0][5]-> token; pn consume receive } int int pn dofunction(t) t; { switch(t) { case 1 case 2: case 3 case 4 : return(produce() ) ; return(sendO); return(recei ve()) ; return(consumeO); default: return(-l); } 31- Users' procon.c "procon.h' #include void initializeO nt produceO int send() nt receiveO nt consumeO void terminateQ -32 Manual