Addressing API¶
Tier: Stable Core
Address model and canonical normalized address helpers.
pyclickplc.AddressRecord
dataclass
¶
Immutable record for a single PLC address.
Simpler than ClickNick's AddressRow -- omits all UI validation state.
For user-facing creation from display addresses, prefer
make_address_record(...).
is_default_retentive
property
¶
Return True if retentive matches the default for this memory_type.
is_default_initial_value
property
¶
Return True if the initial value is the default for its data type.
can_edit_initial_value
property
¶
True if initial value can be edited for this memory type.
can_edit_retentive
property
¶
True if retentive setting can be edited for this memory type.
from_address
classmethod
¶
from_address(
address: str,
*,
nickname: str = "",
comment: str = "",
initial_value: str = "",
retentive: bool | None = None,
used: bool | None = None,
) -> AddressRecord
Build an AddressRecord from a display address string.
pyclickplc.parse_address ¶
Parse a display address string to (memory_type, mdb_address).
Strict: raises ValueError on invalid input. For XD/YD, returns MDB address: "XD1" -> ("XD", 2), "XD0u" -> ("XD", 1).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
address_str
|
str
|
Address string like "X001", "XD0", "XD0u", "XD8" |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, int]
|
Tuple of (memory_type, mdb_address) |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the address string is invalid |
pyclickplc.normalize_address ¶
Normalize an address string to its canonical display form.
E.g., "x1" -> "X001", "xd0u" -> "XD0u".
Returns:
| Type | Description |
|---|---|
str | None
|
The normalized display address, or None if address is invalid. |
pyclickplc.format_address_display ¶
Format a memory type and MDB address as a display string.
X/Y are 3-digit zero-padded. XD/YD use special encoding. Others are unpadded.