Difference between pages "Refinement of Statemachines" and "Help:Assigning permissions"

From Event-B
(Difference between pages)
Jump to navigationJump to search
imported>Colin
 
(yiInRYSih)
 
Line 1: Line 1:
Return to [[UML-B]]
+
comment2, http://xpahcgoo.p2web.biz/horse6286.html horse, suprgp, http://xpahcgoo.110mb.com/horse982.html horse=-), http://xpahcgoo.sitebooth.com/for2183.html for, bqjd, http://xpahcgoo.p2web.biz/free6118.html free, 520248, http://xpahcgoo.seitenclique.net/horse8953.html horse>:-[[, http://xpahcgoo.p2web.biz/free2529.html free, vpjx, http://xpahcgoo.freehostingz.com/free5189.html free, fmzuc, http://xpahcgoo.freewhost.com/free54.html free91047, http://xpahcgoo.hostmo.com/free1678.html free, 11004, http://xpahcgoo.seitenclique.net/free4294.html free%-D,
 
 
This example of an ATM (automated teller machine) shows the techniques used to make a refinement of a state machine. The example uses a machine-level state machine (i.e. not in a class). The state machines use the state-sets translation which, since there are no class instances, results in each state being represented by a boolean variable.
 
 
 
a) Create a new UML-B project using the New-UML-B Project Wizard
 
b) Create a machine called ATM_A using the package diagram palette Machine tool
 
c) Open its class diagram by selecting the machine and then clicking the button in the properties view (or using the pop-up menu).
 
d) Add a statemachine called atm_sm to the canvas using the diagram palette Statemachine tool.
 
c) Open the state machine and draw the state machine model shown in the diagram below using the statemachine diagram palette.
 
 
 
The statemachine models an ATM which has 2 states, ''idle'' (not in use) and ''active''.
 
The ATM starts off in the state ''idle''. When a card is inserted, represented by the transition ''insertCard'', it becomes ''active''. While it is ''active'' transactions can occur (transition ''Transaction''). At some time (after 0 or more transactions) the ATM will return to the ''idle'' state, ejecting the card as it does so (transition ''ejectCard''). The model is accurate but it leaves out many details.
 
 
 
 
 
[[Image:Atm1.jpg]]
 
 
 
 
 
Return to the package diagram, select the machine, ATM_M, and click on "Make a refinement of this Machine..."
 
Name the refinement ATM_R.
 
 
 
 
 
[[Image:Atm2.jpg]]
 
 
 
 
 
Open the class diagram of ATM_R and you will find a 'refined state machine' which is a clone of ''atm_sm''. Open the state machine. Notice that the transitions refine their counterparts in the abstract level.
 
At the moment the refinement is valid because it is an exact copy, but it doesn't make any progress. We will make the refinement more interesting by modifying the state machine and introducing more detail. The detail that we will introduce is that an ATM ''active'' session can result in ejecting the card with cash or without cash. We will also introduce some details of the process involved in a transaction. Firstly, we need to split the transition, ''ejectCard'' into two transitions representing the two outcomes.  
 
 
 
a) Change the name of the transition ''ejectCard'' to ''ejectCardWithCash'' by selecting the transition and editing its name in the properties view.
 
b) Draw a new transition from state ''active'' to state ''idle''.
 
c) With the new transition still selected, enter ''ejectCardWithoutCash'' as its name in the properties view.
 
  d) Using the 'Add Refined Event/Transition' button in the 'Refines' tab of the properties view, add ''ejectCard'' as a refined transition.
 
 
 
 
 
The refined state machine should now look something like the one below. This screen-shot shows step d) where the event refinement relationship is being set.
 
 
 
 
 
[[Image:Atm3.jpg]]
 
 
 
 
 
Now we need to add some detail to show when each of these two eject card options are taken. We do this by  adding a nested statemachine in the next step.
 
 
 
  a) Using the 'State Features-Statemachine' palette option, add a nested state machine called ''active_sm'' to the state, ''active''.  
 
b) In the properties view for the new state machine, set the translation kind to ''state sets''.
 
c) Open the new state machine's diagram by right-clicking on it and selecting 'open diagram'.
 
  d) Draw the state machine states, initial state and final states shown in the model below. (The transitions are discussed in the next step)
 
 
 
 
 
[[Image:Atm4.jpg]]
 
 
 
 
 
 
 
Notice that many of the transitions have the same name as transitions in the parent state machine. These transitions do not represent new events. Instead, they contribute more information about the transitions that have already been introduced to this refinement by the parent state machine. This is specified in the state machine model by an 'elaborates' property on the transition. The elaborates property forces the name of the elaborating transition to match that of the transition it elaborates. The transition must match the entry/exit characteristics of the parent transition it elaborates. For example, a transition that enters the parent state can only be elaborated by a transition from an initial state, an exit transition can only be elaborated by a transition to a final state and a self-loop transition can only be elaborated by a transition between states that are neither initial nor final. These well-formedness criteria are enforced by validation chacks built into the drawing tool.
 
 
 
a) Draw a transition from the initial state to state ''awaitingPin''.
 
b) Do not name it but instead select the transition called ''insertCard'' from the combo box on its properties view. Its name should automatically become the same as the transition it elaborates.
 
c) Repeat this process for the transitions ''ejectCardWithoutCash'', ''Transaction'' and ''ejectCardWithCash'', making sure they elaborate the transition with the same name from the parent. (Notice that each parent transition can only be elaborated once).
 
  d) The transition ''pinEntered'' is a new transition and does not elaborate anything. Instead, enter its name using the name property text box.
 

Revision as of 07:57, 10 August 2008