Representing Embedded System Sequence Diagrams As A Formal Language
Representing Embedded System Sequence Diagrams As A Formal Language
1 Introduction
One of a designer’s toughest challenges is attaining the appropriate level of
abstraction. Include too little information, and a design is under-specified, often
resulting in an incorrect or incomplete implementation. Include too much information,
and the design is overly constrained or exceeds time-to-market allowances. Distributed,
embedded systems present particularly onerous design challenges, combining complex
behavior with a need for quick development cycles.
1
UML can be used to model a wide range of systems. To ensure that our results are
applicable to actual embedded systems, the problem space needs to be carefully defined.
Transaction processing systems are the traditional area of focus. Embedded systems
differ from the transaction processing paradigm in the following major ways:
· Timing sensitivity
Embedded system functionality may depend on temporal properties such as
duration, latency, and absolute time.
In this paper, we explore how to use UML sequence diagrams to support the needs of
embedded systems designers. First, we review methods for composing sequence
diagrams that support flexible embedded systems modeling. Then, we show how
determining required information content can be represented as a grammar parsing
problem to guarantee correct, cohesive diagrams. A generic approach is described, with
supporting embedded systems examples incorporating data, state, and timing
information. Finally, the more commonly discussed transaction processing model is
revisited to illustrate system differences.
A scenario describes a way to use a system to accomplish some function [5]. Scenarios
can be expressed in many forms, both textual and graphical, informal and formal. UML
supports two main ways of expressing scenarios: collaboration diagrams and sequence
2
diagrams. Sequence diagrams emphasize temporal ordering of events, whereas
collaboration diagrams focus on the structure of interactions between objects [7]. Each
may be readily translated into the other [7].
Our first objective is to refine a model that utilizes sequential, conditional, iterative,
and concurrent execution. As many ideas exist, our task is to determine which are
appropriate for embedded systems. [5] discusses a process for scenario analysis that
includes conditional branching. [12] presents three ways of composing scenarios:
sequential, alternative, and parallel. [2] includes iteration as well. [8] and [13] present a
tool that handles “algorithmic scenario diagrams” - sequence diagrams with sequential,
iterative, conditional and concurrent behavior. We use elements of each, for a combined
model that allows sequential, conditional, iterative, and concurrent behavior.
3
2.1.3 Finite State Machines and Statecharts
Finite state automata describe the possible states of a system and transitions between
these states. Unfortunately, properties of complex systems such as concurrent
execution of components lead to extremely large state machines that challenge human
comprehension. Statecharts were proposed by Harel [3] to control state explosion
problems with finite state machines by introducing the concepts of hierarchy and
orthogonal execution. The UML standard 1.3 defines a statechart as “a graph that
represents a state machine”, which is used to “represent the behavior of entities capable
of dynamic behavior by specifying its response to the receipt of event instances” [14].
Existing work has two shortcomings. First, sufficiency of information for generating
statecharts is not checked. Additional information is either absent or applied globally.
Our goal is to provide an approach by which a designer can include a minimum amount
of information, thereby reducing design time and guaranteeing a correct set of
statecharts. We present a methodology to verify sufficiency, by applying
well-established parsing theory.
Second, systems with all three embedded system qualities of multiple initial conditions,
mapping identical user actions to different system responses, and timing dependencies
have not been scrutinized. Systems that lack one of these three qualities generally do not
require additional information to produce correct statecharts; therefore, the sufficiency
question seems to have not arisen.
4
to define possible execution ordering. [15] discusses implications of repeated user
actions as a motivation for incorporating pre-conditions and post-conditions. [8]
annotates sequence diagrams with assertions, conditions guaranteed to be true at a
specified execution point. Timing intervals between messages are included in [10]. Our
examples examine these three categories, exposing situations where additional
information is needed for statechart synthesis, and situations where it is not.
A number of different systems have been explored and documented; however, these
systems lack the combination of multiple initial conditions, same user action evoking
different system responses, and timing criteria. Systems without one of these
characteristics often fail to manifest sufficiency issues.
A library checkout system is explored by [2] and [7]. In [2], scenarios have differing
initial conditions, and system response depends on data attributes. However, statecharts
are constructed directly from an informal textual description, not sequence diagrams.
[7] synthesizes statecharts from UML collaboration diagrams, but these diagrams have
identical initial conditions, one-to-one response mapping, and no timing criteria.
We examine three embedded systems to provoke sufficiency questions, then apply our
methodology to a traditional transaction processing system to show that these systems
do not require additional information for sufficiency.
The hierarchical graph approach used by the Message Sequence Chart community
[6, 9, 10] explicitly represents state and composition information not shown in standard
UML sequence diagrams. Figure 1 shows a set of sequence diagrams for a television
power switch. TV1 and TV2 are regular sequence diagrams. The system has two objects
- the user and the TV. The user can send one message, power. The TV can send two
messages, turn_on and turn_off. TVmain expresses the relationships between TV1
and TV2. The triangle indicates a possible initial condition - the system may start out in
TV1 and TV2 . Arrows indicate legal compositions. TV1 and TV2 must alternate - the
sequence TV1 TV1 is not allowed. Without TVmain , state and composition information
would be lost.
5
TV1 TV2 TVmain
User TV User TV
TV1 TV2
power power
Embedded system statechart synthesis typically requires more information than solely
the messages an object receives. Three cases will be examined where sequence
diagrams can be extended using state information, message pre-conditions, and timing
information to generate a deterministic grammar. Finally, the widely used ATM
example will be reviewed to show that the ATM sequence diagrams generate a
deterministic grammar without additional information regarding state, pre-conditions,
or timing. We note that the next revision of UML is expected to support additional
information through state symbols, OCL constraints and timing marks.
3 Diagram Content
3.1 Deterministic Grammar
The main challenge in statechart synthesis is generating correct statecharts from a set
of sequence diagrams with minimum sufficient information. The statecharts do not
necessarily need to be complete, but they should give an unambiguous representation of
the system. Development time constraints often preclude annotating each message of
every sequence diagram. Rather than attempt an exhaustive annotation, an alternate
goal is to include the minimum sufficient amount of information.
Correct statechart synthesis from sequence diagrams with minimal annotation can be
posed as a context-free grammar parsing problem. A similar approach was used in [5]
for text-based scenarios. To identify information gaps, we locate sequence diagram
messages that translate into non-deterministic transitions in statecharts, as
non-deterministic transitions often indicate information deficiencies. Standard methods
for removing non-determinism, such as left factoring [11], and for implementing
non-determinism, such as backtracking [11], cannot always be applied to embedded
systems sequence charts because messages may have global side effects on the external
environment. Therefore, the only guaranteed correct approach is to ensure that
sequence diagrams form an LL(1) grammar without left factoring or backtracking.
6
SD ® message response SD | e (1)
does not produce a deterministic state machine. Upon receipt of a , the object does not
know whether to execute ResponseA or ResponseB. The sequence diagram set for
this grammar is shown in Figure 2. The system may start in either Seq1 and Seq2, and
execute any combination of Seq1 and Seq2.
Seq1 Seq2 Seqmain
Response A Response B
message response ®a A’
(4)
A’ ® ResponseA | ResponseB
This is equivalent to the sequence diagram set given in Figure 3. The sequence
diagram Seqfactor is executed, followed by either Seq1 and Seq2. However, this only
changes the composition of the diagrams. The problem of whether to execute
ResponseA or ResponseB after receipt of a remains.
7
Upon receipt of a , it is unclear whether ResponseA or ResponseB is the correct
behavior. One must be selected, so assume ResponseA is selected. The next message
is f . It is clear that ResponseA was incorrect, so the system backtracks and
ResponseB is chosen instead. However, this approach is inapplicable to real-time
embedded systems, as many responses cannot be undone. For example, one cannot
undo detonating a bomb. A greater difficulty emerges in scenarios where it is
impossible to select a correct response based on messages alone. For instance, if a is
the only message the user can generate, no amplifying information can be acquired;
thus, the correct choice will never be known without querying existing system state.
Seqfactor
a
Seqfactor
Seq1 Seq2
Response A Response B
SD ® message response SD | e
(6)
message response ® power turn_on | power turn_off
Adding state information can solve this non-determinism. The problem is that the state
of the television is not represented in either sequence diagram, so the response to the
power message is ambiguous. The television can be in two states, on or off. Appending
this information to the sequence diagrams yields Figure 4.
8
TV1 TV2
User TV User TV
TVmain
off on
power power
TV1 TV2
turn on turn off
on off
Figure 4 : Sequence diagrams for a television power switch, including state information
The new state information can be incorporated into the grammar. The template for
constructing the grammar is now
3.3 Preconditions/assertions
SD ® message response SD | e
(10)
message response ® push(f) close | push(f) open
9
This is of the form
Elevatpr1 Elevator2
push(f) push(f)
push(f) push(f) Elevator1 Elevator2
open close
Preconditions for the messages can be added to make this example deterministic, as
shown in Figure 6. The crucial piece of missing information is that the response of the
elevator depends on the value of (f) in push(f) compared to current state. The value of (f)
in push(f) can be either the same as the current floor or other than the current floor.
Elevatpr1
Elevator2
push(f) push(f)
push(f) push(f) Elevator1 Elevator2
open close
and is deterministic.
10
3.4 Timing Information
Finally, the response of an embedded system may depend on the duration of the
stimulus. Consider a car radio with a set of buttons to allow users to save and switch to
preferred stations. If the button is held for a short time, the radio will change stations to
the button’s preset station when the button is released. If the button is held longer, the
radio will save the current station as the value of the button. The basic sequence charts
for this system are given in Figure 7.
Radio1 Radio2
hold hold
hold hold
Radio1 Radio2
release
release
change station station set
SD ® message response SD | e
(14)
message response ® hold release change_station | hold station_set
hold hold
hold hold
[release - hold Radio1 Radio2
< 2 seconds] [hold == true for
release 2 seconds]
release
station set
change station
11
SD ® message duration response SD | e
message duration response ® (16)
hold (holdDuration < 2 seconds) release change_station |
hold (holdDuration reaches 2 seconds) station_set
and is deterministic.
12
SD ® message response SD | e
message response ® Display_main_screen |
Insert_card Request_password | Enter_password Verify_account | (18)
Bad_account Bad_account_message Eject_card Request_take_card |
Take_card Display_main_screen
SD ® message response SD | e
message response ® Display_main_screen |
Insert_card Request_password | Enter_password Verify_account | (19)
Bad_password Request_password |
Cancel Canceled_message Eject_card| Take_card Display_main_screen
SD ® message response SD | e
message response ® Display_main_screen | (20)
Insert_card Request_password |
Cancel Canceled_message Eject_card Request_take_card |
Take_card Display_main_screen
SD ® message response SD | e
message response ® Display_main_screen | (21)
Insert_card Request_password | Enter_password Verify_account |
Cancel Canceled_message Eject_card Request_take_card |
Take_card Display_main_screen
Table 1 lists all the message-response pairs observed in the grammar for the
sequence diagram set.
Note that each incoming message produces a unique set of system responses, with
the exception of Cancel. In the first SD grammar (19), Cancel evokes
Canceled_message and Eject_card. In the third and fourth SD grammars
(20) and (21), cancel evokes Canceled_message, Eject_card, and
Request_take_card. Upon reflection, this is probably an omission in the first
sequence diagram, not a design decision.
13
This is non-deterministic and would mandate additional information for constructing
statecharts (which the authors provide.)
4 Conclusions
We presented a methodology that guarantees sufficient sequence diagram
information to generate correct statecharts. We converted sequence diagrams to a
context-free grammar, and applied parsing theory to locate non-deterministic
behavior. When state, message preconditions, and timing information are included in
the grammar, being LL(1) seems to be sufficient to guarantee determinism for the
embedded systems we discussed. We showed how this approach illustrated what
additional information was required to attain deterministic behavior, and provided
examples incorporating state information, message preconditions, and timing
information. Finally, we discussed a transaction processing example to show that
transaction processing systems are inherently deterministic.
14
5 Acknowledgements
This research is supported by the General Motors Satellite Research Lab at Carnegie
Mellon University and the United States Department of Defense (NDSEG/ONR).
References
[1] Douglass, B. Doing Hard Time. Addison-Wesley, 1999.
[2] Glinz, M. An Integrated Formal Model of Scenarios Based on Statecharts. In
Proceedings of the 5th European Software Engineering Conference (ESEC
95), Sitges, Spain, 1995, pp. 254-271.
[3] Harel, D. Statecharts: A Visual Formalism for Complex Systems. Science of
Computer Programming, vol.8, no.3, 1987, pp. 231-274.
[4] Hitz, M., and G. Kappel. Developing with UML - Some Pitfalls and
Workarounds. UML ‘98 - The Unified Modeling Language, Lecture Notes in Computer
Science 1618, Springer-Verlag, 1999, pp. 9-20.
[5] Hsia, P. et al. Formal Approach to Scenario Analysis. IEEE Software, vol.11,
no.2, 1994, pp. 33-41.
[6] ITU-T. Recommendation Z.120. ITU - Telecommunication Standardization
Sector, Geneva, Switzerland, May 1996.
[7] Khriss, I., M. Elkoutbi, and R. Keller. Automating the Synthesis of UML
StateChart Diagrams from Multiple Collaboration Diagrams. UML ‘98 - The Unified
Modeling Language, Lecture Notes in Computer Science 1618, Springer-Verlag, 1999,
pp. 132-147.
[8] Koskimies, K., T. Systa, J. Tuomi, and T. Mannisto. Automated Support for
Modeling OO Software. IEEE Software, vol.15, no.1, 1998, pp. 87-94.
[9] Leue, S., L. Mehrmann, and M. Rezai. Synthesizing Software Architecture
Descriptions from Message Sequence Chart Specifications. In Proceedings of
the 13th IEEE International Conference on Automated Software Engineering,
Honolulu, Hawaii, 1998, pp. 192-195.
[10] Li, X. and J. Lilius. Checking Compositions of UML Sequence Diagrams for
Timing Inconsistency. In Proceedings of the Seventh Asia-Pacific Software
Engineering Conference (APSEC 2000), Singapore, 2000, pp. 154-161.
[11] Louden, K. Compiler Construction : Principles and Practice. PWS Publishing
Company, 1997.
[12] Some, S., R. Dssouli, and J. Vaucher. From Scenarios to Timed Automata:
Building Specifications from User Requirements. In Proceedings of the 1995
Asia-Pacific Software Engineering Conference, Australia, 1995, pp. 48-57.
[13] Systa, T. Incremental Construction of Dynamic Models for Object-Oriented
Software Systems. Journal of Object-Oriented Programming, vol.13, no.5,
2000, pp. 18-27.
[14] Unified Modeling Language Specification, Version 1.3, 1999. Available from
the Object Management Group. http://www.omg.com.
[15] Whittle, J., and J. Schumann. Generating Statechart Designs from Scenarios.
In Proceedings of the 2000 International Conference on Software Engineering
(ICSE 2000), Limerick, Ireland, 2000, pp. 314-323.
15