Page History
...
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.
In SCT files, annotations are added as in java, with an at-sign e.g. @LightSensor S3. You can write implicit and explicit wrapper code annotations.
Explicit annotations have the form @Wrapper SnippetName arg1 arg2 ... argN
. An explicit wrapper annotation raises an error if the snippet does not exist, thus it is recommened to use the explicit @Wrapper annotation. Every other annotation is tried as wrapper code annotation as well, but will be ignored, if no such snippet could be found. Thus you can write the above explicit annotation as @SnippetName arg1 arg2 ... argN
, but there will be no error if the snippet with this name does not exist or could not be found e.g. because of a typo.
In the template file one can use special placeholders.
...
${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.
To ease the modification of the template file, one can open it with the text editor the final code will be for. This will enable syntax highlighting and code completion for the langauge, but it will not show any errors. You can open the file for example with the Java Editor of Eclipse using Right Click > Open With > Other > Java Editor
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.
...