Skip to content

Commit 2e8ca8f

Browse files
authored
Merge pull request #49 from DiamondLightSource/12-preset_buttons
Added preset buttons
2 parents eac9c87 + b4c1cb7 commit 2e8ca8f

File tree

1 file changed

+85
-1
lines changed

1 file changed

+85
-1
lines changed

src/screens/OavMover.tsx

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
import { Box, Button, Grid2, Stack, TextField, useTheme } from "@mui/material";
1+
import {
2+
Box,
3+
Button,
4+
Drawer,
5+
Grid2,
6+
Stack,
7+
TextField,
8+
Tooltip,
9+
useTheme,
10+
} from "@mui/material";
211
import { OavVideoStream } from "../components/OavVideoStream";
312
import {
413
ArrowBackRounded,
@@ -15,6 +24,13 @@ import { PvDescription } from "../pv/PvComponent";
1524
import { SelectionWithPlanRunner } from "../components/SelectionControl";
1625
import { BacklightPositions, ZoomLevels } from "../pv/enumPvValues";
1726

27+
const buttonStyle = {
28+
color: "white",
29+
margin: "5px",
30+
padding: "15px",
31+
backgroundColor: "#1c2025",
32+
};
33+
1834
function BacklightControl(props: PvDescription) {
1935
const theme = useTheme();
2036
return (
@@ -175,6 +191,73 @@ export function PixelsToMicrons({
175191
);
176192
}
177193

194+
export function PresetMovements() {
195+
return (
196+
<Box sx={{ textAlign: `center` }}>
197+
<p>
198+
<b>Preset Positions</b>
199+
</p>
200+
<Grid2>
201+
<Tooltip title={"Move into position for collection"}>
202+
<Button
203+
style={buttonStyle}
204+
onClick={() =>
205+
submitAndRunPlanImmediately("moveto_preset", {
206+
place: "collect_position",
207+
})
208+
}
209+
>
210+
Collect Position
211+
</Button>
212+
</Tooltip>
213+
214+
<Tooltip title={"Move hardware for sample loading"}>
215+
<Button
216+
style={buttonStyle}
217+
onClick={() =>
218+
submitAndRunPlanImmediately("moveto_preset", {
219+
place: "load_position",
220+
})
221+
}
222+
>
223+
Load Position
224+
</Button>
225+
</Tooltip>
226+
<Tooltip title={"Align microdrop"}>
227+
<Button
228+
style={buttonStyle}
229+
onClick={() =>
230+
submitAndRunPlanImmediately("moveto_preset", {
231+
place: "microdrop_position",
232+
})
233+
}
234+
>
235+
Microdrop Align
236+
</Button>
237+
</Tooltip>
238+
</Grid2>
239+
</Box>
240+
);
241+
}
242+
243+
export function SideDrawer() {
244+
const [open, setOpen] = useState(false);
245+
const toggleDrawer = (newOpen: boolean) => () => {
246+
setOpen(newOpen);
247+
};
248+
249+
return (
250+
<>
251+
<Button style={buttonStyle} onClick={toggleDrawer(true)}>
252+
Preset Positions
253+
</Button>
254+
<Drawer open={open} onClose={toggleDrawer(false)}>
255+
<PresetMovements />
256+
</Drawer>
257+
</>
258+
);
259+
}
260+
178261
export function OavMover() {
179262
const [crosshairX, setCrosshairX] = useState<number>(200);
180263
const [crosshairY, setCrosshairY] = useState<number>(200);
@@ -226,6 +309,7 @@ export function OavMover() {
226309
label="zoom-level"
227310
pv="ca://BL24I-EA-OAV-01:FZOOM:MP:SELECT"
228311
/>
312+
<SideDrawer />
229313
</Grid2>
230314
</Grid2>
231315
</div>

0 commit comments

Comments
 (0)