• No results found

Architecture & Design of Embedded Real-Time Systems (TI-AREM)

N/A
N/A
Protected

Academic year: 2021

Share "Architecture & Design of Embedded Real-Time Systems (TI-AREM)"

Copied!
40
0
0

Loading.... (view fulltext now)

Full text

(1)

Architectural Design Patterns 2.

Components & Connectors and

Component Architecture Patterns and

UML 2.0 Ports

(BPD. Chapter 4. p. 184-201)

Architecture & Design of

Embedded Real-Time

(2)

Slide 2

Agenda

• Component Notation

• Component-based architecture Pattern

• Component & Connectors

• ROOM Pattern

(3)

UML Component Notation (1)

MyInterface

Provided

interface

An interface:

defines operation signatures

(name, parameters and return type)

«component»

Component

Required

interface

(4)

Slide 4

UML Component Notation (2)

OrderEntry

«component»

Order

Person

«component»

Order

«Interface»

Person

+create()

+findByName()

+getDeatils()

«Interface»

OrderEntry

+create()

+validateDetails()

+addOrderline()

«use»

Detailed view

Compact view

(5)

Assembly

Connector

(6)

Slide 6

Component-Based Architecture

A component in UML is a run-time artifact

that forms the basic replaceable unit of

software

Component examples: static libraries,

dynamic link libraries (DLLs), OCX and

(7)
(8)

Slide 8

(9)
(10)

Slide 10

Component & Connectors

• Existing research has focused on

– Component structure

– Component Interfaces

– Component functionality

• More focus needed on component

interactions embodied in the notation of

(11)

Connectors

• Connector definition:

– ”Connectors mediates interactions among

components, that is, they establish the

rules that govern component interaction

and specify any auxiliary mechanism

required”

• Connectors should be

first-class

modeling constructs

• Ref. Article:

(12)

Slide 12

ROOM Pattern

ROOM (Real-Time Object-Oriented

Methodology).

The ROOM Pattern is appropriate when

the interaction of some large-scale

objects is complex and requires special

(13)
(14)

Slide 14

(15)

ROOM Ports (~UML Ports)

Master:

Comm Object

Slave:

Comm Object

iSender

iReceiver

(16)

Slide 16

(17)

UML 2.0 Ports

Ports

“The Ports subpackage provides mechanisms for

isolating a classifier from its environment

. This is

achieved by providing a point for conducting interactions

between the internals of the classifier and its

environment. This interaction point is referred to as a

“port.”

Multiple ports can be defined for a classifier, enabling

different interactions to be distinguished based on the

port through which they occur.

By decoupling the internals of the classifier from its

environment,

ports allow a classifier to be defined

independently of its environment

, making that classifier

reusable in any environment that conforms to the

(18)

Slide 18

New UML 2.0 Concepts for Classes

A

port

groups interfaces belonging to a particular

stakeholder. A port can have as well

provided

as

required interfaces

.

(19)

Example with Internal Structure

Black Box

View

White Box

View

Structured

Class

(20)

Slide 20

(21)

Example: Home Alarm System – version 1

h omeow ner h omeow ner intruder intruder

home alarm

vi a remo te d ete ct intrusio ns

o ccupation simu la tio n

<<e xte nd >>

code entry

<<inclu de>>

arming and di sarming

sound alarm

«extend»

via keypad

<<in clud e>> <<e xte nd >>

<<inclu de>>

«extend»

(22)

Slide 22

(23)

Home Alarm System – version 1

Hardwa rePkg

IHardwa re

«Int erface »

1

1

itsAlarmController

th eHardware

AlarmPkg

Alar mContro ller

« Facad e»

1

1

itsAlarmController

th eHardware

Without

Using

ports

(24)

Slide 24

AlarmController – a Composite Class

Alarm Controller

«Facade» theRedLed:Led 1 theGreenLed:Led 1 t heKey pad:Keypad 1 1 t heLightController:LightController

IHardware

«Interf ace»

setLight(aLight:tLights ,state:tOnOff):void

onArm():void

onDisarm():void

onKeyOff():void

onKeyOn():void

onKey(n:int):void

onMovement():void

onDoor():void

setLed(ident:tLed,s tate:tOnOff):void

setSiren(state:tOnO ff):void

1

1

itsAlarmController

theHardware

(25)

AlarmController State Diagram

off

/init();

armed

exiting

evTemporise

active

detecting

tm (EXIT_TIME)

silence

tm(SILENCE_TIME)

entering

evDoor

intrusion

