ReferenceControlArcStandard library

Standard library

Find the modules and built-in functions that every Arc automation can use.

The Arc standard library has modules and built-in functions. To use a module, import it at the top of the file, then call its functions by their qualified name. A qualified name without an import is an error.

import time

time.interval(period=1s) -> heartbeat

Modules

Module Functions Use
control set_authority Change control authority while it runs.
math avg, min, max, derivative, is_nan, is_infinite, is_finite Get running statistics and rates of change. Test floats.
ranges create, end Mark a period of time as a range.
stable for Pass a value only after it holds steady.
status set Set an alarm, a warning, or a state.
time interval, wait, now, format Fire timers and read or print the time.

Built-in functions

Built-in functions need no import.

Function Signature Use
select bool -> select() -> (true, false) Send each value to a true or a false routing entry.
on on(channel) -> T Read a channel. Same as a channel name at the start of a flow.
write T -> write(channel) -> u8 Write a channel. Same as a channel name at the end of a flow.
ge, gt, le, lt, eq, ne T -> gt(b) -> bool Compare the trigger a with b. Same as >=, >, <=, <, ==, !=.
len len(x) -> i64 Get the length of a series or a string. Only in a function body.

A channel name does the same work as on and write:

on(channel=tank_pt) -> tank_pt_copy
tank_pt -> write(channel=tank_pt_copy)

on and write cannot be in the same flow. The compiler cannot find a type for them and stops with on_0_T: unresolved type variable: constraints.

The comparison functions take two numeric values, a and b, of the same type. A flow value fills the trigger a, and () sets b:

tank_pt -> gt(b=300.0) -> tank_high

and, or, and not are keywords, so text code cannot call them as functions. Use the operators.

Deprecated names

The names avg, min, max, derivative, interval, wait, now, set_authority, and stable_for without a module still compile, with warning ARC4003. Use the qualified names, such as math.avg and stable.for.