0.60

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 Get running statistics and rates of change.
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 Fire timers and read 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 input a with b. Same as >=, >, <=, <, ==, !=.
len len(x) -> i64 Get the length of a series or a string. Only in a function body.

on and write are the nodes that the graph editor shows as Telemetry source and Telemetry sink. In text, a channel name does the same work:

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 input fills 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.