evMovement

evMovement

tm(ENTRY_TIME)

tm(ALARM _TIME)

tm(SILENCE_TIME)

evDoor

evMovement

evMovement

tm(ENTRY_TIME)

tm(ALARM _TIME)

evArm

evDisarm

tm (EXIT_TIME)

tm(SILENCE_TIME)

evDoor

evMovement

evMovement

tm(ENTRY_TIME)

tm(ALARM _TIME)

(26)

Slide 26

AlarmController – Public Operations

AlarmController

«Facade»

configure(aHardware:IHardware*):void

AlarmController()

flashGreenLed():void

onArm():void

onDisarm():void

onDoor():void

onKey(n:int):void

onKeyOff():void

onKeyOn():void

onMovement():void

evArm():void

evMovement():void

evDoor():void

evTemporise():void

evDisarm():void

HardwarePkg::IHardware

«Interface»

setLight(aLight:tLights,state:t...

onArm():void

onDisarm():void

onKeyOff():void

onKeyOn():void

onKey(n:int):void

onMovement():void

onDoor():void

setLed(ident:tLed,state:tOnO...

setSiren(state:tOnOff):void

1

1

theHardware

itsAlarmController

(27)

Possible Hardware Implementations

TestPkg AlarmHw 68kPkg Hw AlarmHw 486Pkg Hw Irq Hw Poll IHardw are «Interf ace» onArm( ):void onDisarm():void onKeyOff() :void onKeyOn():void onKey( n:int):void onMovement():void onDoor ():void setLed(ident:tLed,state:tO... setSiren(state:tOnOff):void SimulatedHw Pkg guiDlg
(28)

Slide 28

Home Alarm – version 2 with Ports

• Ports are a new UML2.x modeling concept

that allows strong encapsulation of classes

from the environment.

• In this case, the Hardware and Alarm

Controller are decoupled by specifying ports

as their boundary interaction points.

(29)

Package Diagram

PORT:

hwObserver

With 3

provided

interface

PORT:

hwCtrl

With 3

required

interface

HardwarePkg Simu la te dHwPkg gui Dlg HwTe stPkg H w AbstractHW AbsHardware

ILedCt rl,ILight Ct rl,ISi ren Ctrl IK ey Li ste ne r,I Mo v emen tList ener, IDoorLi ste ne r

ctrl

AlarmPkg

AlarmCo ntro ller

«F acade»

IDoorListener,IKey Listener,IMov ementListener

hwOb serve r

ILedCtrl,ILightCtrl,ISirenCtrl

hwCtrl

(30)

Slide 30

Home Alarm – version 2 with Ports

Al arm Control ler

«F aca de»

th eGree nL ed :Le d

1

ILedCtrl

hw

th eL igh tController:LightC on trol ler

1

ILightC trl

hw

theKeypad:Keyp ad

1

theRedLed:Le d

1

IL edC trl

hw

theSiren :Siren Co ntroll er

1

IS iren Ctrl

hw

IDoorListener,IKey Listener,IMov ementListen er

hw Obse rve r

IL edC trl,IL igh tCtr l,ISi renC trl

hwC trl

PORT:

hwObserver

PORT:

(31)

Classes: KeyPad, SirenController, Led

Keypad

newCode:int

count:int

oldCode:int

Keypad()

isCodeCorrect():OMBoolean

isCodeEntered():OMBoolean

changeCode():void

evKeyOff():void

evKey():void

evKeyOn():void

SirenController

setSirenOn():void

setSirenOff():void

ISirenCtrl

hw

Led

Led()

evToggle():void

evFlash():void

evOn():void

evOff():void

ILedCtrl

hw

(32)

Slide 32

KeyPad – State Diagram

active

idle

[IS_IN(cor rect)]/

itsController- >GEN(evTemporise); evKeyOn

evKeyOff [IS_IN(cor rect)]/ itsController- >GEN(evDisarm) ; reprogramming w aitNew Code evKeyOn[IS_IN(different) ]/ changeCode(); w aitOldCode [else] [IS_IN(c orrect)] evKey On tm(10000) evKeyOff [IS_IN(notEntered) ] [IS_IN(c orrect)] evKey On armingDisarmingReprogr amming [else] evKeyOn[IS_IN(different) ]/ changeCode(); [IS_IN(cor rect)]/ itsController- >GEN(evTemporise); evKeyOn

evKeyOff [IS_IN(cor rect)]/ itsController- >GEN(evDisarm) ; tm(10000) evKeyOff [IS_IN(notEntered) ] [IS_IN(c orrect)] evKey On currentCode correct dif ferent notEntered tm(3000) tm(3000) [is CodeCorrect()] [else] tm(3000) tm(3000) enteringCode ev KeyOff tm(5000) evKey/

new Code = params->n; count=1;

evKey/

new Code = (10 * new Code ) + par ams ->n; c ount++; [isCodeEnter ed() ] codeEntry [is CodeCorrect()] [else] tm(3000) tm(3000) ev KeyOff tm(5000) evKey/

new Code = params->n; count=1;

evKey/

new Code = (10 * new Code ) + par ams ->n; c ount++; [isCodeEnter ed() ] [else] evKeyOn[IS_IN(different) ]/ changeCode(); [IS_IN(cor rect)]/ itsController- >GEN(evTemporise); evKeyOn

evKeyOff [IS_IN(cor rect)]/ itsController- >GEN(evDisarm) ; tm(10000) evKeyOff [IS_IN(notEntered) ] [IS_IN(c orrect)] evKey On [is CodeCorrect()] [else] tm(3000) tm(3000) ev KeyOff tm(5000) evKey/

new Code = params->n; count=1;

evKey/

new Code = (10 * new Code ) + par ams ->n; c ount++;

[isCodeEnter ed() ]

(33)

Test Configuration

theHW:Hw

1

ILedCtrl ,ILightCtrl,ISi renC trl

IKeyListener,IMovem entListene r,IDoorListener

c trl

theAlarm Ctrl:AlarmController

1

«Facade»

ILedC trl,ILightCtrl,ISirenCtrl

hwCtrl

IDoorListener,IKeyLis tener,IMovementListener

hwObs erver

(34)

Slide 34

Rhapsody Implementation of a Port (1)

PORT:

hwObserver

IDoorListener «Interface» onDoor():void IKeyListener «Interface» onKey(n:int):void onKeyOff():void onKeyOn():void onArm():void onDisarm():void IMovementListener «Interface» onMovement():void

IDoorListener, IKeyListener, IMovementListener

AlarmController

hwObserver_C::InBound_C

Auto generated

Port Class

(35)

Rhapsody Implementation of a Port (2)

PORT:

hwCtrl

ILedCtrl, ILIghtCtrl, ISirenCtrl

ILedCtrl

«Interface»

setLed(ident:tLed,state:tOnOff)...

ILightCtrl

«Interface»

setLight(aLight:tLights,stat...

ISirenCtrl

«Interface»

setSiren(state:tOnOff):void

Auto generated

AlarmController

(36)

Slide 36

Rhapsody Implementation of a Port (3)

PORT:

hwObserver

IDoorListener, IKeyListener,

IMovementListener

hwObserver_C

InBound_C

OutBound_C

x

IDoorListener

IKeyListener

IMovementListener

hwCtrl_C

InBound_C

OutBound_C

x

ILedCtrl

ILightCtrl

ISirenCtrl

PORT:

hwCtrl

ILedCtrl, ILIghtCtrl,

ISirenCtrl

(37)

Rhapsody Implementation of a Port (4)

theAlarmCrtl: AlarmController

hwCtrl: hwCtrl_C

hwObserver: hwObserver_C

InBound: InBound_C

OutBound: OutBound_C

theHW: Hw

ctrl:ctrl_C

InBound: InBound_C

OutBound: OutBound_C

(38)

Slide 38

Test Setup

AlarmController theAlarmCtrl;

Hw theHW;

theHW

.getCtrl()->setItsIKeyListener(

theAlarmCtrl

.

getHwObserver()

->getItsIKeyListener());

theHW.

getCtrl()->setItsIMovementListener(

theAlarmCtrl

.

getHwObserver()

->getItsIMovementListener());

theHW

.getCtrl()->setItsIDoorListener(

theAlarmCtrl

.

getHwObserver()

->getItsIDoorListener());

theAlarmCtrl

.getHwCtrl()->setItsILedCtrl(

theHW

.getCtrl()->getItsILedCtrl());

theAlarmCtrl

.getHwCtrl()->setItsILightCtrl(

theHW

.getCtrl()->getItsILightCtrl());

(39)

UML 2.0 Component Diagram

Gui

«Executable»

AlarmCtrlLib

HWAbsLib

<<Usage>>

<<Usage>>

(40)

Slide 40

Summary

Component patterns and ports:

Component-Based Architecture

ROOM Pattern (=>UML 2.x Ports)

References

Related documents