Skip to content

49 fix instantiation improve connection#51

Merged
Bilchreis merged 18 commits intomasterfrom
49-fix-instantiation-improve-connection
Feb 18, 2026
Merged

49 fix instantiation improve connection#51
Bilchreis merged 18 commits intomasterfrom
49-fix-instantiation-improve-connection

Conversation

@Bilchreis
Copy link
Copy Markdown
Contributor

  • connection and device instantiation is now done via a DeviceConnector (similar to the ophyd-epics and ophyd-tango)
    • unannotated signals are instantiated from introspection
    • annotations have precedence for things like StandardreadableFormat
    • the devices can be instantiated wihout a connection to the SEC node, this is only needed on .connect()
  • class generation is internally realized via a Jinja tamplate
    • class generation is possible directly from the JSON describe message, so no direct connection to the hardware is needed for code gen
    • class generation outputs Annotated secop-ophyd devices (signal type, dtatype, param/property type, stdreadableFormat)
    • commands are generated as abstract methods with the correct signature, they can be used directly as bluesky plans
    • enum classes are generated for signals of type Enum

closes #49

from typing import Annotated as A

from ophyd_async.core import SignalR, SignalRW, StandardReadableFormat as Format, StrictEnum

from numpy import ndarray

from secop_ophyd.SECoPDevices import ParameterType, PropertyType, SECoPMoveableDevice, SECoPNodeDevice


class Cryostat_Mode_Enum(StrictEnum):
    """mode enum for `Cryostat`."""

    RAMP = "ramp"
    PID = "pid"
    OPENLOOP = "openloop"


class Cryostat(SECoPMoveableDevice):
    """A simulated cc cryostat with heat-load, specific heat for the sample and a temperature dependent heat-link between sample and regulation."""

    # Module Properties
    group: A[SignalR[str], PropertyType()]
    description: A[SignalR[str], PropertyType()]
    implementation: A[SignalR[str], PropertyType()]
    interface_classes: A[SignalR[ndarray], PropertyType()]
    features: A[SignalR[ndarray], PropertyType()]

    # Module Parameters
    value: A[SignalR[float], ParameterType(), Format.HINTED_SIGNAL]  # regulation temperature; Unit: (K)
    status: A[SignalR[ndarray], ParameterType()]  # current status of the module
    target: A[SignalRW[float], ParameterType(), Format.HINTED_SIGNAL]  # target temperature; Unit: (K)
    ramp: A[SignalRW[float], ParameterType()]  # ramping speed of the setpoint; Unit: (K/min)
    setpoint: A[SignalR[float], ParameterType()]  # current setpoint during ramping else target; Unit: (K)
    mode: A[SignalRW[Cryostat_Mode_Enum], ParameterType()]  # mode of regulation
    maxpower: A[SignalRW[float], ParameterType()]  # Maximum heater power; Unit: (W)
    heater: A[SignalR[float], ParameterType()]  # current heater setting; Unit: (%)
    heaterpower: A[SignalR[float], ParameterType()]  # current heater power; Unit: (W)
    pid: A[SignalRW[ndarray], ParameterType()]  # regulation coefficients
    p: A[SignalRW[float], ParameterType()]  # regulation coefficient 'p'; Unit: (%/K)
    i: A[SignalRW[float], ParameterType()]  # regulation coefficient 'i'
    d: A[SignalRW[float], ParameterType()]  # regulation coefficient 'd'
    tolerance: A[SignalRW[float], ParameterType()]  # temperature range for stability checking; Unit: (K)
    window: A[SignalRW[float], ParameterType()]  # time window for stability checking; Unit: (s)
    timeout: A[SignalRW[float], ParameterType()]  # max waiting time for stabilisation check; Unit: (s)


class Cryo_7_frappy_demo(SECoPNodeDevice):
    """short description

    This is a very long description providing all the gory details about the stuff we are describing."""

    # Module Devices
    cryo: Cryostat

    # Node Properties
    equipment_id: A[SignalR[str], PropertyType()]
    firmware: A[SignalR[str], PropertyType()]
    description: A[SignalR[str], PropertyType()]
    _interfaces: A[SignalR[ndarray], PropertyType()]

@Bilchreis Bilchreis linked an issue Feb 17, 2026 that may be closed by this pull request
@Bilchreis Bilchreis merged commit c5047d5 into master Feb 18, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix instantiation, improve connection

1 participant