composition of xml dialects
play

Composition of XML Dialects A ModelicaXML case study Adrian Pop, - PowerPoint PPT Presentation

Composition of XML Dialects A ModelicaXML case study Adrian Pop, Ilie S avga, Uwe Amann, Peter Fritzson Programming Environments Laboratory Linkping University Outline Introduction Modelica ModelicaXML Compost


  1. Composition of XML Dialects A ModelicaXML case study Adrian Pop, Ilie S avga, Uwe Aßmann, Peter Fritzson Programming Environments Laboratory Linköping University

  2. Outline � Introduction � Modelica � ModelicaXML � Compost � ModelicaXML extension of Compost � Modelica Component Model � Composition programs � Conclusions and Future Work April 03, 2004 2

  3. Introduction � Why the need for Modelica composition and transformation? � Interoperability between existing modeling languages or CAD tools and Modelica � Automatic generation of different version of models from product specifications. Choosing best design based on automatic simulation. � Automatic configuration of models using external sources (XML, databases, files) � Protection of intellectual property through obfuscation � Fine grain support for library developers April 03, 2004 3

  4. Modelica � Declarative language � Equations and mathematical functions allow acausal modeling, high level specification, increased correctness � Multi-domain modeling � Combine electrical, mechanical, thermodynamic, hydraulic, biological, control, event, real-time, etc... � Everything is a class � S trongly typed obj ect-oriented language with a general class concept, Java & Matlab like syntax � Visual component programming � Hierarchical system architecture capabilities � Efficient, non-proprietary � Efficiency comparable to C; advanced equation compilation, e.g. 300 000 equations April 03, 2004 4

  5. Modelica Visual Programming Decomposition and Abstraction of an Automatic Gearbox d e m u l t p i e l x bearing4 bearing2 bearing1 2 2 C 1 1 . . 8 0 = 0 = . = 0 2 6 1 1 C 2 C shaftS=2e-3 shaftS1=2e-3 S S C4=0.12 C5=0.12 C11=0.12 planetary1=110/50 planetary2=110/50 planetary3=120/44 April 03, 2004 5

  6. ModelicaXML class Test "comment" modelicaxml Real x; Modelica Real xdot; definition equation code xdot = der (x); component equation end Test; read Modelica Parser component < modelicaxml > output < definition ident = "Test" c omment ="comment"> Modelica < component ident ="x" type ="Real" visibility ="public" /> XML < component ident ="xdot" type ="Real" visibility ="public" /> < equation >...</ equation > </ definition > </ modelicaxml > April 03, 2004 6

  7. Compost Overview UNICOMP 5 Interface layer UNICOMP Components Abstract Components Abstract 4 Composition (Boxes) (Core) Semantics Layer Time specific Time Fragment Run Time 3 Composition specific rules Boxes Boxes Layer XML Java Lazy Language specific Fragment Fragment Runtime 2 Composition Layer .... Box Box Component Runtime Java Transformation ModelicaXML X-HTML SVG Fragment Objects Engine 1 Fragment XMI Modelica Values Layer Runtime etc. Values Semantics Java rules Semantics X-HTML rules XML Dialects April 03, 2004 7

  8. ModelicaXML extension of Compost Modelica Code Modelica Modelica UnParser Parser ModelicaXML Composition programs Modelica Compost on Component + Modelica Model XML Recoder Composition,Transformation, and Refactoring Modelica Box Hierarchy on Modelica Components Modelica Hook Hierarchy April 03, 2004 8

  9. Modelica Component Model – Box hierarchy XMLBox ModelicaXMLBox 0..* ModelicaElement ModelicaContainer ModelicaComponent ModelicaClass ModelicaType ModelicaEquationSection ModelicaModel ModelicaPackage ModelicaAlgorithmSection ModelicaRecord ModelicaFunction ModelicaBlock ModelicaConnector April 03, 2004 9

  10. Example Box Hierarchy < definition ident ="Engine" restriction ="class"> < component visibility ="public” variability ="parameter" type ="Integer" ident ="cylinders"> < modification_equals > < integer_literal value ="4"/> </ modification_equals > </ component > < component visibility ="public" type ="Cylinder" ident ="c"> < array_subscripts > < component_reference ident="cylinders"/> </ array_subscripts > </ component > class Engine </ definition > parameter Integer cylinders = 4; ModelicaClass Cylinder c[cylinders]; end Engine; ModelicaComponent ModelicaComponent April 03, 2004 10

  11. Modelica Component Model – Hook hierarchy Hook ImplicitHook DeclaredHook XMLImplicitHook XMLDeclaredHook ModelicaParameterHook ModelicaModifierHook ModelicaRealHook Other Modelica Hooks ModelicaIntegerHook ModelicaStringHook April 03, 2004 11

  12. Example: Hooks < component visibility ="public” variability ="parameter" type ="Integer" ident ="cylinders"> < modification_equals > < integer_literal value ="4"/> ModelicaParameterHook </ modification_equals > name </ component > value parameter Integer cylinders = 4; < definition ident =”NewEngine" restriction ="class"> < extends type =”Engine”> class NewEngine .... extends Engine; </ definition > .... end NewEngine; < definition ident =”Engine” restriction ="class"> < extract > < component >..</ component > ... </ extract > </ definition > April 03, 2004 12

  13. Composition Programs: Mixin ModelicaCompositionSystem cs = new ModelicaCompositionSystem(); ModelicaClass resultBox = cs.createModelicaClass(”Class1.mo.xml”); ModelicaClass firstMixin = cs.createModelicaClass(”Class2.mo.xml”); ModelicaClass secondBox = cs.createModelicaClass(”Result.mo.xml”); resultBox.mixin(firstMixin); resultBox.mixin(secondMixin); resultBox.print(); April 03, 2004 13

  14. Composition Program: Input class CelestialBody ``Celestial Body'' Real mass ; String name ; constant Real g = 6.672e-11 ; parameter Real radius ; end CelestialBody ; April 03, 2004 14

  15. Composition Program ModelicaCompositionSystem cs = new ModelicaCompositionSystem(); ModelicaClass bodyBox = cs.createModelicaClass(``Body.mo.xml''); ModelicaClass celestialBodyBox = cs.createModelicaClass(``Celestial.mo.xml''); ModelicaElement extractedPart = celestialBody.findHook(``extract'').getValue(); celestialBody.findHook(``extract'').bind(null); bodyBox.append(extractedPart); bodyBox.print(); celestialBody.findHook(``superclass'').bind(``Body''); celestialBody.print(); April 03, 2004 15

  16. Composition Programs: Result class Body ``Generic Body'' Real mass ; String name ; end Body ; class CelestialBody ``Celestial Body'' extends Body ; constant Real g = 6.672e-11 ; parameter Real radius ; end CelestialBody ; April 03, 2004 16

  17. Conclusions and Future Work � ModelicaXML+Compost � a start in providing better tools for Modelica language � Future Work � refine the Modelica+Compost extension � more composition operators � validation of composition using OpenModelica compiler � automatic generation of Modelica component model from the Modelica ontology April 03, 2004 17

  18. End 18 Questions? Thank you! April 03, 2004

  19. ModelicaXML and Compost � ModelicaXML � http:/ / www.ida.liu.se/ ~adrpo/ modelica/ xml � Compost � http:/ / www.the-compost-system.org/ April 03, 2004 19

  20. oftware Composition Workshop 2004, Barcelona 20 Transformation and Composition Components Sagrada Familia April 03, 2004 S

Recommend


More recommend