Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The paths for main file origin accept an absolute file path as well as an URL with the platform protocol of Eclipse. An URL for the field has the form plaftorm:/plugin/a.plugin.name/folder/in/the/plugin/file.txt

The snippets directory origin works analog. It accepts an absolute directory path as well as an URL with the platform protocol which points to a directory. An URL for the field has the form plaftorm:/plugin/a.plugin.name/folder/in/the/plugin

...

Prom provides project wizards, which can create and initialize a project and initialize it with a model file, a main file and wrapper code snippets. The wizards for different model file types (e.g. SCChart project vs Esterel project) differ only in the initial content for these. Other initial content is choosen from the environment, which is selected on the first page of the a Prom wizard. The project creation itself is done by another wizard, that is started from within the Prom wizard.The default content for the project is specified in the main file origin and snippets origin fields of the environment

If the snippets directory of an environment is a project relative path, the contents from the snippets origin will be copied to this location. If it is an absolute path, it is not copied to the project. Keeping snippets in a single, project indepentent folder, makes it easier to maintain them. For example it is possible to set an absolute path to a directory outside any project as directory for wrapper code snippets. This directory can then be easily maintained using a version control system. Furthermore, if an issue occurs, it has to be addressed only once, because the snippets are not copied to every new project.

For example to create a project to develop Minstorms running leJOS, one can choose the SCCharts project wizard. In this wizard, one can choose the Mindstorms NXJ environment and define what will be initialized in the project (model file, main file, snippets). Now when pressing the finish button, the related project wizard from the leJOS plugin will be started. When it finishes, the newly created project is initialized with an initial model file, main file and wrapper code snippets. (Screenshot)

Wrapper Code Generation

...

When modeling a program for an embedded system, it is necessary to set inputs and outputs of physical components (sensors/actuators) to inputs and outputs of the model. This is typically done using wrapper code. However, wrapper code is often similar for a specific device and programming language.

Therefore one can write wrapper code snippets for a target device. These can then be injected to a template file as part of a KiCo launch. What snippets are injected is defined using annotations on inputs and outputs directly in the model file.

(Image showing the three components (annotated model file, wrapper code snippets, wrapper code template) and the result of wrapper code injection)

In the template file one can use special placeholders.

${inits} will be replaced with initialization code for components (<@init>...</@init> of a snippet definition). Initialization should occur before the tick loop of the model file.

${inputs} will be replaced with code to set inputs for the model (<@input>...</@input> of a snippet definition). Setting model inputs should occur in the tick loop, before the tick function call.

${outputs} will be replaced with code to read outputs of the model. (<@output>...</@output> of a snippet definition). Reading outputs of the model should occur in the tick loop, after the tick function call.

(Image showing the structure of a template file with the placeholders and the tick loop)

FreeMarker

The wrapper code injection is done using the open source template engine FreeMarker. A wrapper code snippet is basically a Macro definition of FreeMarker. The Macro is called when the corresponding annotation is found in the model file. The file extension of FreeMarker templates is .ftl.

(Image showing snippet definition, template file, annotated model file, template file with macro calls, output file)

There is an Eclipse plugin for FreeMarker as part of the JBoss Tools Project. It can be installed using the Eclipse Marketplace.

Automatically generated files

...