Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indicate reason for pod failures leading to Faulted #111

Merged
merged 5 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions control-station/src/services/PodSocketClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ interface ServerToClientEvents {
connect: () => void;
disconnect: (reason: Socket.DisconnectReason) => void;
serverResponse: (data: string) => void;
faulted: (data: string) => void;
ryescholin marked this conversation as resolved.
Show resolved Hide resolved
}

interface Message {
Expand Down Expand Up @@ -55,6 +56,7 @@ class PodSocketClient {
connect: this.onConnect.bind(this),
disconnect: this.onDisconnect.bind(this),
serverResponse: this.onData.bind(this),
faulted: this.onFault.bind(this),
} as const;
this.setPodData = setPodData;
}
Expand Down Expand Up @@ -121,6 +123,11 @@ class PodSocketClient {
console.log("server says", data);
}

private onFault(data: string): void {
console.error("Server faulted with message:", data);
this.addMessage(data, State.Faulted);
}

private addMessage(response: string, newState: State): void {
const timestamp = new Date();
const newMessage = {
Expand Down
20 changes: 15 additions & 5 deletions pod-operation/src/state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,6 @@ impl StateMachine {

fn _enter_faulted(&mut self) {
info!("Entering Faulted state");
self.io
.of("/control-station")
.unwrap()
.emit("fault", "123")
.ok();
self.signal_light.disable();
self.brakes.engage();
self.high_voltage_system.disable();
Expand All @@ -221,6 +216,11 @@ impl StateMachine {
}

if self.downstream_pressure_transducer.read_pressure() < MIN_PRESSURE {
self.io
.of("/control-station")
.unwrap()
.emit("fault", "Low pressure detected.")
ryescholin marked this conversation as resolved.
Show resolved Hide resolved
.ok();
return State::Faulted;
}
let default_readings = self.lim_temperature_port.read_lim_temps();
Expand All @@ -230,10 +230,20 @@ impl StateMachine {
.chain(alternative_readings.iter())
.any(|&reading| reading > LIM_TEMP_THRESHOLD)
{
self.io
.of("/control-station")
.unwrap()
.emit("fault", "High temperature detected.")
.ok();
return State::Faulted;
}
// Last 20% of the track, as indicated by braking
if self.lidar.read_distance() < END_OF_TRACK {
self.io
.of("/control-station")
.unwrap()
.emit("fault", "End of track detected.")
.ok();
return State::Faulted;
}

Expand Down