Generate Results. Real Models. Real Code. Real Fast. Embedded/Real-Time Software Development with PathMATE and IBM Rational Systems Developer Andreas Henriksson, Ericsson andreas.henriksson@ericsson.com Greg Eakman, Ph.D., Pathfinder Solutions grege@pathfindermda.com Originally presented at the IBM Rational Software Development Conference 2007 2007 IBM Corporation www.pathfindermda.com
Ericsson A world-leading provider of telecommunications equipment and related services to mobile and fixed network operators globally Founded in 1876 Headquarters in Stockholm, Sweden More than 1000 networks in more than 140 countries 40 percent of all mobile calls are made through our systems One of the few companies worldwide that can offer endto-end solutions for all major mobile communication standards CA11 Customer Experience Presentation 2
Pathfinder Solutions Founded in 1995 Headquarters outside of Boston, MA PathMATE Model Automation and Transformation Environment released in 1996 An open, standards based, model transformation environment RSD plug-in Expert practitioners of model driven development for embedded systems Defense and Avionics Automotive Medical Instrumentation Manufacturing Telecommunications Consumer Electronics CA11 Customer Experience Presentation 3
Contents Introduction Model Driven Architecture Realizing MDA benefits with PathMATE and RSD PathMATE and Rose RT integration CA11 Customer Experience Presentation 4
Introduction - Why is Ericsson investigating PathMATE based MDA? Leveling model and action language Platform independent abstraction Full control of code generation Memory management Enable optimizations Ensure generated code complies to QA standards Weave in platform details during transformation Push performance optimizations to design time Real productivity potential CA11 Customer Experience Presentation 5
Rational Rose Real Time Modeling Environment & Code Generator UML with Real-Time Profile Implementation language & Action Code TSL / Runtime Service Library Load Module Runtime Service library CA11 Customer Experience Presentation 6
Why Model Driven Architecture? Manage complexity Address increasing function/feature content Achieve deployment flexibility and performance Topology Environment Complex optimizations Facilitate Product Line architecture, development Separation of Concerns best use of team members CA11 Customer Experience Presentation 7
Why Model Driven Architecture? Improve system quality Apply a defined, enforceable process Improve communication Reduce defects Raise developer productivity Raise the level of abstraction Ease maintenance/extension Deliver systems: Quality product Meet customer need Competitively priced On time CA11 Customer Experience Presentation 8
Separation of Concerns Separate platform independent solution from deployment specifics Platform Independent Model (PIM) Complete, executable UML model of functional solution Independent of target topology, environment Transformed to Simulation/verification executable Deployment - platform-specific implementation System documentation Interchange format Most complex systems can be largely platform independent CA11 Customer Experience Presentation 9
MDA for High Performance Systems - Process Analyze behavioral requirements with Use Cases Develop a logical architecture with Domains Construct PIMs for modeled domains Construct the deployed system CA11 Customer Experience Presentation 10
Use Case Analysis CA11 Customer Experience Presentation 11
MDA for High Performance Systems - Process Analyze behavioral requirements with Use Cases Develop a logical architecture with Domains Construct PIMs for modeled domains Construct the deployed system CA11 Customer Experience Presentation 12
Logical Architecture with Domains Capture the logical architecture on a domain chart Specify inter-domain behavior with Sequence Charts Logical Architecture is problem-space focused Highly durable Deployable to varying topologies CA11 Customer Experience Presentation 13
Logical Architecture Sequence Diagrams CA11 Customer Experience Presentation 14
MDA for High Performance Systems - Process Analyze behavioral requirements with Use Cases Develop a logical architecture with Domains Construct PIMs for modeled domains Construct the deployed system CA11 Customer Experience Presentation 15
Domain Internals CA11 Customer Experience Presentation 16
Domain Internals CA11 Customer Experience Presentation 17
Domain Internals Capture state machines for active classes CA11 Customer Experience Presentation 18
Detailed Behavior: Action Language Specify actual behavior in UML platform independent action language Ref<FieldOfView> available_field_of_view = findavailablefieldofview(); IF (available_field_of_view == NULL) { GENERATE Subject:SensorPreempted(0) TO (this); } ELSE { Ref<Sensor> sensor = FIND available_field_of_view -> A6 -> A3; selectfieldofview(sensor, available_field_of_view); } CA11 Customer Experience Presentation 19
Detailed Behavior: Action Language Dynamically verify PIM correctness through execution CA11 Customer Experience Presentation 20
MDA for High Performance Systems - Process Analyze behavioral requirements with Use Cases Develop a logical architecture with Domains Construct PIMs for modeled domains Construct the deployed system CA11 Customer Experience Presentation 21
Deploy the Models Establish implementation architecture Mark PIM to Indicate topological allocations Specify optimization decisions Transform PIMs to optimized platform specific implementation Build in code-level solutions for non-modeled (realized) domains Test Features Performance CA11 Customer Experience Presentation 22
Deployment Architecture Domain chart is the Logic Architecture Deployment Architecture defines: Processes Threads Communications/middleware Memory maps OS Physical architecture allocates processes to compute nodes Logical Architecture Deployment Architecture Physical Architecture CA11 Customer Experience Presentation 23
Deployment View UML Deployment reflects the system structure Nodes represent execution units Communication paths connect nodes Use multiple diagrams for multiple configurations CA11 Customer Experience Presentation 24
Transformation Flow Custom Doc Java C++ C Rules PIM Marked PIM Transformation Engine Non-Modeled Elements PSM Build System CA11 Customer Experience Presentation 25
High Performance with MDA Incorporating/Interfacing with External Components Deploying to Multiple Platforms/Topologies Performance Optimization CA11 Customer Experience Presentation 26
Integrating with Legacy Code Interface with legacy/handwritten code via domain Only interface is abstracted Automated generation of interfaces from modeled components Provides encapsulation/bridging Advanced performance optimizations Extend mechanisms (if necessary) to use existing infrastructure Generate code that uses/interfaces with legacy primitives CA11 Customer Experience Presentation 27
Integrating with Legacy Code //================================================================== == geo_distance_t LocationServices::UnpackX(geo_location_t location) { } // Mask out Y and shift down X, convert from tenths to miles int x_hundredths = (location & LS_UPPER_MASK) >> LS_SHIFT_HALF_WORD; geo_distance_t x = x_hundredths / 100.0; return x; CA11 Customer Experience Presentation 28
High Performance with MDA Incorporating/Interfacing with External Components Deploying to Multiple Platforms/Topologies Performance Optimization CA11 Customer Experience Presentation 29
System Topology Define processing elements Processors/Processes Tasks/Threads Define communication paths Network protocols Shared memory Target-specific data transport (raw sockets, CORBA, XML, ) CA11 Customer Experience Presentation 30
Example Allocation Alternative 1 # MAIN processor Domain,SAMP.CabinEnvironment,ProcessID,,ProcessID,MAIN Domain,SAMP.ChassisDynamics,ProcessID,,ProcessID,MAIN Domain,SAMP.DeviceInterface,ProcessID,,ProcessID,MAIN Domain,SAMP.GeoLocation,ProcessID,,ProcessID,MAIN Domain,SAMP.LocationServices,ProcessID,,ProcessID,MAIN Domain,SAMP.NavigationSupport,ProcessID,,ProcessID,MAIN Domain,SAMP.PowertrainControl,ProcessID,,ProcessID,MAIN Domain,SAMP.VehicleControl,ProcessID,,ProcessID,MAIN # COCKPIT processor Domain,SAMP.DriverInterface,ProcessID,,ProcessID,COCKPIT Domain,SAMP.GUIToolkit,ProcessID,,ProcessID,COCKPIT # Run locally in ANY process/task Domain,SAMP.SoftwareMechanisms,ProcessID,,ProcessID,ANY CA11 Customer Experience Presentation 31
Example Allocation Alternative 2 # COCKPIT processor Domain,SAMP.DriverInterface,ProcessID,,ProcessID,COCKPIT Domain,SAMP.GUIToolkit,ProcessID,,ProcessID,COCKPIT # MAIN processor Domain,SAMP.CabinEnvironment,ProcessID,,ProcessID,MAIN Domain,SAMP.GeoLocation,ProcessID,,ProcessID,MAIN Domain,SAMP.LocationServices,ProcessID,,ProcessID,MAIN Domain,SAMP.NavigationSupport,ProcessID,,ProcessID,MAIN Domain,SAMP.PowertrainControl,ProcessID,,ProcessID,MAIN Domain,SAMP.VehicleControl,ProcessID,,ProcessID,MAIN # CHASSIS_CONTROL processor Domain,SAMP.ChassisDynamics,ProcessID,,ProcessID,CHASSIS_CONTR OL # Run locally in ANY process/task Domain,SAMP.DeviceInterface,ProcessID,,ProcessID,ANY Domain,SAMP.SoftwareMechanisms,ProcessID,,ProcessID,ANY CA11 Customer Experience Presentation 32
High Performance with MDA Incorporating/Interfacing with External Components Deploying to Multiple Platforms/Topologies Performance Optimization CA11 Customer Experience Presentation 33
Performance Optimizations Start with documented performance requirements Start with functionally correct baseline Review model for conciseness and frugality Initiate performance testing Address Performance Issues Simplify/streamline mechanisms Incorporate specialized infrastructure Transform to alternative implementation pattern CA11 Customer Experience Presentation 34
Custom Markings and Transformation Make up 2 new markings to directly generate hardware register interface code Register and Bit # Set up status bits for digital control channel Attribute,SAMP.DeviceInterface.DigitalControlChannel.busy,Register Register,DI_CTL_REG Attribute,SAMP.DeviceInterface.DigitalControlChannel.busy,Bit Bit, DI_STATUS_BUSY Attribute,SAMP.DeviceInterface.DigitalControlChannel.online,Register Register,DI_CTL_REG Attribute,SAMP.DeviceInterface.DigitalControlChannel.online,Bit Bit,DI_STATUS_ONLINE Attribute,SAMP.DeviceInterface.DigitalControlChannel.overloaded,Register Register,DI_CTL_REG Attribute,SAMP.DeviceInterface.DigitalControlChannel.overloaded,Bit Bit,DI_STATUS_OL CA11 Customer Experience Presentation 35
Custom Markings and Transformation Create a custom templates to use Register and Bit... // Generate code for an attribute read accessor [ASSIGN reg_marking = PROPERTY(action.attribute, Register, )] [IF (reg_marking!= )] [/* Use direct register access pattern */] [ASSIGN bit_marking = PROPERTY(action.attribute, Bit, )] MyHardwarePackage::AccessRegisterBit([reg_marking], [bit_marking]); [ELSE /* Use default data member accessor */] [action.instancereference]->[action.attribute.name]; [ENDIF]... Example generated code for online attribute: MyHardwarePackage::AccessRegisterBit(DI_CTL_REG, DI_STATUS_ONLINE); CA11 Customer Experience Presentation 36
Generate Results. Real Models. Real Code. Real Fast. PathMATE And Rose RT Integration www.pathfindermda.com
Introduction: Why evolve from Rose RT based MDD to PathMATE based MDA? Leveling model and action language PIM abstraction Full control of code generation Control over memory management Enable optimizations Ensure generated code complies to QA standards Weave in platform details at model compiler level Push performance optimizations to design time Real productivity potential CA11 Customer Experience Presentation 38
Background The Rose RT code generation process is a closed technology Difficult to make good concern separation in Rose RT Low level C++ action language Implementation details and optimizations are scattered through out the model Can t migrate large legacy Need an integration that supports full legacy CA11 Customer Experience Presentation 39
Background (2) Model And Runtime Integration Modeled application space Rose RT model PathMATE model Capsule Capsule Capsule Class Hybrid Runtime RTHybridController PMTask Model level bridge Introduce capsule, port and protocols in PathMATE Support for Rose RT communication at model level Runtime level bridge Support for Rose RT communication at runtime level Support joint execution of Rose RT and PathMATE models within the same application context CA11 Customer Experience Presentation 40
Background (3) Building hybrid applications Modeling Code generation Build Execution Rose RT PathMATE Hybrid Build Hybrid Application CA11 Customer Experience Presentation 41
Rose RT Compatibility PathMATE runs side by side with Rose RT Compatible Rose RT communication mechanisms Enables legacy preservation Modeled application space Rose RT model Capsule PathMATE model Capsule Capsule Class Hybrid Runtime RTHybridController PMTask CA11 Customer Experience Presentation 42
Powerful Code Generation Model checking and static analysis Template driven generation, fully customizable Change implementation language and platform with the flip of a switch Performance optimizations automatically leveraged across all models Automatic documentation and report generation CA11 Customer Experience Presentation 43
Powerful Code Generation (2) Capsule example Custom templates generates Rose RT compliant code from modeled capsule s marked with the capsule stereotype const RTActorClass SubrackCapsule = { (const RTActorClass *)0, "SubrackCapsule", (RTVersionId)0, 0 // 0 Relay ports, (const RTRelayDescriptor *)0, new_subrackcapsule_actor }; CA11 Customer Experience Presentation 44
Powerful Code Generation (3) Database persistence example Custom templates generates database interface code for Persistent marked objects Better consistency Easier maintenance # Relational Database markings System,EqcNprSubrackSlotBlU,RdbType,ODBC System,EqcNprSubrackSlotBlU,RdbDropTablesFirst,F Object,EqcNprSubrackSlotBlU.SubrackManager.SubRack,Persistent,T Object,EqcNprSubrackSlotBlU.SubrackManager.Slot,Persistent,T BinaryRel,EqcNprSubrackSlotBlU.SubrackManager.A3,Persistent,T CA11 Customer Experience Presentation 45
Persistence Persistence is a common system requirement Storage between program executions Platform specific technology XML Relational Database Templates become part of the domain Derive implementation artifacts from class diagram and markings Data storage format schema generation Load/Save/Delete/Create tables <<domain>> Persistence CA11 Customer Experience Presentation 46
Abstraction Level PAL raises coding abstraction level Coding at analysis level using PAL rather than low implementation level using C++ Ref<SubRack> subrack = FIND CLASS SubRack WHERE (SubRack.froId == froid); FOREACH slot = subrack -> A3 { Persistence:deleteSlotObject(slot, trid); } CA11 Customer Experience Presentation 47
Abstraction Level (2) Platform independence hides implementation details Raised productivity from raised abstraction level PAL Ref <Slot> slot = FIND CLASS Slot WHERE (Slot.froId == froid); If (slot!= NULL) { // return slot parameters } vs C++ for (int i = 0; i < noofsubracks; i++) { sub = subracks[ i ]; for (int j = 0; j < sub->noofslots; j++) { if (sub->slotfroids[j] == froid) { // return slot parameters } } } CA11 Customer Experience Presentation 48
Separation of Concerns Separating domain and architectural concerns Partition system into separate subject matters Avoids overly complex state-machines due to poor concern separation Reduced complexity when managed by separation CA11 Customer Experience Presentation 49
Concern Separation (2) Subrack Manager Block Unit with DBi and transaction handling Application behavior Persistence and transaction handling concerns Subrack Manager Domain Persistence Domain CA11 Customer Experience Presentation 50
Concern Separation (3) Nested Rose RT state-machine CA11 Customer Experience Presentation 51
Concern Separation (4) CA11 Customer Experience Presentation 52
Concern Separation (5) Big nested state-machine was avoided The number of states and transitions was greatly reduced Tool Rose RT Statemachines 1 States 26 Transitions 64 PathMATE 2 11 20 Tool Action Code External Total Rose RT 375-8822 PathMATE 390 95 4774 CA11 Customer Experience Presentation 53
Conclusions PathMATE executable UML technology looks very promising PathMATE modeling and transformation environment is viable and attractive to work in Template driven code generation proven to be very powerful Concern separation proven to be very powerful PAL vs C++ CA11 Customer Experience Presentation 54