Applying Reengineering on Simulink Model Assisted by UML Statechart

6
CBSEC-Session 6 1 Applying Reengineering on Simulink Model Assisted by UML Statechart Guilherme Freire 1 , Leonardo Pedro 2 , Erik Antonio 1 , Juciara Nepomuceno 1 , Glauco Caurin 2 , Sandra Fabbri 1 1 Computing Department, Federal University of São Carlos, São Carlos-SP, CEP 13565905 BR 2 Mechanical Engineering Department, University of São Paulo, São Carlos-SP, CEP 13566590 BR Abstract—In the context of Embedded Systems (ES), the techniques used for model construction are specific for this domain, widely used by ES developers, and underused by Software Engineering (SE) developers. In general, the abstraction level of these models is close to the code and, after some time, their comprehension is difficult even for the person who developed them. Thus, the objective of this paper is to show that SE techniques, usually applied on conventional domains, can benefits ES domain providing most understandable documentation both for SE and ES developers. Based on a Simulink model developed some time ago by an ES developer, reverse engineering was applied to this model aiming to evaluate the model comprehension facility for both type of developers. Considering the difficulty, we used UML Statecharts that is a widely used SE technique, to elaborate a higher level abstraction model for the Simulink model. The UML Statechart model represented the requirements in a better and clearer way, and provided support for Simulink reconstruction. The results show that UML Statechart was able to represent the application requirements, provided a better representation of the system and contributed for a better documentation. As further work we plan to explore UML Statechart as a forward engineering technique in the context of embedded systems. Index Terms—Embedded Systems, Simulink model, Software Reengineering, UML Statechart. I. INTRODUCTION Embedded Software is seen as a special software category. Commonly, it represents critical applications that need to operate in a reliable way for long periods of time [18][10]. The low abstraction level used in their development process is highly coupled to the need of hardware representation. Usually, the development of embedded systems is not supported by software engineering resources as techniques, methods, tools and processes applied to conventional (non ES) software development. In general, ES developers use resources as Simulink and LabVIEW that provide code generation. Thus, they start the system development from a low level of requirements specification. For example, Simulink is widely used for automotive and aerospace systems development. It is frequently used because the system simulation is an intuitive task and it is model-based designed. However, in spite of its intuitive characteristic, Simulink models correspond to a low abstraction level which makes their comprehension difficult, especially after some time, even by the developer. This is heightened if the user who needs to understand the model is not an ES developer and is not used to use the Simulink technique. Thus, in general, for SE developers, Simulink model comprehension is a challenge task. This context promotes a negative impact on embedded system maintainability. Thus, more recently, there has been an increased focus on this kind of system, aiming to improve its development through the application of SE techniques. The establishment of a process that guides embedded system development is an important contribution in this context. This is the target of this research group that is composed by researchers from mechatronics and software engineering areas. Thus, aiming to define a forward engineering process for embedded systems, first of all a reengineering process based on Simulink models has been applied. The intention is to represent that model into a higher abstraction level, which can be used complementarily to the Simulink model. Based on embedded systems already developed and modeled through Simulink (in this paper named “original Simulink”), a reengineering process has been applied by using the UML Statechart to perform the reverse engineering activity. During this activity the system requirements are extracted and the higher abstraction level model is constructed. The objective of this paper is to describe the reengineering process that was applied to a mechanical cable driven anthropomorphic hand, which is an embedded system under development and study by the mechatronics engineers’ team. The paper is organized as follows: Section II presents a brief overview of UML Statechart and Simulink techniques; Section III discusses some tendencies on ES modeling that are related to this research; Section IV characterizes the system under study and describes its reengineering through the UML Statechart support; and Section V presents the conclusion and further work. II. TECHNIQUES USED IN THE CASE STUDY This section presents the techniques used in this study. The problem was modeled in Simulink and the UML Statechart was used to apply the reengineering process. A. UML Statechart Statechart was first presented by David Harel in 1987 extending the concepts of state machine by the addition of depth, orthogonality, and broadcast-communication [6].Based on these concepts the functional behavior of reactive systems can be described in a clear, realistic, formal and rigorous way. Besides Harel’s Statechart there are two other variants of it: Rhapsody [7] and UML Statechart Diagrams [14]. They

Transcript of Applying Reengineering on Simulink Model Assisted by UML Statechart

CBSEC-Session 6 1

Applying Reengineering on Simulink Model Assisted by UML Statechart

Guilherme Freire1, Leonardo Pedro2, Erik Antonio1, Juciara Nepomuceno1, Glauco Caurin2, Sandra Fabbri1

