diff --git a/csaxs_bec/device_configs/smargon.yaml b/csaxs_bec/device_configs/smargon.yaml index a40932bd..6cfe6737 100644 --- a/csaxs_bec/device_configs/smargon.yaml +++ b/csaxs_bec/device_configs/smargon.yaml @@ -6,7 +6,7 @@ # host/port so they share the controller. # # The motor NAME (the top-level key: sgx, sgchi, ...) is yours to choose. The -# `scs_axis` field binds it to the fixed smargopolo axis (SHX/SHY/SHZ/CHI/PHI/OMEGA). +# `scs_axis` field binds it to the fixed smargopolo axis (SHX/SHY/SHZ/CHI/PHI/OMEGA/OX/OY/OZ). # # Referencing is a deliberate operator action: after loading, run once # dev.smargon.reference() # (or dev.sgx.controller.reference()) @@ -76,6 +76,36 @@ sgphi: onFailure: retry readoutPriority: baseline +# --- O-vector (SCS offset vector OX/OY/OZ, mm) ------------------------------------ +# Drivable like any SCS axis and recorded in the baseline. No soft limits by default +# (smargopolo enforces the real ones) -- add `limits: [low, high]` per experiment. +sgox: + description: SmarGon OX (offset vector) + deviceClass: csaxs_bec.devices.smargon.positioner.SmargopoloMotor + deviceConfig: {scs_axis: OX, host: tt-smargopolo, port: 3000, tolerance: 0.001} + deviceTags: [goniometer, smargon] + enabled: true + onFailure: retry + readoutPriority: baseline + +sgoy: + description: SmarGon OY (offset vector) + deviceClass: csaxs_bec.devices.smargon.positioner.SmargopoloMotor + deviceConfig: {scs_axis: OY, host: tt-smargopolo, port: 3000, tolerance: 0.001} + deviceTags: [goniometer, smargon] + enabled: true + onFailure: retry + readoutPriority: baseline + +sgoz: + description: SmarGon OZ (offset vector) + deviceClass: csaxs_bec.devices.smargon.positioner.SmargopoloMotor + deviceConfig: {scs_axis: OZ, host: tt-smargopolo, port: 3000, tolerance: 0.001} + deviceTags: [goniometer, smargon] + enabled: true + onFailure: retry + readoutPriority: baseline + # --- Optional OMEGA rotation drive (only on builds that have it) ------------------- # sgomega: # description: SmarGon OMEGA (rotation drive) diff --git a/csaxs_bec/device_configs/smargon_sim_session.yaml b/csaxs_bec/device_configs/smargon_sim_session.yaml index dca79d03..b6318fe0 100644 --- a/csaxs_bec/device_configs/smargon_sim_session.yaml +++ b/csaxs_bec/device_configs/smargon_sim_session.yaml @@ -1,6 +1,7 @@ # Self-contained laptop test session for the SmarGon device (SIMULATION). # -# Per-axis motors (dev.sgx, dev.sgy, dev.sgz, dev.sgchi, dev.sgphi, dev.sgomega) + +# Per-axis motors (dev.sgx, dev.sgy, dev.sgz, dev.sgchi, dev.sgphi, dev.sgox/sgoy/sgoz, +# optional dev.sgomega) + # a `smargon` coordinator, all sharing one simulated controller, plus a sim monitor # so scans record data. No smargopolo server / hardware needed. # @@ -102,6 +103,36 @@ sgphi: onFailure: retry readoutPriority: baseline +# --- O-vector (SCS offset vector OX/OY/OZ, mm) ------------------------------------ +# Drivable like any SCS axis and recorded in the baseline. No soft limits by default +# (smargopolo enforces the real ones) -- add `limits: [low, high]` per experiment. +sgox: + description: SmarGon OX (offset vector, sim) + deviceClass: csaxs_bec.devices.smargon.positioner.SmargopoloMotor + deviceConfig: {scs_axis: OX, simulation: true, gradual_motion: true, tolerance: 0.001} + deviceTags: [goniometer, smargon, simulation] + enabled: true + onFailure: retry + readoutPriority: baseline + +sgoy: + description: SmarGon OY (offset vector, sim) + deviceClass: csaxs_bec.devices.smargon.positioner.SmargopoloMotor + deviceConfig: {scs_axis: OY, simulation: true, gradual_motion: true, tolerance: 0.001} + deviceTags: [goniometer, smargon, simulation] + enabled: true + onFailure: retry + readoutPriority: baseline + +sgoz: + description: SmarGon OZ (offset vector, sim) + deviceClass: csaxs_bec.devices.smargon.positioner.SmargopoloMotor + deviceConfig: {scs_axis: OZ, simulation: true, gradual_motion: true, tolerance: 0.001} + deviceTags: [goniometer, smargon, simulation] + enabled: true + onFailure: retry + readoutPriority: baseline + # sgomega: # description: SmarGon OMEGA (sim) # deviceClass: csaxs_bec.devices.smargon.positioner.SmargopoloMotor diff --git a/csaxs_bec/devices/smargon/README.md b/csaxs_bec/devices/smargon/README.md index ccac97e6..817a5393 100644 --- a/csaxs_bec/devices/smargon/README.md +++ b/csaxs_bec/devices/smargon/README.md @@ -34,8 +34,13 @@ poll-to-tolerance moves), since both wrap a non-EPICS, poll-to-confirm HTTP back - **One motor per axis**, top-level: the YAML key is the BEC name (**you choose it**: `sgx`, `sgchi`, …); a `scs_axis:` field binds it to the fixed smargopolo axis name - (`SHX/SHY/SHZ/CHI/PHI/OMEGA`). OMEGA is optional hardware — add a motor entry only on - builds that have it. + (`SHX/SHY/SHZ/CHI/PHI/OMEGA/OX/OY/OZ`). OMEGA is optional hardware — add a motor entry + only on builds that have it. +- **O-vector motors** `sgox/sgoy/sgoz` drive the SCS offset vector `OX/OY/OZ` (all mm). + They are ordinary motors (`umv`, scans, baseline readout), so the offset is recorded + with every scan. They have no soft limits by default; set `limits` per experiment. + `nudge_beamline(modify_offset=True)` (`/nudgeOBCS`) also changes them; their readback + catches up on the next read. - **`dev.smargon`** — the coordinator: `reference()`, `get_mode()`, `is_ready()`, `wait_until_ready()`, `move_scs(...)`, `nudge_beamline(...)`, `motor_positions()`, `stop_all()`, `transport_info()`, plus read-only `mode`/`rosout` signals. @@ -120,4 +125,7 @@ All run against `FakeTransport` — no hardware or server needed. `rosout` carries the reason), so the abort path is dependable. - **PHI wrap**: the MX-lab reference client wraps PHI to `[-180,180)` before sending. Confirm whether smargopolo wraps server-side, or whether the motor should. +- **O-vector semantics**: confirm what `OX/OY/OZ` represent physically, whether + changing them moves the sample (or only re-expresses `SH*`), sensible travel ranges, + and that `OZ` is in mm (the API example shows `OZ: 300.0`, the example client 180). - *(resolved)* OMEGA is drivable via `/targetSCS` wherever it physically exists. diff --git a/csaxs_bec/devices/smargon/positioner.py b/csaxs_bec/devices/smargon/positioner.py index 6921fd53..a8b526c4 100644 --- a/csaxs_bec/devices/smargon/positioner.py +++ b/csaxs_bec/devices/smargon/positioner.py @@ -1,7 +1,7 @@ """Per-axis SmarGon motor -- a top-level BEC device for one SCS axis. ``SmargopoloMotor`` is an independent ophyd positioner (``Device`` + -``PositionerBase``): each SCS axis (SHX/SHY/SHZ/CHI/PHI/OMEGA) is its own top-level +``PositionerBase``): each SCS axis (SHX/SHY/SHZ/CHI/PHI/OMEGA/OX/OY/OZ) is its own top-level BEC motor, exactly like the ``smaract`` motors. It talks to hardware only through a shared :class:`~csaxs_bec.devices.smargon.controller.SmargopoloController` (singleton per smargopolo server), so ``dev.sgx`` and ``dev.sgchi`` pointing at the same host diff --git a/tests/tests_devices/test_smargon_device.py b/tests/tests_devices/test_smargon_device.py index f6da280b..d221b347 100644 --- a/tests/tests_devices/test_smargon_device.py +++ b/tests/tests_devices/test_smargon_device.py @@ -360,3 +360,50 @@ def test_modulo_monitor_does_not_republish_wrapped_position(): time.sleep(0.15) assert published == [] sgphi.destroy() + + +# -- O-vector (OX/OY/OZ) motors ---------------------------------------------- + + +@pytest.mark.parametrize("axis", ["OX", "OY", "OZ"]) +def test_o_vector_axes_are_mm_motors(axis): + m = _motor(f"sgo{axis[1].lower()}", axis) + assert m.egu == "mm" + assert m.limits == (0.0, 0.0) # unbounded unless configured + + +def test_o_vector_initial_readback_and_record(): + sgoz = _motor("sgoz", "OZ") + assert sgoz.position == pytest.approx(180.0) # fake's home O-vector + assert sgoz.read()["sgoz"]["value"] == pytest.approx(180.0) + + +def test_o_vector_move_and_limits(): + coord = _coordinator() + sgox = _motor("sgox", "OX", limits=[-1, 1]) + sgoz = _motor("sgoz", "OZ") + coord.reference() + sgox.move(0.25, wait=True) + sgoz.move(200.0, wait=True) + assert sgox.position == pytest.approx(0.25) + assert sgoz.position == pytest.approx(200.0) + with pytest.raises(LimitError): + sgox.move(5.0) + + +def test_o_vector_move_refused_until_referenced(): + sgoy = _motor("sgoy", "OY") + with pytest.raises(SmargopoloModeError): + sgoy.move(0.1) + + +def test_move_scs_includes_o_vector(): + coord = _coordinator() + sgx = _motor("sgx", "SHX") + sgoy = _motor("sgoy", "OY", limits=[-1, 1]) + coord.reference() + coord.move_scs(SHX=0.1, OY=-0.4, wait=True) + assert sgx.position == pytest.approx(0.1) + assert sgoy.position == pytest.approx(-0.4) + with pytest.raises(LimitError): + coord.move_scs(OY=3.0)