Skip to content

Commit

Permalink
sensor values in control station
Browse files Browse the repository at this point in the history
  • Loading branch information
ryescholin committed May 27, 2024
1 parent 242c454 commit 9ec8d1f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
4 changes: 4 additions & 0 deletions pod-operation/src/components/brakes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ impl Brakes {
debug!("Disengage brakes.");
self.pin.set_high();
}

pub fn is_engaged(&self) -> bool {
self.pin.is_set_low()
}
}
4 changes: 4 additions & 0 deletions pod-operation/src/components/high_voltage_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ impl HighVoltageSystem {
debug!("Enabling high voltage system.");
self.pin.set_high();
}

pub fn is_enabled(&self) -> bool {
self.pin.is_set_high()
}
}
4 changes: 4 additions & 0 deletions pod-operation/src/components/signal_light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ impl SignalLight {
debug!("Enabling signal light.");
self.pin.set_high();
}

pub fn is_enabled(&self) -> bool {
self.pin.is_set_high()
}
}
20 changes: 17 additions & 3 deletions pod-operation/src/state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use tokio::sync::Mutex;
use tracing::info;

use crate::components::brakes::Brakes;
use crate::components::gyro::Gyroscope;
use crate::components::high_voltage_system::HighVoltageSystem;
use crate::components::lim_temperature::LimTemperature;
use crate::components::pressure_transducer::PressureTransducer;
Expand Down Expand Up @@ -40,11 +41,12 @@ pub struct StateMachine {
brakes: Brakes,
signal_light: SignalLight,
wheel_encoder: WheelEncoder,
//upstream_pressure_transducer: PressureTransducer,
upstream_pressure_transducer: PressureTransducer,
downstream_pressure_transducer: PressureTransducer,
lim_temperature_port: LimTemperature,
lim_temperature_starboard: LimTemperature,
high_voltage_system: HighVoltageSystem,
gyro: Gyroscope,
}

impl StateMachine {
Expand Down Expand Up @@ -92,13 +94,14 @@ impl StateMachine {
brakes: Brakes::new(),
signal_light: SignalLight::new(),
wheel_encoder: WheelEncoder::new(),
//upstream_pressure_transducer: PressureTransducer::upstream(),
upstream_pressure_transducer: PressureTransducer::upstream(),
downstream_pressure_transducer: PressureTransducer::downstream(),
lim_temperature_port: LimTemperature::new(ads1x1x::SlaveAddr::Default),
lim_temperature_starboard: LimTemperature::new(ads1x1x::SlaveAddr::Alternative(
false, true,
)),
high_voltage_system: HighVoltageSystem::new(),
gyro: Gyroscope::new(),
}
}

Expand Down Expand Up @@ -137,7 +140,18 @@ impl StateMachine {
self.io
.of("/control-station")
.unwrap()
.emit("pong", "123")
.emit(
"serverResponse",
json!({ "gyroscope": self.gyro.read(),
"wheel_encoder": self.wheel_encoder.read(),
"downstream_pressure_transducer": self.downstream_pressure_transducer.read_pressure(),
"upstream_pressure_transducer": self.upstream_pressure_transducer.read_pressure(),
"lim_temperature_port": self.lim_temperature_port.read_lim_temps(),
"lim_temperature_starboard": self.lim_temperature_starboard.read_lim_temps(),
"high_voltage_system": self.high_voltage_system.is_enabled(),
"brakes": self.brakes.is_engaged(),
"signal_light": self.signal_light.is_enabled()}),
)
.ok();
}

Expand Down

0 comments on commit 9ec8d1f

Please sign in to comment.