Skip to main content

A package for interacting with the Beamline Control System (BCS) using ZeroMQ.

Project description

bcsophyd-zmq

Tests Documentation PyPI License: BSD-3

A Python package for interacting with the Beamline Control System (BCS) using ZeroMQ, providing Ophyd-compatible devices for use with the Bluesky data acquisition framework.

Overview

bcsophyd bridges LabVIEW-based BCS control systems with Python's Bluesky data acquisition framework. It provides:

  • BCSServer: Async ZeroMQ client for communication with the BCS API
  • BCSMotor: Ophyd-compatible motor control for BCS system motors
  • BCSSignal: Ophyd-compatible signal wrapper for BCS analog inputs
  • BCSDeviceManager: Device configuration and Happi database integration
  • BCSAreaDetector: 2D detector support (under development)

Installation

From source

git clone https://git.als.lbl.gov/bcs/bluesky/bcsophyd-zmq.git
cd bcsophyd-zmq
pip install -e .

With development dependencies

pip install -e ".[dev]"

With documentation dependencies

pip install -e ".[docs]"

With test dependencies

pip install -e ".[tests]"

Command-Line Interface

After installation, the bcsophyd command is available for testing connections and listing devices.

Test connection

# Test connection to default localhost:5577
bcsophyd test

# Test connection to specific host
bcsophyd test --host 192.168.195.129 --port 5577

# With verbose output
bcsophyd -v test --host 192.168.195.129

List available devices

# List all devices
bcsophyd devices --host 192.168.195.129

# List only motors
bcsophyd devices --host 192.168.195.129 --no-signals

# List only analog inputs
bcsophyd devices --host 192.168.195.129 --no-motors

# Output as JSON
bcsophyd devices --host 192.168.195.129 --json

Read a device value

# Read current value of a device
bcsophyd read --host 192.168.195.129 motor_1

Help

bcsophyd --help
bcsophyd devices --help

Quick Start

Connect to BCS and discover devices

import asyncio
from bcsophyd.zmq import BCSDeviceManager

async def main():
    # Connect to BCS server
    manager = BCSDeviceManager(host="192.168.195.129", port=5577)
    await manager.connect()

    # List all discovered devices
    for device in manager.client.items():
        print(device)

asyncio.run(main())

Use a BCS motor in a Bluesky scan

import asyncio
from bluesky import RunEngine
from bluesky.plans import scan
from bluesky.callbacks import LiveTable
from ophyd.sim import det
from bcsophyd.zmq import BCSDeviceManager

async def run_scan():
    # Connect and discover devices
    manager = BCSDeviceManager(host="192.168.195.129", port=5577)
    await manager.connect()

    # Get a motor from the Happi database
    results = manager.client.search_regex(name="Motor3")
    motor = results[0].get()

    # Run a Bluesky scan
    RE = RunEngine()
    RE.subscribe(LiveTable([det, motor]))
    RE(scan([det], motor, 0, 10, 11))

asyncio.run(run_scan())

Read an analog input signal

import asyncio
from bcsophyd.zmq import BCSDeviceManager

async def read_signal():
    manager = BCSDeviceManager(host="192.168.195.129", port=5577)
    await manager.connect()

    # Get an analog input signal
    results = manager.client.search_regex(name="new_ai_2")
    signal = results[0].get()

    # Read the value
    value = await signal.get()
    print(f"Signal value: {value}")

asyncio.run(read_signal())

Requirements

  • Python >= 3.9
  • click
  • happi
  • loguru
  • ophyd
  • pyzmq

Documentation

Build the documentation locally:

cd docs
make html

Then open docs/build/html/index.html in your browser.

Examples

See the examples/ directory for more detailed usage examples:

  • basic_connection.py - Testing BCS server connectivity
  • device_discovery.py - Using BCSDeviceManager with Happi
  • bluesky_scans.py - Running Bluesky scans with BCS devices

License

BSD 3-Clause License. See LICENSE.md for details.

Authors

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bcsophyd-0.1.2.tar.gz (73.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bcsophyd-0.1.2-py3-none-any.whl (37.6 kB view details)

Uploaded Python 3

File details

Details for the file bcsophyd-0.1.2.tar.gz.

File metadata

  • Download URL: bcsophyd-0.1.2.tar.gz
  • Upload date:
  • Size: 73.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bcsophyd-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b41a906883bcd7206c5253a315849fb9caa4ee4b98b14cf57e78c9a03e0940d5
MD5 8ed992e8d3d2303b2fd24a7aca33ecaf
BLAKE2b-256 e65f748a032570fd9abf6737753f32d3963c39550d700e11d0a3784cf2baeca2

See more details on using hashes here.

Provenance

The following attestation bundles were made for bcsophyd-0.1.2.tar.gz:

Publisher: publish.yml on als-controls/BCS-Ophyd-ZMQ

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bcsophyd-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: bcsophyd-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 37.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bcsophyd-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 32ed054934a2b6961f9d56075df1c070bbdc7a694edc73875cd544bd1db53c59
MD5 57a7386af09838bdf3b7e79dde7d041c
BLAKE2b-256 a66c69d21db13f5cc3f8113f8da35942c63ee77f96b7ac8202c703139336c410

See more details on using hashes here.

Provenance

The following attestation bundles were made for bcsophyd-0.1.2-py3-none-any.whl:

Publisher: publish.yml on als-controls/BCS-Ophyd-ZMQ

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page