Click Dialect API
Tier: Dialect Surface
Click prebuilt blocks, aliases, and validation/communication helpers.
Mapping and Runtime Helpers
MIGRATIONS
module-attribute
MIGRATIONS: tuple[CommentMigration, ...] = (
CommentMigration(
1,
"profile=pulse:on_dwell=..|off_dwell=.. -> flasher_on=.., flasher_off=..",
"pulse",
(
("on_dwell", "flasher_on"),
("off_dwell", "flasher_off"),
),
("on_dwell", "off_dwell"),
),
CommentMigration(
2,
"profile=ramp:up=..|down=.. -> ramp_on=.., ramp_off=..",
"ramp",
(("up", "ramp_on"), ("down", "ramp_off")),
("up",),
),
CommentMigration(
3,
"profile=approach:toward=..|rate=.. -> approach_to=.., approach_rate=..",
"approach",
(
("toward", "approach_to"),
("rate", "approach_rate"),
),
("toward", "rate"),
),
)
Formula
module-attribute
Formula: TypeAlias = (
Number
| Address
| Pointer
| Pi
| Call
| RangeCall
| Negate
| Plus
| BinaryOp
)
TagMap
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mappings
|
dict[Tag | Block, Tag | BlockRange] | Iterable[MappingEntry] | None
|
|
None
|
include_system
|
bool
|
Whether to include built-in system tag mappings
(SC/SD points). Default |
True
|
from_nickname_file
classmethod
to_nickname_file
validate
validate(
program: Program,
mode: ValidationMode = "warn",
profile: HardwareProfile | None = None,
) -> ClickValidationReport
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
program
|
Program
|
The Program to validate. |
required |
mode
|
ValidationMode
|
"warn" (findings as hints) or "strict" (findings as errors). |
'warn'
|
profile
|
HardwareProfile | None
|
Optional hardware capability profile override. |
None
|
Returns:
| Type | Description |
|---|---|
ClickValidationReport
|
ClickValidationReport with categorized findings. |
tags_from_plc_data
tags_from_plc_data(
data: Mapping[str, bool | int | float | str],
*,
blocks: Iterable[Any] | None = None,
) -> dict[str, bool | int | float | str]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Mapping[str, bool | int | float | str]
|
|
required |
blocks
|
Iterable[Any] | None
|
Click bank blocks whose slots the program uses directly,
without a TagMap entry ( |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, bool | int | float | str]
|
|
dict[str, bool | int | float | str]
|
that appear in both data and this TagMap (or blocks). |
load_snapshot
load_snapshot(
path: str | Path,
*,
skip_default: bool = True,
blocks: Iterable[Any] | None = None,
) -> SystemState
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to a CSV file exported via Click Programming Software's PLC → Read Data from PLC → All → Save. |
required |
skip_default
|
bool
|
If |
True
|
blocks
|
Iterable[Any] | None
|
Click bank blocks to seed for slots used without a
TagMap entry; see :meth: |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
SystemState
|
class: |
Warns:
| Type | Description |
|---|---|
SkippedAddressesWarning
|
If some TXT addresses can be read more than
one way. CLICK writes a TXT comma without quotes, so a TXT row that
holds a comma and an empty address can be read more than one way.
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the file is not a readable PLC data dump. The message keeps the reader's detail, such as the row that is malformed. |
SystemNicknameRepair
dataclass
SystemNicknameRepairRequired
Bases: ValueError
TagMeta
dataclass
OldCommentFormError
Bases: ValueError
SkippedAddressesWarning
Bases: UserWarning
LadderBundle
dataclass
LadderExportError
Bases: RuntimeError
CodegenIdentityError
Bases: Exception
ClickDataProvider
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
runner
|
PLC | Callable[[], PLC]
|
The active |
required |
tag_map
|
TagMap
|
Mapping from logical tag names to Click hardware addresses. |
required |
fallback
|
DataProvider | None
|
Optional provider for unmapped addresses. Defaults to an in-memory provider. |
None
|
blocks
|
Iterable[Any] | None
|
Click bank blocks whose slots the program uses directly,
without a TagMap entry ( |
None
|
on_stop
|
Callable[[], None] | None
|
Called instead of |
None
|
ModbusAddress
dataclass
ModbusReceiveInstruction
dataclass
ModbusRtuTarget
dataclass
Bases: _TargetEquality
ModbusSendInstruction
dataclass
Bases: Instruction
ModbusTcpTarget
dataclass
Bases: _TargetEquality
RegisterType
Bases: Enum
WordOrder
Bases: Enum
NopInstruction
UndecodedInstruction
Bases: Instruction
ClickValidationReport
dataclass
ClickFinding
dataclass
Bases: _FindingTextMixin
StepEstimate
dataclass
ladder_to_pyrung
ladder_to_pyrung(
source: str | Path | LadderBundle,
*,
nickname_csv: str | Path | None = None,
nicknames: dict[str, str] | None = None,
analog_inputs: Iterable[str] = (),
output_path: str | Path | None = None,
validate: bool = True,
) -> str
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str | Path | LadderBundle
|
A file path (to main.csv or a directory containing main.csv
and optional |
required |
nickname_csv
|
str | Path | None
|
Optional path to a Click nickname CSV file (Address.csv).
Read via |
None
|
nicknames
|
dict[str, str] | None
|
Optional pre-parsed |
None
|
analog_inputs
|
Iterable[str]
|
Analog input DF addresses supplied by project channel parameters; their generated tags are marked external. |
()
|
output_path
|
str | Path | None
|
Optional path to write the generated Python file.
If |
None
|
validate
|
bool
|
When True (default), run three codegen self-checks. A settings
check confirms that the declarations give each address the Retentive
setting and initial value of its nickname CSV row (it raises
:class: |
True
|
Returns:
| Type | Description |
|---|---|
str
|
The generated Python source code as a string. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If both |
TypeError
|
If |
CodegenIdentityError
|
If |
ladder_to_pyrung_project
ladder_to_pyrung_project(
source: str | Path | LadderBundle,
*,
nickname_csv: str | Path | None = None,
nicknames: dict[str, str] | None = None,
analog_inputs: Iterable[str] = (),
output_dir: str | Path | None = None,
index: bool = False,
overwrite: bool = False,
machine_name: str = "PLC",
validate: bool = True,
host_guides: Sequence[str] = (),
) -> dict[str, str]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str | Path | LadderBundle
|
A file path (to main.csv or a directory containing main.csv
and optional |
required |
nickname_csv
|
str | Path | None
|
Optional path to a Click nickname CSV file (Address.csv). |
None
|
nicknames
|
dict[str, str] | None
|
Optional pre-parsed |
None
|
analog_inputs
|
Iterable[str]
|
Analog input DF addresses supplied by project channel parameters; their generated tags are marked external. |
()
|
output_dir
|
str | Path | None
|
Optional directory to write the project files into.
If |
None
|
overwrite
|
bool
|
When False (default), scaffolding files (pyproject.toml,
README.md, .vscode/) are skipped if they already exist on disk.
In an existing |
False
|
machine_name
|
str
|
Human-readable machine name for AGENTS.md header (e.g. from the .ckp filename). |
'PLC'
|
validate
|
bool
|
When True (default), run codegen self-checks (see
:func: |
True
|
host_guides
|
Sequence[str]
|
File names of the guides that the tool building the
project writes itself, such as |
()
|
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
A dict mapping relative file paths to their content, e.g. |
dict[str, str]
|
|
pyrung_to_ladder
pyrung_to_ladder(
program: Program,
tag_map: TagMap,
*,
index: bool = False,
validate: bool = True,
allow: Collection[str] = (),
) -> LadderBundle
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
program
|
Program
|
The Program to export. |
required |
tag_map
|
TagMap
|
TagMap mapping logical tags to Click hardware addresses. |
required |
index
|
bool
|
When True, number rung markers sequentially (R1, R2, ...)
instead of bare |
False
|
validate
|
bool
|
When True (default), run pre-export checks and round-trip
verification. The rows must analyze back to the program's outputs.
Importing them ( |
True
|
allow
|
Collection[str]
|
Finding codes that the precheck lets through, for an export that knowingly carries what the CLICK editor refuses (the conformance suite's paste probes). The precheck still refuses the export for other findings. |
()
|
Returns:
| Type | Description |
|---|---|
LadderBundle
|
A LadderBundle containing main and subroutine row matrices. |
send
send(
*,
target: str | ModbusTcpTarget | ModbusRtuTarget,
remote_start: str | ModbusAddress,
source: Tag | BlockRange,
sending: Tag | None = None,
success: Tag | None = None,
error: Tag | None = None,
exception_response: Tag | None = None,
count: int | None = None,
word_swap: bool = False,
) -> None
receive
receive(
*,
target: str | ModbusTcpTarget | ModbusRtuTarget,
remote_start: str | ModbusAddress,
dest: Tag | BlockRange,
receiving: Tag | None = None,
success: Tag | None = None,
error: Tag | None = None,
exception_response: Tag | None = None,
count: int | None = None,
word_swap: bool = False,
) -> None