Skip to main content

Execution Control

Wait commands​

These commands are specific to OneVision Scripts and are used for handling timing and synchronization in computer vision tasks.

info

Instead of events, waits expect conditions.

  • WaitOn: Waits for a condition to be true.

    waitOn(condition);
  • WaitOff: Waits for a condition to be false.

    waitOff(condition);
  • WaitTime: Waits a specific amount of time, in milliseconds.

    waitTime(milliseconds);

For example:

// Assume some condition variables
global var increments = 0;
global var flag = true;

// Wait for a condition to become true. For example some variable in a different sequence sets camera to 3
waitOn(increments>3);

// Wait for a specific time (e.g., 2000 milliseconds or 2 seconds)
waitTime(2000);

// Waits for another sequence to set flag to false
waitOff(flag);

Stop command​

The stop command finishes the runtime execution. This is useful for terminating the execution based on certain conditions or errors.

For example:

var isError = true;

if (isError) {
console.log("An error occurred. Stopping execution.");
stop();
}

// This code will not execute if stop() is called
console.log("This line will not be reached if stop() is executed.");