1Computing Department, Federal University of São Carlos, São Carlos-SP, CEP 13565905 BR 2Mechanical Engineering Department, University of São Paulo, São Carlos-SP, CEP 13566590 BR

Abstract—In the context of Embedded Systems (ES), the techniques used for model construction are specific for this domain, widely used by ES developers, and underused by Software Engineering (SE) developers. In general, the abstraction level of these models is close to the code and, after some time, their comprehension is difficult even for the person who developed them. Thus, the objective of this paper is to show that SE techniques, usually applied on conventional domains, can benefits ES domain providing most understandable documentation both for SE and ES developers. Based on a Simulink model developed some time ago by an ES developer, reverse engineering was applied to this model aiming to evaluate the model comprehension facility for both type of developers. Considering the difficulty, we used UML Statecharts that is a widely used SE technique, to elaborate a higher level abstraction model for the Simulink model. The UML Statechart model represented the requirements in a better and clearer way, and provided support for Simulink reconstruction. The results show that UML Statechart was able to represent the application requirements, provided a better representation of the system and contributed for a better documentation. As further work we plan to explore UML Statechart as a forward engineering technique in the context of embedded systems.

Index Terms—Embedded Systems, Simulink model, Software Reengineering, UML Statechart.

I. INTRODUCTION

Embedded Software is seen as a special software category. Commonly, it represents critical applications that need to operate in a reliable way for long periods of time [18][10]. The low abstraction level used in their development process is highly coupled to the need of hardware representation. Usually, the development of embedded systems is not supported by software engineering resources as techniques, methods, tools and processes applied to conventional (non ES) software development. In general, ES developers use resources as Simulink and LabVIEW that provide code generation. Thus, they start the system development from a low level of requirements specification.

For example, Simulink is widely used for automotive and aerospace systems development. It is frequently used because the system simulation is an intuitive task and it is model-based designed. However, in spite of its intuitive characteristic, Simulink models correspond to a low abstraction level which makes their comprehension difficult, especially after some time, even by the developer. This is heightened if the user who needs to understand the model is not an ES developer and is not used to use the Simulink technique.

Thus, in general, for SE developers, Simulink model comprehension is a challenge task. This context promotes a negative impact on embedded system maintainability. Thus, more recently, there has been an increased focus on this kind of system, aiming to improve its development through the application of SE techniques. The establishment of a process that guides embedded system development is an important contribution in this context. This is the target of this research group that is composed by researchers from mechatronics and software engineering areas. Thus, aiming to define a forward engineering process for embedded systems, first of all a reengineering process based on Simulink models has been applied. The intention is to represent that model into a higher abstraction level, which can be used complementarily to the Simulink model.

Based on embedded systems already developed and modeled through Simulink (in this paper named “original Simulink”), a reengineering process has been applied by using the UML Statechart to perform the reverse engineering activity. During this activity the system requirements are extracted and the higher abstraction level model is constructed.

The objective of this paper is to describe the reengineering process that was applied to a mechanical cable driven anthropomorphic hand, which is an embedded system under development and study by the mechatronics engineers’ team.

The paper is organized as follows: Section II presents a brief overview of UML Statechart and Simulink techniques; Section III discusses some tendencies on ES modeling that are related to this research; Section IV characterizes the system under study and describes its reengineering through the UML Statechart support; and Section V presents the conclusion and further work.

II. TECHNIQUES USED IN THE CASE STUDY

This section presents the techniques used in this study. The problem was modeled in Simulink and the UML Statechart was used to apply the reengineering process.

A. UML Statechart Statechart was first presented by David Harel in 1987

extending the concepts of state machine by the addition of depth, orthogonality, and broadcast-communication [6].Based on these concepts the functional behavior of reactive systems can be described in a clear, realistic, formal and rigorous way. Besides Harel’s Statechart there are two other variants of it: Rhapsody [7] and UML Statechart Diagrams [14]. They

CBSEC-Session 6 2

inherited most of the notations, their formalism is similar, but UML and Rhapsody statechart are object-oriented designed. Concerning UML Statecharts the differences related to OO paradigm refer to component reuse. Thus, UML Statechart provides submachine instantiation (that are composite states) and inheritance concept. The later corresponds to inherited states and transitions represented by dashed round corner rectangle and arrows, respectively.

Fig. 1. Example of UML Statechart [19]

Figure 1 is an example of UML Statechart diagram that shows climate modeling. There are three concurrent regions distinguished by dashed lines. The upper region contains a state machine representing day and night transition; the middle region represents temperature transition; and the lower region represents weather transition. The states representing day and night are called composite states.

