7/29/2019 Capsule Structure
1/26
Developing Real-Time Software with
Rational Rose RealTimeVersion 2001A.04.00
Module 10: Capsule Structure: Ports, Protocols,
and Sub-capsules
7/29/2019 Capsule Structure
2/26
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00
Copyright 2001 Rational Software, all rights reserved
Ports, Protocols, and Components Topics
Capsule Interfaces
Ports
Protocol Classes
Capsule Structure
7/29/2019 Capsule Structure
3/26
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00
Copyright 2001 Rational Software, all rights reserved
The Encapsulation Shell
Abstracts the functionality of the capsule
Keeps changes within the capsule fromaffecting elements that interact with it
Protects objects it contains
7/29/2019 Capsule Structure
4/26
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00
Copyright 2001 Rational Software, all rights reserved
Capsule Interfaces
A capsules interface is completely defined
by its ports.
Ports
7/29/2019 Capsule Structure
5/26
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00
Copyright 2001 Rational Software, all rights reserved
Ports, Protocols, and Components Topics
Capsule Interfaces
Ports
Protocol Classes
Capsule Structure
7/29/2019 Capsule Structure
6/26
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00
Copyright 2001 Rational Software, all rights reserved
Ports
Capsules communicate by sending and receiving
messages through ports A port can only send and receive specific sets of
messages
Defined by a protocol class
Stimulus
message
Response
messages
7/29/2019 Capsule Structure
7/26
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00
Copyright 2001 Rational Software, all rights reserved
Ports (cont.)
Ports are interface elements between a
capsules structure and behavior Ports have a composition relationship with
the capsule they serve
Ports are created and destroyed along with thecapsule that owns them
7/29/2019 Capsule Structure
8/26
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00
Copyright 2001 Rational Software, all rights reserved
Ports: Port Compatibility
Only ports with compatible protocols can
communicate with each other Two ports are compatible if they are of the
same protocol or subclass
In order for two ports to be connected, theymust be opposite in conjugation
Base port
Conjugated port
7/29/2019 Capsule Structure
9/26
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00
Copyright 2001 Rational Software, all rights reserved
Ports: Port Termination
End ports: terminate
connectors; delivermessages from acapsules structureto capsulesbehavior, and viceversa
Relay ports: relaymessages to/from asubcapsule to acapsule outside itscontainer
Relay PortContained
Capsule RoleContaining
Capsule
Boundary
End Port
7/29/2019 Capsule Structure
10/26
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00
Copyright 2001 Rational Software, all rights reserved
Ports: Wired vs. Unwired Ports (Java)
Wired ports: use
connectors to set upmessage channelsExplicit visible
associations
Unwired ports: usename binding to setup message channelsNo connectors used
Dynamic connectionsMechanism used with
Connexis
Unwired port Wired ports
7/29/2019 Capsule Structure
11/26
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00
Copyright 2001 Rational Software, all rights reserved
Ports: Port Visibility (Java)
Public ports: define a
capsules externalinterfaceAppear on capsules
boundary in a structurediagram
Use UML + in the name
Protected ports: connecta capsule to itssubcapsules Not accessible from outside
a capsule, unless published
Use UML # in the nameProtected port
Public port
7/29/2019 Capsule Structure
12/26
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00
Copyright 2001 Rational Software, all rights reserved
Ports, Protocols, and Components Topics
Capsule Interfaces
Ports
Protocol Classes
Capsule Structure
7/29/2019 Capsule Structure
13/26
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00
Copyright 2001 Rational Software, all rights reserved
Protocol Class
Specifies which messages can be sent to and
received from a port A message is defined by a named signal and any
optional data
Protocol
Class
DeviceControl
isOn (void)
isOff (void)
turnOn (void)
turnOff (void)
7/29/2019 Capsule Structure
14/26
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00
Copyright 2001 Rational Software, all rights reserved
Protocol Classes: Contractual Interaction Patterns
Protocol classes act as a contract
between capsules, specifying whatmessages can be sent between them
Example: operator-assisted call
time
call
ack
number
ringBack
Caller Operator
connected
7/29/2019 Capsule Structure
15/26
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00
Copyright 2001 Rational Software, all rights reserved
Protocol Roles
A protocol class specifies the communication
patterns between capsules, viewed from either endof the connection.
The protocol role represents only a single view(base orconjugate), specifying which messages
can be sent to and received by that specific porttype
The protocol role of the port determines whichsignals are incoming and outgoing
Two ports must realize compatible protocols topermit a connector to be established betweenthem
7/29/2019 Capsule Structure
16/26
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00
Copyright 2001 Rational Software, all rights reserved
Protocol Roles: Example
Aprotocol role specifies the protocol from
the perspective of one partyOne protocol definition
defines two roles:
Base Conjugate
significant sequence
caller operator
call
ack
number
ringBack
connected
ProtocolRoleB
ack (void)
ringBack (void)
connected (void)
call (void)
number (void)
ProtocolRoleA
call (void)
number (void)
ack (void)
ringBack (void)
connected (void)
Base Protocol Role Conjugate Protocol Role
7/29/2019 Capsule Structure
17/26
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00
Copyright 2001 Rational Software, all rights reserved
Defining Protocols
Protocols capture the interactions related to each
role a capsule plays in its collaborations
Capsules that playsimilar roles may reuseprotocol definitions
Protocols should not beoverloaded and shouldhave a clear purpose: Capture a complete
message dialog betweencollaborating capsules
7/29/2019 Capsule Structure
18/26
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00
Copyright 2001 Rational Software, all rights reserved
Ports, Protocols, and Components Topics
Capsule Interfaces
Ports
Protocol Classes
Capsule Structure
7/29/2019 Capsule Structure
19/26
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00
Copyright 2001 Rational Software, all rights reserved
Capsule Structure
Capsules contain
componentelements:
Subcapsules
Passive classesPorts
Connectors
7/29/2019 Capsule Structure
20/26
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00
Copyright 2001 Rational Software, all rights reserved
Structure Diagram
A specialized form of the collaboration
diagram Specifies the capsule's interface and its
internal composition
Ports
Connector
Capsule
Subcapsule
7/29/2019 Capsule Structure
21/26
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00
Copyright 2001 Rational Software, all rights reserved
Connectors
Objects that show key communication
relationships between capsulesConnect ports that play complementary roles in
the protocol they are associated with
Can connect ports associated with differentprotocols if the ports are conjugate and theprotocols have compatible in- and out-signals.
Connector
7/29/2019 Capsule Structure
22/26
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00
Copyright 2001 Rational Software, all rights reserved
Collaboration Diagram to Structure Diagram
A structure diagram is a more specialized
form of collaboration diagram.
Collaboration Diagram
Structure Diagram
7/29/2019 Capsule Structure
23/26
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00
Copyright 2001 Rational Software, all rights reserved
Showing Structure in a Class Diagram
A class diagram provides more detailed
system decomposition
Structure Diagram
TheSystem
Client
+ / link : Link
Server
+ / link : Link~
Link
response (void)
command (void)
+ / link
+ / link~
/ server/ client
Class Diagram
/ client: Client
/ server: Server
+ / link
: Link
+ / link
: Link~
7/29/2019 Capsule Structure
24/26
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00
Copyright 2001 Rational Software, all rights reserved
Review: Designing Ports and Protocols
Why are ports used to connect capsules?
Why must connected end ports beopposite in conjugation?
Why use a class diagram instead of a
structure diagram?
L T D i
7/29/2019 Capsule Structure
25/26
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00
Copyright 2001 Rational Software, all rights reserved
Low Temp Dyeing
Controller Tank
fill
drain
level
start
Operator
done
The Dying System
Dyeing
Level
Filling EmptyDraining
Time
7/29/2019 Capsule Structure
26/26
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00
Copyright 2001 Rational Software all rights reserved