• Keine Ergebnisse gefunden

C ONCEPT OF T IME

Im Dokument UML Profile for Communicating Systems (Seite 170-175)

When specifying communication protocols, time concepts are essential in order to provide precise and complete specifications. Timers are used as a means to manipulate and control a communication protocol’s behavior and to verify time bounds and proper termination. The UML 2 features the SimpleTime concept but this does not cover the full needs for communication protocol specifications.

The SimpleTime package allows to start a timer implicitly and to wait until its timeout. This is accomplished using the expressions after for relative time bounds and at for absolute time. The unit for time value is usually specified informally.

For communication protocols it is necessary to start a timer independently from waiting on the timeout trigger. The timeout of a timer must be able to occur after several actions have been taken. The UML 2 profiles specified in [OMG05b, OMG05c] also introduce an own time concept which has a greater applicability than the basic UML 2 time concept. The [OMG05c] specifies a time concept for real time purposes, including features like skew, stability, drift, time zones and density. As its usage introduces high complexity and high requirements to simulators, validators and code generators a less exact time concept is used in this profile. It is inspired from the UML 2 testing profile specified in [OMG05b].

The following metaclasses of the UML are extended in this section: Signal, WriteStructuralFeatureAction and ReadStructuralFeatureAction.

Timer and Time Trigger

A timer is a pre-defined class and active objects can own the instances. An active class may own multiple instances. Pre-defined operations like set, reset and read are defined for the timer objects. For example, “set(timer1, now+2)” starts the timer instance timer1 and sets its expiration time to the current system time increased by two time units. When the system timer reaches this timeout value from the timer1, timer1 triggers a TimeEvent. With the reset() operation a timer can be stopped. When a timer is stopped a TimeEvent cannot be triggered. The active() operation allows to read the time when the timer is scheduled to timeout. It results a true Boolean value if the timer is currently scheduled to trigger a timeout signal. Following Figure 73 gives an overview of the extended metaclasses. A timer is a specialization of a signal with an association to the TimeExpression metaclass. The TimeExpression defines the timeout by a ValueSpecification. The timer’s attributes can be read and written by the appropriate StructuralFeatureActions.

7.6 Concept of Time

Figure 73: UML CS Profile Timer Concept

The recommended graphical notation for all timer related actions is an empty hourglass as shown in the following Figure 74, Figure 75 and Figure 76. The hourglass has one single incoming transition and one single outgoing transition. Alternatively, a textual notation is provided, e.g. in a task box.

7.6.1 Timer

The reception of a Timer is an event that can trigger transitions in the same fashion as a signal. A timer is initialized by a state machine. When a timeout is reached, the owning state machine can receive a timer signal. A time value is associated with an active timer which is the point of timeout.

UMLNODE TYPE UMLNOTATION REFERENCE

Signal <<timer>>

sampleTimer

13.3.23 Signal

UMLCSSTEREOTYPE UMLMETACLASS TAGGED VALUES

«timer» Signal (from Communications) timeout: Time

OCLCONSTRAINTS INFORMAL CONSTRAINTS

context Signal

inv: self.name->notEmpty()

Semantics

Similar to signals, a «timer» may have parameters. Therefore, this does allow setting of more than one timer of the same kind. It is not required to reset an already active timer. That is, several timers with different parameter values may be active at the same time.

The ownedAttribute attribute defines the parameters of the timer instance. The timeout tag definition defines the time when a timeout shall occur.

7.6.2 Timer Start

WriteStructuralFeatureAction is extended with the stereotype «setTimer» from the metaclass WRITESTRUCTURALFEATUREACTION (FROM STRUCTUREDACTIONS). «setTimer» is an action to start a timer with a defined value when a timeout occurs. A timeout does not occur if the given time is lower than current system time or if the timer is not running.

Textual Notation

<setTimer> ::= ‘set(’ <timer identifier> ‘,’ <time expression> ‘)’

<semicolon>

set(timer1, now+10);

