Skip to content

Commit 3745abd

Browse files
committed
web: add notification about DUT power failures
The DUT powering off due to one of the possible errors may come as a surprise to the user. Help them troubleshoot by displaying a prominent error message. Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
1 parent 5e4a610 commit 3745abd

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

web/src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
IOBusFaultNotification,
3535
RebootNotification,
3636
UpdateNotification,
37+
PowerFailNotification,
3738
ProgressNotification,
3839
LocatorNotification,
3940
OverTemperatureNotification,
@@ -161,6 +162,7 @@ function Notifications() {
161162
<OverTemperatureNotification />
162163
<ProgressNotification />
163164
<UsbOverloadNotification />
165+
<PowerFailNotification />
164166
<UpdateNotification />
165167
<LocatorNotification />
166168
<IOBusFaultNotification />

web/src/TacComponents.tsx

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,17 @@ enum UsbOverload {
9696
Port3 = "Port3",
9797
}
9898

99+
enum OutputState {
100+
On = "On",
101+
Off = "Off",
102+
OffFloating = "OffFloating",
103+
Changing = "Changing",
104+
InvertedPolarity = "InvertedPolarity",
105+
OverCurrent = "OverCurrent",
106+
OverVoltage = "OverVoltage",
107+
RealtimeViolation = "RealtimeViolation",
108+
}
109+
99110
type Duration = {
100111
secs: number;
101112
nanos: number;
@@ -563,3 +574,48 @@ export function UsbOverloadNotification() {
563574
</Alert>
564575
);
565576
}
577+
578+
export function PowerFailNotification() {
579+
const state = useMqttSubscription<OutputState>("/v1/dut/powered");
580+
581+
let reason = null;
582+
583+
switch (state) {
584+
case OutputState.InvertedPolarity:
585+
reason = "an inverted polarity event";
586+
break;
587+
case OutputState.OverCurrent:
588+
reason = "an overcurrent event";
589+
break;
590+
case OutputState.OverVoltage:
591+
reason = "an overvoltage event";
592+
break;
593+
case OutputState.RealtimeViolation:
594+
reason = "a realtime violation";
595+
break;
596+
}
597+
598+
return (
599+
<Alert
600+
statusIconAriaLabel="Info"
601+
visible={reason !== null}
602+
action={
603+
<SpaceBetween size="xs">
604+
<MqttButton iconName="refresh" topic="/v1/dut/powered" send={"On"}>
605+
Turn DUT back on
606+
</MqttButton>
607+
<MqttButton
608+
iconName="status-stopped"
609+
topic="/v1/dut/powered"
610+
send={"Off"}
611+
>
612+
Keep DUT powered off
613+
</MqttButton>
614+
</SpaceBetween>
615+
}
616+
header="DUT powered off"
617+
>
618+
The DUT was powered off due to {reason}.
619+
</Alert>
620+
);
621+
}

0 commit comments

Comments
 (0)