Skip to main content

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.

Jump to: navigation, search

VIATRA2/Live Transformations/HelloWorld

< VIATRA2‎ | Live Transformations
Revision as of 10:59, 2 July 2008 by Unnamed Poltroon (Talk) (New page: The following "hello world" trigger shows another important property of the live transformation engine, the handling of the ASMfunctions. These can be considered as global variables, the v...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The following "hello world" 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. If we start this trigger, then the action sequence will be executed after each entity creation in the model space.

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") );
    }
}

Back to the top