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.
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 Dynamic Analysis Non Dipendente Dallo Stato
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 > :Operator Interface > :Workstation StatusServer V1.2:Workstation Data V1.1:Worksation Status Request > : FactoryOperator V1:Operator Request V1.3:Displayed Info Message Sequence Description
View Workstation Status è un semplice esempio di uno use case client/server. E’ composto semplicemente da due oggetti: Un oggetto client (Operator Request) Un oggetto server (Workstation Status Server) View Workstation Status
La message sequence description è la seguente: V1:The operator requests a workstation status sevice – for example, to view the status of a factory worksation. V1.1:Operator Interface object sends a workstationstatus request to the Workstation Status Server. V1.2:Workstation Status Server responds – for example, with the requested workstation status data. V1.3:Operator Interface object displays the workstation status information to the operator. View Workstation Status Message Sequence Description
Dynamic Analysis Dipendente Dallo Stato Riguarda la interazione tra oggetti che partecipano a use-case dipendenti dallo stato.use-case dipendenti dallo stato Vedremo due esempi: Validate PIN. Validate PIN Cruise Control. Cruise Control
Use-case Dipendenti Dallo Stato Definizione: uno use-case dipendente dallo stato e` uno use-case in cui l`output non dipende solo dallo input dell`attore, ma anche da cosa e` precedentemente accaduto nel sistema.
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
Dynamic Analysis Approfondimento Messaggio: evento + dati riguardanti lo evento (attributi del messaggio). In genere, si parla di messaggi per gli interaction diagram e di eventi per gli statechart. Quando si descrive uno scenario dipendente dallo stato si usa il termine evento
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? Dynamic Analysis Dipendente Dallo Stato Un evento nel collaboration diagram deve essere consistente con lo stesso nello statechart.
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.
2.5 Validate PIN (Customer Info) 2.4:PIN Entered (Customer Info) 2.3:Customer Info 2.7a: UpdateStatus Banking System <<external I/O Device>> :CardReader > :BankServer <<state dependent control>> :ATMControl > :ATMTransaction 1.2:Card Inserted 2.6[Valid]: Valid PIN > :CustomerInterface > :ATMCard <<I/O device interface>> :Card Reader Interface 1.3:GetPIN 2.7Display Menu 2.1:Card Request 2.2:Card Data 1.1:Card Input Data 1 :Card Reader Input 1.4:PIN Prompt 2.8:Selection Menu 2:PIN Input Collaboration Diagram:Valid PIN
La message sequence description corrispondente è: 1:The ATM Customer actor inserts the ATM card into the Card Reader. The card input is read by the Card Reader Interface Object. 1.1:The Card Reader Interface sends tha Card Input Data, containing Card ID and Expiration Date to the entity object ATM Card. 1.2:Card Reader Interface sends the Card Inserted event to ATM Control. This results in transition to the ATM Control statechart from Idle state to Waiting for PIN state.The action associated with the transaction is Get PIN. Banking System Message Sequence Description
1.3: ATM Control sends the Get PIN to Customer Interface. 1.4:Customer Inerface displays the Pin Prompt to the ATM Customer actor 2: ATM Customer inputs the PIN number to the Customer Interface object. 2.1:Customer Interface requests Card Data from ATM Card. 2.2:ATM Card provides the Card Data to the Customer Interface. Banking System Message Sequence Description
2.3:Customer Interface sends the Customer Info, containing Card ID,PIN,Expiration Data,to the ATMranasction entity object. 2.4:Customer Interface sends the PIN Entered (Customer Info) event to ATM Control.This causes ATM Control to transition from Waiting for PIN state to Validating PIN state. The output event associated with this transaction is Validate PIN. 2.5:ATM Control sends a Validate PIN (Customer Info) request to the Bank Server. Banking System Message Sequence Description
2.6:Bank Server validates the PIN and sends a Valid PIN response to ATM Control.Because of this event, ATM Control transitions to Waiting for Customer Choice state. Two outputs events are associated with this transiction, as described next. 2.7:ATM Control sends the Display Menu event to the Customer Interface. 2.7a:ATM Customer sends an Update Status message to the ATM Transaction. 2.8:Customer Interface displays a menu showing the Withdraw, Query, and Transfer options to the ATM Customer actor Banking System Message Sequence Description
Idle Entry/Display Welcome Waiting for Pin Validating Pin Waiting for Customer Choice 1.2:Card Inserted/ 1.3:Get PIN 2.4:PIN Entered/ 2.5:Validate PIN 2.6:Valid PIN/ 2.7:Display Menu, 2.7a:Update Status Banking System
2.5,2.6A.8: Validate PIN (Customer Info) 2.6A.1a,2.7a: UpdateStatus 2.4,2.6A.7 :PIN Entered (Customer Info) 2.3,2.6A.6 :Customer Info <<external I/O Device>> :CardReader > :BankServer <<state dependent control>> :ATMControl > :ATMTransaction A * [Invalid] Invalid PIN 2.6[Valid]: Valid PIN > :CustomerInterface > :ATMCard <<I/O device interface>> :Card Reader Interface 1.3, ,2.6A.5 :Card Data 1.1 2,2.6A.3:PIN Input 1 2.6A.1:Invalid PIN Prompt A.2:Invalid PIN Prompt ,2.6a.4 :Card Request Banking System Collaboration Diagram:Invalid PIN
2.5,2.6A.8: 2.6A.1a,2.7a 2.4,2.6A.7 2.3,2.6A.6 <<external I/O Device>> :CardReader > :BankServer <<state dependent control>> :ATMControl > :ATMTransaction A * [Invalid] 2.6B[Third Invalid]:Third Invalid PIN > :CustomerInterface > :ATMCard <<I/O device interface>> :Card Reader Interface 1.3,2.6A.1, ,2.6A.42.2,2.6A ,2.6A , 2.6A.2, B.1: Confiscate 2.6B.2: Confiscate Card Banking System Collaboration Diagram:Third Invalid PIN
2.5,2.6A.8: 2.6A.1a,2.7a 2.4,2.6A.7 2.3,2.6A.6 <<external I/O Device>> :CardReader > :BankServer <<state dependent control>> :ATMControl > :ATMTransaction C[Stolen OR Expired]: Card Stolen, Card Expired > :CustomerInterface > :ATMCard <<I/O device interface>> :Card Reader Interface 1.3,2.6A.1, ,2.6A.42.2,2.6A ,2.6A , 2.6A.2, C.1: Confiscate 2.6C.2: Confiscate Card Banking System Collaboration Diagram:stolen or expired card
1.2:Card Inserted/ 1.3:Get PIN 2.4,2.6A.7:PIN Entered/ 2.5,2.6A.8:Validate PIN 2.6:Valid PIN/ 2.7:Display Menu, 2.7a:Update Stauts 2A.1:Cancel/ 2A.2:Eject, 2A.2:Display Cancel 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 Idle Entry/Display Welcome Waiting for Pin Validating Pin Waiting for Customer Choice Confiscating Ejecting 2.6A:invalid PIN/ 2.6A.1:Invalid PIN Prompt, 2.6A.1a:Update Status Banking System
Cruise Control > :CruiseControl LeverInterface > :CruiseControlLever > :CurrentSpeed > :Acceleration > :CruiseControl > :ThrottleInterface > :Throttle C1:Accel Input C1.1:Accel C1.2: Enable Increase Speed C1.6:Throttle Position C1.3:Read C1.4 Current Speed Value C1.5 Throttle Value Collaboration Diagram:Accel event
Cruising Do/Maintain Speed Initial Accelerating C1.2 Do/Increase Speed Resuming Do/Resume Cruising Idle Engine On/ Clear Desired Speed Engine Off C1.1:Accel [Brake Off] Cruise/Select Desired Speed Reached Cruising Brake Pressed Resume [Brake Off] Cruising Off Cruise Control
> :Cruiser C2:Cruise Input C2.1:Cruise > :CurrentSpeed > :CruiseControl > :ThrottleInterface > :CruiseControl LeverInterface > :Desired Speed > :Acceleration > :CruiseControlLever C2.2:Disable Increase Control C2.3 Select Desired Speed C2.6:Enable Maintain Speed C2.7:Read C2.8:Desired Speed Value C2.9:Read C2.10:Current Speed Value C2.4:Read C2.5:Current Speed Value C2.11:Throttle Value Cruise Control Collaboration Diagram:Cruise event
Cruising C2.6 Do/Maintain Speed Initial Accelerating C2.2 Do/Increase Speed Resuming Do/Resume Cruising Idle Engine On/ Clear Desired Speed Engine Off Accel [Brake Off] C2.1:Cruise/ C2.3:Select Desired Speed Reached Cruising Brake Pressed Resume [Brake Off] Cruising Off Cruise Control
> :BrakeInterface > :Brake > :Cruiser > :CruiseControl > :ThrottleInterface C3:Brake Input C3.1:Brake Pressed C3.2:Disable Maintain Speed C3.3 Throttle Value Collaboration Diagram:Brake event
Cruising C3.2 Do/Maintain Speed Initial Resuming Do/Resume Cruising Idle Engine On/ Clear Desired Speed Engine Off Accel [Brake Off] Accelerating Do/Increase Speed Cruise/ Select Desired Speed Reached Cruising C3.1:Brake Pressed Resume [Brake Off] Cruising Off Cruise Control
Cruising C2.6,C3.2,C4.11 Do/Maintain Speed Initial Resuming C4.2,C4.10 Do/Resume Cruising Idle Engine On/ Clear Desired Speed Engine Off C1.1Accel [Brake Off] Accelerating C1.2,C2.2 Do/Increase Speed C2.1:Cruise/ C2.3:Select Desired Speed C4.9:Reached Cruising C3.1:Brake Pressed C4.1:Resume [Brake Off] Cruising Off Cruise Control