Jump to: navigation, search

VIATRA2/Live Transformations/TriggerASM

Outdated page

This page contains obsolete information about the VPM based VIATRA2 and preserved for archive purposes only.
The currently maintained wiki is available at http://wiki.eclipse.org/VIATRA

The following trigger shows another important property of the live transformation engine, the handling of the ASMfunctions. These can be considered as global variables, the values stored in them are preserved throughout the triggers lifecycle.

machine HelloTriggerWorld
{
  // Beware, this is a global variable, which _holds_ it's value throughout the triggers lifecycle.
  asmfunction testFruit / 1
  {
    ("fruit") = "apple"; // Startup value of the variable
  }
 
  @Trigger(priority='100', mode='always', sensitivity='rise', startup='passive', execution='iterate')
  gtrule testTrigger(inout E) =
  {
    // This pattern triggers the action sequence.
    precondition pattern lhs(E)=
    {
      entity(E);
    }
 
    // The action sequence.
    action
    {
      println( "Trigger Action triggered by: " + E );
      println( "Trigger AsmTest: " + testFruit("fruit") );
      update testFruit("fruit") = "orange";
    }
  } 
 
  //Main rule, the startTrigger() method invokes the engine.
  rule main() =
    seq
    {
      println ( "VTCL AsmTest: " + testFruit("fruit") );
      println ( startTrigger("testTrigger") );
    }
}