Stop Watch
Block Group: | Logic |
Icon: |
The Stop Watch block counts up when enabled. An event is fired when the block loops or stops.
For information on using dataflow blocks, see Dataflow.
Input/Output Properties
The following properties of the Stop Watch block can take input and give output.
- enabled (boolean)
- interval (number)
- step (number)
- modulo (number)
- loop (boolean)
- reset (trigger)
- onLoop (event)
enabled sets or returns whether the Stop Watch block is currently counting up.
interval specifies the duration, in seconds, between updates to the output property. For example, if interval is 0.5, the output property counts up every 0.5 seconds.
step specifies the number that is added to the output with each update. For example, if step is 1, then each time the stopwatch counts up, its output increases by 1.
modulo Specifies the value that signals the stopwatch to loop or stop.If loop is TRUE, then the stopwatch will loop when it reaches the final step before modulo, and output is always less than modulo. If loop is FALSE, then the stopwatch will stop when it reaches modulo or the final step before modulo, and output is always equal to or less than modulo.
loop determines whether the Stop Watch block will start again when it nears modulo.
- TRUE—The stopwatch starts again after its output reaches the final step before reaching modulo. If the difference between the final step and modulo equals the step value, the stopwatch restarts at 0. If the difference is less than the step value, the stopwatch restarts with a value of that difference.
- FALSE—The stopwatch stops counting when it reaches the final step where output is less than or equal to modulo.
reset causes the stopwatch to restart at 0.
onLoop fires when the stopwatch either loops or stops.
Output Property
The following property of the Stop Watch block can give output but cannot take input.
- output (number)
output returns the current stopwatch value.
Example
The following image demonstrates a Stop Watch block. In this example, the block counts up by 1 every 0.5 seconds.
Use Case
This thread in the DGLogik Community Forum shows a use cases for the block: