From 930bf4157decf899ab2835b5de34fd913fce885d Mon Sep 17 00:00:00 2001 From: Tamoor Shahid Date: Mon, 16 Feb 2026 16:55:52 +0000 Subject: [PATCH 1/2] Fixed display_config endpoint and moved function out of jsx --- src/screens/OavMover/OAVStageController.tsx | 47 ++++++++++----------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/src/screens/OavMover/OAVStageController.tsx b/src/screens/OavMover/OAVStageController.tsx index e55204c..29356dc 100644 --- a/src/screens/OavMover/OAVStageController.tsx +++ b/src/screens/OavMover/OAVStageController.tsx @@ -10,7 +10,7 @@ import { useMemo } from "react"; export function OavMover() { const DISPLAY_CONFIG_ENDPOINT = - "/dls_sw/i24/software/daq_configuration/display.configuration"; + "/dls_sw/i24/software/daq_configuration/domain/display.configuration"; const beamCenterQuery = useConfigCall(DISPLAY_CONFIG_ENDPOINT); const currentZoomValue = String( useParsedPvConnection({ @@ -46,6 +46,27 @@ export function OavMover() { const fullVisit = readVisitFromPv(); + function onCoordClick(x: number, y: number) { + const [x_um, y_um] = [x / pixelsPerMicron, y / pixelsPerMicron]; + console.debug( + `Clicked on position (${x}, ${y}) (px relative to beam centre) in original stream. Relative position in um (${x_um}, ${y_um}). Submitting to BlueAPI...`, + ); + if (Number.isNaN(x_um) || Number.isNaN(y_um)) { + console.log("Not submitting plan while disconnected from PVs!"); + } else { + const [x_int, y_int] = [Math.round(x), Math.round(y)]; + submitAndRunPlanImmediately({ + planName: "move_on_oav_view_click", + planParams: { position_px: [x_int, y_int] }, + instrumentSession: parseInstrumentSession(fullVisit), + }).catch((error) => { + console.log( + `Failed to run plan , see console and logs for full error. Reason: ${error}`, + ); + }); + } + } + return (
@@ -56,29 +77,7 @@ export function OavMover() { label="I24 OAV image stream" crosshairX={crosshairX} crosshairY={crosshairY} - onCoordClick={(x: number, y: number) => { - const [x_um, y_um] = [x / pixelsPerMicron, y / pixelsPerMicron]; - console.log( - `Clicked on position (${x}, ${y}) (px relative to beam centre) in original stream. Relative position in um (${x_um}, ${y_um}). Submitting to BlueAPI...`, - ); - const [x_int, y_int] = [Math.round(x), Math.round(y)]; - if (Number.isNaN(x_um) || Number.isNaN(y_um)) { - console.log( - "Not submitting plan while disconnected from PVs!", - ); - } else { - // This is an example but not useful for actual production use. - submitAndRunPlanImmediately({ - planName: "gui_gonio_move_on_click", - planParams: { position_px: [x_int, y_int] }, - instrumentSession: parseInstrumentSession(fullVisit), - }).catch((error) => { - console.log( - `Failed to run plan gui_gonio_move_on_click, see console and logs for full error. Reason: ${error}`, - ); - }); - } - }} + onCoordClick={onCoordClick} /> From 22ecf43b71580bf896b8f489fd891bda560ec388 Mon Sep 17 00:00:00 2001 From: Tamoor Shahid Date: Thu, 19 Feb 2026 10:02:04 +0000 Subject: [PATCH 2/2] Cleaned up click canvas code with new plan --- src/components/OavVideoStream.tsx | 12 +-------- src/screens/OavMover/OAVStageController.tsx | 29 +++++++-------------- 2 files changed, 10 insertions(+), 31 deletions(-) diff --git a/src/components/OavVideoStream.tsx b/src/components/OavVideoStream.tsx index 82defa4..585d71f 100644 --- a/src/components/OavVideoStream.tsx +++ b/src/components/OavVideoStream.tsx @@ -137,18 +137,8 @@ function VideoBoxWithOverlay(props: { const canvas = canvasRef.current; if (canvas) { const rect = canvas.getBoundingClientRect(); - // x and y relative to the canvas const [x, y] = [e.clientX - rect.left, e.clientY - rect.top]; - // x and y relative to the crosshair - const [relX, relY] = [x - props.crosshairX, y - props.crosshairY]; - // fraction of the image in x/y * original dimension in pixels - const scaledX = props.originalDims - ? (relX / width) * props.originalDims.width - : x; - const scaledY = props.originalDims - ? (relY / height) * props.originalDims.height - : y; - props.onCoordClick(scaledX, scaledY); + props.onCoordClick(x, y); } } }} diff --git a/src/screens/OavMover/OAVStageController.tsx b/src/screens/OavMover/OAVStageController.tsx index 29356dc..29a4fcd 100644 --- a/src/screens/OavMover/OAVStageController.tsx +++ b/src/screens/OavMover/OAVStageController.tsx @@ -39,32 +39,21 @@ export function OavMover() { return [Number(xLine.split(" ")[2]), Number(yLine.split(" ")[2])]; }, [beamCenterQuery.data, zoomIndex]); - // #Issue 86: Remove these constants - https://github.com/DiamondLightSource/mx-daq-ui/issues/86 - const pixelsPerMicron = 1.25; const theme = useTheme(); const bgColor = theme.palette.background.paper; const fullVisit = readVisitFromPv(); function onCoordClick(x: number, y: number) { - const [x_um, y_um] = [x / pixelsPerMicron, y / pixelsPerMicron]; - console.debug( - `Clicked on position (${x}, ${y}) (px relative to beam centre) in original stream. Relative position in um (${x_um}, ${y_um}). Submitting to BlueAPI...`, - ); - if (Number.isNaN(x_um) || Number.isNaN(y_um)) { - console.log("Not submitting plan while disconnected from PVs!"); - } else { - const [x_int, y_int] = [Math.round(x), Math.round(y)]; - submitAndRunPlanImmediately({ - planName: "move_on_oav_view_click", - planParams: { position_px: [x_int, y_int] }, - instrumentSession: parseInstrumentSession(fullVisit), - }).catch((error) => { - console.log( - `Failed to run plan , see console and logs for full error. Reason: ${error}`, - ); - }); - } + submitAndRunPlanImmediately({ + planName: "move_on_oav_view_click", + planParams: { position: [x, y] }, + instrumentSession: parseInstrumentSession(fullVisit), + }).catch((error) => { + console.log( + `Failed to run plan , see console and logs for full error. Reason: ${error}`, + ); + }); } return (