Software Engineering (phần 9) pdf

40 293 0
Software Engineering (phần 9) pdf

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

' p l . $ ' ! l ' . aa* t u A p T % R 14 * Spetifitollon Phose ! i ' h supplier : m g 'is supplied by i 1 fn ! Part ' ' ( l : . 1 ( FI ure 11 . 40 Many.to-monyk .9 , . . . ,entlty - relatlonshlp dlagram.l ' j j . . l ; . I I Supplier j ' $ m . k y - . j is supplied by pi . projectl f0r uSe in ; ' n 2 ; ' Pad ' . ! ; l i 1 n E I . 1 ( ( ; . l p ists of( Cons ' 1 ; ' j ' ' j Flgvee 11.:1 More complex entitprelationship diagram. i ! l ' ! L ' J Ports. Also, many-to-many-to-many relationships are possible . Consider the three ' entities Supplier, Part, and Proiect shown in that hgure. A particular part may be sup-i l plied by several suppliers, depending on the project. Also, the various parts suppliedl for a specihc project may come from different suppliers. A many-to-many-to-many1 é 1. . relationship is necessary to m odel such a situation accurately. C I .i ; Entity-relationship modeling is discussed further in the next chapter, which de- , 5 ib bject-oriented analysis another semiformal technique. The next topic of this 'l ! . scr es o , $ i : 1 ! ë chapter is formal techniques. The underlying theme of the next four seetions is that1 6 employing form al techniques can Iead to more precise specifieations than are possible ,C i . ' 1 with semiformal or informal techniques. However. the use of formal techniques, in ? ' ! l ' eneral , requires lengthy training, and software engineers using formal techniques 'i L g ! k k need exposure to the relevant mathem atics. The following sections have been written ' ; . . ' ; . with the mathematical content kept to a minimum. Furthermore. wherever oossible. 1 't' ' '' ' ' , mathematical formulations are preceded by informal presentations of the same ma- r terial. Nevertheless, the level of Sections 1 1 .6 through l l .9 is higher than that of the . i rest of the book .J ' jI 1 . : 1 - 1 j ! i ' j . i ë ! i . ' . Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. ! i i @ . n.4 FINITE STATE M ACHINES 335 1 j ' f ' ' j ' II.ê FINITK STATE AtHINES i l i inally formulated by the 51202 team at the Open i IConsider the following example , or g ; jj University, U.K. (Brady, 1 9771. A safe has a combination lock that can be in one 1! Iof three positions , Iabeled 1 , 2, and 3. The dial can be turned left or right (L or R). lj Thus, at any time, six dial movements are possible: 1 L, 1 R, 2L, 2R, 3L, and 3R. The 'j' combination to the safe is 1 L, 3R, 2L; any other dial movement will cause an alarm It o go off. The situation is depicted in Figure l 1 . l 2. There is one initial state, Safe ' k d If the input is 1 L, then the next state is A. but if any other dial movement, 1 R 1Loc e . j or 3L, say, is made, then the next state is Sound Alarm. one of the two hnal states. I If the correct combination is chosen, then the sequence of transitions is from Safe 11 Locked to A to B to Safe Unlocked, the other tinal state. Figure 1 l . 12 shows a state I transition diagram (STD) of a linite state machine. It is not necessary to depict a I lSTD graphically', the same information is shown in tabular form in Figure 1 I . l 3. For ; . each state other than the two final states, the transition to the next state is indicated, : I depending on the way the dial is m oved. ( ' ë ! i ; I è i @ j 'a #aj #tà à i. èè, ., u -,v arf j yjj jj jtjj j -1 k :19 I:qI 14! 1 j i6 , 1/1 l ) . . is tt,sa: A B Safe Unlocked 1i .! @ t . t .ê$. o, ,,, .:, ,$ itê : : any other ( !: any other dial any other : ; dial movement movem ent dial movement ' ' : i l - b' - l rlitizll E;t E't () ! 1 . 0 j . ' Sq : sound Alarm yinal state ; ki i ' l Flgvre 11.12 Finite stote machine representation of a combination safe. . 1 ) te ?- Toble ol Nexi S'otes rd Current state safe locked A B i ly Diol movement ( q !1 L A s ound Alarm sound Alarm ; ls- 1 R sound Alorm sound Alorm sound Alarm ' , 1 , at l 2L sound Alarm sound Alarm sofe unlocked rl.l e in 2R Sound Alarm Sound Alarm Sound Alorm ! . ! i . 1zs :n 3L Sound Alarm Sound Alarm Sound Alarm : : ; ' e, d Alarm B sound Alorm l i ,aR souna - , I j lle iFIgvr@ Xl . 1a Transition table for a finite state machine. ! 1 '( ' l l l I Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. ' k . I 1 1 aa* t H A p T z k 41 @ Spetifitojion Phose ' j ' : A finite state machine consists of five parts: a set of states , J; a set of inputs, . K; the transition function, T, that specihes the next state given the current state and . ' . the cun-ent input; the initial state, S) and the set of linal states, F. In the case of the . : combination Iock on the safe: I 'Th e set of states J is lsafe Locked, A, B, Safe Unlocked, Sound Alarm ). The set of inputs K is ( 1 L. 1 R, 2L, 2R, 3L, 3R).I j The transition function T is depicted in tabular form in Figure 1 1 . 1 3. The initial state S is Safe Locked. The set of tinal states F is ( Safe Unlocked, Sound Alarm ) .l . l ln more formal terms , a finite state machine is a s-tuple (J, K, T. S, F), where , ' ) I J is a finite, nonempty Set Of States. . 1 r K is a finite, nonempty set of inputs. . Ii 1 'I- i s a function from (J x F) x K into J, called the transitionfunaion. '; ' j' l q S j is the initial state . ' . ! C . ( ! . F is the set of final states , F ç J. : 1 ' i U se of the finite state m achine approach is widespread in computing applications . , ii por example, every menu-driven user interface is an implementation of a finite statei , ' ; . :1 machine. The display of a m enu corresponds to a state, and enterinc an inout at the j ( ' '*' *''''' 't . . ) i keyboard or selecting an icon with the m ouse is an event that causes the product to l ) j go into some other state. For example. entering V when the main menu appears on l $' j ; the screen might cause a volumetric analysis to be performed on the current data set. ; j . A new menu then appears, and the user may enter G, F, or R. Selecting G causes the i results of the calculation to be graphed , P causes them to be printed, and R causes aI 1 return to the main menu. Each transition has the form 1 1 current slale (menul and eveni goption selectedl =u> nex, stoie (1 1 .1) . 1 . ' To specify a product , a useful extension of FSMS is to add a sixth component1 1 to the preceding s-tuple: a set of predicates, P, where each predicate is a function j Of the global state, Y, ot the product gKampen, 1 9871. More tormally, the transition ,i function , T, is now a funetion from (J x F) x K x P into J. Transition rules now have . 7 l .i , the form ' j7 ! t sioge and event and predkofe =:> next sfote (1 1.2) (( turrenl l . ' ! k i ite state machines are a powerful tbrmalism tbr specifying a product that: ( ) F n ' i 'F ' can be modeled in terms of states and transitions between states . To see how this ? . :! formalism works in practice , the technique will now be applied to a modified versioni 1 . E 14 of the so-called elevator problem' , see the Just in Case You Wanted to Know box on l ; 337 tbr background inform ation on the ele vator problem. :! ! , Page ' g .! ; . j ' ' l 11.*.1 Eu vv op Ppoet:M: FINIT: STAT: M v ulxzs ' j I j The problem concerns the logic required to move n elevators between m lloors ac-! I cording to the tbllowing constraints. ' ! j 1 'p ' 1 l ; ' . i ' ! ' j 1 . Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. i2 ï ' ( 11.* FINITE STATE M ACHINES 33F : ! ' 2 S. ëIJ usT IN ZAS: You W ANTZP To Kwowd I ktir @ l . I ITh e elevator problem truly is a classic problem of soft- gineering Notes in the Call for Papers for the Fourth . j ware engineering. lt first appeared in print in j 968 in the International Workshop on Software Specification and ( j 'Don Knuth's Iandmark book, TheArt 0J' Design (IW SSD, 19861. The elevator problem was one ' . Ifirst volume ot Computer Programming, I Knuth, 1 9681. lt is based on of five problems to be used as examples by researchers l ( lthe single elevator in the mathematics building at the in their submissions to the conference , held in Mon- ' ia, in May 1 987. In the form in which i lCalifornia Institute of Technology . The example was terey, Calitorn j used to illustrate coroutines in the mythical program- it appeared in the Call for Papers, it was termed the l ming Ianguage MIX. l4t problem and attributed to N. (Neil) Davis of STC- I IBy the mid - l980s. the elevator problem had been IDEC (a division of Standard Telecommunications and ! generalized to n elevators; in addition, specific prop- Cable, in Stevenage, United Kingdoml. ' I erties of the solution had to be proven, for example, Since then, the problem has attained even wider : jthat an elevator eventually would arrive within a finite prominence and been used to demonstrate an extensive s time. It was now the problem for researchers working variety of techniques within software engineering in ! ' in the area of formal specilication languages, and any general, not just formal specification languages. It is ' proposed formal specitication language had to work for used in this book to illustrate every technique because, the elevator problem. as you soon will discover, the problem is by no means . I The problem attained broader prominence in l 986 as simple as it Iooks. l q ' . is . when it was published in ACM SIGSOFT Sqftware En- tti ' IC '5 L() k ln I . Each elevator has a set of m buttons, one tor each floor. These illuminate when . ( ' ),t . pressed and cause the elevator to visit the corresponding lloor. The illum ination le is canceled when the corresponding tloor is visited by the elevator. i ' !a 2. Each floor, except the first floor and the top floor, has two buttons. one to request ! an up-elevator and one to request a down-elevator. These buttons illuminate w hen 1) pressed. The illumination is canceled when an elevator visits the floor and then : imoves in the desired direction . nt l 3. W hen an elevator has no requests, it remains at its current lloor with its doors 'ln closed.ln /e The product now is specitied using an extended finite state machine (Kampen, ' the n elevators, there l19871. There are two sets of buttons in the problem. In each ot I a) is a set of m buttons, one for each floor. Because these n x m buttons are inside Ii 1the elevators , they are referred to as elevator buttons. Then, on each floor there are ( at I two buttons, one to request an up-elevator, one to request a down-elevator. These are ' Ii s referred to asjloor buttons. , I ln l . kThe state transition diagram for an elevator button is shown in Figure 1 l . 14. Let k 'FI EB(e f) denote the button in elevator e that is pressed to request lloor f. EB(e, f) can 1# I j be in two states, with the button on (illuminated) or off. More precisely, the states are '. 'j iI 1 . EBON(e, f) : - ilevator Buiton (e, f) ON 1. I j( 1 1 .3) . ,EBOFFI e, f) : klevator Qutton (e, f) OFF ; If the button is on and the elevator arrives at Eoor f, then the button is turned off. . !c- l if the button is off and it is pressed, then the button comes on. Thus, two lConverse y , j l ' j l ; . . Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. l .; ' i 1 aae < u A p : : R 11 * Spetlfkafion Phose j ' ; ( ' , 1 EBP (e, f ) ! EBOFF (e, f ) EBON (e, f ) E EAF (e, f ) ' # l1 ylsu 11 . 1* syD for elevotor button (Kampen, . 1 987) . (@ 1 987 IEEE .) ) i . j events are involved: ) EBP(e, f) : Ylevator lppon (e, f) zressed 1 EAF(e f) : ilevator e Arrives at jloor f tl 1-4) f . ? l To deune the state transition rules connecting these events and states - a predicatel i V(e, f) is needed (a predicate is a condition that is either true or false): . f s vte, f): Elevator e is yisiting (stopped at) floor f (1 1.5j . ! I E 1 1 :' ' j : Now the formal transition rules can be stated. If elevatorbutton (e, h is off (current ' 1 . tate) and elevator button (e . f) is pressed (event) and elevator e is not visiting floor f: k s ? (predicate) , then the button is turned on. In the format of transition rule ( 1 I .2) this l 1 becomes( : '. 1: jk' ' EBOFFIe, f) ond EBP(e, f) ond not V(e, f) :::u> EBON(e, f) (11.:) , 1 J : ' ' i ' i If the elevator currently is visiting floor f, nothing happens. In Kampen's formalism,. : i i i 1 events that do not trigger a transition indeed may occur; but if they do, then they are ' ! 1 ! ignored. j ' $' . * ( 'j Conversely, if the elevator arrives at floor f and the button is on, then it is turned i off. This is expressed as 1 I EBON(e, f) and EAF(e, f) :z:4. EBOFFIe, f) (1 1.7)1 ' Now the lloor buttons are considered . FB(d, f) denotes the button on tloor f that l requests an elevator traveling in direction d. The STD for tloor button FB(d: f) is i hown in Figure 1 1 . 15. M ore precisely, the states are '1 S l l FBoxtd. f) : yoor Autton (d, f) ox$ FBoFF(d f) : (loor Autton (d, f) oFF t11-'1' : l y' ' j! 1 y l k If the button is on and an elevatorarrives at floor f traveling in the correct direction, ' i . r j : , d, then the button is turned off. Conversely, if the button is off and it is pressed, then t 1 the button comes on. Again, two events are involved: ! 7 ( ( p ; r FBP(d, f) : Floor :utton (d, f) ?ressedï i ' . f '-levotor 1 or or n Arrives ot yoor f t11-9). ! . . EAFII n, ) : .ri :;1 ' N ote the use of 1 n to denote disjunction. Throughout this section an expression such :!1 ( as P (a, 1 n, b) denotes j ' ' j P(a# 1 # b) or P(a, 2, b) or . or P(a, n, b) (1 1.10) 1' j !l g ! ) 1 : : . à l ': Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. @ ' . l !' j 1 . ; 41.* FINITE STATE M ACHINES 33@ : FBP (d, f ) q;. . ilFBOFF (d , f ) FBON (d, f ) !: I EAF (1 n, f) ( 2 j FI@?e* 11.15 STD for floor button (Kampen, l 1 987) . (@ 1 987 IEEE .) ( j ' . I E I . ; 1 To dehne the state transition rules connecting these events and states, a predicate jS (d e f), which is delined as follows: Iagain is needed. ln this case, it is , , - 41 ' std, e, f): Elevotor e is visitino floor f ond the direction *1 ' in which it is obou-t to move is either 1àte (1 1 . 1 1) up (d = U), down (d = D), or no requests are pending (d = N) I è ; . 5) Thi s predicate actually is a state. In fact, the formalism allows both events and states ; be treated as predicates. i !mt to 'r f Using std, e, f), the formal transition rules then are l i qAis FBOFFIH, f) ond FBPId, f) and not S(d, 1 n, f) è i ; , E =,> FBoN(d, f), j( 1 1 . 1 2) . . . ô) FBON(d, f) and EAFII n, h ond S(d, 1 n, f) ; j =u> FBOFFId, f), d = U or D 1 m l ' , j lre That is , if the qoor button at floor f for motion in direction d is off and the button is C 1 ' 1 pushed and none of the elevators currently is visiting floor f about to move in direction 'j Cd d hen the lloor button is turned on . Conversely, if the button is on and at least one 'r . 1 '' t5 elevator anives at Poor f and the elevator is about to move in direction d, then the button is turned off. The notation 1 n in S(d, 1 n, f) and EAFII n, f) was defined in ' ' . 7) definition ( 1 l . 10). The predicate V(e, h of definition (1 1 .5) can be defined in terms i ' Aat of S(d, e. f) as follows: is i ' V(e, f) = s(U, e, f) or s(D, e, f) or s(N, e, f) (11.la) . i The states of the elevator button and tloor button were straightforward to define. 81 '' ' T urning to the elevators, complications arise. The state of an elevator essentially L consists of a num ber of component substates. Kampen identifies several, such as the : . 7n, elevator slowing and stopping, the dooropening, the dooropen with atimer running, or ! i ::en th e doorclosing after a timeout gKampen, 19871. He makes the reasonable assumption : .E ' I that the elevator controller (the mechanism that directs the motion of the elevator) ! . initiates a state such as S(d, e, f) and that the controller then moves the elevator 2 I i ' ' j r I j9) th rough the substates. Three elevator states can be delined, one of which, S(d, e, t), E was defined in dehnition (1 l .1 1) but is included here for completeness: ! : kch ) M(d, e, f): Elevator e is Moving in direction d (floor f is next) i 11 l ' ' ' f Elevator e is >topped (d-bound) af floor f (1 1.14 i ' 's(d , e, ): y 10) . . w le, f): Elevator e is Waiiing at floor f (door closed) ' '' 1 . . l 1 . I ' j E . Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. f 1 .' ' i ' j-t i a*@ t H A p T : R M * Spetilitqlion Phose i ! These states are shown in Figure 1 1 . I 6. Note that the three stopped states S(U,i t e, h, S(N, e, f), and S(D, e, h have been grouped into one larger state to simplify 8 the diagram and reduce the overall number of states. 1 ; The events that can trigger state transitions are DC (e, f), the closing of the door ' 1 Of elevator e at floor f; ST(e, f), which occurs when the sensor on the elevator is 6 triggered as it nears floor f and the elevator controller must decide whether to stop 1 he elevator at that floor; and RL . which occurs whenever an elevator button or a Qoor1 t 1 1 : button is Pressed and enters its OS state. l DC(e, f): poor çlosed for elevator e, at floor f . ' I sT(e, f): :ensor Jriggered as elevctor e nears floor f (1 1.15) I RL: Request kogged (buqon pressed) . 1 ' i These events are indicated in Figure 1 1. 16. ' Finally, the state transition rules for an elevator can be presented. They can bei ! . . I ) deduced from Figure 1 l . l 6, but in some cases additional predicates are necessary. To ! , ' j be more precise, Figure l 1 . 16 is nondeterministic; among other reasons, the predicates ; ! 6 are necessary to make the STD deterministic . The interested reader should consult : j . .) j (Kampen. 19871 for the complete set of rules; for the sake of brevity, the only rules ! l presented here are those that declare what happens when the door eloses. The elevator . ' t (( j moves up . down, or enters a wait state, depending on the eurrent state: k ' 1 . I stU , e, f) and DC(e, f) ::u:> M(U, e, f + 1) . j 1 - ) i S(D, e, f) and DC(e, f) =::> M(D, e, f - 1 ) (1 1.1ô) t i : ' S(N, e, f) and DC(e, f) rr:::> W (e, f) i 1 ij k : : j ! ' t j ' I M ( U , e, f + 1 ) M ( D, e, f )l l s-r (e, f ) ' t Dc (e, f ) i j : ! C N r N r - - NRL RL , l S ( U , e, f ) i.e l S ( N , e, f ) F +1 S ( D , e , f ) I L -1 u. -! t- - j' - - - - - - - - - - - . - . - - . . -: ' : ! l t I ' DC (e, f ) DC (e, f ) , j i nt- . 1 : !( ' ? ' l . . w (e, f ) ! ! RL RL ! ' 1 s'r (e , f ) .; ' 1 1 t i ' M (u e , f) M (o, e, f - 1)l j t , i '1 1 r ' l . 1 FI@ur* 11.1* STD for elevotor IKompen, 1 987) . (@1 987 IEEE.) . 1; 1 d ' J ' . ; .4l ë ' i : : . ! : Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. n.y PETRI NzTs a*1 l The first rule states that, if elevator e is in state S(U, e, f) , that is, stopped at floor f I labout to go up , and the doors close, then the elevator will move up toward the next j . ' floor . The second and third l'ules correspond to the cases of the elevator about to go l . down or with no requests pending. t , The format of these rules reQects the power of finite state m achines for specifying 1 l complex products. Instead of having to list a complex set of preconditions that have j to hold for the product to do something and then having to list all the conditions that II hold after the product has done it, the specitications take the simple form ) ' I ) turreni stcte and evenù ond predicote = next siaùe 1 ' ' l ! ' This type of specification is easy to write, easy to validate. and easy to con- 1 $1 ve14 into a design and into code. ln fact, it is straightforward to construct a CASE t 1 t't ool that will translate a finite state machine specilication directly into source code. j $ Maintenance is achieved by replay. That is, if new states or events are needed, the I 1 C specitications are modified and a new version of the product generated directly from j the new specifications. k i . . The FSM approach is more precise than the graphical technique of Gane and i Sarsen presented in Section 1 1.3. 1, but it is almost as easy to understand. It has a ; ' drawback, in that for large systems the number of (siofe, evenl, predkoie) triplcs ( can grow rapidly. Also, like Gane and Sarsen's technique, timing considerations are i ' s formalism . 1not handled in Kampen These problems can be solved using statecharts, an extension of FSMS gldarel et I ' al 19901. Statecharts are extremely powerful and are supported by a CASE work- : 1; ! 1bench , Rhapsody. The approach has been successfully used for a number of large I real-time systems. 1 hnique that can handle timing issues is Petri nets. ë i i IAnother formal tec' r 2 : l ' : : ' i ' j I l '.ê l1.y PETRI N KT: 1 ,I' : j . A major difticulty with specifying concurrent systems is coping with timing. This l!) ' . ' 1 * . ' difhculty can manifest itself in many different ways. such as synchronization prob- : j y lems, race conditions, and deadlock (Silberschatz and Galvin, 19981. Although timing 8 jl ' i / ' oroblems can arise as a consecluence of a ooor desien or a faultv imolementation, such I j' 't ''' ''' f''-J ' ''' ' t ! ' designs and implementations often are the consequence of poor specihcations. lf spec- , l à ifications are not properly drawn up. there is a very real risk that the corresponding 1 j design and implementation will be inadequate. One powerful technique for specify- i ) q 'ing systems with potential timing problems is Petri nets . A further advantage of this ( 1 technique is that it can be used for the design as well. ' ' 1 . Petri nets were invented by Carl Adam Petri (Petri, 19621. Originally of in- j l terest only to automata theorists, Petri nets have found wide applicability in com- ! ; : q - I .puter science , being used in such fields as performance evaluation, operating system s, : . - Iand software engineering . In particular, Petri nets have proven useful for describing t . ! I L . é ' j u i i E' , l ' Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. ! l i ' i j ,! ' a*x t u A p T . R ,1 . spetifito.ion phose 1 ' ( ' 1 ! :2 l , t ' l t . ! 2 1 t , j 13 1 1 ' pa j ' . I ( ' l . J' rx 1 *' 4 ,) ' - 1 . . 1 Flguee 11.17 Petri net. i 1 i f ' k ( l concurrent intenrlated activities. But, before the use of Petri nets for specihcations 4 I ; ; 1 can be demonstrated, a brief introduction to Petri nets is given for those readers who ' ; ; : may be unfamiliar with them.l t A petri net consists of four parts: a set of places , P; a set of transitions, T; an input' y . t ' ' 1. d t ut function , 0 . Consider the Petri net shown in Figure l 1.17. '. l : function. , an an ou p ? I. j : rjx e set of jgaces, P, is tpj g p; g gg t gg j. . ( l Tj-je set of transitiolàs s Y, is (t) # tz ) . 1 : - l k ) The input functions for the two transitions, represented by the arrows from places ! ' to transitions , are 91 J ' ' 1 ! ' 1 j . . I(t1 ) = ( p2, pz )l , l l(t2) = .( pa ) , j The output functions for the two transitions , represented by the arrows from1 transitions to olaces , are 1 ''' - 1 O(tI ) = lp, J 1 o(t2) = lpa , pa ) . ' l . 1 Note the duplication of pa; there are two arrows from t2 to pa. l More formally (Peterson, l98 l1, a Petri net structure is a 4-tuple, C = L I p y 1 o) . ( , , si l i 1 p is a finite set of places . n a: 0.I j . =z l p) , pa, . . . , pn l . 1 ; 'j ( ! T = ( tl , t2, . . . , tm ) is a finite set of transitions, m k2 0. with P and T disjoint. ' .i . l ! l : T > P= is the input function. a mapping from transitions to bags of places. ! I 1' , o : T > Pcxl is the output function, a mapping from transitions to bags of places. 1 f ' ' . ; t t . : ) : (A bag, or multiset, is a generalization of a set that allows for multiple instances of l ! . i t an element.) g 1 l M arking a Petri net is the assignment of tokens to that Petri net . Figure 1 l .l8 '1 f tokens'. one in pl , two in p2, none in pa, and one in pz. The markingcontains our ; k ' . ( can be represented by the vector ( 1 , 2- 0, 1 ). Transition t, is enabled (ready to tire), ') ; i -l I ! l : ! :1 i ; 1 ( . Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. ' . 1 . : t E II.y PETRI N ETS a*a 92 j ' @ j , * 1 ta ( l ' ) t ' $p 1 1 , pa l @ j . I l l I * Ir) 4 li ! IFl guee 11.1* M orked Fetri net. ' l l I' j ls because there are tokens in p2 and in pa; in general, a transition is enabled if each of its input places has as many tokens in it as there are ar - cs from the place to that 1'o lt ransition. lf @1 were to lire, one token would be removed lrom p2 and one from pz, I at and one new token would be placed in pl . The number of tokens is not conserved-two . ! 7. tokens are removed, but only one new one is placed in pl . ln Figure l l . l 8, transition q ' l is enabled, because there are tokens in p2. If t2 were to hre, one token would : i it2 a SO ! 4' j be removed from p2. and two new tokens would be placed in pa. E Petri nets are nondeterministic', that is, if more than one transition can tire, then l l zs any one of them may be fired. Figure l 1 .l8 has marking (1 , 2. 0, 1)'. both tl and : . i ,t 2 are enabled. suppose that tl fires. The resulting marking (2, 1 , 0, 0) is shown in ! 19 where only t2 is enabled. It tires, the enabling token is removed from ! 1yigure l 1 . s ( o,, and two new tokens are placed in pa. The marking now is (2, 0, 2, O), as shown in ; ' 1 '''' '' ' ' '''- jFigure l l .20. 'i m ' More formally gpeterson, l98 11, a marking, M, of a Petri net, C = (P, T, 1, O), is a function from the set of places, P, to the set of nonnegative integers'. ' M : P > l 0, 1 , 2, . . . ) . I ' A marked Petri net then is a s-tuple (P, T, 1, 0, M). ' An important extension to a Petri net is an inhibitor arc. ln Figure l 1 .2 l , the : . inhibitor arc is m arked by a sm all circle rather than an arrowhead. Transition tl is : = . enabled because a token is in pa but no token in pa. ln general, a transition is enabled l I ' g p . if at least one token is on each of its (normal) input arcs and no tokens on any of g 1I i its inhibitor input arcs. This extension will be used in a Petri net specification of the : I : : j 7 elevator problem presented in Section l l .6. 1 tGuha, Lang, and Bassiouni, 19871. . 1 . i . I . ! I' ll.KI Euvv oR pRoetz-: PETRI N zTs I f ' i :O . . . I @ Recall that an n elevator system is to be installed in a building with m floors. In $ l j ' I 'i 8 thi s Petri net specitication, each floor in the building is represented by a place, Ff, 1 , i i' 2 jAg ' s f s m , in the Petri net; an elevator is represented by a token. A token in Fj denotes that an elevator is at noor f. 'l:t), q h ! j i . I .l 1' j i . 1 Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. [...]... j, t An c( ci 1 19) n Se t on CSF(e t 11 S ci on 9) E t de fnt sat mac ies xen d i i t e h n e (et n 11é) S ci o ; ' ' i ' F mal or E t yprcs xr emel e ie Canrdu es e iiat e c p cf i c on f ut al s Har f tcm t Iar d ore o e n Har t ue do s Al os i osi e f mo t m t mp sbl or s Canrdu ede eo n e c v lpme t Gs(etn1.) i Sco 1 t i 9 Fti et( ci 11Z) ern s Se t on VM(cin 11 D S to 9) e ' cinst un san... F tin t e es t in o anelv orbutn er e r pr enat f e at t o o (ua Ln , n B siu i1 8 )( 98 IE G h,a g a d as n, 9 7.@1 7 EE) o q i 1 ! 1 l i , l : i ! ' ' ! , E Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you ' lI ; ' : ' ' r1 ' i l a*l t H A p T: R 1 @ 4 ;, , jI l F ? pes d F B rse B/ I spetii i Phos fiogon e Elvtri at n e ao n ci o F f , @ E... e You W a e t For he orec onun ai he e he us n s ntd o Know box on pa 3 )Us ofZ rquie kno edgeofs t y,f tons a d ge 47 e e r s wl et heor unei , n t;1 f i Ii : Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you ' ' i 4 Z 4* a*y : ' Jus I tAs Y ou w Axn p T Kxow Tx : o : J 1 ) ) ' l ' ' 7 Th nameZ wasgient t f mals ecii aton l ne v o he or p fc i a... tonconsssofanum be ofs hemat Ea p ii ai it r c a ch s he a conss sof a g oup ofva i bl de ar i t t rw ih a ls ofpr di at c m it r r a e cl atons oge he t it e c es ' Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you l l l ' j j I p j * ' 1j ' 1 i ' t a*a t u A p T :p 1 * s tft i Phos 1 pe iioton e h : i I ; , ' 5 de l at cor i ons 1 ll : ji ( prdf e ec... he tt t on at The r i e nput ra e i l but ? Asnv ro s te ln u g s sc a CSP( ae 1 8 )teq eto mak t i aiu oh ra g a e (u h s on Ho r, 9 51,h u sin r l l I 1' Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you ' ' ' I Z 4a a4@ 1 : - I! Ps-tfn ubBl lo (1 : l2 * h Bvt sae t tt on bue :Bu on? qon 1, - I; ; ' ( eon?e buq l bu onsA (t tn 6 pse A (uhd = pse... Tersl fe udb us cf d s a s 1r 1 : r ', l qr 1 a b e u e s c esul i awiev rey o poe t,icu n CAS tos s e n s d u c sf l n d ait f rjcs n ldig y E ol ' t ! j j( l ! Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you ' l i ! t j 4 t ; a5@ tH A p TK R M Fo r Ar a l o nv / A But Sat t te on kj ? Btn ) j : ut uon o l : k i lr ;1 b t ?e b f sz uon uonlq ( ... h th l t a n t n esa d p cf ai wrt n n a b e e i on t s ve i a numbe ofwa , i udi rwrtng t s ciiatons i naua ol d n r ys ncl ng e ii he pe fc i n trl p ! l1 j Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you , ' t ' 1 O T R F m LTK HNI S ,* HE oR QUE asl t expe i e w ih M e ' Engls pa aphr e o hi f m als cii ton f he renc t yers i h r as f s or pe... r m w k or ng r pe fc i o i o m em nt ton i a s quenc ofs e t tpr s ve va i t I o herwor ,i t e s ci atons a e n e e t ps ha e er ldiy n t ds f h pe hc i r ' Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you ' j j ' 2 ' I i ij lI@ '' ! ( j j ; I ' ' !1! : ; '1 I l ' ! : )i 1 j ' ' 1 1 1 l$ ! p !' ' : ;lt l :, ' ' 2 ' j l 2 : eHApTzR * s e ic f... dvlp nta t ngmetem,n r tefcos h h a , s c a tecin i itn ta ase icmeh db u e (rn tue ) As wih s u h s h l tnssig h t p cf to e sd o o sd e i t o il ' I! i J?f l Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you ' ! 1.1 TE TNO ouRl T 5p cIIAToN PHAS 44 SI No H: E Fc I E asa l ) ' 5 e iioi Meh P tft d on #od Coe or ig y ' Natr I gu e (e t i12) ualan... t , 't jr ! 1l :2 l' 5 ;1 l ! i j J/ i t' ! l (' , 5 i ' q 9 @ a Fl e 1 gur 1Q1 P ti et t an er n wi h i hbi ar n i t c or I !! l 1 t! I I' i : ;! ( It Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you ' 4y 4 PER NES TI T I I a*5 I 1i $ I; j Fls:tlns: el r r n: Ea ee t ha as tofm b t , ef ea foorThes ch lvaor s e utons on or ch l e il m . s, : . - Iand software engineering . In particular, Petri nets have proven useful for describing t . ! I L . é ' j u i i E' , l ' Please purchase Image To PDF Converter on. for a finite state machine. ! 1 '( ' l l l I Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. ' k . I 1 1 aa* t H A p T z k 41. 'p ' 1 l ; ' . i ' ! ' j 1 . Please purchase Image To PDF Converter on http://www.verypdf.com/ to remove this message, thank you. i2 ï ' ( 11.* FINITE STATE M ACHINES

Ngày đăng: 07/07/2014, 06:20

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan