Skip to main content

Base library for building python based EPICS IOCs using CaProto.

Features

  • AbstractBaseIOC: Generic base class for all device IOCs
  • ScpiBaseIOC: For SCPI/VISA-based devices (e.g. LS336, PM100, etc.)
  • DirectAccessIOC: For direct hardware access devices (PiXtend, GPIO, etc.)
  • TrinamicBaseIOC: For Trinamic TMCM modules (3351, 6110)
  • ReadOnly / WriteRead: Reusable PV groups with YAML configuration
  • Channel Generator: E.g. RELAY{0..3} → RELAY0, RELAY1, RELAY2, RELAY3 → 4 PVs
  • Composite Actions – Set multiple PVs atomically from YAML
  • CALC Operations – Define a PV to perfom mathematical calculations (SUM, SUB, ...) of PVs
  • Status Monitoring: Status PVs, event-driven logging, status box
  • Simulation – Simulate devices for testing (--sim)
  • Automatic Semantic Versioning: auto_release.py with changelog generation (details)
  • UI: Monitoring of IOC PVs

Architecture

IOC Classes

AbstractBaseIOC(PVGroup)
├── ScpiBaseIOC          # SCPI/VISA devices (LS336, PM100)
└── DirectAccessIOC      # Direct hardware access (no SCPI)
    └── TrinamicBaseIOC  # Trinamic controllers

Important modules of ioc-base

src/ioc_base/
├── base/
│   ├── ioc_core.py          # AbstractBaseIOC (Main Loop)
│   ├── pv_groups.py         # ReadOnly, WriteRead, _map_dtype
│   ├── scpi_ioc.py          # ScpiBaseIOC
│   ├── direct_ioc.py        # DirectAccessIOC
│   ├── trinamic_ioc.py      # TrinamicBaseIOC (USB), _read_hardware(), write_hardware()
│   ...
├── config/
│   └── config.py            # IocConfig, expand_channels, expand_composite_actions
├── modules/
│   ├── tmcm3351.py          # TMCM3351KMC3
│   └── tmcm6110.py          # TMCM6110KMC3
├── ui/
│   └── base_ui.py           # UIs 
└── app/
    └── application.py       # Generic application class

Workflow (Short)

flowchart LR
    A["PV-Configuration<br>(YAML)"] -->|"expand_channels()"| B["PV-Groups<br>(RO/RW)"]
    B -->|"_read_hardware()/<br>write_hardware()"| C["Hardware<br>(VISA/USB/etc.)"]

Installation

# Base (for all IOCs)
pip install ioc-base

# With Trinamic support
pip install ioc-base[trinamic]

# With SCPI/VISA support
pip install ioc-base[scpi]

# With UI support
pip install ioc-base[ui]

# For pytest, e.g. in pipelines
pip install ioc-base[dev]

Environment Variables

Variable Description
<iocname>_LOGGING Log level (info, debug, warning, error)
<iocname>_ADV_LOGGING Log level (debug, info)
PV_CFG_FILE Path to PV configuration
<iocname>_EPICS_PREFIX EPICS prefix

PV Configuration (YAML)

read_only_pvs:
  "CH1:TEMP_RBV":
    "doc": "Channel 1 temperature"
    "cmd_rbv": "KRDG? A"
    "dtype": "float"

read_write_pvs:
  "CH1:SETPOINT":
    "doc": "Channel 1 setpoint"
    "cmd_rbv": "SETP? 1"
    "cmd_set": "SETP 1,"
    "dtype": "float"

  "CH{2..3}:HEATER":
    "doc": "Read/Set heater for channel {index}"
    "cmd_rbv": "SETP? {index}"
    "cmd_set": "SETP {index},"
    "dtype": "float"

  "TLIM{1..4}":
    "doc": "Read/Set temperature limit for sensor {index} [K]"
    "cmd_rbv": "TLIMIT? {index|A,B,C,D}"
    "cmd_set": "TLIMIT {index|A,B,C,D},"
    "dtype": "str"

  "MOTOR{1..2}:VTAR":
    "doc": "Motor {index} target velocity"
    "cmd_rbv": "axis:{index|0,1}:TargetVelocity"
    "cmd_set": "axis:{index|0,1}:TargetVelocity"
    "dtype": "int"
    
composite_actions:
  "HEATER":
    "enum_strings": ["OFF", "ON"]
    "actions":
      "ON": 
        "CH1:SETPOINT": "3.3" 
        "RELAY1": "ON"

CALC Operations

read_only_pvs:
  "SUM_RBV":
    "cmd_rbv": "CALC:SUM|PV1|PV2"
    "dtype": "int"

Supported: SUM, SUB, AVG, MULT, DIV, MIN, MAX

Example Usage

# 1. Select Subclass
class MyDeviceIOC(ScpiBaseIOC):    # SCPI-Devices
class MyDeviceIOC(TrinamicBaseIOC): # Trinamic-Controller

# 2. Module (e.g. for Trinamic)
_module_class = MyDeviceModule
_axis_count = 3

# 3. PV-Configuration (YAML)
read_only_pvs:
  "CH1:TEMP_RBV":
    "cmd_rbv": "MEAS:TEMP? 1"

# 4. IOC 
def create_ioc(prefix, dev, pv_group_a, pv_group_b, iocname, **opts):
    ioc = MyDeviceIOC(...)
    # Register PV-Groups
    return ioc

# 5. Application (Entry Point)
def main():
    from ioc_base.config.ioc_config import IocConfig, parse_args
    from ioc_base.app.application import Application
    from ioc_base.base.scpi_device_sim import connect_simulated_device
    
    config = IocConfig()
    args = parse_args()
    
    app = Application(
        config=config,
        device_factory=lambda: None,  # _init_device creates device
        ioc_factory=create_ioc,
        simulation=args.sim,
        device_factory_sim=connect_simulated_device,
    )
    asyncio.run(app.async_run())

# 5. Run
PV_CFG_FILE=my_pvs.yaml IOCNAME=MYDEVICE my-ioc
PV_CFG_FILE=my_pvs.yaml IOCNAME=MYDEVICE my-ioc --sim

For more details see IOCs: tempctrl-ioc, abox-ioc, ...

Metadata

Release files for ioc-base 0.0.21

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ioc-base 0.0.21
File Size Uploaded Provenance Actions
ioc_base-0.0.21.tar.gz 75.8 kB Without provenance Details for ioc_base-0.0.21.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ioc-base 0.0.21
File Interpreter ABI Platform Actions
ioc_base-0.0.21-py3-none-any.whl Python 3 none any Details for ioc_base-0.0.21-py3-none-any.whl

Total release size: 153.5 kB

Release files / ioc_base-0.0.21.tar.gz

Download URL ioc_base-0.0.21.tar.gz
Size 75.8 kB
Tags Source
SHA-256 checksum
How to use checksums
57e296252bd57894bb2e22aad483bf5a6dd3386f7bfb2770cafeab52cda841c8
BLAKE2b-256 checksum
How to use checksums
0d53aeafcd259577c37ab6f9fab425ab1db29c1c6f1d6ca79d5eea78466ed1b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.18

Release files / ioc_base-0.0.21-py3-none-any.whl

Download URL ioc_base-0.0.21-py3-none-any.whl
Size 77.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
acb480b8ab3ab0a832e6d6167ff4df4b15f8361c176a0030c60ec58b62076f74
BLAKE2b-256 checksum
How to use checksums
092d501620e5d694b7c1c38362ddf54b1b11be6d231cfa38d19a59dcb174de1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.18

Security for ioc-base 0.0.21

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.

Release history Release notifications | RSS feed

This release

0.0.21 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page