Professional Documents
Culture Documents
∗ †
Kamel Boukhelfa Faiza Belala
LIRE Laboratory LIRE Laboratory
University of Constantine 2 University of Constantine 2
Constantine 25000, Algeria Constantine 25000, Algeria
kamel.boukhelfa@univ-constantine2.dz faiza.belala@univ-constantine2.dz
ABSTRACT 1. INTRODUCTION
Design patterns (DPs) and real-time design patterns (RT- A design pattern expresses solution of a known and recur-
DPs) are described in informal way (UML and natural lan- rent problem in a particular context [7]. Design patterns
guage) to facilitate their understanding by software devel- are applied in object programming software to improve the
opers. However, these descriptions lead to ambiguities and quality of the resulting system.
limiting their correct usage. Moreover, this conventional The reuse concept is also important in the development of
representation has reached its limits and in particular for real-time and embedded systems. Thus, design patterns can
the representation of temporal proprieties and constraints. be used to capture the experience and allow the reuse of the
The representation of RTDPs in UML-MARTE profile per- ”good” solutions to resolve the problems encountered during
mits to well express their temporal proprieties and con- the design process of such systems [5, 15].
straints and thus, their algebraic specification become more
natural and more efficient. In the literature, several design patterns qualified as being
”real-time” are proposed in different domains [5]. Intuitively,
In this paper, we propose a formalization approach of real- the term ”real-time” refers to design patterns those dealing
time design patterns (RTDPs). We present an architecture with the temporal aspects of systems, whereas this is not
support for the formalization process and we show how to always the case. Indeed, real-time design patterns (RTDPs)
formalize the different concepts of a given RTDP represented deal with the general problems encountered in the design of
in UML-MARTE profile. Then, we illustrate our approach real-time systems (that may be or not related to the time)
by a realistic case study that represents a real-time design such as synchronization or memory allocation. The RTDPs
resulting from the use of RTDPs by the means of the instan- vary according to their areas of application and according
tiation and composition mechanisms. This design is speci- to the design approaches. Generally, design patterns and
fied as a set of some generated Maude (based on rewriting also RTDPs were described, until now, by using a com-
logic) Oriented Object modules. The execution of the latter bination of textual descriptions, object oriented graphical
allows to verify the feasibility of the proposed formalization notations such as UML diagrams and sample fragments of
approach. code[7, 5, 15]. This informal description of design patterns is
adopted to facilitate their understanding by software devel-
opers. However, informal descriptions give rise to ambigu-
Keywords ity, and limit tool support and correct usage. Tool support
Real-time Design Pattern, MARTE profile, Rewriting Logic, can aid pattern mining, detection of pattern within a de-
Maude sign model, and code generation from pattern specification.
∗Mr. Kamel Boukhelfa: Lecturer (preparing a Phd thesis) Hence, there is a need for a formal specification of the design
patterns to ensure their successful application.
in the department of Software Technologies and Informa-
tion Systems - Faculty of New Information Technologies and
Communication - University of Constantine 2, Algeria. Formal specifications provide a precise and rigorous descrip-
†Pr. Belala: Professor in the department of Software Tech- tion for better understanding patterns and their instantia-
nologies and Information Systems - Faculty of New Informa- tion and composition. The formal specifications of the de-
tion Technologies and Communication - University of Con- sign patterns are not intended to replace informal ones, but
stantine 2, Algeria. to complement them. The object-based design process can
be more productive by adopting a design patterns based
modelling and some steps of analysis and verification to
make sure that the application result is in accordance with
the input design.
(omod BANK-ACCOUNT is
protecting INT .
including CONFIGURATION .
op Account : -> Cid. Figure 1: The global architecture support of RDTPs
op bal :_ : Int -> Attribute . formalization.
ops credit debit : Oid Nat -> Msg .
var A : Oid . vars M N :Int
NFP_Frequency.
rl [credit]: < A : Account | bal : N >
The second step consists to pass from UML-MARTE to
credit(A, M) => < A : Account | bal:N + M >
Maude specifications. Here, we use Full-Maude, an exten-
crl [debit] : < A : Account | bal : N >
sion of Maude that, allows us to manipulate the object-
debit(A, M) =>
oriented concepts such as objects, classes, attributes, etc.
< A : Account | bal : N - M > If N >= M .
endom .)
4.2 Formalization of the structural part
We can note the existence of a correspondence between a
4. FORMALIZATION APPROACH some concepts of Maude language and UML-MARTE con-
4.1 Our contribution cepts. Unfortunately, this correspondence is not fully es-
We present in Figure 1, the proposed global architecture tablished, there are various concepts in UML-MARTE with
supporting our approach of RTDPs formalization based on no direct equivalent in Maude such as, associations, method
rewriting logic. The left side of the architecture presents calls in sequence diagram and the temporal properties and
the needed concepts for generating a RTDPs based design. constraints.
Thus, we use one or more of the cataloged RTDPs repre- The structural part of a design pattern is represented as an
sented in UML, then we enriched them by the MARTE no- UML class diagram with the different classes and relation-
tations. The resulting models are instantiated and composed ships between them. This part will serve as a model to gener-
for providing a design for a given system. ate, by means of the instantiation mechanism any structural
In the other side, the generation approach of the Maude design based on this pattern. A class is a set of attributes
specifications, associated to RDTPs and their underlined de- and methods, and it can be related to an another class
signs in all their forms (UML, MARTE), is depicted. Here, through inheritance mechanism to emphasize parental rela-
we need to define as Maude modules all RTDPs and the in- tionships. Other relationships are possible between classes,
stantiation and composition mechanisms. So, from the RT- each relationship is represented by a specific arc in the class
DPs Maude module and the instantiation mechanism defi- diagram.
nition, some modules defining the instances are generated. The table 1 contains the MARTE concepts and their corre-
The composition module uses these instances to generate spondences in Maude. For some MARTE concepts without
the Maude specification of the RT design. We will note here direct correspondence, we have also proposed their defini-
that the formalization process is performed in parallel with tions in Maude. Particular attention is given to the MARTE
the design process. concepts, such as stereotyping and the definition of methods.
The definition of the RTDPs meta-model (in UML and Maude) Thus, we propose the following: For the stereotyping, we de-
serves to automate the generation of the specifications at the fine a new class for each stereotype and so, the stereotyped
different levels. For the sake of the paper space, we will limit class (in MARTE) is represented by a subclass in Maude.
our work in this paper to study the passage from the result- While, for the specification of the methods definition within
ing RT design represented in MARTE to the Maude specifi- classes, we define a new sort called method and we add the
cations. Besides, we will verify the feasibility of the formal- declaration of a Maude operation that permits to link each
ization approach by applying it on a realistic case study. method to its appropriate class (op Methods : class ->
For this purpose, we use firstly a given design pattern to SetMethod). In addition, we use the predefined concepts
generate an UML design (structural and dynamic parts). in several modules of Maude such as the SET module, for
The result design will be enriched by the MARTE notations, defining empty and non-empty set (Set, NeSet), and others
namely the concepts defined in HLAM sub-profile such as modules such as BOOL, FLOAT, NAT and STRING to express re-
RtUnit, PpUnit and Rtfeature, and those defined in the spectively the types Boolean, Float, Natural and string of
NFP sub-profile such as NFP_DateTime, NFP_Duration and characters. The figure 2 shows how to use the above cor-
• the trigger object,
Table 1: Correspondence between MARTE and
Maude concepts • the target object,
MARTE Concept Maude Concept
• the Occurrence Kind (occkind),
Class/objet Class/Oid
Attribute Attribute • the triggering time (Tref: reference time) and
Directed Association Operation
• the deadline (reldl) (time to response).
Non-Directed Association Two operation
(one for each direction)
Association 1..1 operation op For the occurrence kind of a signal (occkind), we define a
Association 1..* op − > Set Maude operation called periodic that permits to identify
Association 1..n op − > NeSet the nature of this signal appearance (periodically or not).
(not empty Set) In the case of a periodic signal the periodVal operation is
Composition Operation defined to get the value of the period (for the simplicity, we
inheritance Subclass consider the default unit of time (ms)). The others elements
stereotyping Defining a new class that characterize a signal are represented in Maude language
and subclass as operations upon this signal. The following fragment of
Method sort method + op Methods Maude code illustrates the specification of the signal ins
with a t0 as triggering time:
Figure 8: Representation of the dynamic part of the ”Cruise control system” as a sequence diagram that
models the capturing activity of a speed and distance.
--- sorts one in each direction) is done in the following Maude code.
Sort Method . Each association is specified as a Maude operation taking as
Sort NFP_duration . parameter the first class and result the second one.
The specification of the different associations between classes --- add ceq to ensure that invoked method
(undirected association is considered as a two associations, --- belongs to the class of this object
var t1 : Time .
ceq Target(S : Signal) = < O : C | > op GETVALUE_S : -> Signal .
if operation(S) in Methods(C) . eq operation (GETVALUE_S) = getValue .
op periodic : Signal -> Bool . eq Trigger (GETVALUE_S) = Speed_C .
op periodVal : Signal -> Float . eq Target (GETVALUE_S) = Sp .
eq Time_ref (GETVALUE_S) = t1 .
--- if the signal occurrence is eq periodic (GETVALUE_S) = TRUE .
--- periodic then, the period eq periodVal(GETVALUE_S) = 20 .
--- value must be identified. eq relDl (GETVALUE_S) = 3.3 .
msg Distance_Subscrib_Call :
Part 2 : Specification related to a capturing (Speed and Oid Oid -> Msg [ctor] .
Distance) activity
vars C S Not_C : Oid .
eq Instance(Speed_Client) = Speed_Subscrib_Call
< Speed_C | isDymamic : false (Cruise_C , Speed_C) .
ismain : true poolsize : 10
main : Speed_Subscribe > . rl[Speed_Sub]
< C : Cuise_Controller >
eq Instance(Distance_Client) = < S : Speed_Controller >
< Speed_C | isDymamic : false Speed_Subscrib_Call =>
ismain : true poolsize : 10 < C : Cuise_Controller >
main : Distance_Subscribe >. < S : Speed_Controller >
< N : Speed_Notify > .
eq Instance(Speed_Notify) :
Notify_Sp .
Definition of a conditional rewriting rule to ensure that a
eq Instance(Distance_Notify) :
time constraint is verified.
Notify_D .