Skip to content

Commit 82eab2a

Browse files
committed
Slightly better but not by much
1 parent 0f72d28 commit 82eab2a

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

src/blueapi/BlueapiComponents.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
Tooltip,
99
Typography,
1010
} from "@mui/material";
11-
import { ReadPvRawValue } from "../pv/util";
11+
import { forceString, ReadPvRawValue } from "../pv/util";
1212
import { RawValue } from "../pv/types";
1313

1414
type SeverityLevel = "success" | "info" | "warning" | "error";
@@ -40,21 +40,25 @@ type RunPlanButtonProps = {
4040
function readInstrumentSessionFromVisitPv(): string {
4141
const fullVisitPath: RawValue = ReadPvRawValue({
4242
label: "visit",
43-
pv: "ca://ME14E-MO-IOC-01:GP100",
43+
pv: "ca://BL24I-MO-IOC-13:GP100",
4444
});
45-
let visitString: string = "";
46-
if (fullVisitPath === "not connected" || !fullVisitPath) {
45+
const visitString: string = forceString(fullVisitPath);
46+
let instrumentSession: string | undefined = "";
47+
if (visitString === "not connected" || !visitString) {
4748
const msg: string =
4849
"Unable to run plan as instrument session not set. Please check visit PV.";
4950
console.log(msg);
5051
// throw new Error(msg);
5152
} else {
52-
visitString = fullVisitPath.toString();
53-
}
54-
const instrumentSession = visitString.toString().split("/").at(-1);
55-
if (!instrumentSession) {
56-
console.log("Something seems to be wrong with visit path");
57-
// throw new Error("Something seems to be wrong with visit path");
53+
if (visitString.endsWith("/")) {
54+
instrumentSession = visitString.split("/").at(-2);
55+
} else {
56+
instrumentSession = visitString.split("/").at(-1);
57+
}
58+
if (!instrumentSession) {
59+
console.log("NOPE");
60+
throw new Error("Something is wrong with visit path");
61+
}
5862
}
5963
return instrumentSession;
6064
}

src/blueapi/blueapi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const BLUEAPI_SOCKET: string = import.meta.env.VITE_BLUEAPI_SOCKET;
55
type BlueApiRequestBody = {
66
planName: string;
77
planParams: object;
8-
// instrumentSession: string;
8+
instrumentSession: string;
99
};
1010
// Update to latest blueapi (> 1.0.0), See https://github.com/DiamondLightSource/mx-daq-ui/issues/72
1111
// @todo check if blueapi request still works if planParams optional (since some times there's none)

0 commit comments

Comments
 (0)