|
8 | 8 | Tooltip, |
9 | 9 | Typography, |
10 | 10 | } from "@mui/material"; |
11 | | -import { ReadPvRawValue } from "../pv/util"; |
| 11 | +import { forceString, ReadPvRawValue } from "../pv/util"; |
12 | 12 | import { RawValue } from "../pv/types"; |
13 | 13 |
|
14 | 14 | type SeverityLevel = "success" | "info" | "warning" | "error"; |
@@ -40,21 +40,25 @@ type RunPlanButtonProps = { |
40 | 40 | function readInstrumentSessionFromVisitPv(): string { |
41 | 41 | const fullVisitPath: RawValue = ReadPvRawValue({ |
42 | 42 | label: "visit", |
43 | | - pv: "ca://ME14E-MO-IOC-01:GP100", |
| 43 | + pv: "ca://BL24I-MO-IOC-13:GP100", |
44 | 44 | }); |
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) { |
47 | 48 | const msg: string = |
48 | 49 | "Unable to run plan as instrument session not set. Please check visit PV."; |
49 | 50 | console.log(msg); |
50 | 51 | // throw new Error(msg); |
51 | 52 | } 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 | + } |
58 | 62 | } |
59 | 63 | return instrumentSession; |
60 | 64 | } |
|
0 commit comments