set(timer1, now+10)

(a) Textual notation in a Task Box (b) Timer Expression Figure 74: Notations for Starting Timer inv: self.ownedOperation->isEmpty()

UMLNODE TYPE UMLNOTATION REFERENCE

WriteStructuralFeatureAction

set(timer1, timeoutValue)

11.3.54

WriteStructuralFeatureAction

UMLCSSTEREOTYPE UMLMETACLASS TAGGED VALUES

«setTimer» WriteStructuralFeatureAction (from StructuredActions)

timer: Timer

timeout: TimeExpression

OCLCONSTRAINTS INFORMAL CONSTRAINTS

timer and timeout are derived values from the StructuralFeature and the from the value property.

7.6 Concept of Time

Semantics

A process can own timers. A timer has a defined timeout expression that – when being equal to the current system time (now) – will trigger a timer signal to be sent to its owning process. The timer signal will be sent only once. The time when the timer fires a timer signal is specified in the timeout attribute. For relative time specification, the pre-defined expression now is available representing the current system time when execution is running.

The timer and timeout tag definitions define the timer and the value when a timeout shall occur.

7.6.3 Timer Status

The ReadStructuralFeatureAction is extended with the stereotype «timerActive» from the metaclass READSTRUCTURALFEATUREACTION (FROM STRUCTUREDACTIONS). When being executed

«timerActive» is an action that obtains the status of timeout time of the specified timer when the timeout occurs. If the result is that the timer is currently active and a timeout is scheduled to occur, it writes a true value to the given structural feature. If one of the conditions is not satisfied, it writes a false Boolean value.

Textual Notation

«active» ::= ‘active(’ <timer identifier> ‘)’ <semicolon>

isActive:=active(timer1);

isactive:=active(timer1);

(a) Timer Expression (b) Textual notation in a Task Box Figure 75: Notations for Reading Timer’s Status

Semantics

A timer can be tested if it is active. Active means that a timer has been started and that the timer event has not yet occurred. In addition, its timeout expression is greater or equal than the current time (now).

UMLNODE TYPE UMLNOTATION REFERENCE

ReadStructuralFeatureAction

isactive:=active(timer1);

11.3.36

ReadStructuralFeatureAction

UMLCSSTEREOTYPE UMLMETACLASS TAGGED VALUES

«timerActive» ReadStructuralFeatureAction (from StructuredActions) timer: Timer

OCLCONSTRAINTS INFORMAL CONSTRAINTS

The timer tagged value is derived from the

StructuralFeature property.

If the timer object is active, the stereotype reads a true value, otherwise a false value. The timer tag definition defines the timer that is to be read. The result attribute defines the target variable or pin.

7.6.4 Timer Reset

The WriteStructuralFeatureAction is extended with the stereotype «resetTimer» from the metaclass WRITESTRUCTURALFEATUREACTION (FROM STRUCTUREDACTIONS). «resetTimer» is an action to stop a running timer. If the timer is not running, it does nothing.

Textual Notation

«resetTimer» ::= ‘reset(’ <timer identifier> ‘)’ <semicolon>

reset(timer1);

reset(timer1)

(a) Textual notation in a Task Box (b) Timer Expression Figure 76: Notation for Resetting Timer

Semantics

A timer can be stopped by re-setting it. If a timer is stopped, a time event caused by this timer does not occur until it is re-started. The timer tag definition defines the timer that is to be re-setted.

UMLNODE TYPE UMLNOTATION REFERENCE

WriteStructuralFeatureAction

reset(timer1)

11.3.26

WriteStructuralFeatureAction

UMLCSSTEREOTYPE UMLMETACLASS TAGGED VALUES

«resetTimer» WriteStructuralFeatureAction (from StructuredActions) timer: Timer

OCLCONSTRAINTS INFORMAL CONSTRAINTS

The timer tagged value is derived from the

StructuralFeature property.

Im Dokument UML Profile for Communicating Systems (Seite 170-175)