This action might not be possible to undo. Are you sure you want to continue?
State Transition Diagram
• State machine visualizes an object of a class as an isolated entity • Describes how the object communicates with the rest of the world by detecting events and responding to them • State diagram also models the dynamic aspect of the system • Sequence and communication also fulfill the same purpose but in a different manner
State Transition Diagram
• Sequence and Colloboration deals with community of objects and describe the messages passed between them • Whereas state diagram treats the particular object in an isolated manner • Describes all possible states that an object can have during its life cycle • How the object responds to an event when it is in a particular state
State Machine – characteristic features
• An object has various states during its life cycle • The arrival of an event triggers the transition of object from one state to another state • An object behaves different in different states
A generalised state machine diagram .
then the printouts can be taken without any problem . till the problem is resolved • If the printer is fine and paper is loaded properly.Example printer • Consider a printer is switched on • Command is given to the printer to print a document • If there are no papers loaded in the printer. it will give a signal which will compel the computer to display a message to load paper • If the printer is jammed. it will refuse to print. even if paper is loaded in the printer.
Example : CD Player Power switch on Stopped state Insert CD Ready state Eject CD Power switch on Press Play button Press stop button Playing state .
• The object is examined in an isolated manner • • How the object responds to an event depends on the current state of the object One starting point shown by filled circle Several end points shown bull’s eye symbol A state is shown by rectangle with rounded corners Arrow between states shows the transition of object from one state to another states .Stat Machine • A state machine is a graph of states and transitions • • Usually a state machine is attached to a class and it • describes the response of object of the class to event it • receives.
Events • A noteworthy occurrence which has consequences is called an event • Types – Time event – Guard condition becoming true event – Change event – Call event – Signal event .
Antivirus software to run at 1. – State – non scanned.00pm daily. under scanning • Set the machine in locked ode if idle for 2 minutes .Time event • Time is calculated as absolute time or the passage of relative amount of time • eg.
Guard condition becoming true event • When transition occurs . condition is being tested. if it is true then the state changes • Conditional Event – Debit if current balance is > debit amount else cancel .
• When it is true transition fires .Change Event • Change event is evaluated continuously till it becomes true.
the receiver transitions to a new state. a call event is synchronous • When an object invokes an operation on another object that has a state machine. malpractice) .Call event • Call event represents the dispatch of an operation. control passes from the sender to the receiver. the event may trigger a state transition in a state machine. (Exam hall. the operation is completed. and control returns to the sender. • A signal is asynchronous. the transition is triggered by the event.
Signal • A signal represents a named object that is dispatched (thrown) asynchronously by one object and then received (caught) by another. stereotypes as send • You can use a dependency. • A signal may be sent as the action of a state transition in a state machine or the sending or a message in an interaction • In UML you can model the relationship between an operation and the events that it can send by using a dependency relationship. stereotypes as send. Exceptions are supported by all programming languages. . to indicate that an operation sends a particular signal.
the actor may continue along its way independent of the system to which the signal was sent • The sender dispatches the operation and then waits for the receiver. the sender dispatches the signal and then continues along its flow of control. not waiting for any return from the receiver • For example. Here the sender is put in lock step with the flow of control of the receiver until the activity of the operation is carried out.Sending and Receiving Events • Signal events and call events involve at least two objects • Object sends a signal. . an actor sends push-Button signal to the ATM system.
Customer Arrival in a Bank • • • • Customer Arrival in a bank branch is an event Customer does a transaction that is the action Object concerned with is the bank branch If no customer is in waiting state.Eg. i.e if zero customers are ready. then the Teller is is not busy state. then the teller is in busy state • Completion of transaction process take to next state . teller is in idle state • If n customers are there in the queue.
State Transition Diagram • Not every state classes exhibit such behavior • We can draw a state diagram to show event-ordered behavior of the system as a whole • During Analysis: – We use state diagram to indicate dynamic behavior of the system • During Design: – We capture dynamic behavior of the individual classes or collection of collaboration classes .
State • State of an Object represents the cumulative results of its behavior • Transition – Progression from one state to another and will be triggered by event – Event may be external or internal .
Telephone 1. the phone is ready to initiate or receive calls) 2. Phone is not expected to ring. Phone is on-hook Receiving state (if it rings we are expected to converse with the initiating phone) . Phone is off-hook Dialing state (Someone picks of the hand-set .Eg. we expect to initiate conversation on to another phone) 3. Telephone first installed Idle State (No previous behavior is of great interest.
can on-hook.cumulative results of its behavior • At a given point of time the state of the object encompasses all of its properties together with the current value of each of those properties • Telephone’s property: can dial. of possible states . can receive calls • Here the property mans the totality of the object ‘s attributes and relationship with other objects • We can generalize the concept of individual object's state to apply to object’s class because – All instances of the same class live in same state space which encompasses an indefinite yet finite no. can-off hook • Current: if on-hook .
State • Simple state – A state that has no sub states • Super or Composite state – A state that has sub states • Concurrent Composite State • Sequential Composite state .
Example : Simple state Close Opened Open Closed locked Unlocked Locked .
.Superstate or Composite Substate • Objects with complex behaviour can be modeled at different levels of abstraction • So we need composite states to express the same • Composite states further consists of elaborate internal state or substates inside individual composite states.
Example for Concurrent Composite states In Service Pump gas Filling Gas tank Depart Begin Wash Begin Wash .
Sequential Composite state Transmission Transmission Neutral Push N Push R Reverse Push F Push N Forward up shift up shift up shift up shift First Down shift Second Down shift Third Down shift Fourth Down shift Fifth .
State Chart diagram for Car Transmission • Car Transmission has three states – Neutral – Reverse – Forward • Forward state is sequential composite state showing First. • Substate: A state nested in another state is called substate . fourth. Third. second.
Concurrent Composite states • Useful when object has sets of independent behaviors • However there should not be too many sets of concurrent behaviors • If concurrent composite state is active then one of the nested states from which each concurrent state is active .
an event is an occurrence of a stimulus that can trigger a state transition. .• An Event is the specification of a significant occurrence that has a location in time and space. • In the context of state machines. • A signal is a kind of event that represents the specification of an asynchronous stimulus communicated between instances.
Entry. it is possible to define actions within a state – entry – defines an action to be performed on entering a state updating – exit – defines an action to be performed when leaving a state entry/getBalance() – do – defines an action to be performed do/addToBalance() while in a state exit/tellBalance() . exit and do actions • As well as labelling transitions with actions.
ATM example (with send event) Customer at ATM Authentication Check PIN [correct] Withdraw Check PIN [incorrect] / incrementErrorCounter Check PIN [incorrect and ErrCounter >=Limit] /authentication Failed Rejection .
Example Event State Transition digit (n) digit (n) dial tone on-hook off-hook dialling on-hook idle .
which is made up of executable atomic computations that result in a change in state of the model or a return of a value • The state of an object is a condition or situation during the life of an object during which it satisfies some condition.Activities • Activities ultimately result in some action. performs some activity. or waits for some event .
It shows the flow of control from one state to another . By emphasizing the potential states of the objects and the transitions among these state using State chart Diagrams State diagrams are used to model different states of an object during its lifetime.You can visualize a state machine in two ways: 1. By emphasizing the flow of control from activity to activity using Activity Diagrams 2. from the time it is created until it is destroyed.
. only for classes with significant" dynamic behavior. • Sometimes it is necessary to look at the behavior inside an object. • A state chart diagram shows the states of a single object.• Use Cases and scenarios provide a way to describe system behavior. and the actions that result from a state change • A state chart diagram will not be created for every class in the system. the events or messages that cause a transition from one state to another. that is. the interaction between objects in the system.
• The state of an object may be characterized by the value of one or more of the attributes of the class. . Active. • The Heater in a home might be in any of four states: Idle. a CourseOffering object may be open (able to add a student) or closed (maximum number of students already assigned to the CourseOffering object). Activating. or waits for an event.States • A state is a condition during the life of an object during which it satisfies some condition. performs some action. and ShuttingDown • For example.
States A state has several parts: 1. but are postponed and queued for handling by the object in another state ( Message option during conversation in mobile phone) . Internal transitions 4. Entry/exit actions 3. Sub states 5. Deferred events: a list of events not handled in that state. Name 2.
– Canceled (no longer offered). – Closed (maximum number of students already registered for it). – Open (able to accept students). .Example • Objects in CourseOffering class can be in one of the following states: – Initialization (created prior to registration but students have not been added to it).
• An activity starts when the state is entered and either completes or is interrupted by an outgoing state transition. • As with actions and guards. this behavior typically is mapped to operations on the object . • Likewise.State Details • actions that accompany all state transitions into a state may be placed as an entry action within the state. actions that accompany all state transitions out of a state may be placed as exit actions within the state. • Behavior that occurs within the state is called an activity.
• An action can accompany a state transition. .State transition • Represents a change from an originating state to a successor state (which may be the same as the originating state). • There are two ways to transition out of a state— – automatic and nonautomatic.
• A non-automatic state transition is caused by a named event (either from another object or from outside the system). • Both types of state transitions are considered to take zero time and cannot be interrupted. • A state transition is represented by an arrow that points from the originating state to the successor state.Transition out of a state • An automatic state transition occurs when the activity of the originating state completes—there is no named event associated with the state transition. .
providing its guard condition is satisfied • Guard condition: A Boolean expression that is evaluated when the transition is triggered by the reception of the event trigger. If true. If false.A transition has five parts: • Source state • Event trigger: The event whose reception by the object in the source state makes the transition eligible to fire. and indirectly on other objects that are visible to the object • Target state: The state that is active after the completion of the transition . the transition is eligible for fire. the transition is not fired • Action: An execution atomic computations that may directly act on the object that owns the state machine.
Special States • There are two special states that are added to the state chart diagram. The UML notation for a start state is a small solid-filled circle. . Each diagram must have one and only one start state since the object must be in a consistent state when it is created. • The first is a start state. An object can have multiple stop states. • The second special state is a stop state. The UML notation for a stop state is a bull's eye.
• An event is a message that is sent to another object in the system. . they are used only by the object itself. • Often. these operations are private—that is.State Transition Details • A state Transition may have an action and/or a guard condition associated with it and may also trigger an event. • Both actions and guards are behaviors of the object and typically become operations. • A guard condition is a Boolean expression of attribute values that allows a state transition only if the condition is true. • An action is behavior that occurs when the state transition occurs.
event name [ guard condition ] / action ^Class name.Send event .
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue reading from where you left off, or restart the preview.