VIATRA2/Live Transformations/HelloWorld

From Eclipsepedia

Jump to: navigation, search

The following "hello world" trigger is actually the simplest trigger one can write. If we start this trigger, then the action sequence will be executed after each entity creation in the model space.

machine HelloTriggerWorld
{
  @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 );
    }
  } 
 
  //Main rule, the startTrigger() method invokes the engine.
  rule main() =
    seq
    {
      println ( startTrigger("testTrigger") );
    }
}