timers-latches
Lightweight, production-ready implementations of PLC-style primitives in Python:
TON — On-delay timer
SR — Set/Reset latch (reset dominant)
These primitives are useful for industrial automation logic, simulations, or anywhere you want PLC-like control behavior in Python.
Installation pip install timers-latches
Or, for development:
git clone https://github.com/yourorg/timers-latches.git cd timers-latches pip install -e .
Usage from timers_latches import TON, SR
--- TON example ---
ton = TON(preset_s=2.0) # 2-second delay for step in range(5): q = ton.update(enable=True, dt_s=0.5) print(f"t={step*0.5:.1f}s, Q={q}")
Q will turn True after 2.0 seconds of accumulated enable time
--- SR example ---
latch = SR(initial=False) print(latch.update(set_=True, reset=False)) # True print(latch.update(set_=False, reset=True)) # False (reset dominates)
API TON(preset_s: float)
preset_s: delay time in seconds (must be ≥ 0).
.update(enable: bool, dt_s: float) -> bool: call once per scan; returns the done bit (Q).
.Q: current output (done bit).
SR(initial: bool = False)
initial: starting state.
.update(set_: bool, reset: bool) -> bool: updates and returns current state. Reset dominates set.
.state: current latched state.
Versioning
Follows Semantic Versioning .
API is stable from 1.0.0 onward.
License
MIT © Your Name / Your Organization
⚡️ This package is intentionally minimal and focused: no dependencies, only core primitives. You can drop it into simulations, control logic, or larger automation frameworks.
Metadata
Release files for primitives 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| primitives-0.1.0.tar.gz | 2.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| primitives-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 5.7 kB
Release files / primitives-0.1.0.tar.gz
| Download URL | primitives-0.1.0.tar.gz |
|---|---|
| Size | 2.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
156fd13c04a1cfa568e4602dfa3e0684ae960d99396a7ff2544d47032a9a0c47
|
|
BLAKE2b-256 checksum How to use checksums |
a3e65c37751e06ecfa7400b6e27154cd0dcdf3ca40297e0ec2cf6dc0456b14c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.15
|
Release files / primitives-0.1.0-py3-none-any.whl
| Download URL | primitives-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
da0bd6947d9e06ec533bce8fea3f3fd6c9a6c1b2f83ebe6a8e60ade3004566d5
|
|
BLAKE2b-256 checksum How to use checksums |
3130997fc581aefdabad32eecec335372b7ec251551dcae32c5306debd2f3c84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.15
|
Security for primitives 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.