Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.

20090109 Dsl2cpp Md Workbench

225 Aufrufe

Veröffentlicht am

Veröffentlicht in: News & Politik, Technologie
  • Als Erste(r) kommentieren

  • Gehören Sie zu den Ersten, denen das gefällt!

20090109 Dsl2cpp Md Workbench

  1. 1. Ander Zubizarreta 9/1/2009<br />DSLto C++<br />Sysdefcodegenerationusing MDWorkbench<br />
  2. 2. ProblemDefinition<br />Wehave a source XML filedescribing a system, accordingto a XML Schemametamodel<br />System has manyelements of thetypeControllable<br />Thegoalistogeneratea cppimplementationforeachControllabletypeelement<br />
  3. 3. Problemdefinition<br />XSD<br />
  4. 4. ProblemDefinition<br />Source<br />XML file<br />The XML file describes a system<br />Thesystem has manycontrollables<br />Eachcontrollable has inputs, outputs, params, faults…<br />Target<br />.h and .cppfileforeachControllable<br />The generation of the .H file is straightforward<br />The generation of the .CPP file comprises several RuleSets<br />Locals:<br />For each input/output/param/fault/timer <br />define a local of that type<br />doInit<br />initialize each local variable<br />by getting its value (using mappings in wtsl)<br />WHY IS USED?<br />We’ll use MDWorkbench forthatpurpose<br />
  5. 5. MDWorkbench<br />MDWorkbench is a model-driven engineering development environment to build:<br />Source code and text generators<br />Word documentation<br />Model transformers<br />Eclipse-based IDE<br />Java code may be used in MDWorkbench projects<br />Developed by Sodius SAS <br />
  6. 6. MDWorkbench<br />
  7. 7. Solution<br />Metamodel<br />C++ code<br />Model<br />Rules<br />Templates<br />
  8. 8. Steps<br />Importthemetamodelto MDWorkbench<br />Browsethemodelusing MDWorkbench<br />Createtherulesets and templatesforcodegeneration<br />Runthegenerator<br />
  9. 9. 1. Importing a metamodel<br />MDWorkbench nativelyallowstoworkwithEcore, Relationalor UML models<br />New metamodels can beimported, allowingtoworkwithdifferentkind of models<br />Importing a metamodelconsists in creatingan Eclipse pluginwhichwillbeusedby MDWorkbench<br />Ourmetamodelisdefinedusing XML Schema<br />
  10. 10. 1. Importing a metamodel<br />1<br />3<br />4<br />2<br />Select the specific file<br />
  11. 11. 1. Importing a metamodelCreatingPlugin<br />Wenowhavetoexportthecreatedproject as a plugin<br />Whenwerestart MDWorkbench the new metamodelwillbeavailable<br />
  12. 12. 2. Browsingthemodel<br />Once themetamodel has beenimportedwe can open themodel in MDWorkbench and browseit<br />
  13. 13. 3. Writingthegenerators<br />Rulesets, texttemplates and scripts can beusedtogeneratecode<br />Rulesets are written in MQL<br />Templatesarwritten in TGL<br />Scripts can bewritten in MQL, TGL or Java<br />First sketch of thesolution:<br />Twocodetemplates: onefor .h files and otherfor .cpp files<br />A ruleset: toapplythetemplatestoeachcontrollable in themodel<br />Scripts: we’llcalltosomescrpitsfromthetemplatestogettheelements of thecontrollable<br />
  14. 14. 3. Writingthegenerators<br />Ruleset:<br />cppGenerator.mqr<br />Templates:<br />hGen.tgt<br />cppGen.tgt<br />Scripts:<br />doGetInitializations()<br />doGetLocalsDefinitions()<br />
  15. 15. 3. WritingthegeneratorshGen.tgt<br />Refer to “20081202_MDWorkbench_Tool.ppt” for a detailed overview of Templates<br />
  16. 16. 3. WritingthegeneratorscppGen.Tgt (callto script)<br />Refer to “20081202_MDWorkbench_Tool.ppt” for a detailed overview of Templates<br />
  17. 17. 3. WritingthegeneratorsScripts<br />Refer to “20081202_MDWorkbench_Tool.ppt” for a detailed overview of Scripts<br />
  18. 18. 3. WritingthegeneratorsRuleset<br />cppGeneration.mqr: appliesthetexttemplatestoeachcontrollable<br />Refer to “20081202_MDWorkbench_Tool.ppt”for a detailed overview of Rulesets<br />
  19. 19. 4. RunningthegeneratorRunconfiguration<br />Selecttheruleset as themainelementwewanttorun and the input model<br />
  20. 20. 4. RunningthegeneratorOutput<br />Console output:<br />Report:<br />
  21. 21. 4. RunningthegeneratorOutput<br />Part of a generated .cppfile:<br />

×