B. Simulink Simulink is a development environment distributed by

MathWorks. It is a graphical extension of MATLAB for multi-domain simulation and model-based design for dynamic and embedded systems. It provides an interactive graphical environment and a customizable set of block libraries that allows design, simulation, implementation, and testing of a variety of time-varying systems, including communications, controls, signal processing, video processing, and image processing1. Figure 2 presents an example of a Simulink window and a simulation output (the black screen). Through the Simulink window the developer can draw a model. The example contains three blocks: (i) Source Block Step, that originates an input signal; (ii) Transfer Function, which modifies inputs (signal) into outputs (signal); and (iii) Scope Block that provides a simple visualization block, used to display a signal, like an oscilloscope. Directional lines, indicated by arrows, link the blocks.

III. RELATED WORKS

Recent researches have proposed approaches trying to reduce software development complexity. One of these approaches is the use of SE techniques that are able to increase the capability of ES component reuse, aiming to decrease ES complexity [17]. Another approach is the Model-Driven Architecture (MDA). According to Kent [9], MDA is an approach that involves architecture, artifacts and system modeling. It explores the model usefulness as an essential tool for systems development.

1 www.mathworks.com/products/simulink

Thus, there are models of high abstraction level related to two different viewpoints - (PSM - Platform Specific Model) and (PIM - Platform Independent Model) [9].

Fig. 2. Example of a Simulink model and a simulation output

Nowadays, MDA has been used in different areas as an approach to guide system development such as Subject-Oriented Modeling [15], Service-Oriented Architecture (SOA) [8], and Embedded Systems development supported by UML/MOF repository [12]. MDA is a well-known approach that provides alternatives to: (i) specify a system independently of its supporting platform; (ii) specify platforms; (iii) choose a specific development platform for the system and also (iv) transform the system specification into a specific deployment platform [13].

A third approach mentioned in the literature is Design Patterns that is a very common SE technique that describes the solution core through a pair problem-solution, which occurs several times in system development [4]. It is considered a template that provides a way to solve recurrent problems. Thus, Design Patterns approach can accelerate the development process due to reuse application [11]. However, currently, many embedded systems are developed through an ad hoc approach. According to Konrad et al [10], in order to improve the development of this kind of system and to facilitate the construction of its UML-based conceptual models, design patterns can be useful, mainly in requirements analysis phase. Undetected errors in that phase can be propagated to later stages when using MDA. Recently, to address this problem, CORBA patterns are used to capture undetected errors of the requirement model [5].

IV. THE SIMULINK MODEL REENGINEERING

In this section the embedded system used in the case study is characterized and the reengineering process applied to explore the support of UML Statechart in this context is described.

A. System description The Kanguera hand is a mechanical cable driven

anthropomorphic hand. It is composed of five hybrid independent fingers. The idea of hybrid finger is related to the electrical motor that actuates on the finger joints. Each finger has four joints, which are controlled by three virtual motors and one real motor.

Object manipulation tasks using robot hands is one of the greatest challenges in robotics [2]. The dexterous

CBSEC-Session 6 3

manipulation development involves several fields of science, which must be carried out in parallel. A higher manipulation capability is reached by anthropomorphic robot hands with a non-trivial mechanical project due to the great number of degrees of freedom (DOF) of each finger. For the object manipulation a Simulink model was developed. This model executes the pencil manipulation task. This task requires independent movement of three fingers. Figure 3 illustrates the initial and final position for a pencil manipulation. The motor trajectories previously obtained for the fingers were used as the controller references. In manipulation tasks, the movement of each joint must be combined with the appropriate forces and torques to generate the object desired movements. Therefore, during a manipulation task, speed and torque must be controlled synchronously.

Fig. 3. Manipulation task, initial/final position [3]

B. Case Study Description As mentioned before, in the context of embedded system

developers start the development from a low abstraction level, using, for example, Simulink or LabVIEW techniques.

Aiming to identify a forward software engineering process for embedded systems, some systems that were already developed were identified and they were submitted to the reengineering process depicted in Figure 4. These systems are associated to different domains and, in this paper, the case study conducted for the Kanguera hand, previously described, is presented.

Fig. 4. The reengineering process of the Simulink model (adapted from [16])

The starting point of the study was a Simulink model that corresponds to the system “close finger action” (closeFingerPIDControl diagram). The system had no higher level modeling phase and no specification document that could aid in the implementation phase. As usual, the developer just elaborated the Simulink model of Figure 5. The model was elaborated iteratively as the developer simulated the model. Thus, the model has evolved as new requirements were

