02291: System Integration Components (part II) Hubert Baumeister - - PowerPoint PPT Presentation
02291: System Integration Components (part II) Hubert Baumeister - - PowerPoint PPT Presentation
02291: System Integration Components (part II) Hubert Baumeister huba@dtu.dk DTU Compute Technical University of Denmark Spring 2020 Problem for the connection of components BankATM verifyPIN verifyPIN withdraw Clearing Bank ATM
Problem for the connection of components
pinNotOK pinOk verifyPIN verifyPIN withdraw pinOk pinNotOK withdrawOK withdrawNotOk
Company Clearing− Bank ATM BC BankATM AB CB BA
Interconnecting Components: What can go wrong?
- 1. message sent but not understood
- 2. message sent but component is not ready to receive
- 3. component waits for a message not sent
◮ . . .
Solution for 1: Interfaces
Port AB Bank Clearing Company ATM Port BC Port BA Provided Interface by port AB Required Interface by port BA Provided Interface by port BA Required Interface by port AB Bank ATM <<interface>> AtmToBank pinOK pinNotOK withdrawOk withdrawNotOk <<interface>> BankToAtm verifyPIN(iban:IBAN, pin:int) withdraw(iban, amount:Money)
Solution for 2+3: Protocol state machines
Protocol state machine ◮ Associated to provided interfaces of a port ◮ Sending messages to the required interface ◮ [post] usually [ˆm] meaning: A message m has been sent to the required interface
s2 s1 [pre] operation / [post]
Behavioural state machine
s2 s1
- peration [guard] / action
Solution for 2+3: Protocol state machines
Protocol for the interface BankToAtm which is the provided interface of PortBA and the required interface of PortAB
withdrawing withdraw verifying idle sm: BankToAtm {protocol} /[^pinNotOk] /[^withdrawOk] /[^withdrawNoOk] withdraw(i,a) /[^pinOk] verifyPin(p)
Protocol for interface AtmToBank which is the provided interface of PortAB and the required interface of portBA
waiting AtmToBank {protocol} Idle pinOk pinNotOk /[^verifyPin]
Protocol state machines
Protocol for the interface BankToAtm which is the provided interface of PortBA and the required interface of PortAB
withdrawing withdraw verifying idle sm: BankToAtm {protocol} /[^pinNotOk] /[^withdrawOk] /[^withdrawNoOk] withdraw(i,a) /[^pinOk] verifyPin(p)
Protocol for interface AtmToBank which is the provided interface of PortAB and the required interface of portBA
waiting AtmToBank {protocol} Idle Withdraw pinNotOk /[^verifyPin] pinOk/[^withdraw(i,a)] withdrawNotOk withdrawOk
Exercise: Bank to Clearing Company
Port AB Bank Clearing Company ATM Port BC Port BA Provided Interface by port AB Required Interface by port BA Provided Interface by port BA Required Interface by port AB
«interface» CcToBank verifyPin(p) «interface» BankToCc pinOk pinNotOk
What are the two PSM’s for the two interfaces?
PSM’s CcToBank and BankToCc
«interface» CcToBank verifyPin(p) «interface» BankToCc pinOk pinNotOk
Implementing components by components
UML User Manual, Grady Booch
Bank component showing Implementation by classes
Bank Bank Customer Account ClearingCompanyToBank BankToAtm
*
«delegate» «delegate» * BankToATMPort «delegate» BankToClearingCompany AtmToBank «delegate»
Detailed Class Diagram for the Bank Component
Port BC Port BA <<interface>> BankToClearingCompany pinOK pinNotOk <<interface>> ClearingCompanyToBank verifyPIN(a,p) <<interface>> BankToAtm verifyPIN(a,p) withdraw(a,m) BankToATMPort verifyPIN(a,p) withdraw(a,m) pinOK pinNotOk Account number : IBAN balance : int withdraw(amount:int): bool ... Customer name address ... <<interface>> AtmToBank pinOK pinNotOK withdrawOk withdrawNotOk Bank name: String ... pinOK pinNotOk accountFor(a): Account ... 1 atm * 1 b * c * 1..* 1..* 1 cc
Behaviour implementation
Lifecycle state machine BankToATMPort
withdrawing waiting for withdraw verifying idle sm: BankToATMPort withdrawOk/atm.withdrawOK withdrawNotOk/atm.withdrawNotOk widthdraw(a,m)/b.withdraw(self,a,m) pinOK/atm.pinOK pinNotOk/atm.pinNotOk verifyPin(a,p)/b.verifyPin(self,ap,p)
Lifecycle state machine Bank
waiting for withdraw withdrawing waiting for verification verifying idle sm: Bank pinOK/p.pinOK [wok]/p.widthdrawOk [else]/p.withdrawNotOk withdraw(p,a1,m)[not(a1=a)]/p.withdrawNotOk withdraw(p,a1,m)[a1=a]/acc := accountFor(a1); wok := acc.withdraw(m) pinNoOk/p.pinNotOk [else]/p.pinNotOk [c.account->exists(nbr-a)]/cc.verifyPin(a,pin) verifyPin(p,a,pin)
Account number balance withdraw .. Customer name address .. ClearingCompany verifyPin Bank verifyPin pinOk pinNotOk withdraw withdrawOk withdrawNotOk
- accountFor
BankToAtmPort verifyPin pinOk pinNotOk withdraw withdrawOk withdrawNotOk * *
LSM conformance with PSM
Protocol for provided interface of the port Bank to ATM
withdrawing withdraw verifying idle sm: BankToAtm {protocol} /[^pinNotOk] /[^withdrawOk] /[^withdrawNoOk] withdraw(i,a) /[^pinOk] verifyPin(p)
BankToAtmPort lifecycle state machines
withdrawing waiting for withdraw verifying idle sm: BankToATMPort withdrawOk/atm.withdrawOK withdrawNotOk/atm.withdrawNotOk widthdraw(a,m)/b.withdraw(self,a,m) pinOK/atm.pinOK pinNotOk/atm.pinNotOk verifyPin(a,p)/b.verifyPin(self,ap,p)
«interface» AtmToBank pinOk pinNotOk withdrawOk withdrawNotOk BankToAtmPort verifyPin pinOk pinNotOk withdraw withdrawOk withdrawNotOk «interface» BankToAtm verifyPin withdraw