Tag
pyrung.core.tag
Tag definitions for the immutable PLC engine.
Tags are lightweight references to values in SystemState. They carry type metadata but hold no runtime state.
TagType
Bases: Enum
Data types for tags (IEC 61131-3 naming).
MappingEntry
dataclass
Logical-to-hardware mapping declaration used by TagMap.
Tag
dataclass
A reference to a value in SystemState.
Tags define what a value is (name, type, behavior) but hold no runtime state. Values live only in SystemState.tags.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Unique identifier for this tag. |
type |
TagType
|
Data type (BOOL, INT, DINT, REAL, WORD, CHAR). |
default |
Any
|
Default value (None means use type default). |
retentive |
bool
|
Whether value survives power cycles. |
value
property
writable
Read or write this tag's value through the active runner scope.
Returns the current value as seen by the runner, including any pending
patches or forces. Writes are staged as one-shot patches consumed at
the next step().
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If called outside |
LiveTag
dataclass
Bases: Tag
Tag with runner-bound staged value access via .value.
LiveTag is the concrete type returned by all IEC constructor functions
(Bool, Int, Dint, Real, Word, Char) and by block indexing.
It extends Tag with the .value property, which provides read/write
access to the current runner state.
Note
.value requires an active runner scope. Access outside
with runner.active(): ... raises RuntimeError.
ImmediateRef
dataclass
InputTag
dataclass
Bases: Tag
Tag representing a physical input channel.
InputTag instances are produced exclusively by indexing an InputBlock.
They add the .immediate property for bypassing the scan-cycle image table.
.immediate semantics by context:
- Simulation (pure): validation-time annotation only; no runtime effect.
- Click dialect: transcription hint for Click software export.
- CircuitPython dialect: generates direct hardware-read code.
- Hardware-in-the-loop: triggers a real hardware read mid-scan.
You cannot create an InputTag directly; use InputBlock[n] instead.
Example
OutputTag
dataclass
Bases: Tag
Tag representing a physical output channel.
OutputTag instances are produced exclusively by indexing an OutputBlock.
They add the .immediate property for bypassing the scan-cycle image table.
.immediate semantics by context:
- Simulation (pure): validation-time annotation only; no runtime effect.
- Click dialect: transcription hint for Click software export.
- CircuitPython dialect: generates direct hardware-write code.
- Hardware-in-the-loop: triggers a real hardware write mid-scan.
You cannot create an OutputTag directly; use OutputBlock[n] instead.