Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "i24-daq-ui",
"private": true,
"version": "0.0.7",
"version": "0.0.9",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
9 changes: 8 additions & 1 deletion src/blueapi/BlueapiComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type RunPlanButtonProps = {
btnLabel: string | ReactNode;
planName: string;
planParams?: object;
currentVisit?: string;
title?: string;
btnVariant?: VariantChoice;
btnSize?: ButtonSize;
Expand All @@ -36,7 +37,12 @@ export function RunPlanButton(props: RunPlanButtonProps) {
const [msg, setMsg] = React.useState<string>("Running plan...");
const [severity, setSeverity] = React.useState<SeverityLevel>("info");

const fullVisit = readVisitFromPv();
let fullVisit: string;
if (props.currentVisit === undefined) {
fullVisit = readVisitFromPv();
} else {
fullVisit = props.currentVisit;
}
let instrumentSession: string;

const params = props.planParams ? props.planParams : {};
Expand All @@ -52,6 +58,7 @@ export function RunPlanButton(props: RunPlanButtonProps) {
setOpenSnackbar(true);
try {
instrumentSession = parseInstrumentSession(fullVisit);
console.log(`Current instrument session: ${instrumentSession}`);
submitAndRunPlanImmediately({
planName: props.planName,
planParams: params,
Expand Down
1 change: 1 addition & 0 deletions src/blueapi/blueapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ function submitTask(request: BlueApiRequestBody): Promise<string | void> {
return blueApiCall("/tasks", "POST", {
name: request.planName,
params: request.planParams,
instrument_session: request.instrumentSession,
}).then((res) => {
if (!res.ok) {
throw new Error(
Expand Down
9 changes: 8 additions & 1 deletion src/components/JungFrau/CollectDarksPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import {
Typography,
useTheme,
} from "@mui/material";
import React from "react";
import React, { useContext } from "react";
import { ParameterInput } from "../ParameterInputs";
import { GainModes } from "./constants";
import { RunPlanButton } from "#/blueapi/BlueapiComponents.tsx";
import { VisitContext } from "#/context/VisitContext.ts";
import { getCurrentVisit } from "./jfUtils";

export function CollectDarksPanel() {
const theme = useTheme();
Expand All @@ -25,6 +27,9 @@ export function CollectDarksPanel() {
const [totTriggers, setTotTriggers] = React.useState<number>(1000);
const [gainMode, setGainMode] = React.useState<string>(GainModes[0]);

const { visit } = useContext(VisitContext);
const currentVisit = getCurrentVisit(visit);

return (
<Box sx={{ flexGrow: 1, marginLeft: 15, marginRight: 5 }}>
<Card variant="outlined" sx={{ minWidth: 300, minHeight: 600 }}>
Expand Down Expand Up @@ -87,6 +92,7 @@ export function CollectDarksPanel() {
pedestal_loops: pedestalLoops,
filename: filename,
}}
currentVisit={currentVisit}
title="Collect pedestal darks"
btnSize="large"
/>
Expand Down Expand Up @@ -139,6 +145,7 @@ export function CollectDarksPanel() {
total_triggers: totTriggers,
filename: filename,
}}
currentVisit={currentVisit}
title="Collect non pedestal darks"
btnSize="large"
/>
Expand Down
15 changes: 6 additions & 9 deletions src/components/JungFrau/CollectionSetupJf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,9 @@ import {
import React from "react";
import { useContext } from "react";
import { ParameterInput } from "../ParameterInputs";
import { fullStorageDirectory, getCurrentVisit } from "./jfUtils";

function fullStorageDirectory(visit: string): string {
const date = new Date();
const year = date.getFullYear();
return `/dls/i24/data/${year}/${visit}/jungfrau/`;
}

function RunButtons(): JSX.Element {
function RunButtons({ currentVisit }: { currentVisit: string }): JSX.Element {
const {
expTime,
detDist,
Expand All @@ -45,6 +40,7 @@ function RunButtons(): JSX.Element {
transmissions: transFract,
sample_id: sampleId,
}}
currentVisit={currentVisit}
title="Run the jungfrau rotation scan plan"
btnSize="large"
/>
Expand All @@ -58,7 +54,8 @@ export function CollectionSetupJf() {
const theme = useTheme();
const context = useContext(JungfrauRotationContext);
const { visit } = useContext(VisitContext);
const storageDirectory = fullStorageDirectory(visit);
const currentVisit = getCurrentVisit(visit);
const storageDirectory = fullStorageDirectory(currentVisit);
return (
<Box sx={{ flexGrow: 1 }}>
<Stack direction={"column"} alignItems={"center"} spacing={5}>
Expand Down Expand Up @@ -129,7 +126,7 @@ export function CollectionSetupJf() {
tooltip="Request transmission value(s) for collection, expressed as a fraction. If running a single rotation, just input one value, if running multiples please pass a list."
/>
</Grid>
<RunButtons />
<RunButtons currentVisit={currentVisit} />
</Stack>
</Box>
);
Expand Down
9 changes: 9 additions & 0 deletions src/components/JungFrau/jfUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export function fullStorageDirectory(currentVisit: string): string {
return `${currentVisit}jungfrau/`;
}

export function getCurrentVisit(instrumentSession: string): string {
const date = new Date();
const year = date.getFullYear();
return `/dls/i24/data/${year}/${instrumentSession}/`;
}
8 changes: 7 additions & 1 deletion src/components/SelectionControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FormControl, InputLabel, MenuItem, Select } from "@mui/material";
import { forceString, useParsedPvConnection } from "#/pv/util.ts";
import { submitAndRunPlanImmediately } from "#/blueapi/blueapi.ts";
import type { PvDescription } from "#/pv/types.ts";
import { parseInstrumentSession, readVisitFromPv } from "#/blueapi/visit.ts";

type SelectionProps = PvDescription & {
id: string;
Expand All @@ -24,12 +25,17 @@ export function SelectionWithPlanRunner(props: SelectionProps) {
console.log(`${props.id} current value: ${currentValue}`);
const [_, updateVal] = React.useState<string>(currentValue.toString());

// FIXME, temporary - will be fixed by using context everywhere
const fullVisit = readVisitFromPv();
let instrumentSession: string;

const handleChange = (newValue: typeof currentValue) => {
updateVal(newValue);
instrumentSession = parseInstrumentSession(fullVisit);
submitAndRunPlanImmediately({
planName: props.plan_name,
planParams: { position: newValue },
instrumentSession: "", // FIXME, temporary
instrumentSession: instrumentSession,
});
};

Expand Down
5 changes: 4 additions & 1 deletion src/routes/JungfrauRotation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ErrorBoundary } from "react-error-boundary";
import { RoPvBox } from "#/pv/PvComponent.tsx";

import { FallbackScreen } from "#/screens/FallbackScreen.tsx";
import { VisitProvider } from "#/context/VisitProvider.tsx";

export function JfRotation() {
const theme = useTheme();
Expand All @@ -30,7 +31,9 @@ export function JfRotation() {
</Stack>
<Grid2 container marginTop={2} spacing={2}>
<Grid2 size={5}>
<CollectDarksPanel />
<VisitProvider>
<CollectDarksPanel />
</VisitProvider>
</Grid2>
<ParamsPanel expt="jf" />
</Grid2>
Expand Down