Dynamic Modeling in COMET Seconda parte Valentina Cordì Dynamic Analysis La Dynamic Analysis e` una tecnica che aiuta a determinare come gli oggetti interagiscono tra loro nell`esecuzione di uno use-case. Si puo` suddividere in relazione al tipo di use-case in: Non dipendente dallo stato. Dipendente dallo stato. Dynamic Analysis Non Dipendente Dallo Stato Parte dagli use-case e considera ogni interazione tra l`attore principale e il sistema. Un interazione inizia con un evento esterno. Dynamic Analysis Non Dipendente Dallo Stato Considera ogni interazione in sequenza, nel modo seguente: Determina gli oggetti interfaccia. Determina gli oggetti interni. Determina la collaborazione tra gli oggetti. Considera eventuali sequenze alternative Esempio: View Workstation Status Use Case Name: View Workstation status. Actor:factory operator. Summary: This use case describes the factory operator viewing the status of one or more factory workstation. Precondition: The factory operator is logged in. Description: The factory operator request to view the status of one or more factory workstation.Operator requests may be on demand.The operator may also subscribe to receive notification of changes in workstation satus. Alternatives: Factory workstation is down. Warning message is dysplayed to operator. Postocndition: Workstation status has been displayed. View Workstation Status Message Sequence Description <<actor>> V1:Operator Request <<user Inteface>> :Operator Interface V1.3:Displayed Info :FactoryOperator V1.1:Worksation Status Request V1.2:Workstation Data <<entity>> :Workstation StatusServer Dynamic Analysis Dipendente Dallo Stato Riguarda la interazione tra oggetti che partecipano a use-case dipendenti dallo stato. Vedremo due esempi: Validate PIN. Cruise Control. Dynamic Analysis Dipendente Dallo Stato Obiettivi: determinare la interazione tra i seguenti oggetti: Lo state-dependent control object. Gli oggetti (solitamente interfacce), che spediscono eventi al control object. Gli oggetti che eseguono le azioni e le attivita`. Gli altri oggetti che partecipano nello use-case. Dynamic Analysis Dipendente Dallo Stato I passi principali sono: Determinare oggetti interfaccia. Determinare gli state-dependent control object. Determinare gli altri oggetti interni. Determinare collaborazione tra gli oggetti. Determinare la esecuzione dello statechart. Considerare le sequenze alternative. Dynamic Analysis Dipendente Dallo Stato Perche` e` importante costruire insieme il collaboration diagrams e lo statechart? Un evento nel collaboration diagram deve essere consistente con lo stesso nello statechart. Dynamic Analysis Dipendente Dallo Stato La costruzione del collaboration diagram e dello statechart e` iterativa. Ogni evento di input e di output deve essere considerato in sequenza. Determinare attivita` e azioni. Determinare i messaggi generati dagli oggetti. Mostrare gli eventi esterni e le sottosequenze di eventi interni sia nello statechart che nel collaboration diagram. Dynamic Analysis Dipendente Dallo Stato Per completare la Dynamic Analysis è necessario controllare che: Lo statechart sia guidato da ogni stato e da ogni transizione almeno una volta Ogni azione e ogni attivita` sia eseguita almeno una volta. Banking System Collaboration Diagram:Valid PIN <<external I/O Device>> :CardReader 1:Card Reader Input <<I/O device interface>> :Card Reader Interface 2:PIN Input 2.2:Card Data <<subsystem>> :BankServer 2.5 Validate PIN (Customer Info) 1.1:Card Input Data <<entity>> :ATMCard 1.4:PIN Prompt 2.8:Selection Menu 1.2:Card Inserted 2.1:Card Request 2.6[Valid]: Valid PIN <<state dependent control>> :ATMControl 2.4:PIN Entered (Customer Info) 1.3:GetPIN 2.7Display Menu 2.7a: UpdateStatus <<entity>> :ATMTransaction <<user interface>> :CustomerInterface 2.3:Customer Info Banking System Idle Waiting for Pin 1.2:Card Inserted/ 1.3:Get PIN 2.4:PIN Entered/ 2.5:Validate PIN Validating Pin 2.6:Valid PIN/ 2.7:Display Menu, 2.7a:Update Status Waiting for Customer Choice Entry/Display Welcome Banking System Collaboration Diagram:Invalid PIN <<external I/O Device>> :CardReader <<I/O device interface>> :Card Reader Interface 1 1.2 2.5,2.6A.8: Validate PIN (Customer Info) 1.1 2.4,2.6A.7 :PIN Entered (Customer Info) <<entity>> :ATMCard 2.2,2.6A.5 :Card Data 1.4 2.6A.2:Invalid PIN Prompt 2.8 2,2.6A.3:PIN Input <<subsystem>> :BankServer 2.1,2.6a.4 :Card Request 2.6A*[Invalid] Invalid PIN 2.6[Valid]: Valid PIN <<state dependent control>> :ATMControl 1.3,2.7 2.6A.1:Invalid PIN Prompt 2.6A.1a,2.7a: UpdateStatus <<entity>> :ATMTransaction <<user interface>> :CustomerInterface 2.3,2.6A.6 :Customer Info Banking System Collaboration Diagram:Third Invalid PIN <<external I/O Device>> :CardReader 1 2.6B.2: Confiscate Card <<I/O device interface>> :Card Reader Interface <<subsystem>> :BankServer 1.2 1.1 <<entity>> :ATMCard 2.2,2.6A.5 2.5,2.6A.8: 2.6B.1: Confiscate 2.1,2.6A.4 2.4,2.6A.7 2.6A*[Invalid] 2.6B[Third Invalid]:Third Invalid PIN <<state dependent control>> :ATMControl 1.3,2.6A.1,2.7 2.6A.1a,2.7a 1.4, 2.6A.2, 2.8 <<entity>> :ATMTransaction <<user interface>> :CustomerInterface 2,2.6A.3 2.3,2.6A.6 Banking System Collaboration Diagram:stolen or expired card <<external I/O Device>> :CardReader 1 2.6C.2: Confiscate Card <<I/O device interface>> :Card Reader Interface <<subsystem>> :BankServer 1.2 1.1 <<entity>> :ATMCard 2.2,2.6A.5 2.5,2.6A.8: 2.6C.1: Confiscate 2.1,2.6A.4 2.4,2.6A.7 2.6C[Stolen OR Expired]: Card Stolen, Card Expired <<state dependent control>> :ATMControl 1.3,2.6A.1,2.7 2.6A.1a,2.7a 1.4, 2.6A.2, 2.8 <<entity>> :ATMTransaction <<user interface>> :CustomerInterface 2,2.6A.3 2.3,2.6A.6 Banking System 1.2:Card Inserted/ 1.3:Get PIN Idle Entry/Display Welcome Waiting for Pin 2.4,2.6A.7:PIN Entered/ 2.5,2.6A.8:Validate PIN 2.6A:invalid PIN/ 2.6A.1:Invalid PIN Prompt, 2.6A.1a:Update Status 2.6B:Third Invalid PIN 2.6C:Card Stolen, Card Expired/ 2.6B.1,2.6C.1:Confiscate 2.6B.1a,2.6C1.a:Update Status Validating Pin Confiscating 2.6:Valid PIN/ 2.7:Display Menu, 2.7a:Update Stauts Waiting for Customer Choice 2A.1:Cancel/ 2A.2:Eject, 2A.2:Display Cancel Ejecting Cruise Control Collaboration Diagram:Accel event <<external input device>> :CruiseControlLever C1:Accel Input <<algorithm>> :Acceleration C1.5 Throttle Value C1.2: Enable Increase Speed <<input device interface>> :CruiseControl LeverInterface C1.1:Accel <<state dependent control>> :CruiseControl C1.4 Current Speed Value <<entity>> :CurrentSpeed C1.3:Read <<output device interface>> :ThrottleInterface <<external output device>> :Throttle C1.6:Throttle Position Cruise Control Engine On/ Clear Desired Speed Initial C1.2 Do/Increase Speed Cruising Off Idle C1.1:Accel [Brake Off] Accelerating Engine Off Cruise/Select Desired Speed Resuming Resume [Brake Off] Do/Resume Cruising Reached Cruising Cruising Do/Maintain Speed Brake Pressed Cruise Control Collaboration Diagram:Cruise event <<external input device>> :CruiseControlLever C2:Cruise Input C2.2:Disable Increase Control <<algorithm>> :Acceleration <<entity>> :Desired Speed C2.5:Current Speed Value C2.4:Read <<entity>> :CurrentSpeed C2.3 Select Desired Speed C2.7:Read C2.8:Desired Speed Value C2.9:Read C2.10:Current Speed Value <<input device interface>> :CruiseControl LeverInterface C2.1:Cruise <<state dependent control>> :CruiseControl C2.6:Enable Maintain Speed <<algorithm>> :Cruiser C2.11:Throttle Value <<output device interface>> :ThrottleInterface Cruise Control Engine On/ Clear Desired Speed Engine Off Initial Accel [Brake Off] Accelerating Cruising Off Idle Resuming Do/Resume Cruising C2.1:Cruise/ C2.3:Select Desired Speed C2.2 Do/Increase Speed Resume [Brake Off] Reached Cruising Cruising C2.6 Do/Maintain Speed Brake Pressed Cruise Control Collaboration Diagram:Brake event C3:Brake Input <<input device interface>> :BrakeInterface <<external input device>> :Brake C3.2:Disable Maintain Speed <<algorithm>> :Cruiser C3.3 Throttle Value <<output device interface>> :ThrottleInterface C3.1:Brake Pressed <<state dependent control>> :CruiseControl Cruise Control Engine On/ Clear Desired Speed Initial Do/Increase Speed Cruising Off Idle Accel [Brake Off] Accelerating Engine Off Cruise/ Select Desired Speed Resuming Resume [Brake Off] Do/Resume Cruising Reached Cruising Cruising C3.2 Do/Maintain Speed C3.1:Brake Pressed Cruise Control Engine On/ Clear Desired Speed Engine Off Initial C1.1Accel [Brake Off] Accelerating Cruising Off Idle Resuming C4.2,C4.10 Do/Resume Cruising C2.1:Cruise/ C2.3:Select Desired Speed C1.2,C2.2 Do/Increase Speed C4.1:Resume [Brake Off] C4.9:Reached Cruising Cruising C2.6,C3.2,C4.11 Do/Maintain Speed C3.1:Brake Pressed