Download presentation
Presentation is loading. Please wait.
Published byThomasine Park Modified over 9 years ago
1
University of Toronto at Scarborough © Bennett, McRobb and Farmer 2005 CSCC40 state diagrams 1 state machine for the class GradeRate. Movement from one state to another is dependent upon events that occur with the passage of time. Pending Active Lapsed Transition between states [rateStartDate <= currentDate] [rateFinishDate <= currentDate] after [1 year] Final psuedostate Initial pseudostate Change trigger GradeRate Relative time trigger State Change trigger state machine GradeRate
2
University of Toronto at Scarborough © Bennett, McRobb and Farmer 2005 CSCC40 state diagrams 2 Commissioned Active authorized(authorizationCode) [contractSigned] / setCampaignActive This trigger must correspond to an operation in the Campaign class events
3
University of Toronto at Scarborough © Bennett, McRobb and Farmer 2005 CSCC40 state diagrams 3 State Name entry /activity-expression exit /activity-expression do /activity Name compartment Internal activities compartment Internal activities
4
University of Toronto at Scarborough © Bennett, McRobb and Farmer 2005 CSCC40 state diagrams 4 Menu Visible state for a DropDownMenu object. Menu Visible itemSelected / highlightItem entry/ displayMenu do / playSoundClip exit / hideMenu Name compartment Internal activities compartment Internal transitions compartment event itemSelected() triggers the action highlightItem() While the object remains in the Menu Visible state, the activity causes a sound clip to be played. Exiting the state triggers hideMenu() entry action causes the menu to be displayed
5
University of Toronto at Scarborough © Bennett, McRobb and Farmer 2005 CSCC40 state diagrams 5 state machine for the class Campaign. Commissioned Authorized(authorizationCode) [contractSigned] /setCampaignActive /assignManager; assignStaff Active Completed Paid campaignCompleted /prepareFinalStatement paymentReceived(payment) [paymentDue - payment > zero] paymentReceived(payment) [paymentDue - payment <= zero] archiveCampaign /unassignStaff; unassignManager Recursive transition models any payment event that does not reduce the amount due to zero or beyond. Action-expression assigning manager and staff on object creation Guard condition ensuring complete payment before entering Paid
6
University of Toronto at Scarborough © Bennett, McRobb and Farmer 2005 CSCC40 state diagrams 6 A revised state machine for the class Campaign Commissioned Authorized(authorizationCode) [contract signed] /setCampaignActive /assignManager; assignStaff Active Completed Paid campaignCompleted /prepareFinalStatement paymentReceived(payment) [paymentDue - payment > zero] paymentReceived(payment) [paymentDue - payment = zero] archiveCampaign /unassignStaff; unassignManager paymentReceived(payment) [paymentDue - payment < zero] /generateRefund If the user requirements were to change, so that an overpayment is now to result in the automatic generation of a refund, a new transition is added.
7
University of Toronto at Scarborough © Bennett, McRobb and Farmer 2005 CSCC40 state diagrams 7 Advert Preparation campaignCompleted /prepareFinalStatement Running AdvertsScheduling confirmSchedule extendCampaign /modify Budget advertsApproved /authorize Active Decomposition compartment The Active state of Campaign showing nested substates. The transition from the initial pseudostate symbol should not be labelled with an event but may be labelled with an action, though it is not required in this example
8
University of Toronto at Scarborough © Bennett, McRobb and Farmer 2005 CSCC40 state diagrams 8 The Active state of Campaign with the detail hidden. Active : Running The submachine Running is referenced using the include statement. Hidden decomposition indicator icon
9
University of Toronto at Scarborough © Bennett, McRobb and Farmer 2005 CSCC40 state diagrams 9 Advert Preparation Running AdvertsScheduling confirmSchedule extendCampaign /modify Budget advertsApproved /authorize Active Survey Evaluation surveyComplete runSurvey Running Monitoring campaignCompleted /prepareFinalStatement Active state with concurrent substates
10
University of Toronto at Scarborough © Bennett, McRobb and Farmer 2005 CSCC40 state diagrams 10 State 1 Transition caused by the event someTrigger Transition fired by completion event State 2 someTrigger
11
University of Toronto at Scarborough © Bennett, McRobb and Farmer 2005 CSCC40 state diagrams 11 Synchronized Concurrent Threads. Explicitly showing how an event triggering a transition to a state with nested concurrent states causes specific concurrent substates to be entered. Shows that the composite state is not exited until both concurrent nested state machines are exited. Fork Join
12
University of Toronto at Scarborough © Bennett, McRobb and Farmer 2005 CSCC40 state diagrams 12 StoryBoard AdvertPrep: AdvertPrepSM AdvertRunning abort sm AdvertPrepSM abort Advert Aborted Advert Reworked Advert Reworked Advert Aborted sm Advert Exit pseudostate Entry pseudostate
13
University of Toronto at Scarborough © Bennett, McRobb and Farmer 2005 CSCC40 state diagrams 13 x [condition1] [condition2] Junction pseudostate Choice pseudostate [<15] [=15] [>15] StateA StateCStateB StateD
14
University of Toronto at Scarborough © Bennett, McRobb and Farmer 2005 CSCC40 state diagrams 14 Advert Preparation Running AdvertsScheduling confirmSchedule extendCampaign /modify Budget advertsApproved /authorize Active Survey Evaluation surveyComplete runSurvey Running Monitoring campaignCompleted /prepareFinalStatement Suspended H suspendCampaign /stopAdverts resume Campaign H Shallow history psuedostates with transition to the default shallow history substates.
15
University of Toronto at Scarborough © Bennett, McRobb and Farmer 2005 CSCC40 state diagrams 15 :Client :Campaign listCampaigns :CampaignManager sd Record completion of a campaign loop :CompleteCampaignUI :CompleteCampaign getClient selectClient loop getCampaignDetails() startInterface [For all clients] showClientCampaigns completeCampaign [For all client’s campaigns] completeCampaign Active state Completed state Active Completed Sequence Diagram with States Shown
16
University of Toronto at Scarborough © Bennett, McRobb and Farmer 2005 CSCC40 state diagrams 16 Initial state machine for the Campaign class—a behavioural approach. Commissioned authorized(authorizationCode) [contract signed] /setCampaignActive /assignManager; assignStaff Advert Preparation Completed Paid campaignCompleted /prepareFinalStatement paymentReceived(payment) [paymentDue - payment > zero] paymentReceived(payment) [paymentDue - payment = zero] archiveCampaign /unassignStaff; unassignManager paymentReceived(payment) [paymentDue - payment < zero] /generateRefund Running AdvertsScheduling confirmSchedule extendCampaign /modify Budget advertsApproved /authorize sm Campaign Version 1
17
University of Toronto at Scarborough © Bennett, McRobb and Farmer 2005 CSCC40 state diagrams 17 Commissioned Authorized (authorizationCode) [contract signed] /setCampaignActive /assignManager; assignStaff Advert Preparation Completed Paid campaignCompleted /prepareFinalStatement paymentReceived (payment) [paymentDue - payment > zero] paymentReceived (payment) [paymentDue - payment = zero] archiveCampaign /unassignStaff; unassignManager paymentReceived (payment) [paymentDue - payment < zero] /generateRefund Running AdvertsScheduling confirmSchedule extendCampaign /modifyBudget advertsApproved /authorize Active sm Campaign Version 2 Revised state machine for the Campaign class.
18
University of Toronto at Scarborough © Bennett, McRobb and Farmer 2005 CSCC40 state diagrams 18 Advert Preparation Running AdvertsScheduling confirmSchedule extendCampaign /modify Budget advertsApproved /authorize Running Survey Evaluation surveyComplete runSurvey Monitoring authorized(authorizationCode) [contract signed] /setCampaignActive /assignManager; assignStaff Paid paymentReceived(payment) [paymentDue - payment > zero] paymentReceived(payment) [paymentDue - payment = zero] archiveCampaign /unassignStaff; unassignManager Active campaignCompleted /prepareFinalStatement Commissioned Completed campaignCancelled /cancelSchedule calculateCosts; prepareFinalStatement Suspended H suspendCampaign /stopAdverts resumeCampaign H campaignCancelled /calculateCosts; prepareFinalStatement sm Campaign Version 3 paymentReceived(payment) [paymentDue - payment < zero] /generateRefund Final version of Campaign state machine.
19
University of Toronto at Scarborough © Bennett, McRobb and Farmer 2005 CSCC40 state diagrams 19 :TicketMachine :Barrier after:WeightSensor sd Car enters car park raiseBarrier lowerBarrier before:WeightSensor activate Raised Lowered Active deactivate Blocked barrierLowered Inactive ticketRequested
20
University of Toronto at Scarborough © Bennett, McRobb and Farmer 2005 CSCC40 state diagrams 20 [barrierState = Raised and barrierRaisedTime > 20s] lowerBarrier/ [barrierState = Lowered] Lowered Raised [barrierState = Lowered] raiseBarrier/ [barrierState = Raised] sm Barrier {Protocol}
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.