2. ProblemDefinition Wehave a source XML filedescribing a system, accordingto a XML Schemametamodel System has manyelements of thetypeControllable Thegoalistogeneratea cppimplementationforeachControllabletypeelement
4. ProblemDefinition Source XML file The XML file describes a system Thesystem has manycontrollables Eachcontrollable has inputs, outputs, params, faults… Target .h and .cppfileforeachControllable The generation of the .H file is straightforward The generation of the .CPP file comprises several RuleSets Locals: For each input/output/param/fault/timer define a local of that type doInit initialize each local variable by getting its value (using mappings in wtsl) WHY IS USED? We’ll use MDWorkbench forthatpurpose
5. MDWorkbench MDWorkbench is a model-driven engineering development environment to build: Source code and text generators Word documentation Model transformers Eclipse-based IDE Java code may be used in MDWorkbench projects Developed by Sodius SAS
9. 1. Importing a metamodel MDWorkbench nativelyallowstoworkwithEcore, Relationalor UML models New metamodels can beimported, allowingtoworkwithdifferentkind of models Importing a metamodelconsists in creatingan Eclipse pluginwhichwillbeusedby MDWorkbench Ourmetamodelisdefinedusing XML Schema
10. 1. Importing a metamodel 1 3 4 2 Select the specific file
11. 1. Importing a metamodelCreatingPlugin Wenowhavetoexportthecreatedproject as a plugin Whenwerestart MDWorkbench the new metamodelwillbeavailable
12. 2. Browsingthemodel Once themetamodel has beenimportedwe can open themodel in MDWorkbench and browseit
13. 3. Writingthegenerators Rulesets, texttemplates and scripts can beusedtogeneratecode Rulesets are written in MQL Templatesarwritten in TGL Scripts can bewritten in MQL, TGL or Java First sketch of thesolution: Twocodetemplates: onefor .h files and otherfor .cpp files A ruleset: toapplythetemplatestoeachcontrollable in themodel Scripts: we’llcalltosomescrpitsfromthetemplatestogettheelements of thecontrollable