Skip to content

Commit 73b8e7b

Browse files
committed
put into instrument class
1 parent 5a8dd8b commit 73b8e7b

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

app/components/Instrument.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
getExtraPVsForBlock,
1111
toPrecision,
1212
yesToBoolean,
13-
getAllBlockPVs,
1413
Instrument,
1514
} from "@/app/components/Instrument";
1615
import {
@@ -239,7 +238,7 @@ test("getAllBlockPVs returns flat list of blocks, their RC and SPRBV pvs", () =>
239238
},
240239
];
241240

242-
const res = getAllBlockPVs(inst);
241+
const res = inst.getAllBlockPVs();
243242

244243
expect(res.length).toBe(2 * 4); // 2 blocks, which means 4 PVs to subscribe to
245244

app/components/Instrument.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,16 @@ export class Instrument {
186186
},
187187
];
188188
}
189+
190+
getAllBlockPVs(): Array<string> {
191+
return this.groups
192+
.map((g: IfcGroup) => g.blocks)
193+
.flat(1) // flatten to a big array of blocks
194+
.map((b: IfcBlock) =>
195+
getExtraPVsForBlock(this.prefix + CSSB + b.human_readable_name),
196+
)
197+
.flat(1); //flatten block, rc, sp_rbv pvs for every block to a 1d array
198+
}
189199
}
190200

191201
export function findPVInDashboard(
@@ -282,15 +292,3 @@ export function findPVInGroups(
282292
updatedPVName == prefix + CSSB + block.human_readable_name,
283293
);
284294
}
285-
286-
export function getAllBlockPVs(currentInstrument: Instrument): Array<string> {
287-
return currentInstrument.groups
288-
.map((g: IfcGroup) => g.blocks)
289-
.flat(1) // flatten to a big array of blocks
290-
.map((b: IfcBlock) =>
291-
getExtraPVsForBlock(
292-
currentInstrument.prefix + CSSB + b.human_readable_name,
293-
),
294-
)
295-
.flat(1); //flatten block, rc, sp_rbv pvs for every block to a 1d array
296-
}

app/components/InstrumentData.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
import {
1010
findPVInDashboard,
1111
findPVInGroups,
12-
getAllBlockPVs,
1312
getGroupsWithBlocksFromConfigOutput,
1413
Instrument,
1514
RC_ENABLE,
@@ -110,7 +109,7 @@ export function InstrumentData({ instrumentName }: { instrumentName: string }) {
110109

111110
sendJsonMessage({
112111
type: PVWSRequestType.subscribe,
113-
pvs: getAllBlockPVs(currentInstrument),
112+
pvs: currentInstrument.getAllBlockPVs(),
114113
});
115114
} else {
116115
const pvVal = getPvValue(updatedPV);

0 commit comments

Comments
 (0)