Skip to content

Commit 5e95bbd

Browse files
committed
show block SPs if they exist
1 parent a682cb2 commit 5e95bbd

File tree

5 files changed

+61
-3
lines changed

5 files changed

+61
-3
lines changed

app/components/Block.test.tsx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,48 @@ it("renders block without run control without tick or cross", () => {
115115
.innerHTML,
116116
).toBe("");
117117
});
118+
119+
it("renders block with SP and shows SP value", () => {
120+
const expectedValue = 123;
121+
const expectedSpValue = 124;
122+
const aBlock: IfcBlock = {
123+
pvaddress: "SOME:PV",
124+
visible: true,
125+
human_readable_name: "MyBlock",
126+
runcontrol_inrange: false,
127+
runcontrol_enabled: false,
128+
sp_value: expectedSpValue,
129+
value: expectedValue,
130+
};
131+
const { container } = render(
132+
<Block pv={aBlock} instName={""} showHiddenBlocks={false} />,
133+
{
134+
container: tableBody,
135+
},
136+
);
137+
expect(
138+
container.querySelector(`#${aBlock.human_readable_name}_VALUE`)!.innerHTML,
139+
).toContain(`${expectedValue} (SP: ${expectedSpValue})`);
140+
});
141+
142+
it("renders block without SP and hides SP value", () => {
143+
const expectedValue = 123;
144+
const expectedSpValue = 124;
145+
const aBlock: IfcBlock = {
146+
pvaddress: "SOME:PV",
147+
visible: true,
148+
human_readable_name: "MyBlock",
149+
runcontrol_inrange: false,
150+
runcontrol_enabled: false,
151+
value: expectedValue,
152+
};
153+
const { container } = render(
154+
<Block pv={aBlock} instName={""} showHiddenBlocks={false} />,
155+
{
156+
container: tableBody,
157+
},
158+
);
159+
expect(
160+
container.querySelector(`#${aBlock.human_readable_name}_VALUE`)!.innerHTML,
161+
).toContain(`${expectedValue} `);
162+
});

app/components/Block.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ export default function Block({
5858

5959
<td className="py-1 px-4 ">
6060
<span id={pv.human_readable_name + "_VALUE"}>
61-
{pv.value} {pv.units != null && pv.units}{" "}
61+
{pv.value} {pv.units != null && pv.units}
62+
{pv.sp_value && "(SP: " + pv.sp_value + ")"}{" "}
6263
<a
6364
href="https://github.com/ISISComputingGroup/ibex_user_manual/wiki/Blocks#alarms"
6465
className="text-red-600"

app/components/InstrumentPage.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
getGroupsWithBlocksFromConfigOutput,
44
RC_ENABLE,
55
RC_INRANGE,
6+
SP,
67
subscribeToBlockPVs,
78
} from "@/app/components/InstrumentPage";
89

@@ -13,7 +14,7 @@ test("subscribeToBlockPVs subscribes to all run control PVs", () => {
1314
expect(mockSendJsonMessage.mock.calls.length).toBe(1);
1415
const expectedCall: IfcPVWSRequest = {
1516
type: "subscribe",
16-
pvs: [aBlock, aBlock + RC_ENABLE, aBlock + RC_INRANGE],
17+
pvs: [aBlock, aBlock + RC_ENABLE, aBlock + RC_INRANGE, aBlock + SP],
1718
};
1819
expect(JSON.stringify(mockSendJsonMessage.mock.calls[0][0])).toBe(
1920
JSON.stringify(expectedCall),

app/components/InstrumentPage.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ export const RC_ENABLE = ":RC:ENABLE";
3030

3131
export const RC_INRANGE = ":RC:INRANGE";
3232

33+
export const SP = ":SP";
34+
3335
export const CSSB = "CS:SB:";
3436

3537
export function subscribeToBlockPVs(
@@ -41,7 +43,12 @@ export function subscribeToBlockPVs(
4143
*/
4244
sendJsonMessage({
4345
type: "subscribe",
44-
pvs: [block_address, block_address + RC_ENABLE, block_address + RC_INRANGE],
46+
pvs: [
47+
block_address,
48+
block_address + RC_ENABLE,
49+
block_address + RC_INRANGE,
50+
block_address + SP,
51+
],
4552
});
4653
}
4754

@@ -239,6 +246,9 @@ function InstrumentData({ instrumentName }: { instrumentName: string }) {
239246
} else if (updatedPVName == block_full_pv_name + RC_ENABLE) {
240247
block.runcontrol_enabled = updatedPV.value == 1;
241248
return;
249+
} else if (updatedPVName == block_full_pv_name + SP) {
250+
block.sp_value = pvVal;
251+
return;
242252
}
243253
}
244254
}

app/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export interface IfcBlock extends IfcPV {
2727
suspend_on_invalid?: boolean;
2828
low_rc?: number;
2929
high_rc?: number;
30+
sp_value?: number | string;
3031
}
3132

3233
export interface IfcGroup {

0 commit comments

Comments
 (0)