VR-Forces 4.2 Class Documentation
13.9 - Triggers

Trigger (DtSimTrigger, in simTrigger.h) objects are created by When statements (DtWhenStmt) when they are executed.

Triggers register with a DtPlan object so that they can get ticked. They keep a pointer to the plan so that they can unregister when they fire and are deleted.

When a DtSimTrigger is created, it saves a pointer to the When statement that created it. When DtSimTrigger::tick() is called, the trigger uses the DtWhenStmt statement pointer to get the conditional expression so that it can test it. When the trigger condition becomes true, the following occurs:

  1. The trigger's activate() function is called. The activate() function uses its DtWhenStmt pointer to look up the matching DtWhenBlock pointer.
  2. If the trigger is a "ReTask" trigger, the trigger tells the DtPlan to pushExecutionStack().

    Note
    The type of trigger is specified in the Option parameter in the trigger block in a plan, as in:
    (Option "ReTask")

    In a ReTask trigger, when the trigger fires, the entity stops executing the current task and begins to execute the trigger block. When the trigger is complete, the entity executes the first plan statement after the task it was executing at the time the trigger fired.

    The ReTask option is the only option implemented by VR-Forces. A user cannot change the trigger type in the GUI.

  3. The trigger tells the DtPlan to execute the DtWhenBlock by calling DtPlan::executeTrigger().
  4. The trigger sets its isDone flag, which indicates to the DtPlan that it should be deleted
Note
If a trigger block contains only set data requests, concurrent tasks, or both, the current task is not interrupted. The sets and concurrent tasks are executed while the current task continues to be executed. For details about triggers and how they work from the user perspective, please see VR-Forces Scenario Management Guide.

[<< Conditional Expressions] [Home] [Top of Page]


Document ID: Generated on Sun Nov 24 19:49:21 EST 2013 from SVN revision 133924
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)