Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "VIATRA2/UseCases/DebuggingAndVisualisation"
m (format updates) |
(→The VIATRA Console) |
||
Line 28: | Line 28: | ||
=== Undoable Transformations === | === Undoable Transformations === | ||
− | When [[VIATRA2/GettingStarted/Using_Transformations| | + | When [[VIATRA2/GettingStarted/Using_Transformations|you execute a transformation program]] from the user interface of VIATRA2, it may change the model space (although these changes are not automatically saved). However, during transformation development, it is a common need to execute the same transformation program on the same model, so it is useful to be able to revert the changes after a transformation has been executed. |
− | + | To achieve this, the <code>runmachineundoable</code> and <code>runruleundoable</code> commands can execute ASM machines or a single ASM rule in a way that the <code>undotransaction</code> command can undo all of their changes. This technique speeds up the debugging process by eliminating the need to close and re-open model spaces. | |
− | + | An example interaction sequence may look like this: | |
+ | |||
+ | runmachineundoable(notions.transformer,Model=notions.model.01_preliminaries) | ||
+ | > runmachineundoable([notions.transformer, Model=notions.model.01_preliminaries]) | ||
+ | [info] Entity successfully interpreted. | ||
+ | [info] Trigger engine: A transactional operation ended in the system. | ||
+ | [info] Transformation engine ran for 61 milliseconds. | ||
+ | [info] Transformation transaction ID: TRANS_4 | ||
+ | |||
+ | undotransaction(TRANS_4) | ||
+ | > undotransaction([TRANS_4]) | ||
+ | [info] Trigger engine: A transactional operation ended in the system. | ||
+ | |||
+ | In this sequence, we first execute the "notions.transformer" transformation (using an input parameter mapping where the "Model" parameter takes the value of "notions.model.01_preliminaries") in an undoable transaction, and then undo this transaction to ensure that the state of the model space is restored to its original (before the transformation was executed). | ||
+ | |||
+ | === Command scripts === | ||
+ | The VIATRA Console has the ability to save a history of executed commands into line-delimited textual files ("command scripts"), by calling the ''savecommandscript'' built-in command. These scripts can be later loaded and automatically executed, by the ''executecommandscript'' built-in command. You can use this facility as a light-weight batch execution environment for e.g. importing models (''nativeimport''), executing rules or transformations (''runmachine'') etc. | ||
+ | |||
+ | === Extending the VIATRA Console with new commands === | ||
== Model Space Visualisation and Debugging == | == Model Space Visualisation and Debugging == |
Revision as of 10:03, 7 September 2010
Contents
Transformation Debugging in VIATRA2
The VIATRA2 framework does not contain a dedicated debugger, but there are other features that can be used to support debugging. These are:
- Output rules
- The VIATRA Console
- Undoable Transformations
- Executing Single Rules
- Model Space Visualisation
Output rules
The print
and println
rules can be used to output the value of any selected transformation program variable to the output. A typical use would be to output the matches of the precondition in the action part of a graph transformation rule:
gtrule rule(in Token) = { precondition find token(Token) action { println(Token); } }
The VIATRA Console
The VIATRA framework provides a VIATRA2 Console view that is capable of displaying the messages of the framework, and allowing the execution of commands. By default the debug messages are disabled because of their possible large number - it is only recommended to turn it on while it is explicitely needed.
The commands of the console can be listed used the listcommands
code together with a short description. The Console supports command name auto-completion, by using the tab key.
Executing single rules
During debugging it is a common need to run only a single ASM rule of the transformation program, not the whole of it. The runrule
allows executing a single rule of the transformation on the current model space.
Undoable Transformations
When you execute a transformation program from the user interface of VIATRA2, it may change the model space (although these changes are not automatically saved). However, during transformation development, it is a common need to execute the same transformation program on the same model, so it is useful to be able to revert the changes after a transformation has been executed.
To achieve this, the runmachineundoable
and runruleundoable
commands can execute ASM machines or a single ASM rule in a way that the undotransaction
command can undo all of their changes. This technique speeds up the debugging process by eliminating the need to close and re-open model spaces.
An example interaction sequence may look like this:
runmachineundoable(notions.transformer,Model=notions.model.01_preliminaries) > runmachineundoable([notions.transformer, Model=notions.model.01_preliminaries]) [info] Entity successfully interpreted. [info] Trigger engine: A transactional operation ended in the system. [info] Transformation engine ran for 61 milliseconds. [info] Transformation transaction ID: TRANS_4 undotransaction(TRANS_4) > undotransaction([TRANS_4]) [info] Trigger engine: A transactional operation ended in the system.
In this sequence, we first execute the "notions.transformer" transformation (using an input parameter mapping where the "Model" parameter takes the value of "notions.model.01_preliminaries") in an undoable transaction, and then undo this transaction to ensure that the state of the model space is restored to its original (before the transformation was executed).
Command scripts
The VIATRA Console has the ability to save a history of executed commands into line-delimited textual files ("command scripts"), by calling the savecommandscript built-in command. These scripts can be later loaded and automatically executed, by the executecommandscript built-in command. You can use this facility as a light-weight batch execution environment for e.g. importing models (nativeimport), executing rules or transformations (runmachine) etc.
Extending the VIATRA Console with new commands
Model Space Visualisation and Debugging
The model space visualisation component can be used to view a part of the model space as a graph, and it also reacts to changes of the model space: when a displayed model element changes (e.g. after the execution of a rule it is deleted), the changes are immediately reflected on the visualisation (e.g. the related node is deleted).
It is important to note that the model space visualisation component only helps to understand the actual state of the model space, but it does not contain any option to alter it.