added and errors were corrected. As showed in Figure 5, the model is confusing, difficult to read and certainly to maintain.

The first SE team’s attempt was to organize the model trying to construct a higher level Simulink model. However, the result did not help in understanding the system. After this unsuccessful attempt, the SE team requested the assistance of the ES developer for extracting the system requirements from the Simulink model. Based on a brainstorm section and on the the main characteristics of the system, it was decided to use UML Statechart to model a higher abstraction level of the Kanguera hand system. This technique seemed to provide the enough resources to model those characteristics and to represent the system independently from the development platform, i.e, to represent the PIM viewpoint.

The reverse engineering process is represented in Figure 4. The Information Extraction step was conducted by the SE and the ES teams and the objective was to identify concurrent tasks and the set of functional and non-functional requirements. During this step, as the SE team applied the brainstorm technique aiming to understand the system, the ES developer identified two block patterns as showed in Figure 6. These blocks represent finger articulations and from the moment they were identified and separated, the comprehension of the whole system becomes easier. The finger movement is controlled by four articulations, each one corresponding to a motor.

The Articulation Motor becomes a superstate composed of two substates - Controlling Voltage and Moving Articulation - that executes, in a loop, a time constraint of 5 milliseconds. This time constraint has been treated as a non-functional requirement in Figure 7, where it is modeled as a timeout condition from the Articulation Motor state to the Calculating Direct Cinematic state.

Certainly, the four articulations- Articulation Motor – must be parallel states in the UML Statechart diagram since they can move simultaneously. Once these states were organized as the Moving Finger orthogonal state of Figure 7, the remaining states were identified.

After leaving the orthogonal superstate, the time constraint triggers the transition to Calculating Direct Cinematic state. In this state some correction calculation runs for 20 milliseconds aiming to correct the finger trajectory. Again, a timeout event triggers the transition to Planning Trajectory state. If the desired trajectory was achieved, a transition will leave the Finger submachine. Otherwise, new remaining trajectory information will be sent to Calculating Inverse Cinematicstate so it can generate new data to Articulation Motor state.

Besides the states mentioned above, there are two other states that represent specific simulation task and trajectory planning (Figure 7). Planning Trajectory state gets the information sent by Calculating Direct Cinematic state, to identify the executed trajectory. Thus, it verifies if the desired trajectory was reached. If so, the final position is sent out of Finger superstate, otherwise, it recalculates the new trajectory and sends it to Calculating Inverse Cinematic state. This later state generates the movement of each articulation that is composed of appropriated speed, force and torque which are sent to Moving Finger superstate.

After the system was abstracted into the UML Statechart

CBSEC-Session 6 4

diagram the ES developer was able to reconstruct the Simulink model and the new model is presented in Figure 8. The improvement of the model is notorious. It becomes clearer and certainly easier to maintain.

However, it was observed that the low level abstraction elements, such as logical gates, could not be represented through the UML Statechart notation. On the other hand, higher abstraction elements such as functional and non-functional requirements were captured into the statechart diagram. Thus, the Simulink model and the UML Statecharts diagram were, in the context of this case study, considered as complementary techniques that can be used together aiming to enhance the comprehension of embedded systems and, consequently, to decrease their complexity.

V. CONCLUSION

This paper presented the reengineering of a Simulink model supported by the use of the UML Statechart. The system under study was an embedded system that corresponds to a mechanical cable driven anthropomorphic hand. As usually used in ES context, the development was made iteratively, exchanging between the Simulink model construction and its simulation, i.e., the development was supported by a low level abstraction model.

At the end of that process the result was a Simulink model without prior planning. On one hand, the use of this kind of technique has the advantage of code generation but, on the other hand, the system has no high level documentation. After a while, the model comprehension becomes difficult even for its developer. This fact increases the system complexity and

decreases its maintainability. Therefore, recently, researches are being conducted to

investigate the application of software engineering techniques on embedded system development, aiming to enhance this scenario. Hence, trying to establish a development process that starts in a higher level of abstraction (from the requirements documentation, their modeling, and so on), the reengineering of Simulink models are being applied aiming to identify a better development process and complementary techniques.

The results obtained in this case study showed the contribution of UML Statechart during the reverse engineering activity and, in addition, its complementary aspect in relation to Simulink model. UML Statechart contributed for an easier information extraction and also for the reconstruction of the original Simulink model. Besides, as the information was extracted and the statechart model was constructed, some embedded system patterns were identified. This is an issue that will be investigated in further works, as well as the MDA approach. Also, it is important to notice that the use of formal techniques as statecharts allows the application of testing criteria that improves the quality of the product and of the development process.

Nowadays, other embedded systems are being used with the same purpose of identifying software engineering techniques that are useful in this domain and can aid the establishment of a better development process.

Fig. 5. Original Simulink model of the Kanguera Hand

CBSEC-Session 6 5

Fig. 6. States identified from original Simulink model

Fig. 7. UML Statechart of the Kanguera Hand

CBSEC-Session 6 6

Fig. 8. New Simulink model of the Kanguera Hand

ACKNOWLEDGMENT

We thank to Capes, CNPq and INCT-Sec for the financial support.

REFERENCES

[1] Benante, R. C., Pedro, L. M., Massaro, L. C., Belini, V. L., Araujo, A. F. R. and Caurin, G.A.P., A Self-Organizing State Trajectory Planner applied to an Anthropomorphic Robot Hand, IEEE/RSJ Int. Conf. on Intelligent Robots and Systems - IROS, 2007.

[2] Bicchi, A. and Kumar, V., A MDA-based approach for real time embedded systems simulation, Robotic Grasping and Manipulation, Articulated and mobile robots for services and Technology, vol. 270, pp. 55-74,2001.

[3] Caurin, G. A. P., Albuquerque, A. R. L. and Mirandola, A. L. A., Manipulation strategy for an anthropomorphic robotic hand, IEEE/RSJ Int. Conf. on Intelligent Robots and Systems, Vol.2, pp.1656-1661,2004.

[4] Gamma E., Helm, R., Johnson, R. and Vlissides, J. Design Patterns: Elements of Reusable Object Oriented Software. Addison-Wesley, 1994.

[5] Goldsby, Heather J. and Konrad, Sascha and Cheng, Betty H. C., Goal-Oriented Patterns for UML-Based Modeling of Embedded Systems Requirements, Proceedings of the 10th IEEE High Assurance Systems Engineering Symposium, Washington, DC, USA, HASE ’07 (2007).

[6] Harel, D. Statecharts: A Visual Formalism for Complex Systems, Science of Computer Programming (1987).

[7] Harel, D., Kugler H. The Rhapsody semantics of statecharts (on, on the executable core of the UML) (preliminary version), SoftSpez Final Report, Lecture Notes in Computer Science., vol. 3147, pp. 325-354. Springer, Heidelberg, 2004.

[8] Jardim-Goncalves, R., Grilo, A. and Steiger-Garcao, A., Challenging the interoperability between computers industry with MDA and SOA, Computers in Industry (2006).

[9] Kent, S. Model Driven Engineering, Integrated Formal Methods, Lecture Notes in Computer Science, Springer Berlin, Heidelberg (2002).

[10] Konrad, S., Betty, H. C. C. and Campbell, L. A. Object Analysis Patterns for Embedded Systems, IEEE Transaction. Software Engineering, Dec. 2004.

[11] Lo, C. and Huang, S. Embedded control system development using UML for automatic doors, Proceedings of SICE Annual Conference,(2010)

[12] Nascimento, F. A. M., S. Oliveira, Marcio F., Wehrmeister, Marco A., Pereira, Carlos E. and Wagner Flávio R. MDA-based approach for embedded software generation from a UML/MOF repository, Proceedings of the 19th annual symposium on Integrated circuits and systems design, SBCCI (2006).

[13] Object Management Group (OMG). MDA Guide Version 1.0.1, Document Number: omg/2003-06-01, 12th June 2003.

[14] OMG, Unified Modeling Language: Superstructure version 2.0, Document formal/2009-02-02, Object Management Group ,2009.

[15] Tandon, G. and Ghosh, S. Using subject-oriented modeling to develop Jini applications, Proceedings - IEEE International Enterprise Distributed Object Computing Workshop, EDOC, 2004.

[16] Pressman, R. S., Software Engineering : A Practional Approach, 6th ed, McGraw-Hill Co, 2005.

[17] Rekhis, S., Bouassida, N. and Bouaziz, R., Modeling Real-Time Applications with Reusable Design Patterns, Advanced Computer Science and Information Technology, 2010.

[18] Wang, Y., Zhou, X., Dong, Y. and Li, C. A. MDA-based approach for general embedded software simulation platform, International Conference on Scalable Computing and Communications - The 8th International Conference on Embedded Computing, ScalCom-EmbeddedCom (2009).

[19] Weilkiens, T. and Oestereich, B. UML 2 Certification Guide: Fundamental and Intermediate Exams, MK (2007).