Integrating Legacy Code / Models with Model Based Development Using Rhapsody M.W.Richardson 28/11/06 1 Telelogic AB
Model Driven Development Very few Green Field projects are started, nearly always there is some existing code or model base that works and that needs to be reused: Existing C++ / Java / Ada code Existing C code Existing Rational Rose models Existing Rational Rose RT models For some specific parts of the model, other tools and methods are more appropriate: Continuous applications: Existing Mathworks Simulink models Safety critical code generation: Existing Esterel SCADE models Protocol development : Existing Telelogic TAU SDL models 2 Telelogic AB
Existing C++ / Java / Ada code Clean mapping from Object Oriented Languages to UML Ensure that existing code can be compiled and linked Set up paths, select files and reverse engineer Forward generate, compile and link Create Object Model Diagrams Use Design level debugging to capture sequence diagrams Add new behaviour 3 Telelogic AB
Simple Java Example : Scribble.java 4 Telelogic AB
Scribble reversed engineered 5 Telelogic AB
Animated model 6 Telelogic AB
Existing C code Doesn t map naturally to UML Can reverse engineer, but would get a multitude of variables, functions and types However we can extend the UML by creating a new element File (this is a class with stereotype «File») Now we can visualize the files We can reverse engineer the files so that we can: Forward generation & modification External code visualization & usage visualization 7 Telelogic AB
Visualizing C code 8 Telelogic AB
Visualizing the usage of external files 9 Telelogic AB
Existing Rational Rose models Rational Rose was the first UML tool, but today doesn t support many of the UML 2.0 features. Any existing model can be seamlessly imported into Rhapsody and a profile added, so that the resulting diagrams have the same look in Rhapsody as they did in Rational Rose 10 Telelogic AB
Existing Rational Rose RT models Rational RoseRT models can not be directly imported since they are not based on UML2 but on ROOM. Instead of directly importing the model, the generated code can be reversed engineered Once the code is in Rhapsody, then the same code can be forwarded generated and executed Diagrams can be created Once the forward generated code can be shown to behave the same as the original code, then changes can be started to be made at the model level, new classes can be added etc. 11 Telelogic AB
Reverse Engineering code 12 Telelogic AB
Model Reorganisation Once reversed into the model, the RoseRTFormatter macro needs to be run to make some minor reorganisation of the model such as to move all the RoseRT Framework classes into a separate Framework package 13 Telelogic AB
Forward generation 14 Telelogic AB
Execution 15 Telelogic AB
Creating Diagrams 16 Telelogic AB
Observing Behaviour 17 Telelogic AB
Ports and Flow Ports In SysML there are two types of Ports: signal ports and flow ports. Signal ports are the same as UML ports and are used to describe the operations that can be invoked by and on the object. Flow ports are used to show data flow and are ideal for interfacing to tools such as Simulink and SCADE 18 Telelogic AB
Existing Mathworks Simulink models A Simulink model maps very well to a SysML block with flow ports. By adding a Simulink profile to Rhapsody, we can stereotype a block as a Simulink block and then by reading the Simulink model, automatically add appropriate flow ports to the block and add the generated Simulink code to the make file 19 Telelogic AB
Vehicle Dynamics 20 Telelogic AB
Feedback Loop 21 Telelogic AB
Cruise Control System 22 Telelogic AB
Code Generation and Execution 23 Telelogic AB
Existing Esterel SCADE models For safety critical code applications, Esterel s SCADE is a very good and well accepted solution. A SCADE model can be represented in UML as a Block or Class Stereotyped «SCADE Block» with ports describing inputs and outputs. 24 Telelogic AB
Import into SCADE The SCADE Block can be imported or re-imported/synchronized into SCADE All the blocks of the original Rhapsody model are imported as SCADE nodes 25 Telelogic AB
Development in SCADE Once the «SCADE» Block has been exported to SCADE, it can then be developed, tested and the resulting code executed in a separate thread. 26 Telelogic AB
Existing Telelogic TAU SDL models For protocol development, Telelogic TAU SDL is the ideal development platform. Protocol block Rhapsody serves as the embedded software design environment Protocol blocks are built and tested with SDL/TTCN suite. Code and interface definition are imported into Rhapsody, and the complete application is compiled and linked with a click of a button 27 Telelogic AB
Summary This presentation has shown how existing code or models can be easily reused and incorporated into a UML model using Rhapsody: Existing C++ / Java / Ada code Existing C code Existing Rational Rose models Existing Rational Rose RT models Continuous applications: Existing Mathworks Simulink models Safety critical code generation: Existing Esterel SCADE models Protocol development : Existing Telelogic TAU SDL models That s enough slides, let s see a demo 28 Telelogic AB