0.60

ReferenceChannelsFind

Find channels

Find channels in the Console, or retrieve them in code by name, key, pattern, or search term.

In the Console, you find a channel to plot it or to add it to a schematic. In a script, you retrieve a channel before you read or write its data.

Find a channel in the Console

The channels toolbar lists all of the channels in Synnax. To open it, click or press C. To add a channel to a schematic, drag it from the toolbar onto the schematic.

To find a channel by name, click at the top of the left bar, or press Ctrl+P (Cmd+P on macOS), to open the search palette. Then type part of the name. Select a result to add the channel to the open line plot, or to a new line plot. A virtual channel opens in a log.

Retrieve channels in code

A script gets a channel from the Core before it reads or writes its data. Retrieve channels by name or key, by a pattern, or by a search term.

By name or key

Enterprise
# One channel, by name or by key
tank_pressure = client.channels.retrieve("tank_pressure")
tank_pressure = client.channels.retrieve(tank_pressure.key)

# Many channels, by names or by keys
channels = client.channels.retrieve(["tank_pressure", "tank_temperature"])
channels = client.channels.retrieve([tank_pressure.key, tank_temperature.key])

When you pass one name or key, retrieve returns one channel. It raises sy.NotFoundError when no channel matches. When you pass a list, retrieve returns a list and leaves out the channels that it does not find.

Pass names or keys, not both in one list. A key never changes, but a name can change. Store keys in programs that run for a long time.

By pattern

A name that is not a valid channel name is a regular expression, in Go RE2 syntax. The pattern must match the full name, unless it starts with ^ or ends with $. For example, tank_.* matches tank_pressure and tank_time, but not ox_tank_pressure.

Enterprise
# Returns list[sy.Channel]
tank_channels = client.channels.retrieve(["tank_.*"])

Put the pattern in a list. With a pattern that is not in a list, retrieve raises sy.MultipleFoundError when more than one channel matches.

By search term

Both clients can search channels by a part of their name and filter them by their properties.

Enterprise
import synnax as sy

matches = client.channels.retrieve(search_term="pressure", limit=10)
floats = client.channels.retrieve(data_types=[sy.DataType.FLOAT32], is_index=False)

The filters are search_term, data_types, not_data_types, is_index, virtual, internal, node_key, limit, and offset. Results match all the filters. Use range_key to include aliases from a range and search those aliases too. Set include_status=True to attach each channel’s status; a channel with no status gets None.

Find the channels of a range

A range can give channels a different name, called an alias. To find channels by alias, or to read their data in a range, see read and write range data.