time
Look up time.interval, time.wait, and time.now, the timers and the clock of an Arc automation.
The time module has timers and the clock. Import it with import time. interval and
wait are flow functions: a function body cannot call them.
The period and duration parameters have the type i64 ns. They take a literal, such
as 500ms or 10hz, or a variable of type i64 ns. A variable declared as
hold := 5s has the type i64 s, and gives error ARC3002 expected i64 ns, got i64 s.
Declare it with the type:
import time
hold i64 ns := 5s
sequence fire {
time.wait{duration=hold} => next
1 -> ign_cmd
}
start_cmd == 1 => fireA literal of 0 or less is a compile error, such as period must be positive, got 0s. A
variable that becomes 0 or less stops the timer and reports an error. On the Core the
error is a warning. On a Driver it stops the automation.
interval
Fires again and again, once each period.
periodi64 nsRequiredThe time between two fires.
- Input -> optional. Trigger-only: the first input value starts the timer, and later values have no effect. With no input, the timer starts when its stage starts.
- Output ->
u8value 1 on each fire, with the time of the cycle. - Runs -> on the first timer cycle after the timer starts, then on a fixed schedule,
once each
period. A late fire does not move the next one. When a cycle takes longer thanperiod, the timer fires once and does not make up the fires that it missed. At the top level, it fires when the automation starts.
import time
time.interval{period=1s} -> heartbeatnow
Gives the current time.
- Input -> optional. Trigger-only: each new input value runs it, whatever the value. With no input, it runs once each time its stage starts.
- Output -> the time as a timestamp, type
i64 ns. Write it to atimestampchannel or ani64channel. Another channel type, such asf64, is an error. - Function form ->
time.now(). All calls in the same cycle give the same time.
now has no parameters.
import time
start_cmd == 1 => time.now{} -> start_timewait
Fires once, after duration.
durationi64 nsRequiredThe time to wait.
- Input -> optional. Trigger-only: the first input value starts the timer, and later values have no effect. With no input, the timer starts when its stage starts.
- Output ->
u8value 1, once, with the time of the cycle. - Runs -> when
durationhas passed since the timer started. It counts from zero again each time its stage starts. As a sequence step, the sequence moves on when it fires.
import time
sequence fire {
1 -> ign_cmd
time.wait{duration=2s} => next
1 -> press_vlv_cmd
}
start_cmd == 1 => fireThe timers follow the same rules on the Core and on a Driver. They never fire early. How soon after its deadline a timer fires depends on where the automation runs and its performance level. See Arc timing.