Addressing API¶
Address model and canonical normalized address helpers.
pyclickplc.AddressRecord
dataclass
¶
Immutable record for a single PLC address.
The record has no UI validation state. To build one from a display address
such as "X001", use 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. Any letter case is accepted
(x1 is X001), as are leading zeros and surrounding whitespace.
The u suffix is only for XD0u and YD0u. Letters and digits
are ASCII only.
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 and Y are zero-padded to 3 digits. XD and YD show MDB 0 as XD0, MDB 1 as XD0u and MDB 2n as XDn. Other banks are not padded.
pyclickplc.iter_address_slots ¶
Yield (memory_type, mdb_address) for every slot CLICK shows, bank by bank.
Banks come in BANKS order. X/Y use their valid ranges, other banks run
min_addr to max_addr, and the hidden XD/YD slots are skipped. Pass a pair to
format_address_display for the name CLICK shows.